]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-3.0-3.12.8-201401160931.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-3.0-3.12.8-201401160931.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..903b673 100644
3 --- a/Documentation/dontdiff
4 +++ b/Documentation/dontdiff
5 @@ -2,9 +2,11 @@
6 *.aux
7 *.bin
8 *.bz2
9 +*.c.[012]*.*
10 *.cis
11 *.cpio
12 *.csp
13 +*.dbg
14 *.dsp
15 *.dvi
16 *.elf
17 @@ -14,6 +16,7 @@
18 *.gcov
19 *.gen.S
20 *.gif
21 +*.gmo
22 *.grep
23 *.grp
24 *.gz
25 @@ -48,14 +51,17 @@
26 *.tab.h
27 *.tex
28 *.ver
29 +*.vim
30 *.xml
31 *.xz
32 *_MODULES
33 +*_reg_safe.h
34 *_vga16.c
35 *~
36 \#*#
37 *.9
38 -.*
39 +.[^g]*
40 +.gen*
41 .*.d
42 .mm
43 53c700_d.h
44 @@ -69,9 +75,11 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 +TRACEEVENT-CFLAGS
53 aconf
54 af_names.h
55 aic7*reg.h*
56 @@ -80,6 +88,7 @@ aic7*seq.h*
57 aicasm
58 aicdb.h*
59 altivec*.c
60 +ashldi3.S
61 asm-offsets.h
62 asm_offsets.h
63 autoconf.h*
64 @@ -92,32 +101,40 @@ bounds.h
65 bsetup
66 btfixupprep
67 build
68 +builtin-policy.h
69 bvmlinux
70 bzImage*
71 capability_names.h
72 capflags.c
73 classlist.h*
74 +clut_vga16.c
75 +common-cmds.h
76 comp*.log
77 compile.h*
78 conf
79 config
80 config-*
81 config_data.h*
82 +config.c
83 config.mak
84 config.mak.autogen
85 +config.tmp
86 conmakehash
87 consolemap_deftbl.c*
88 cpustr.h
89 crc32table.h*
90 cscope.*
91 defkeymap.c
92 +devicetable-offsets.h
93 devlist.h*
94 dnotify_test
95 docproc
96 dslm
97 +dtc-lexer.lex.c
98 elf2ecoff
99 elfconfig.h*
100 evergreen_reg_safe.h
101 +exception_policy.conf
102 fixdep
103 flask.h
104 fore200e_mkfirm
105 @@ -125,12 +142,15 @@ fore200e_pca_fw.c*
106 gconf
107 gconf.glade.h
108 gen-devlist
109 +gen-kdb_cmds.c
110 gen_crc32table
111 gen_init_cpio
112 generated
113 genheaders
114 genksyms
115 *_gray256.c
116 +hash
117 +hid-example
118 hpet_example
119 hugepage-mmap
120 hugepage-shm
121 @@ -145,14 +165,14 @@ int32.c
122 int4.c
123 int8.c
124 kallsyms
125 -kconfig
126 +kern_constants.h
127 keywords.c
128 ksym.c*
129 ksym.h*
130 kxgettext
131 lex.c
132 lex.*.c
133 -linux
134 +lib1funcs.S
135 logo_*.c
136 logo_*_clut224.c
137 logo_*_mono.c
138 @@ -162,14 +182,15 @@ mach-types.h
139 machtypes.h
140 map
141 map_hugetlb
142 -media
143 mconf
144 +mdp
145 miboot*
146 mk_elfconfig
147 mkboot
148 mkbugboot
149 mkcpustr
150 mkdep
151 +mkpiggy
152 mkprep
153 mkregtable
154 mktables
155 @@ -185,6 +206,8 @@ oui.c*
156 page-types
157 parse.c
158 parse.h
159 +parse-events*
160 +pasyms.h
161 patches*
162 pca200e.bin
163 pca200e_ecd.bin2
164 @@ -194,6 +217,7 @@ perf-archive
165 piggyback
166 piggy.gzip
167 piggy.S
168 +pmu-*
169 pnmtologo
170 ppc_defs.h*
171 pss_boot.h
172 @@ -203,7 +227,10 @@ r200_reg_safe.h
173 r300_reg_safe.h
174 r420_reg_safe.h
175 r600_reg_safe.h
176 +realmode.lds
177 +realmode.relocs
178 recordmcount
179 +regdb.c
180 relocs
181 rlim_names.h
182 rn50_reg_safe.h
183 @@ -213,8 +240,12 @@ series
184 setup
185 setup.bin
186 setup.elf
187 +signing_key*
188 +size_overflow_hash.h
189 sImage
190 +slabinfo
191 sm_tbl*
192 +sortextable
193 split-include
194 syscalltab.h
195 tables.c
196 @@ -224,6 +255,7 @@ tftpboot.img
197 timeconst.h
198 times.h*
199 trix_boot.h
200 +user_constants.h
201 utsrelease.h*
202 vdso-syms.lds
203 vdso.lds
204 @@ -235,13 +267,17 @@ vdso32.lds
205 vdso32.so.dbg
206 vdso64.lds
207 vdso64.so.dbg
208 +vdsox32.lds
209 +vdsox32-syms.lds
210 version.h*
211 vmImage
212 vmlinux
213 vmlinux-*
214 vmlinux.aout
215 vmlinux.bin.all
216 +vmlinux.bin.bz2
217 vmlinux.lds
218 +vmlinux.relocs
219 vmlinuz
220 voffset.h
221 vsyscall.lds
222 @@ -249,9 +285,12 @@ vsyscall_32.lds
223 wanxlfw.inc
224 uImage
225 unifdef
226 +utsrelease.h
227 wakeup.bin
228 wakeup.elf
229 wakeup.lds
230 +x509*
231 zImage*
232 zconf.hash.c
233 +zconf.lex.c
234 zoffset.h
235 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
236 index 4f7c57c..a2dc685 100644
237 --- a/Documentation/kernel-parameters.txt
238 +++ b/Documentation/kernel-parameters.txt
239 @@ -1031,6 +1031,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
240 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
241 Default: 1024
242
243 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
244 + ignore grsecurity's /proc restrictions
245 +
246 +
247 hashdist= [KNL,NUMA] Large hashes allocated during boot
248 are distributed across NUMA nodes. Defaults on
249 for 64-bit NUMA, off otherwise.
250 @@ -2001,6 +2005,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
251 noexec=on: enable non-executable mappings (default)
252 noexec=off: disable non-executable mappings
253
254 + nopcid [X86-64]
255 + Disable PCID (Process-Context IDentifier) even if it
256 + is supported by the processor.
257 +
258 nosmap [X86]
259 Disable SMAP (Supervisor Mode Access Prevention)
260 even if it is supported by processor.
261 @@ -2268,6 +2276,25 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
262 the specified number of seconds. This is to be used if
263 your oopses keep scrolling off the screen.
264
265 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
266 + virtualization environments that don't cope well with the
267 + expand down segment used by UDEREF on X86-32 or the frequent
268 + page table updates on X86-64.
269 +
270 + pax_sanitize_slab=
271 + 0/1 to disable/enable slab object sanitization (enabled by
272 + default).
273 +
274 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
275 +
276 + pax_extra_latent_entropy
277 + Enable a very simple form of latent entropy extraction
278 + from the first 4GB of memory as the bootmem allocator
279 + passes the memory pages to the buddy allocator.
280 +
281 + pax_weakuderef [X86-64] enables the weaker but faster form of UDEREF
282 + when the processor supports PCID.
283 +
284 pcbit= [HW,ISDN]
285
286 pcd. [PARIDE]
287 diff --git a/Makefile b/Makefile
288 index 5d0ec13..d3dcef2 100644
289 --- a/Makefile
290 +++ b/Makefile
291 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
292
293 HOSTCC = gcc
294 HOSTCXX = g++
295 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
296 -HOSTCXXFLAGS = -O2
297 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
298 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
299 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
300
301 # Decide whether to build built-in, modular, or both.
302 # Normally, just do built-in.
303 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
304 # Rules shared between *config targets and build targets
305
306 # Basic helpers built in scripts/
307 -PHONY += scripts_basic
308 -scripts_basic:
309 +PHONY += scripts_basic gcc-plugins
310 +scripts_basic: gcc-plugins
311 $(Q)$(MAKE) $(build)=scripts/basic
312 $(Q)rm -f .tmp_quiet_recordmcount
313
314 @@ -576,6 +577,65 @@ else
315 KBUILD_CFLAGS += -O2
316 endif
317
318 +ifndef DISABLE_PAX_PLUGINS
319 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
320 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
321 +else
322 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
323 +endif
324 +ifneq ($(PLUGINCC),)
325 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
326 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
327 +endif
328 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
329 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
330 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
331 +endif
332 +ifdef CONFIG_KALLOCSTAT_PLUGIN
333 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
334 +endif
335 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
336 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
337 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
338 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
339 +endif
340 +ifdef CONFIG_CHECKER_PLUGIN
341 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
342 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
343 +endif
344 +endif
345 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
346 +ifdef CONFIG_PAX_SIZE_OVERFLOW
347 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
348 +endif
349 +ifdef CONFIG_PAX_LATENT_ENTROPY
350 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
351 +endif
352 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
353 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
354 +endif
355 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
356 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
357 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
358 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
359 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
360 +ifeq ($(KBUILD_EXTMOD),)
361 +gcc-plugins:
362 + $(Q)$(MAKE) $(build)=tools/gcc
363 +else
364 +gcc-plugins: ;
365 +endif
366 +else
367 +gcc-plugins:
368 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
369 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
370 +else
371 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
372 +endif
373 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
374 +endif
375 +endif
376 +
377 include $(srctree)/arch/$(SRCARCH)/Makefile
378
379 ifdef CONFIG_READABLE_ASM
380 @@ -733,7 +793,7 @@ export mod_sign_cmd
381
382
383 ifeq ($(KBUILD_EXTMOD),)
384 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
385 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
386
387 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
388 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
389 @@ -782,6 +842,8 @@ endif
390
391 # The actual objects are generated when descending,
392 # make sure no implicit rule kicks in
393 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
394 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
395 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
396
397 # Handle descending into subdirectories listed in $(vmlinux-dirs)
398 @@ -791,7 +853,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
399 # Error messages still appears in the original language
400
401 PHONY += $(vmlinux-dirs)
402 -$(vmlinux-dirs): prepare scripts
403 +$(vmlinux-dirs): gcc-plugins prepare scripts
404 $(Q)$(MAKE) $(build)=$@
405
406 define filechk_kernel.release
407 @@ -834,10 +896,13 @@ prepare1: prepare2 $(version_h) include/generated/utsrelease.h \
408
409 archprepare: archheaders archscripts prepare1 scripts_basic
410
411 +prepare0: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
412 +prepare0: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
413 prepare0: archprepare FORCE
414 $(Q)$(MAKE) $(build)=.
415
416 # All the preparing..
417 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
418 prepare: prepare0
419
420 # Generate some files
421 @@ -945,6 +1010,8 @@ all: modules
422 # using awk while concatenating to the final file.
423
424 PHONY += modules
425 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
426 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
427 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
428 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
429 @$(kecho) ' Building modules, stage 2.';
430 @@ -960,7 +1027,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
431
432 # Target to prepare building external modules
433 PHONY += modules_prepare
434 -modules_prepare: prepare scripts
435 +modules_prepare: gcc-plugins prepare scripts
436
437 # Target to install modules
438 PHONY += modules_install
439 @@ -1026,7 +1093,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
440 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
441 signing_key.priv signing_key.x509 x509.genkey \
442 extra_certificates signing_key.x509.keyid \
443 - signing_key.x509.signer
444 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
445
446 # clean - Delete most, but leave enough to build external modules
447 #
448 @@ -1066,6 +1133,7 @@ distclean: mrproper
449 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
450 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
451 -o -name '.*.rej' \
452 + -o -name '.*.rej' -o -name '*.so' \
453 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
454 -type f -print | xargs rm -f
455
456 @@ -1227,6 +1295,8 @@ PHONY += $(module-dirs) modules
457 $(module-dirs): crmodverdir $(objtree)/Module.symvers
458 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
459
460 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
461 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
462 modules: $(module-dirs)
463 @$(kecho) ' Building modules, stage 2.';
464 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
465 @@ -1366,17 +1436,21 @@ else
466 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
467 endif
468
469 -%.s: %.c prepare scripts FORCE
470 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
471 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
472 +%.s: %.c gcc-plugins prepare scripts FORCE
473 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
474 %.i: %.c prepare scripts FORCE
475 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
476 -%.o: %.c prepare scripts FORCE
477 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
478 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
479 +%.o: %.c gcc-plugins prepare scripts FORCE
480 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
481 %.lst: %.c prepare scripts FORCE
482 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
483 -%.s: %.S prepare scripts FORCE
484 +%.s: %.S gcc-plugins prepare scripts FORCE
485 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
486 -%.o: %.S prepare scripts FORCE
487 +%.o: %.S gcc-plugins prepare scripts FORCE
488 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
489 %.symtypes: %.c prepare scripts FORCE
490 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
491 @@ -1386,11 +1460,15 @@ endif
492 $(cmd_crmodverdir)
493 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
494 $(build)=$(build-dir)
495 -%/: prepare scripts FORCE
496 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
497 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
498 +%/: gcc-plugins prepare scripts FORCE
499 $(cmd_crmodverdir)
500 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
501 $(build)=$(build-dir)
502 -%.ko: prepare scripts FORCE
503 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
504 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
505 +%.ko: gcc-plugins prepare scripts FORCE
506 $(cmd_crmodverdir)
507 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
508 $(build)=$(build-dir) $(@:.ko=.o)
509 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
510 index 78b03ef..da28a51 100644
511 --- a/arch/alpha/include/asm/atomic.h
512 +++ b/arch/alpha/include/asm/atomic.h
513 @@ -292,6 +292,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
514 #define atomic_dec(v) atomic_sub(1,(v))
515 #define atomic64_dec(v) atomic64_sub(1,(v))
516
517 +#define atomic64_read_unchecked(v) atomic64_read(v)
518 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
519 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
520 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
521 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
522 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
523 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
524 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
525 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
526 +
527 #define smp_mb__before_atomic_dec() smp_mb()
528 #define smp_mb__after_atomic_dec() smp_mb()
529 #define smp_mb__before_atomic_inc() smp_mb()
530 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
531 index ad368a9..fbe0f25 100644
532 --- a/arch/alpha/include/asm/cache.h
533 +++ b/arch/alpha/include/asm/cache.h
534 @@ -4,19 +4,19 @@
535 #ifndef __ARCH_ALPHA_CACHE_H
536 #define __ARCH_ALPHA_CACHE_H
537
538 +#include <linux/const.h>
539
540 /* Bytes per L1 (data) cache line. */
541 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
542 -# define L1_CACHE_BYTES 64
543 # define L1_CACHE_SHIFT 6
544 #else
545 /* Both EV4 and EV5 are write-through, read-allocate,
546 direct-mapped, physical.
547 */
548 -# define L1_CACHE_BYTES 32
549 # define L1_CACHE_SHIFT 5
550 #endif
551
552 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
553 #define SMP_CACHE_BYTES L1_CACHE_BYTES
554
555 #endif
556 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
557 index 968d999..d36b2df 100644
558 --- a/arch/alpha/include/asm/elf.h
559 +++ b/arch/alpha/include/asm/elf.h
560 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
561
562 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
563
564 +#ifdef CONFIG_PAX_ASLR
565 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
566 +
567 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
568 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
569 +#endif
570 +
571 /* $0 is set by ld.so to a pointer to a function which might be
572 registered using atexit. This provides a mean for the dynamic
573 linker to call DT_FINI functions for shared libraries that have
574 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
575 index bc2a0da..8ad11ee 100644
576 --- a/arch/alpha/include/asm/pgalloc.h
577 +++ b/arch/alpha/include/asm/pgalloc.h
578 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
579 pgd_set(pgd, pmd);
580 }
581
582 +static inline void
583 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
584 +{
585 + pgd_populate(mm, pgd, pmd);
586 +}
587 +
588 extern pgd_t *pgd_alloc(struct mm_struct *mm);
589
590 static inline void
591 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
592 index d8f9b7e..f6222fa 100644
593 --- a/arch/alpha/include/asm/pgtable.h
594 +++ b/arch/alpha/include/asm/pgtable.h
595 @@ -102,6 +102,17 @@ struct vm_area_struct;
596 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
597 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
598 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
599 +
600 +#ifdef CONFIG_PAX_PAGEEXEC
601 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
602 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
603 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
604 +#else
605 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
606 +# define PAGE_COPY_NOEXEC PAGE_COPY
607 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
608 +#endif
609 +
610 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
611
612 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
613 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
614 index 2fd00b7..cfd5069 100644
615 --- a/arch/alpha/kernel/module.c
616 +++ b/arch/alpha/kernel/module.c
617 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
618
619 /* The small sections were sorted to the end of the segment.
620 The following should definitely cover them. */
621 - gp = (u64)me->module_core + me->core_size - 0x8000;
622 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
623 got = sechdrs[me->arch.gotsecindex].sh_addr;
624
625 for (i = 0; i < n; i++) {
626 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
627 index 1402fcc..0b1abd2 100644
628 --- a/arch/alpha/kernel/osf_sys.c
629 +++ b/arch/alpha/kernel/osf_sys.c
630 @@ -1298,10 +1298,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
631 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
632
633 static unsigned long
634 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
635 - unsigned long limit)
636 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
637 + unsigned long limit, unsigned long flags)
638 {
639 struct vm_unmapped_area_info info;
640 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
641
642 info.flags = 0;
643 info.length = len;
644 @@ -1309,6 +1310,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
645 info.high_limit = limit;
646 info.align_mask = 0;
647 info.align_offset = 0;
648 + info.threadstack_offset = offset;
649 return vm_unmapped_area(&info);
650 }
651
652 @@ -1341,20 +1343,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
653 merely specific addresses, but regions of memory -- perhaps
654 this feature should be incorporated into all ports? */
655
656 +#ifdef CONFIG_PAX_RANDMMAP
657 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
658 +#endif
659 +
660 if (addr) {
661 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
662 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
663 if (addr != (unsigned long) -ENOMEM)
664 return addr;
665 }
666
667 /* Next, try allocating at TASK_UNMAPPED_BASE. */
668 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
669 - len, limit);
670 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
671 +
672 if (addr != (unsigned long) -ENOMEM)
673 return addr;
674
675 /* Finally, try allocating in low memory. */
676 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
677 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
678
679 return addr;
680 }
681 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
682 index 98838a0..b304fb4 100644
683 --- a/arch/alpha/mm/fault.c
684 +++ b/arch/alpha/mm/fault.c
685 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
686 __reload_thread(pcb);
687 }
688
689 +#ifdef CONFIG_PAX_PAGEEXEC
690 +/*
691 + * PaX: decide what to do with offenders (regs->pc = fault address)
692 + *
693 + * returns 1 when task should be killed
694 + * 2 when patched PLT trampoline was detected
695 + * 3 when unpatched PLT trampoline was detected
696 + */
697 +static int pax_handle_fetch_fault(struct pt_regs *regs)
698 +{
699 +
700 +#ifdef CONFIG_PAX_EMUPLT
701 + int err;
702 +
703 + do { /* PaX: patched PLT emulation #1 */
704 + unsigned int ldah, ldq, jmp;
705 +
706 + err = get_user(ldah, (unsigned int *)regs->pc);
707 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
708 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
709 +
710 + if (err)
711 + break;
712 +
713 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
714 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
715 + jmp == 0x6BFB0000U)
716 + {
717 + unsigned long r27, addr;
718 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
719 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
720 +
721 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
722 + err = get_user(r27, (unsigned long *)addr);
723 + if (err)
724 + break;
725 +
726 + regs->r27 = r27;
727 + regs->pc = r27;
728 + return 2;
729 + }
730 + } while (0);
731 +
732 + do { /* PaX: patched PLT emulation #2 */
733 + unsigned int ldah, lda, br;
734 +
735 + err = get_user(ldah, (unsigned int *)regs->pc);
736 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
737 + err |= get_user(br, (unsigned int *)(regs->pc+8));
738 +
739 + if (err)
740 + break;
741 +
742 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
743 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
744 + (br & 0xFFE00000U) == 0xC3E00000U)
745 + {
746 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
747 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
748 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
749 +
750 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
751 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
752 + return 2;
753 + }
754 + } while (0);
755 +
756 + do { /* PaX: unpatched PLT emulation */
757 + unsigned int br;
758 +
759 + err = get_user(br, (unsigned int *)regs->pc);
760 +
761 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
762 + unsigned int br2, ldq, nop, jmp;
763 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
764 +
765 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
766 + err = get_user(br2, (unsigned int *)addr);
767 + err |= get_user(ldq, (unsigned int *)(addr+4));
768 + err |= get_user(nop, (unsigned int *)(addr+8));
769 + err |= get_user(jmp, (unsigned int *)(addr+12));
770 + err |= get_user(resolver, (unsigned long *)(addr+16));
771 +
772 + if (err)
773 + break;
774 +
775 + if (br2 == 0xC3600000U &&
776 + ldq == 0xA77B000CU &&
777 + nop == 0x47FF041FU &&
778 + jmp == 0x6B7B0000U)
779 + {
780 + regs->r28 = regs->pc+4;
781 + regs->r27 = addr+16;
782 + regs->pc = resolver;
783 + return 3;
784 + }
785 + }
786 + } while (0);
787 +#endif
788 +
789 + return 1;
790 +}
791 +
792 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
793 +{
794 + unsigned long i;
795 +
796 + printk(KERN_ERR "PAX: bytes at PC: ");
797 + for (i = 0; i < 5; i++) {
798 + unsigned int c;
799 + if (get_user(c, (unsigned int *)pc+i))
800 + printk(KERN_CONT "???????? ");
801 + else
802 + printk(KERN_CONT "%08x ", c);
803 + }
804 + printk("\n");
805 +}
806 +#endif
807
808 /*
809 * This routine handles page faults. It determines the address,
810 @@ -133,8 +251,29 @@ retry:
811 good_area:
812 si_code = SEGV_ACCERR;
813 if (cause < 0) {
814 - if (!(vma->vm_flags & VM_EXEC))
815 + if (!(vma->vm_flags & VM_EXEC)) {
816 +
817 +#ifdef CONFIG_PAX_PAGEEXEC
818 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
819 + goto bad_area;
820 +
821 + up_read(&mm->mmap_sem);
822 + switch (pax_handle_fetch_fault(regs)) {
823 +
824 +#ifdef CONFIG_PAX_EMUPLT
825 + case 2:
826 + case 3:
827 + return;
828 +#endif
829 +
830 + }
831 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
832 + do_group_exit(SIGKILL);
833 +#else
834 goto bad_area;
835 +#endif
836 +
837 + }
838 } else if (!cause) {
839 /* Allow reads even for write-only mappings */
840 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
841 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
842 index 1ad6fb6..9406b3d 100644
843 --- a/arch/arm/Kconfig
844 +++ b/arch/arm/Kconfig
845 @@ -1832,7 +1832,7 @@ config ALIGNMENT_TRAP
846
847 config UACCESS_WITH_MEMCPY
848 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
849 - depends on MMU
850 + depends on MMU && !PAX_MEMORY_UDEREF
851 default y if CPU_FEROCEON
852 help
853 Implement faster copy_to_user and clear_user methods for CPU
854 @@ -2097,6 +2097,7 @@ config XIP_PHYS_ADDR
855 config KEXEC
856 bool "Kexec system call (EXPERIMENTAL)"
857 depends on (!SMP || PM_SLEEP_SMP)
858 + depends on !GRKERNSEC_KMEM
859 help
860 kexec is a system call that implements the ability to shutdown your
861 current kernel, and to start another kernel. It is like a reboot
862 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
863 index da1c77d..2ee6056 100644
864 --- a/arch/arm/include/asm/atomic.h
865 +++ b/arch/arm/include/asm/atomic.h
866 @@ -17,17 +17,35 @@
867 #include <asm/barrier.h>
868 #include <asm/cmpxchg.h>
869
870 +#ifdef CONFIG_GENERIC_ATOMIC64
871 +#include <asm-generic/atomic64.h>
872 +#endif
873 +
874 #define ATOMIC_INIT(i) { (i) }
875
876 #ifdef __KERNEL__
877
878 +#define _ASM_EXTABLE(from, to) \
879 +" .pushsection __ex_table,\"a\"\n"\
880 +" .align 3\n" \
881 +" .long " #from ", " #to"\n" \
882 +" .popsection"
883 +
884 /*
885 * On ARM, ordinary assignment (str instruction) doesn't clear the local
886 * strex/ldrex monitor on some implementations. The reason we can use it for
887 * atomic_set() is the clrex or dummy strex done on every exception return.
888 */
889 #define atomic_read(v) (*(volatile int *)&(v)->counter)
890 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
891 +{
892 + return v->counter;
893 +}
894 #define atomic_set(v,i) (((v)->counter) = (i))
895 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
896 +{
897 + v->counter = i;
898 +}
899
900 #if __LINUX_ARM_ARCH__ >= 6
901
902 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
903 int result;
904
905 __asm__ __volatile__("@ atomic_add\n"
906 +"1: ldrex %1, [%3]\n"
907 +" adds %0, %1, %4\n"
908 +
909 +#ifdef CONFIG_PAX_REFCOUNT
910 +" bvc 3f\n"
911 +"2: bkpt 0xf103\n"
912 +"3:\n"
913 +#endif
914 +
915 +" strex %1, %0, [%3]\n"
916 +" teq %1, #0\n"
917 +" bne 1b"
918 +
919 +#ifdef CONFIG_PAX_REFCOUNT
920 +"\n4:\n"
921 + _ASM_EXTABLE(2b, 4b)
922 +#endif
923 +
924 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
925 + : "r" (&v->counter), "Ir" (i)
926 + : "cc");
927 +}
928 +
929 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
930 +{
931 + unsigned long tmp;
932 + int result;
933 +
934 + __asm__ __volatile__("@ atomic_add_unchecked\n"
935 "1: ldrex %0, [%3]\n"
936 " add %0, %0, %4\n"
937 " strex %1, %0, [%3]\n"
938 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
939 smp_mb();
940
941 __asm__ __volatile__("@ atomic_add_return\n"
942 +"1: ldrex %1, [%3]\n"
943 +" adds %0, %1, %4\n"
944 +
945 +#ifdef CONFIG_PAX_REFCOUNT
946 +" bvc 3f\n"
947 +" mov %0, %1\n"
948 +"2: bkpt 0xf103\n"
949 +"3:\n"
950 +#endif
951 +
952 +" strex %1, %0, [%3]\n"
953 +" teq %1, #0\n"
954 +" bne 1b"
955 +
956 +#ifdef CONFIG_PAX_REFCOUNT
957 +"\n4:\n"
958 + _ASM_EXTABLE(2b, 4b)
959 +#endif
960 +
961 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
962 + : "r" (&v->counter), "Ir" (i)
963 + : "cc");
964 +
965 + smp_mb();
966 +
967 + return result;
968 +}
969 +
970 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
971 +{
972 + unsigned long tmp;
973 + int result;
974 +
975 + smp_mb();
976 +
977 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
978 "1: ldrex %0, [%3]\n"
979 " add %0, %0, %4\n"
980 " strex %1, %0, [%3]\n"
981 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
982 int result;
983
984 __asm__ __volatile__("@ atomic_sub\n"
985 +"1: ldrex %1, [%3]\n"
986 +" subs %0, %1, %4\n"
987 +
988 +#ifdef CONFIG_PAX_REFCOUNT
989 +" bvc 3f\n"
990 +"2: bkpt 0xf103\n"
991 +"3:\n"
992 +#endif
993 +
994 +" strex %1, %0, [%3]\n"
995 +" teq %1, #0\n"
996 +" bne 1b"
997 +
998 +#ifdef CONFIG_PAX_REFCOUNT
999 +"\n4:\n"
1000 + _ASM_EXTABLE(2b, 4b)
1001 +#endif
1002 +
1003 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1004 + : "r" (&v->counter), "Ir" (i)
1005 + : "cc");
1006 +}
1007 +
1008 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1009 +{
1010 + unsigned long tmp;
1011 + int result;
1012 +
1013 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
1014 "1: ldrex %0, [%3]\n"
1015 " sub %0, %0, %4\n"
1016 " strex %1, %0, [%3]\n"
1017 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1018 smp_mb();
1019
1020 __asm__ __volatile__("@ atomic_sub_return\n"
1021 -"1: ldrex %0, [%3]\n"
1022 -" sub %0, %0, %4\n"
1023 +"1: ldrex %1, [%3]\n"
1024 +" subs %0, %1, %4\n"
1025 +
1026 +#ifdef CONFIG_PAX_REFCOUNT
1027 +" bvc 3f\n"
1028 +" mov %0, %1\n"
1029 +"2: bkpt 0xf103\n"
1030 +"3:\n"
1031 +#endif
1032 +
1033 " strex %1, %0, [%3]\n"
1034 " teq %1, #0\n"
1035 " bne 1b"
1036 +
1037 +#ifdef CONFIG_PAX_REFCOUNT
1038 +"\n4:\n"
1039 + _ASM_EXTABLE(2b, 4b)
1040 +#endif
1041 +
1042 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1043 : "r" (&v->counter), "Ir" (i)
1044 : "cc");
1045 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1046 return oldval;
1047 }
1048
1049 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1050 +{
1051 + unsigned long oldval, res;
1052 +
1053 + smp_mb();
1054 +
1055 + do {
1056 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1057 + "ldrex %1, [%3]\n"
1058 + "mov %0, #0\n"
1059 + "teq %1, %4\n"
1060 + "strexeq %0, %5, [%3]\n"
1061 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1062 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1063 + : "cc");
1064 + } while (res);
1065 +
1066 + smp_mb();
1067 +
1068 + return oldval;
1069 +}
1070 +
1071 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1072 {
1073 unsigned long tmp, tmp2;
1074 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1075
1076 return val;
1077 }
1078 +
1079 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1080 +{
1081 + return atomic_add_return(i, v);
1082 +}
1083 +
1084 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1085 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1086 +{
1087 + (void) atomic_add_return(i, v);
1088 +}
1089
1090 static inline int atomic_sub_return(int i, atomic_t *v)
1091 {
1092 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1093 return val;
1094 }
1095 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1096 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1097 +{
1098 + (void) atomic_sub_return(i, v);
1099 +}
1100
1101 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1102 {
1103 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1104 return ret;
1105 }
1106
1107 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1108 +{
1109 + return atomic_cmpxchg(v, old, new);
1110 +}
1111 +
1112 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1113 {
1114 unsigned long flags;
1115 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1116 #endif /* __LINUX_ARM_ARCH__ */
1117
1118 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1119 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1120 +{
1121 + return xchg(&v->counter, new);
1122 +}
1123
1124 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1125 {
1126 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1127 }
1128
1129 #define atomic_inc(v) atomic_add(1, v)
1130 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1131 +{
1132 + atomic_add_unchecked(1, v);
1133 +}
1134 #define atomic_dec(v) atomic_sub(1, v)
1135 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1136 +{
1137 + atomic_sub_unchecked(1, v);
1138 +}
1139
1140 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1141 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1142 +{
1143 + return atomic_add_return_unchecked(1, v) == 0;
1144 +}
1145 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1146 #define atomic_inc_return(v) (atomic_add_return(1, v))
1147 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1148 +{
1149 + return atomic_add_return_unchecked(1, v);
1150 +}
1151 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1152 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1153
1154 @@ -241,6 +428,14 @@ typedef struct {
1155 u64 __aligned(8) counter;
1156 } atomic64_t;
1157
1158 +#ifdef CONFIG_PAX_REFCOUNT
1159 +typedef struct {
1160 + u64 __aligned(8) counter;
1161 +} atomic64_unchecked_t;
1162 +#else
1163 +typedef atomic64_t atomic64_unchecked_t;
1164 +#endif
1165 +
1166 #define ATOMIC64_INIT(i) { (i) }
1167
1168 #ifdef CONFIG_ARM_LPAE
1169 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1170 return result;
1171 }
1172
1173 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1174 +{
1175 + u64 result;
1176 +
1177 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1178 +" ldrd %0, %H0, [%1]"
1179 + : "=&r" (result)
1180 + : "r" (&v->counter), "Qo" (v->counter)
1181 + );
1182 +
1183 + return result;
1184 +}
1185 +
1186 static inline void atomic64_set(atomic64_t *v, u64 i)
1187 {
1188 __asm__ __volatile__("@ atomic64_set\n"
1189 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1190 : "r" (&v->counter), "r" (i)
1191 );
1192 }
1193 +
1194 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1195 +{
1196 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1197 +" strd %2, %H2, [%1]"
1198 + : "=Qo" (v->counter)
1199 + : "r" (&v->counter), "r" (i)
1200 + );
1201 +}
1202 #else
1203 static inline u64 atomic64_read(const atomic64_t *v)
1204 {
1205 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1206 return result;
1207 }
1208
1209 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1210 +{
1211 + u64 result;
1212 +
1213 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1214 +" ldrexd %0, %H0, [%1]"
1215 + : "=&r" (result)
1216 + : "r" (&v->counter), "Qo" (v->counter)
1217 + );
1218 +
1219 + return result;
1220 +}
1221 +
1222 static inline void atomic64_set(atomic64_t *v, u64 i)
1223 {
1224 u64 tmp;
1225 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1226 : "r" (&v->counter), "r" (i)
1227 : "cc");
1228 }
1229 +
1230 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1231 +{
1232 + u64 tmp;
1233 +
1234 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1235 +"1: ldrexd %0, %H0, [%2]\n"
1236 +" strexd %0, %3, %H3, [%2]\n"
1237 +" teq %0, #0\n"
1238 +" bne 1b"
1239 + : "=&r" (tmp), "=Qo" (v->counter)
1240 + : "r" (&v->counter), "r" (i)
1241 + : "cc");
1242 +}
1243 +
1244 #endif
1245
1246 static inline void atomic64_add(u64 i, atomic64_t *v)
1247 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1248 __asm__ __volatile__("@ atomic64_add\n"
1249 "1: ldrexd %0, %H0, [%3]\n"
1250 " adds %0, %0, %4\n"
1251 +" adcs %H0, %H0, %H4\n"
1252 +
1253 +#ifdef CONFIG_PAX_REFCOUNT
1254 +" bvc 3f\n"
1255 +"2: bkpt 0xf103\n"
1256 +"3:\n"
1257 +#endif
1258 +
1259 +" strexd %1, %0, %H0, [%3]\n"
1260 +" teq %1, #0\n"
1261 +" bne 1b"
1262 +
1263 +#ifdef CONFIG_PAX_REFCOUNT
1264 +"\n4:\n"
1265 + _ASM_EXTABLE(2b, 4b)
1266 +#endif
1267 +
1268 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1269 + : "r" (&v->counter), "r" (i)
1270 + : "cc");
1271 +}
1272 +
1273 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1274 +{
1275 + u64 result;
1276 + unsigned long tmp;
1277 +
1278 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1279 +"1: ldrexd %0, %H0, [%3]\n"
1280 +" adds %0, %0, %4\n"
1281 " adc %H0, %H0, %H4\n"
1282 " strexd %1, %0, %H0, [%3]\n"
1283 " teq %1, #0\n"
1284 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1285
1286 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1287 {
1288 - u64 result;
1289 - unsigned long tmp;
1290 + u64 result, tmp;
1291
1292 smp_mb();
1293
1294 __asm__ __volatile__("@ atomic64_add_return\n"
1295 +"1: ldrexd %1, %H1, [%3]\n"
1296 +" adds %0, %1, %4\n"
1297 +" adcs %H0, %H1, %H4\n"
1298 +
1299 +#ifdef CONFIG_PAX_REFCOUNT
1300 +" bvc 3f\n"
1301 +" mov %0, %1\n"
1302 +" mov %H0, %H1\n"
1303 +"2: bkpt 0xf103\n"
1304 +"3:\n"
1305 +#endif
1306 +
1307 +" strexd %1, %0, %H0, [%3]\n"
1308 +" teq %1, #0\n"
1309 +" bne 1b"
1310 +
1311 +#ifdef CONFIG_PAX_REFCOUNT
1312 +"\n4:\n"
1313 + _ASM_EXTABLE(2b, 4b)
1314 +#endif
1315 +
1316 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1317 + : "r" (&v->counter), "r" (i)
1318 + : "cc");
1319 +
1320 + smp_mb();
1321 +
1322 + return result;
1323 +}
1324 +
1325 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1326 +{
1327 + u64 result;
1328 + unsigned long tmp;
1329 +
1330 + smp_mb();
1331 +
1332 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1333 "1: ldrexd %0, %H0, [%3]\n"
1334 " adds %0, %0, %4\n"
1335 " adc %H0, %H0, %H4\n"
1336 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1337 __asm__ __volatile__("@ atomic64_sub\n"
1338 "1: ldrexd %0, %H0, [%3]\n"
1339 " subs %0, %0, %4\n"
1340 +" sbcs %H0, %H0, %H4\n"
1341 +
1342 +#ifdef CONFIG_PAX_REFCOUNT
1343 +" bvc 3f\n"
1344 +"2: bkpt 0xf103\n"
1345 +"3:\n"
1346 +#endif
1347 +
1348 +" strexd %1, %0, %H0, [%3]\n"
1349 +" teq %1, #0\n"
1350 +" bne 1b"
1351 +
1352 +#ifdef CONFIG_PAX_REFCOUNT
1353 +"\n4:\n"
1354 + _ASM_EXTABLE(2b, 4b)
1355 +#endif
1356 +
1357 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1358 + : "r" (&v->counter), "r" (i)
1359 + : "cc");
1360 +}
1361 +
1362 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1363 +{
1364 + u64 result;
1365 + unsigned long tmp;
1366 +
1367 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1368 +"1: ldrexd %0, %H0, [%3]\n"
1369 +" subs %0, %0, %4\n"
1370 " sbc %H0, %H0, %H4\n"
1371 " strexd %1, %0, %H0, [%3]\n"
1372 " teq %1, #0\n"
1373 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1374
1375 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1376 {
1377 - u64 result;
1378 - unsigned long tmp;
1379 + u64 result, tmp;
1380
1381 smp_mb();
1382
1383 __asm__ __volatile__("@ atomic64_sub_return\n"
1384 -"1: ldrexd %0, %H0, [%3]\n"
1385 -" subs %0, %0, %4\n"
1386 -" sbc %H0, %H0, %H4\n"
1387 +"1: ldrexd %1, %H1, [%3]\n"
1388 +" subs %0, %1, %4\n"
1389 +" sbcs %H0, %H1, %H4\n"
1390 +
1391 +#ifdef CONFIG_PAX_REFCOUNT
1392 +" bvc 3f\n"
1393 +" mov %0, %1\n"
1394 +" mov %H0, %H1\n"
1395 +"2: bkpt 0xf103\n"
1396 +"3:\n"
1397 +#endif
1398 +
1399 " strexd %1, %0, %H0, [%3]\n"
1400 " teq %1, #0\n"
1401 " bne 1b"
1402 +
1403 +#ifdef CONFIG_PAX_REFCOUNT
1404 +"\n4:\n"
1405 + _ASM_EXTABLE(2b, 4b)
1406 +#endif
1407 +
1408 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1409 : "r" (&v->counter), "r" (i)
1410 : "cc");
1411 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1412 return oldval;
1413 }
1414
1415 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1416 +{
1417 + u64 oldval;
1418 + unsigned long res;
1419 +
1420 + smp_mb();
1421 +
1422 + do {
1423 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1424 + "ldrexd %1, %H1, [%3]\n"
1425 + "mov %0, #0\n"
1426 + "teq %1, %4\n"
1427 + "teqeq %H1, %H4\n"
1428 + "strexdeq %0, %5, %H5, [%3]"
1429 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1430 + : "r" (&ptr->counter), "r" (old), "r" (new)
1431 + : "cc");
1432 + } while (res);
1433 +
1434 + smp_mb();
1435 +
1436 + return oldval;
1437 +}
1438 +
1439 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1440 {
1441 u64 result;
1442 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1443
1444 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1445 {
1446 - u64 result;
1447 - unsigned long tmp;
1448 + u64 result, tmp;
1449
1450 smp_mb();
1451
1452 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1453 -"1: ldrexd %0, %H0, [%3]\n"
1454 -" subs %0, %0, #1\n"
1455 -" sbc %H0, %H0, #0\n"
1456 +"1: ldrexd %1, %H1, [%3]\n"
1457 +" subs %0, %1, #1\n"
1458 +" sbcs %H0, %H1, #0\n"
1459 +
1460 +#ifdef CONFIG_PAX_REFCOUNT
1461 +" bvc 3f\n"
1462 +" mov %0, %1\n"
1463 +" mov %H0, %H1\n"
1464 +"2: bkpt 0xf103\n"
1465 +"3:\n"
1466 +#endif
1467 +
1468 " teq %H0, #0\n"
1469 -" bmi 2f\n"
1470 +" bmi 4f\n"
1471 " strexd %1, %0, %H0, [%3]\n"
1472 " teq %1, #0\n"
1473 " bne 1b\n"
1474 -"2:"
1475 +"4:\n"
1476 +
1477 +#ifdef CONFIG_PAX_REFCOUNT
1478 + _ASM_EXTABLE(2b, 4b)
1479 +#endif
1480 +
1481 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1482 : "r" (&v->counter)
1483 : "cc");
1484 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1485 " teq %0, %5\n"
1486 " teqeq %H0, %H5\n"
1487 " moveq %1, #0\n"
1488 -" beq 2f\n"
1489 +" beq 4f\n"
1490 " adds %0, %0, %6\n"
1491 -" adc %H0, %H0, %H6\n"
1492 +" adcs %H0, %H0, %H6\n"
1493 +
1494 +#ifdef CONFIG_PAX_REFCOUNT
1495 +" bvc 3f\n"
1496 +"2: bkpt 0xf103\n"
1497 +"3:\n"
1498 +#endif
1499 +
1500 " strexd %2, %0, %H0, [%4]\n"
1501 " teq %2, #0\n"
1502 " bne 1b\n"
1503 -"2:"
1504 +"4:\n"
1505 +
1506 +#ifdef CONFIG_PAX_REFCOUNT
1507 + _ASM_EXTABLE(2b, 4b)
1508 +#endif
1509 +
1510 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1511 : "r" (&v->counter), "r" (u), "r" (a)
1512 : "cc");
1513 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1514
1515 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1516 #define atomic64_inc(v) atomic64_add(1LL, (v))
1517 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1518 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1519 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1520 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1521 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1522 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1523 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1524 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1525 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1526 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1527 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1528 index 75fe66b..ba3dee4 100644
1529 --- a/arch/arm/include/asm/cache.h
1530 +++ b/arch/arm/include/asm/cache.h
1531 @@ -4,8 +4,10 @@
1532 #ifndef __ASMARM_CACHE_H
1533 #define __ASMARM_CACHE_H
1534
1535 +#include <linux/const.h>
1536 +
1537 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1538 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1539 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1540
1541 /*
1542 * Memory returned by kmalloc() may be used for DMA, so we must make
1543 @@ -24,5 +26,6 @@
1544 #endif
1545
1546 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1547 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1548
1549 #endif
1550 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1551 index 15f2d5b..43ffa53 100644
1552 --- a/arch/arm/include/asm/cacheflush.h
1553 +++ b/arch/arm/include/asm/cacheflush.h
1554 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1555 void (*dma_unmap_area)(const void *, size_t, int);
1556
1557 void (*dma_flush_range)(const void *, const void *);
1558 -};
1559 +} __no_const;
1560
1561 /*
1562 * Select the calling method
1563 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1564 index 6dcc164..b14d917 100644
1565 --- a/arch/arm/include/asm/checksum.h
1566 +++ b/arch/arm/include/asm/checksum.h
1567 @@ -37,7 +37,19 @@ __wsum
1568 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1569
1570 __wsum
1571 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1572 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1573 +
1574 +static inline __wsum
1575 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1576 +{
1577 + __wsum ret;
1578 + pax_open_userland();
1579 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1580 + pax_close_userland();
1581 + return ret;
1582 +}
1583 +
1584 +
1585
1586 /*
1587 * Fold a partial checksum without adding pseudo headers
1588 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1589 index 4f009c1..466c59b 100644
1590 --- a/arch/arm/include/asm/cmpxchg.h
1591 +++ b/arch/arm/include/asm/cmpxchg.h
1592 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1593
1594 #define xchg(ptr,x) \
1595 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1596 +#define xchg_unchecked(ptr,x) \
1597 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1598
1599 #include <asm-generic/cmpxchg-local.h>
1600
1601 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1602 index 6ddbe44..b5e38b1 100644
1603 --- a/arch/arm/include/asm/domain.h
1604 +++ b/arch/arm/include/asm/domain.h
1605 @@ -48,18 +48,37 @@
1606 * Domain types
1607 */
1608 #define DOMAIN_NOACCESS 0
1609 -#define DOMAIN_CLIENT 1
1610 #ifdef CONFIG_CPU_USE_DOMAINS
1611 +#define DOMAIN_USERCLIENT 1
1612 +#define DOMAIN_KERNELCLIENT 1
1613 #define DOMAIN_MANAGER 3
1614 +#define DOMAIN_VECTORS DOMAIN_USER
1615 #else
1616 +
1617 +#ifdef CONFIG_PAX_KERNEXEC
1618 #define DOMAIN_MANAGER 1
1619 +#define DOMAIN_KERNEXEC 3
1620 +#else
1621 +#define DOMAIN_MANAGER 1
1622 +#endif
1623 +
1624 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1625 +#define DOMAIN_USERCLIENT 0
1626 +#define DOMAIN_UDEREF 1
1627 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1628 +#else
1629 +#define DOMAIN_USERCLIENT 1
1630 +#define DOMAIN_VECTORS DOMAIN_USER
1631 +#endif
1632 +#define DOMAIN_KERNELCLIENT 1
1633 +
1634 #endif
1635
1636 #define domain_val(dom,type) ((type) << (2*(dom)))
1637
1638 #ifndef __ASSEMBLY__
1639
1640 -#ifdef CONFIG_CPU_USE_DOMAINS
1641 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1642 static inline void set_domain(unsigned val)
1643 {
1644 asm volatile(
1645 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1646 isb();
1647 }
1648
1649 -#define modify_domain(dom,type) \
1650 - do { \
1651 - struct thread_info *thread = current_thread_info(); \
1652 - unsigned int domain = thread->cpu_domain; \
1653 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1654 - thread->cpu_domain = domain | domain_val(dom, type); \
1655 - set_domain(thread->cpu_domain); \
1656 - } while (0)
1657 -
1658 +extern void modify_domain(unsigned int dom, unsigned int type);
1659 #else
1660 static inline void set_domain(unsigned val) { }
1661 static inline void modify_domain(unsigned dom, unsigned type) { }
1662 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1663 index f4b46d3..abc9b2b 100644
1664 --- a/arch/arm/include/asm/elf.h
1665 +++ b/arch/arm/include/asm/elf.h
1666 @@ -114,7 +114,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1667 the loader. We need to make sure that it is out of the way of the program
1668 that it will "exec", and that there is sufficient room for the brk. */
1669
1670 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1671 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1672 +
1673 +#ifdef CONFIG_PAX_ASLR
1674 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1675 +
1676 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1677 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1678 +#endif
1679
1680 /* When the program starts, a1 contains a pointer to a function to be
1681 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1682 @@ -124,10 +131,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1683 extern void elf_set_personality(const struct elf32_hdr *);
1684 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1685
1686 -struct mm_struct;
1687 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1688 -#define arch_randomize_brk arch_randomize_brk
1689 -
1690 #ifdef CONFIG_MMU
1691 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
1692 struct linux_binprm;
1693 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1694 index de53547..52b9a28 100644
1695 --- a/arch/arm/include/asm/fncpy.h
1696 +++ b/arch/arm/include/asm/fncpy.h
1697 @@ -81,7 +81,9 @@
1698 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1699 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1700 \
1701 + pax_open_kernel(); \
1702 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1703 + pax_close_kernel(); \
1704 flush_icache_range((unsigned long)(dest_buf), \
1705 (unsigned long)(dest_buf) + (size)); \
1706 \
1707 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1708 index e42cf59..7b94b8f 100644
1709 --- a/arch/arm/include/asm/futex.h
1710 +++ b/arch/arm/include/asm/futex.h
1711 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1712 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1713 return -EFAULT;
1714
1715 + pax_open_userland();
1716 +
1717 smp_mb();
1718 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1719 "1: ldrex %1, [%4]\n"
1720 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1721 : "cc", "memory");
1722 smp_mb();
1723
1724 + pax_close_userland();
1725 +
1726 *uval = val;
1727 return ret;
1728 }
1729 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1730 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1731 return -EFAULT;
1732
1733 + pax_open_userland();
1734 +
1735 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1736 "1: " TUSER(ldr) " %1, [%4]\n"
1737 " teq %1, %2\n"
1738 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1739 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1740 : "cc", "memory");
1741
1742 + pax_close_userland();
1743 +
1744 *uval = val;
1745 return ret;
1746 }
1747 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1748 return -EFAULT;
1749
1750 pagefault_disable(); /* implies preempt_disable() */
1751 + pax_open_userland();
1752
1753 switch (op) {
1754 case FUTEX_OP_SET:
1755 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1756 ret = -ENOSYS;
1757 }
1758
1759 + pax_close_userland();
1760 pagefault_enable(); /* subsumes preempt_enable() */
1761
1762 if (!ret) {
1763 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1764 index 83eb2f7..ed77159 100644
1765 --- a/arch/arm/include/asm/kmap_types.h
1766 +++ b/arch/arm/include/asm/kmap_types.h
1767 @@ -4,6 +4,6 @@
1768 /*
1769 * This is the "bare minimum". AIO seems to require this.
1770 */
1771 -#define KM_TYPE_NR 16
1772 +#define KM_TYPE_NR 17
1773
1774 #endif
1775 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1776 index 9e614a1..3302cca 100644
1777 --- a/arch/arm/include/asm/mach/dma.h
1778 +++ b/arch/arm/include/asm/mach/dma.h
1779 @@ -22,7 +22,7 @@ struct dma_ops {
1780 int (*residue)(unsigned int, dma_t *); /* optional */
1781 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1782 const char *type;
1783 -};
1784 +} __do_const;
1785
1786 struct dma_struct {
1787 void *addr; /* single DMA address */
1788 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1789 index 2fe141f..192dc01 100644
1790 --- a/arch/arm/include/asm/mach/map.h
1791 +++ b/arch/arm/include/asm/mach/map.h
1792 @@ -27,13 +27,16 @@ struct map_desc {
1793 #define MT_MINICLEAN 6
1794 #define MT_LOW_VECTORS 7
1795 #define MT_HIGH_VECTORS 8
1796 -#define MT_MEMORY 9
1797 +#define MT_MEMORY_RWX 9
1798 #define MT_ROM 10
1799 -#define MT_MEMORY_NONCACHED 11
1800 +#define MT_MEMORY_NONCACHED_RX 11
1801 #define MT_MEMORY_DTCM 12
1802 #define MT_MEMORY_ITCM 13
1803 #define MT_MEMORY_SO 14
1804 #define MT_MEMORY_DMA_READY 15
1805 +#define MT_MEMORY_RW 16
1806 +#define MT_MEMORY_RX 17
1807 +#define MT_MEMORY_NONCACHED_RW 18
1808
1809 #ifdef CONFIG_MMU
1810 extern void iotable_init(struct map_desc *, int);
1811 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1812 index f94784f..9a09a4a 100644
1813 --- a/arch/arm/include/asm/outercache.h
1814 +++ b/arch/arm/include/asm/outercache.h
1815 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1816 #endif
1817 void (*set_debug)(unsigned long);
1818 void (*resume)(void);
1819 -};
1820 +} __no_const;
1821
1822 extern struct outer_cache_fns outer_cache;
1823
1824 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1825 index 4355f0e..c229913 100644
1826 --- a/arch/arm/include/asm/page.h
1827 +++ b/arch/arm/include/asm/page.h
1828 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1829 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1830 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1831 unsigned long vaddr, struct vm_area_struct *vma);
1832 -};
1833 +} __no_const;
1834
1835 #ifdef MULTI_USER
1836 extern struct cpu_user_fns cpu_user;
1837 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1838 index 943504f..c37a730 100644
1839 --- a/arch/arm/include/asm/pgalloc.h
1840 +++ b/arch/arm/include/asm/pgalloc.h
1841 @@ -17,6 +17,7 @@
1842 #include <asm/processor.h>
1843 #include <asm/cacheflush.h>
1844 #include <asm/tlbflush.h>
1845 +#include <asm/system_info.h>
1846
1847 #define check_pgt_cache() do { } while (0)
1848
1849 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1850 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1851 }
1852
1853 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1854 +{
1855 + pud_populate(mm, pud, pmd);
1856 +}
1857 +
1858 #else /* !CONFIG_ARM_LPAE */
1859
1860 /*
1861 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1862 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1863 #define pmd_free(mm, pmd) do { } while (0)
1864 #define pud_populate(mm,pmd,pte) BUG()
1865 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1866
1867 #endif /* CONFIG_ARM_LPAE */
1868
1869 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1870 __free_page(pte);
1871 }
1872
1873 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1874 +{
1875 +#ifdef CONFIG_ARM_LPAE
1876 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1877 +#else
1878 + if (addr & SECTION_SIZE)
1879 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1880 + else
1881 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1882 +#endif
1883 + flush_pmd_entry(pmdp);
1884 +}
1885 +
1886 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1887 pmdval_t prot)
1888 {
1889 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1890 static inline void
1891 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1892 {
1893 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1894 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1895 }
1896 #define pmd_pgtable(pmd) pmd_page(pmd)
1897
1898 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1899 index 5cfba15..f415e1a 100644
1900 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1901 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1902 @@ -20,12 +20,15 @@
1903 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1904 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1905 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1906 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1907 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1908 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1909 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1910 +
1911 /*
1912 * - section
1913 */
1914 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1915 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1916 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1917 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1918 @@ -37,6 +40,7 @@
1919 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1920 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1921 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1922 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1923
1924 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1925 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1926 @@ -66,6 +70,7 @@
1927 * - extended small page/tiny page
1928 */
1929 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1930 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1931 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1932 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1933 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1934 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1935 index f97ee02..cc9fe9e 100644
1936 --- a/arch/arm/include/asm/pgtable-2level.h
1937 +++ b/arch/arm/include/asm/pgtable-2level.h
1938 @@ -126,6 +126,9 @@
1939 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1940 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1941
1942 +/* Two-level page tables only have PXN in the PGD, not in the PTE. */
1943 +#define L_PTE_PXN (_AT(pteval_t, 0))
1944 +
1945 /*
1946 * These are the memory types, defined to be compatible with
1947 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
1948 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1949 index 626989f..9d67a33 100644
1950 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1951 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1952 @@ -75,6 +75,7 @@
1953 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1954 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1955 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1956 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1957 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1958
1959 /*
1960 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1961 index 5689c18..eea12f9 100644
1962 --- a/arch/arm/include/asm/pgtable-3level.h
1963 +++ b/arch/arm/include/asm/pgtable-3level.h
1964 @@ -82,6 +82,7 @@
1965 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1966 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1967 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1968 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1969 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1970 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1971 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1972 @@ -95,6 +96,7 @@
1973 /*
1974 * To be used in assembly code with the upper page attributes.
1975 */
1976 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1977 #define L_PTE_XN_HIGH (1 << (54 - 32))
1978 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1979
1980 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1981 index 1571d12..b8a9b43 100644
1982 --- a/arch/arm/include/asm/pgtable.h
1983 +++ b/arch/arm/include/asm/pgtable.h
1984 @@ -33,6 +33,9 @@
1985 #include <asm/pgtable-2level.h>
1986 #endif
1987
1988 +#define ktla_ktva(addr) (addr)
1989 +#define ktva_ktla(addr) (addr)
1990 +
1991 /*
1992 * Just any arbitrary offset to the start of the vmalloc VM area: the
1993 * current 8MB value just means that there will be a 8MB "hole" after the
1994 @@ -48,6 +51,9 @@
1995 #define LIBRARY_TEXT_START 0x0c000000
1996
1997 #ifndef __ASSEMBLY__
1998 +extern pteval_t __supported_pte_mask;
1999 +extern pmdval_t __supported_pmd_mask;
2000 +
2001 extern void __pte_error(const char *file, int line, pte_t);
2002 extern void __pmd_error(const char *file, int line, pmd_t);
2003 extern void __pgd_error(const char *file, int line, pgd_t);
2004 @@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2005 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
2006 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
2007
2008 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
2009 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2010 +
2011 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2012 +#include <asm/domain.h>
2013 +#include <linux/thread_info.h>
2014 +#include <linux/preempt.h>
2015 +
2016 +static inline int test_domain(int domain, int domaintype)
2017 +{
2018 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2019 +}
2020 +#endif
2021 +
2022 +#ifdef CONFIG_PAX_KERNEXEC
2023 +static inline unsigned long pax_open_kernel(void) {
2024 +#ifdef CONFIG_ARM_LPAE
2025 + /* TODO */
2026 +#else
2027 + preempt_disable();
2028 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2029 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2030 +#endif
2031 + return 0;
2032 +}
2033 +
2034 +static inline unsigned long pax_close_kernel(void) {
2035 +#ifdef CONFIG_ARM_LPAE
2036 + /* TODO */
2037 +#else
2038 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2039 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2040 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2041 + preempt_enable_no_resched();
2042 +#endif
2043 + return 0;
2044 +}
2045 +#else
2046 +static inline unsigned long pax_open_kernel(void) { return 0; }
2047 +static inline unsigned long pax_close_kernel(void) { return 0; }
2048 +#endif
2049 +
2050 /*
2051 * This is the lowest virtual address we can permit any user space
2052 * mapping to be mapped at. This is particularly important for
2053 @@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2054 /*
2055 * The pgprot_* and protection_map entries will be fixed up in runtime
2056 * to include the cachable and bufferable bits based on memory policy,
2057 - * as well as any architecture dependent bits like global/ASID and SMP
2058 - * shared mapping bits.
2059 + * as well as any architecture dependent bits like global/ASID, PXN,
2060 + * and SMP shared mapping bits.
2061 */
2062 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2063
2064 @@ -260,7 +308,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2065 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2066 {
2067 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2068 - L_PTE_NONE | L_PTE_VALID;
2069 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2070 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2071 return pte;
2072 }
2073 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2074 index 5324c11..bcae5f0 100644
2075 --- a/arch/arm/include/asm/proc-fns.h
2076 +++ b/arch/arm/include/asm/proc-fns.h
2077 @@ -75,7 +75,7 @@ extern struct processor {
2078 unsigned int suspend_size;
2079 void (*do_suspend)(void *);
2080 void (*do_resume)(void *);
2081 -} processor;
2082 +} __do_const processor;
2083
2084 #ifndef MULTI_CPU
2085 extern void cpu_proc_init(void);
2086 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2087 index c4ae171..ea0c0c2 100644
2088 --- a/arch/arm/include/asm/psci.h
2089 +++ b/arch/arm/include/asm/psci.h
2090 @@ -29,7 +29,7 @@ struct psci_operations {
2091 int (*cpu_off)(struct psci_power_state state);
2092 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2093 int (*migrate)(unsigned long cpuid);
2094 -};
2095 +} __no_const;
2096
2097 extern struct psci_operations psci_ops;
2098 extern struct smp_operations psci_smp_ops;
2099 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2100 index a8cae71c..65dd797 100644
2101 --- a/arch/arm/include/asm/smp.h
2102 +++ b/arch/arm/include/asm/smp.h
2103 @@ -110,7 +110,7 @@ struct smp_operations {
2104 int (*cpu_disable)(unsigned int cpu);
2105 #endif
2106 #endif
2107 -};
2108 +} __no_const;
2109
2110 /*
2111 * set platform specific SMP operations
2112 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2113 index df5e13d..97efb82 100644
2114 --- a/arch/arm/include/asm/thread_info.h
2115 +++ b/arch/arm/include/asm/thread_info.h
2116 @@ -88,9 +88,9 @@ struct thread_info {
2117 .flags = 0, \
2118 .preempt_count = INIT_PREEMPT_COUNT, \
2119 .addr_limit = KERNEL_DS, \
2120 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2121 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2122 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2123 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2124 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2125 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2126 .restart_block = { \
2127 .fn = do_no_restart_syscall, \
2128 }, \
2129 @@ -163,7 +163,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2130 #define TIF_SYSCALL_AUDIT 9
2131 #define TIF_SYSCALL_TRACEPOINT 10
2132 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2133 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2134 +/* within 8 bits of TIF_SYSCALL_TRACE
2135 + * to meet flexible second operand requirements
2136 + */
2137 +#define TIF_GRSEC_SETXID 12
2138 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2139 #define TIF_USING_IWMMXT 17
2140 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2141 #define TIF_RESTORE_SIGMASK 20
2142 @@ -176,10 +180,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2143 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2144 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2145 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2146 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2147
2148 /* Checks for any syscall work in entry-common.S */
2149 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2150 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2151 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2152
2153 /*
2154 * Change these and you break ASM code in entry-common.S
2155 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2156 index 72abdc5..9eba222 100644
2157 --- a/arch/arm/include/asm/uaccess.h
2158 +++ b/arch/arm/include/asm/uaccess.h
2159 @@ -18,6 +18,7 @@
2160 #include <asm/domain.h>
2161 #include <asm/unified.h>
2162 #include <asm/compiler.h>
2163 +#include <asm/pgtable.h>
2164
2165 #if __LINUX_ARM_ARCH__ < 6
2166 #include <asm-generic/uaccess-unaligned.h>
2167 @@ -70,11 +71,38 @@ extern int __put_user_bad(void);
2168 static inline void set_fs(mm_segment_t fs)
2169 {
2170 current_thread_info()->addr_limit = fs;
2171 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2172 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2173 }
2174
2175 #define segment_eq(a,b) ((a) == (b))
2176
2177 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2178 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2179 +
2180 +static inline void pax_open_userland(void)
2181 +{
2182 +
2183 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2184 + if (segment_eq(get_fs(), USER_DS)) {
2185 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2186 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2187 + }
2188 +#endif
2189 +
2190 +}
2191 +
2192 +static inline void pax_close_userland(void)
2193 +{
2194 +
2195 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2196 + if (segment_eq(get_fs(), USER_DS)) {
2197 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2198 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2199 + }
2200 +#endif
2201 +
2202 +}
2203 +
2204 #define __addr_ok(addr) ({ \
2205 unsigned long flag; \
2206 __asm__("cmp %2, %0; movlo %0, #0" \
2207 @@ -150,8 +178,12 @@ extern int __get_user_4(void *);
2208
2209 #define get_user(x,p) \
2210 ({ \
2211 + int __e; \
2212 might_fault(); \
2213 - __get_user_check(x,p); \
2214 + pax_open_userland(); \
2215 + __e = __get_user_check(x,p); \
2216 + pax_close_userland(); \
2217 + __e; \
2218 })
2219
2220 extern int __put_user_1(void *, unsigned int);
2221 @@ -195,8 +227,12 @@ extern int __put_user_8(void *, unsigned long long);
2222
2223 #define put_user(x,p) \
2224 ({ \
2225 + int __e; \
2226 might_fault(); \
2227 - __put_user_check(x,p); \
2228 + pax_open_userland(); \
2229 + __e = __put_user_check(x,p); \
2230 + pax_close_userland(); \
2231 + __e; \
2232 })
2233
2234 #else /* CONFIG_MMU */
2235 @@ -237,13 +273,17 @@ static inline void set_fs(mm_segment_t fs)
2236 #define __get_user(x,ptr) \
2237 ({ \
2238 long __gu_err = 0; \
2239 + pax_open_userland(); \
2240 __get_user_err((x),(ptr),__gu_err); \
2241 + pax_close_userland(); \
2242 __gu_err; \
2243 })
2244
2245 #define __get_user_error(x,ptr,err) \
2246 ({ \
2247 + pax_open_userland(); \
2248 __get_user_err((x),(ptr),err); \
2249 + pax_close_userland(); \
2250 (void) 0; \
2251 })
2252
2253 @@ -319,13 +359,17 @@ do { \
2254 #define __put_user(x,ptr) \
2255 ({ \
2256 long __pu_err = 0; \
2257 + pax_open_userland(); \
2258 __put_user_err((x),(ptr),__pu_err); \
2259 + pax_close_userland(); \
2260 __pu_err; \
2261 })
2262
2263 #define __put_user_error(x,ptr,err) \
2264 ({ \
2265 + pax_open_userland(); \
2266 __put_user_err((x),(ptr),err); \
2267 + pax_close_userland(); \
2268 (void) 0; \
2269 })
2270
2271 @@ -425,11 +469,44 @@ do { \
2272
2273
2274 #ifdef CONFIG_MMU
2275 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2276 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2277 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2278 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2279 +
2280 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2281 +{
2282 + unsigned long ret;
2283 +
2284 + check_object_size(to, n, false);
2285 + pax_open_userland();
2286 + ret = ___copy_from_user(to, from, n);
2287 + pax_close_userland();
2288 + return ret;
2289 +}
2290 +
2291 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2292 +{
2293 + unsigned long ret;
2294 +
2295 + check_object_size(from, n, true);
2296 + pax_open_userland();
2297 + ret = ___copy_to_user(to, from, n);
2298 + pax_close_userland();
2299 + return ret;
2300 +}
2301 +
2302 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2303 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2304 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2305 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2306 +
2307 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2308 +{
2309 + unsigned long ret;
2310 + pax_open_userland();
2311 + ret = ___clear_user(addr, n);
2312 + pax_close_userland();
2313 + return ret;
2314 +}
2315 +
2316 #else
2317 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2318 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2319 @@ -438,6 +515,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2320
2321 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2322 {
2323 + if ((long)n < 0)
2324 + return n;
2325 +
2326 if (access_ok(VERIFY_READ, from, n))
2327 n = __copy_from_user(to, from, n);
2328 else /* security hole - plug it */
2329 @@ -447,6 +527,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2330
2331 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2332 {
2333 + if ((long)n < 0)
2334 + return n;
2335 +
2336 if (access_ok(VERIFY_WRITE, to, n))
2337 n = __copy_to_user(to, from, n);
2338 return n;
2339 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2340 index 5af0ed1..cea83883 100644
2341 --- a/arch/arm/include/uapi/asm/ptrace.h
2342 +++ b/arch/arm/include/uapi/asm/ptrace.h
2343 @@ -92,7 +92,7 @@
2344 * ARMv7 groups of PSR bits
2345 */
2346 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2347 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2348 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2349 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2350 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2351
2352 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2353 index 60d3b73..e5a0f22 100644
2354 --- a/arch/arm/kernel/armksyms.c
2355 +++ b/arch/arm/kernel/armksyms.c
2356 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2357
2358 /* networking */
2359 EXPORT_SYMBOL(csum_partial);
2360 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2361 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2362 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2363 EXPORT_SYMBOL(__csum_ipv6_magic);
2364
2365 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2366 #ifdef CONFIG_MMU
2367 EXPORT_SYMBOL(copy_page);
2368
2369 -EXPORT_SYMBOL(__copy_from_user);
2370 -EXPORT_SYMBOL(__copy_to_user);
2371 -EXPORT_SYMBOL(__clear_user);
2372 +EXPORT_SYMBOL(___copy_from_user);
2373 +EXPORT_SYMBOL(___copy_to_user);
2374 +EXPORT_SYMBOL(___clear_user);
2375
2376 EXPORT_SYMBOL(__get_user_1);
2377 EXPORT_SYMBOL(__get_user_2);
2378 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2379 index ec3e5cf..b450ee3 100644
2380 --- a/arch/arm/kernel/entry-armv.S
2381 +++ b/arch/arm/kernel/entry-armv.S
2382 @@ -47,6 +47,87 @@
2383 9997:
2384 .endm
2385
2386 + .macro pax_enter_kernel
2387 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2388 + @ make aligned space for saved DACR
2389 + sub sp, sp, #8
2390 + @ save regs
2391 + stmdb sp!, {r1, r2}
2392 + @ read DACR from cpu_domain into r1
2393 + mov r2, sp
2394 + @ assume 8K pages, since we have to split the immediate in two
2395 + bic r2, r2, #(0x1fc0)
2396 + bic r2, r2, #(0x3f)
2397 + ldr r1, [r2, #TI_CPU_DOMAIN]
2398 + @ store old DACR on stack
2399 + str r1, [sp, #8]
2400 +#ifdef CONFIG_PAX_KERNEXEC
2401 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2402 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2403 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2404 +#endif
2405 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2406 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2407 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2408 +#endif
2409 + @ write r1 to current_thread_info()->cpu_domain
2410 + str r1, [r2, #TI_CPU_DOMAIN]
2411 + @ write r1 to DACR
2412 + mcr p15, 0, r1, c3, c0, 0
2413 + @ instruction sync
2414 + instr_sync
2415 + @ restore regs
2416 + ldmia sp!, {r1, r2}
2417 +#endif
2418 + .endm
2419 +
2420 + .macro pax_open_userland
2421 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2422 + @ save regs
2423 + stmdb sp!, {r0, r1}
2424 + @ read DACR from cpu_domain into r1
2425 + mov r0, sp
2426 + @ assume 8K pages, since we have to split the immediate in two
2427 + bic r0, r0, #(0x1fc0)
2428 + bic r0, r0, #(0x3f)
2429 + ldr r1, [r0, #TI_CPU_DOMAIN]
2430 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2431 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2432 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2433 + @ write r1 to current_thread_info()->cpu_domain
2434 + str r1, [r0, #TI_CPU_DOMAIN]
2435 + @ write r1 to DACR
2436 + mcr p15, 0, r1, c3, c0, 0
2437 + @ instruction sync
2438 + instr_sync
2439 + @ restore regs
2440 + ldmia sp!, {r0, r1}
2441 +#endif
2442 + .endm
2443 +
2444 + .macro pax_close_userland
2445 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2446 + @ save regs
2447 + stmdb sp!, {r0, r1}
2448 + @ read DACR from cpu_domain into r1
2449 + mov r0, sp
2450 + @ assume 8K pages, since we have to split the immediate in two
2451 + bic r0, r0, #(0x1fc0)
2452 + bic r0, r0, #(0x3f)
2453 + ldr r1, [r0, #TI_CPU_DOMAIN]
2454 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2455 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2456 + @ write r1 to current_thread_info()->cpu_domain
2457 + str r1, [r0, #TI_CPU_DOMAIN]
2458 + @ write r1 to DACR
2459 + mcr p15, 0, r1, c3, c0, 0
2460 + @ instruction sync
2461 + instr_sync
2462 + @ restore regs
2463 + ldmia sp!, {r0, r1}
2464 +#endif
2465 + .endm
2466 +
2467 .macro pabt_helper
2468 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2469 #ifdef MULTI_PABORT
2470 @@ -89,11 +170,15 @@
2471 * Invalid mode handlers
2472 */
2473 .macro inv_entry, reason
2474 +
2475 + pax_enter_kernel
2476 +
2477 sub sp, sp, #S_FRAME_SIZE
2478 ARM( stmib sp, {r1 - lr} )
2479 THUMB( stmia sp, {r0 - r12} )
2480 THUMB( str sp, [sp, #S_SP] )
2481 THUMB( str lr, [sp, #S_LR] )
2482 +
2483 mov r1, #\reason
2484 .endm
2485
2486 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2487 .macro svc_entry, stack_hole=0
2488 UNWIND(.fnstart )
2489 UNWIND(.save {r0 - pc} )
2490 +
2491 + pax_enter_kernel
2492 +
2493 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2494 +
2495 #ifdef CONFIG_THUMB2_KERNEL
2496 SPFIX( str r0, [sp] ) @ temporarily saved
2497 SPFIX( mov r0, sp )
2498 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2499 ldmia r0, {r3 - r5}
2500 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2501 mov r6, #-1 @ "" "" "" ""
2502 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2503 + @ offset sp by 8 as done in pax_enter_kernel
2504 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2505 +#else
2506 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2507 +#endif
2508 SPFIX( addeq r2, r2, #4 )
2509 str r3, [sp, #-4]! @ save the "real" r0 copied
2510 @ from the exception stack
2511 @@ -317,6 +411,9 @@ ENDPROC(__pabt_svc)
2512 .macro usr_entry
2513 UNWIND(.fnstart )
2514 UNWIND(.cantunwind ) @ don't unwind the user space
2515 +
2516 + pax_enter_kernel_user
2517 +
2518 sub sp, sp, #S_FRAME_SIZE
2519 ARM( stmib sp, {r1 - r12} )
2520 THUMB( stmia sp, {r0 - r12} )
2521 @@ -416,7 +513,9 @@ __und_usr:
2522 tst r3, #PSR_T_BIT @ Thumb mode?
2523 bne __und_usr_thumb
2524 sub r4, r2, #4 @ ARM instr at LR - 4
2525 + pax_open_userland
2526 1: ldrt r0, [r4]
2527 + pax_close_userland
2528 #ifdef CONFIG_CPU_ENDIAN_BE8
2529 rev r0, r0 @ little endian instruction
2530 #endif
2531 @@ -451,10 +550,14 @@ __und_usr_thumb:
2532 */
2533 .arch armv6t2
2534 #endif
2535 + pax_open_userland
2536 2: ldrht r5, [r4]
2537 + pax_close_userland
2538 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2539 blo __und_usr_fault_16 @ 16bit undefined instruction
2540 + pax_open_userland
2541 3: ldrht r0, [r2]
2542 + pax_close_userland
2543 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2544 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2545 orr r0, r0, r5, lsl #16
2546 @@ -483,7 +586,8 @@ ENDPROC(__und_usr)
2547 */
2548 .pushsection .fixup, "ax"
2549 .align 2
2550 -4: mov pc, r9
2551 +4: pax_close_userland
2552 + mov pc, r9
2553 .popsection
2554 .pushsection __ex_table,"a"
2555 .long 1b, 4b
2556 @@ -693,7 +797,7 @@ ENTRY(__switch_to)
2557 THUMB( str lr, [ip], #4 )
2558 ldr r4, [r2, #TI_TP_VALUE]
2559 ldr r5, [r2, #TI_TP_VALUE + 4]
2560 -#ifdef CONFIG_CPU_USE_DOMAINS
2561 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2562 ldr r6, [r2, #TI_CPU_DOMAIN]
2563 #endif
2564 switch_tls r1, r4, r5, r3, r7
2565 @@ -702,7 +806,7 @@ ENTRY(__switch_to)
2566 ldr r8, =__stack_chk_guard
2567 ldr r7, [r7, #TSK_STACK_CANARY]
2568 #endif
2569 -#ifdef CONFIG_CPU_USE_DOMAINS
2570 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2571 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2572 #endif
2573 mov r5, r0
2574 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2575 index bc6bd96..bd026cb 100644
2576 --- a/arch/arm/kernel/entry-common.S
2577 +++ b/arch/arm/kernel/entry-common.S
2578 @@ -10,18 +10,46 @@
2579
2580 #include <asm/unistd.h>
2581 #include <asm/ftrace.h>
2582 +#include <asm/domain.h>
2583 #include <asm/unwind.h>
2584
2585 +#include "entry-header.S"
2586 +
2587 #ifdef CONFIG_NEED_RET_TO_USER
2588 #include <mach/entry-macro.S>
2589 #else
2590 .macro arch_ret_to_user, tmp1, tmp2
2591 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2592 + @ save regs
2593 + stmdb sp!, {r1, r2}
2594 + @ read DACR from cpu_domain into r1
2595 + mov r2, sp
2596 + @ assume 8K pages, since we have to split the immediate in two
2597 + bic r2, r2, #(0x1fc0)
2598 + bic r2, r2, #(0x3f)
2599 + ldr r1, [r2, #TI_CPU_DOMAIN]
2600 +#ifdef CONFIG_PAX_KERNEXEC
2601 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2602 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2603 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2604 +#endif
2605 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2606 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2607 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2608 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2609 +#endif
2610 + @ write r1 to current_thread_info()->cpu_domain
2611 + str r1, [r2, #TI_CPU_DOMAIN]
2612 + @ write r1 to DACR
2613 + mcr p15, 0, r1, c3, c0, 0
2614 + @ instruction sync
2615 + instr_sync
2616 + @ restore regs
2617 + ldmia sp!, {r1, r2}
2618 +#endif
2619 .endm
2620 #endif
2621
2622 -#include "entry-header.S"
2623 -
2624 -
2625 .align 5
2626 /*
2627 * This is the fast syscall return path. We do as little as
2628 @@ -413,6 +441,12 @@ ENTRY(vector_swi)
2629 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2630 #endif
2631
2632 + /*
2633 + * do this here to avoid a performance hit of wrapping the code above
2634 + * that directly dereferences userland to parse the SWI instruction
2635 + */
2636 + pax_enter_kernel_user
2637 +
2638 adr tbl, sys_call_table @ load syscall table pointer
2639
2640 #if defined(CONFIG_OABI_COMPAT)
2641 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2642 index 39f89fb..d612bd9 100644
2643 --- a/arch/arm/kernel/entry-header.S
2644 +++ b/arch/arm/kernel/entry-header.S
2645 @@ -184,6 +184,60 @@
2646 msr cpsr_c, \rtemp @ switch back to the SVC mode
2647 .endm
2648
2649 + .macro pax_enter_kernel_user
2650 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2651 + @ save regs
2652 + stmdb sp!, {r0, r1}
2653 + @ read DACR from cpu_domain into r1
2654 + mov r0, sp
2655 + @ assume 8K pages, since we have to split the immediate in two
2656 + bic r0, r0, #(0x1fc0)
2657 + bic r0, r0, #(0x3f)
2658 + ldr r1, [r0, #TI_CPU_DOMAIN]
2659 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2660 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2661 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2662 +#endif
2663 +#ifdef CONFIG_PAX_KERNEXEC
2664 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2665 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2666 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2667 +#endif
2668 + @ write r1 to current_thread_info()->cpu_domain
2669 + str r1, [r0, #TI_CPU_DOMAIN]
2670 + @ write r1 to DACR
2671 + mcr p15, 0, r1, c3, c0, 0
2672 + @ instruction sync
2673 + instr_sync
2674 + @ restore regs
2675 + ldmia sp!, {r0, r1}
2676 +#endif
2677 + .endm
2678 +
2679 + .macro pax_exit_kernel
2680 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2681 + @ save regs
2682 + stmdb sp!, {r0, r1}
2683 + @ read old DACR from stack into r1
2684 + ldr r1, [sp, #(8 + S_SP)]
2685 + sub r1, r1, #8
2686 + ldr r1, [r1]
2687 +
2688 + @ write r1 to current_thread_info()->cpu_domain
2689 + mov r0, sp
2690 + @ assume 8K pages, since we have to split the immediate in two
2691 + bic r0, r0, #(0x1fc0)
2692 + bic r0, r0, #(0x3f)
2693 + str r1, [r0, #TI_CPU_DOMAIN]
2694 + @ write r1 to DACR
2695 + mcr p15, 0, r1, c3, c0, 0
2696 + @ instruction sync
2697 + instr_sync
2698 + @ restore regs
2699 + ldmia sp!, {r0, r1}
2700 +#endif
2701 + .endm
2702 +
2703 #ifndef CONFIG_THUMB2_KERNEL
2704 .macro svc_exit, rpsr, irq = 0
2705 .if \irq != 0
2706 @@ -203,6 +257,9 @@
2707 blne trace_hardirqs_off
2708 #endif
2709 .endif
2710 +
2711 + pax_exit_kernel
2712 +
2713 msr spsr_cxsf, \rpsr
2714 #if defined(CONFIG_CPU_V6)
2715 ldr r0, [sp]
2716 @@ -266,6 +323,9 @@
2717 blne trace_hardirqs_off
2718 #endif
2719 .endif
2720 +
2721 + pax_exit_kernel
2722 +
2723 ldr lr, [sp, #S_SP] @ top of the stack
2724 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2725 clrex @ clear the exclusive monitor
2726 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2727 index 918875d..cd5fa27 100644
2728 --- a/arch/arm/kernel/fiq.c
2729 +++ b/arch/arm/kernel/fiq.c
2730 @@ -87,7 +87,10 @@ void set_fiq_handler(void *start, unsigned int length)
2731 void *base = vectors_page;
2732 unsigned offset = FIQ_OFFSET;
2733
2734 + pax_open_kernel();
2735 memcpy(base + offset, start, length);
2736 + pax_close_kernel();
2737 +
2738 if (!cache_is_vipt_nonaliasing())
2739 flush_icache_range((unsigned long)base + offset, offset +
2740 length);
2741 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2742 index 476de57..4857a76 100644
2743 --- a/arch/arm/kernel/head.S
2744 +++ b/arch/arm/kernel/head.S
2745 @@ -52,7 +52,9 @@
2746 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2747
2748 .macro pgtbl, rd, phys
2749 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2750 + mov \rd, #TEXT_OFFSET
2751 + sub \rd, #PG_DIR_SIZE
2752 + add \rd, \rd, \phys
2753 .endm
2754
2755 /*
2756 @@ -432,7 +434,7 @@ __enable_mmu:
2757 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2758 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2759 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2760 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2761 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2762 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2763 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2764 #endif
2765 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2766 index 084dc88..fce4e68 100644
2767 --- a/arch/arm/kernel/module.c
2768 +++ b/arch/arm/kernel/module.c
2769 @@ -37,12 +37,39 @@
2770 #endif
2771
2772 #ifdef CONFIG_MMU
2773 -void *module_alloc(unsigned long size)
2774 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2775 {
2776 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2777 + return NULL;
2778 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2779 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2780 + GFP_KERNEL, prot, -1,
2781 __builtin_return_address(0));
2782 }
2783 +
2784 +void *module_alloc(unsigned long size)
2785 +{
2786 +
2787 +#ifdef CONFIG_PAX_KERNEXEC
2788 + return __module_alloc(size, PAGE_KERNEL);
2789 +#else
2790 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2791 +#endif
2792 +
2793 +}
2794 +
2795 +#ifdef CONFIG_PAX_KERNEXEC
2796 +void module_free_exec(struct module *mod, void *module_region)
2797 +{
2798 + module_free(mod, module_region);
2799 +}
2800 +EXPORT_SYMBOL(module_free_exec);
2801 +
2802 +void *module_alloc_exec(unsigned long size)
2803 +{
2804 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2805 +}
2806 +EXPORT_SYMBOL(module_alloc_exec);
2807 +#endif
2808 #endif
2809
2810 int
2811 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2812 index 07314af..c46655c 100644
2813 --- a/arch/arm/kernel/patch.c
2814 +++ b/arch/arm/kernel/patch.c
2815 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2816 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2817 int size;
2818
2819 + pax_open_kernel();
2820 if (thumb2 && __opcode_is_thumb16(insn)) {
2821 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2822 size = sizeof(u16);
2823 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2824 *(u32 *)addr = insn;
2825 size = sizeof(u32);
2826 }
2827 + pax_close_kernel();
2828
2829 flush_icache_range((uintptr_t)(addr),
2830 (uintptr_t)(addr) + size);
2831 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2832 index 92f7b15..7048500 100644
2833 --- a/arch/arm/kernel/process.c
2834 +++ b/arch/arm/kernel/process.c
2835 @@ -217,6 +217,7 @@ void machine_power_off(void)
2836
2837 if (pm_power_off)
2838 pm_power_off();
2839 + BUG();
2840 }
2841
2842 /*
2843 @@ -230,7 +231,7 @@ void machine_power_off(void)
2844 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2845 * to use. Implementing such co-ordination would be essentially impossible.
2846 */
2847 -void machine_restart(char *cmd)
2848 +__noreturn void machine_restart(char *cmd)
2849 {
2850 local_irq_disable();
2851 smp_send_stop();
2852 @@ -253,8 +254,8 @@ void __show_regs(struct pt_regs *regs)
2853
2854 show_regs_print_info(KERN_DEFAULT);
2855
2856 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2857 - print_symbol("LR is at %s\n", regs->ARM_lr);
2858 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2859 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2860 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2861 "sp : %08lx ip : %08lx fp : %08lx\n",
2862 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2863 @@ -425,12 +426,6 @@ unsigned long get_wchan(struct task_struct *p)
2864 return 0;
2865 }
2866
2867 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2868 -{
2869 - unsigned long range_end = mm->brk + 0x02000000;
2870 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2871 -}
2872 -
2873 #ifdef CONFIG_MMU
2874 #ifdef CONFIG_KUSER_HELPERS
2875 /*
2876 @@ -446,7 +441,7 @@ static struct vm_area_struct gate_vma = {
2877
2878 static int __init gate_vma_init(void)
2879 {
2880 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2881 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2882 return 0;
2883 }
2884 arch_initcall(gate_vma_init);
2885 @@ -472,41 +467,16 @@ int in_gate_area_no_mm(unsigned long addr)
2886
2887 const char *arch_vma_name(struct vm_area_struct *vma)
2888 {
2889 - return is_gate_vma(vma) ? "[vectors]" :
2890 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2891 - "[sigpage]" : NULL;
2892 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2893 }
2894
2895 -static struct page *signal_page;
2896 -extern struct page *get_signal_page(void);
2897 -
2898 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2899 {
2900 struct mm_struct *mm = current->mm;
2901 - unsigned long addr;
2902 - int ret;
2903 -
2904 - if (!signal_page)
2905 - signal_page = get_signal_page();
2906 - if (!signal_page)
2907 - return -ENOMEM;
2908
2909 down_write(&mm->mmap_sem);
2910 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2911 - if (IS_ERR_VALUE(addr)) {
2912 - ret = addr;
2913 - goto up_fail;
2914 - }
2915 -
2916 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2917 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2918 - &signal_page);
2919 -
2920 - if (ret == 0)
2921 - mm->context.sigpage = addr;
2922 -
2923 - up_fail:
2924 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2925 up_write(&mm->mmap_sem);
2926 - return ret;
2927 + return 0;
2928 }
2929 #endif
2930 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2931 index 4693188..4596c5e 100644
2932 --- a/arch/arm/kernel/psci.c
2933 +++ b/arch/arm/kernel/psci.c
2934 @@ -24,7 +24,7 @@
2935 #include <asm/opcodes-virt.h>
2936 #include <asm/psci.h>
2937
2938 -struct psci_operations psci_ops;
2939 +struct psci_operations psci_ops __read_only;
2940
2941 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2942
2943 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2944 index 0dd3b79..e018f64 100644
2945 --- a/arch/arm/kernel/ptrace.c
2946 +++ b/arch/arm/kernel/ptrace.c
2947 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2948 return current_thread_info()->syscall;
2949 }
2950
2951 +#ifdef CONFIG_GRKERNSEC_SETXID
2952 +extern void gr_delayed_cred_worker(void);
2953 +#endif
2954 +
2955 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2956 {
2957 current_thread_info()->syscall = scno;
2958
2959 +#ifdef CONFIG_GRKERNSEC_SETXID
2960 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2961 + gr_delayed_cred_worker();
2962 +#endif
2963 +
2964 /* Do the secure computing check first; failures should be fast. */
2965 if (secure_computing(scno) == -1)
2966 return -1;
2967 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2968 index 0e1e2b3..c0e821d 100644
2969 --- a/arch/arm/kernel/setup.c
2970 +++ b/arch/arm/kernel/setup.c
2971 @@ -98,21 +98,23 @@ EXPORT_SYMBOL(system_serial_high);
2972 unsigned int elf_hwcap __read_mostly;
2973 EXPORT_SYMBOL(elf_hwcap);
2974
2975 +pteval_t __supported_pte_mask __read_only;
2976 +pmdval_t __supported_pmd_mask __read_only;
2977
2978 #ifdef MULTI_CPU
2979 -struct processor processor __read_mostly;
2980 +struct processor processor;
2981 #endif
2982 #ifdef MULTI_TLB
2983 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2984 +struct cpu_tlb_fns cpu_tlb __read_only;
2985 #endif
2986 #ifdef MULTI_USER
2987 -struct cpu_user_fns cpu_user __read_mostly;
2988 +struct cpu_user_fns cpu_user __read_only;
2989 #endif
2990 #ifdef MULTI_CACHE
2991 -struct cpu_cache_fns cpu_cache __read_mostly;
2992 +struct cpu_cache_fns cpu_cache __read_only;
2993 #endif
2994 #ifdef CONFIG_OUTER_CACHE
2995 -struct outer_cache_fns outer_cache __read_mostly;
2996 +struct outer_cache_fns outer_cache __read_only;
2997 EXPORT_SYMBOL(outer_cache);
2998 #endif
2999
3000 @@ -245,9 +247,13 @@ static int __get_cpu_architecture(void)
3001 asm("mrc p15, 0, %0, c0, c1, 4"
3002 : "=r" (mmfr0));
3003 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3004 - (mmfr0 & 0x000000f0) >= 0x00000030)
3005 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3006 cpu_arch = CPU_ARCH_ARMv7;
3007 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3008 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3009 + __supported_pte_mask |= L_PTE_PXN;
3010 + __supported_pmd_mask |= PMD_PXNTABLE;
3011 + }
3012 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3013 (mmfr0 & 0x000000f0) == 0x00000020)
3014 cpu_arch = CPU_ARCH_ARMv6;
3015 else
3016 @@ -571,7 +577,7 @@ static void __init setup_processor(void)
3017 __cpu_architecture = __get_cpu_architecture();
3018
3019 #ifdef MULTI_CPU
3020 - processor = *list->proc;
3021 + memcpy((void *)&processor, list->proc, sizeof processor);
3022 #endif
3023 #ifdef MULTI_TLB
3024 cpu_tlb = *list->tlb;
3025 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3026 index ab33042..11248a8 100644
3027 --- a/arch/arm/kernel/signal.c
3028 +++ b/arch/arm/kernel/signal.c
3029 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3030 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3031 };
3032
3033 -static unsigned long signal_return_offset;
3034 -
3035 #ifdef CONFIG_CRUNCH
3036 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3037 {
3038 @@ -411,8 +409,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3039 * except when the MPU has protected the vectors
3040 * page from PL0
3041 */
3042 - retcode = mm->context.sigpage + signal_return_offset +
3043 - (idx << 2) + thumb;
3044 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3045 } else
3046 #endif
3047 {
3048 @@ -616,33 +613,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3049 } while (thread_flags & _TIF_WORK_MASK);
3050 return 0;
3051 }
3052 -
3053 -struct page *get_signal_page(void)
3054 -{
3055 - unsigned long ptr;
3056 - unsigned offset;
3057 - struct page *page;
3058 - void *addr;
3059 -
3060 - page = alloc_pages(GFP_KERNEL, 0);
3061 -
3062 - if (!page)
3063 - return NULL;
3064 -
3065 - addr = page_address(page);
3066 -
3067 - /* Give the signal return code some randomness */
3068 - offset = 0x200 + (get_random_int() & 0x7fc);
3069 - signal_return_offset = offset;
3070 -
3071 - /*
3072 - * Copy signal return handlers into the vector page, and
3073 - * set sigreturn to be a pointer to these.
3074 - */
3075 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3076 -
3077 - ptr = (unsigned long)addr + offset;
3078 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3079 -
3080 - return page;
3081 -}
3082 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3083 index 72024ea..ae302dd 100644
3084 --- a/arch/arm/kernel/smp.c
3085 +++ b/arch/arm/kernel/smp.c
3086 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3087
3088 static DECLARE_COMPLETION(cpu_running);
3089
3090 -static struct smp_operations smp_ops;
3091 +static struct smp_operations smp_ops __read_only;
3092
3093 void __init smp_set_ops(struct smp_operations *ops)
3094 {
3095 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3096 index 1f735aa..08af6f7 100644
3097 --- a/arch/arm/kernel/traps.c
3098 +++ b/arch/arm/kernel/traps.c
3099 @@ -61,7 +61,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3100 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3101 {
3102 #ifdef CONFIG_KALLSYMS
3103 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3104 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3105 #else
3106 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3107 #endif
3108 @@ -263,6 +263,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3109 static int die_owner = -1;
3110 static unsigned int die_nest_count;
3111
3112 +extern void gr_handle_kernel_exploit(void);
3113 +
3114 static unsigned long oops_begin(void)
3115 {
3116 int cpu;
3117 @@ -305,6 +307,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3118 panic("Fatal exception in interrupt");
3119 if (panic_on_oops)
3120 panic("Fatal exception");
3121 +
3122 + gr_handle_kernel_exploit();
3123 +
3124 if (signr)
3125 do_exit(signr);
3126 }
3127 @@ -635,7 +640,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3128 * The user helper at 0xffff0fe0 must be used instead.
3129 * (see entry-armv.S for details)
3130 */
3131 + pax_open_kernel();
3132 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3133 + pax_close_kernel();
3134 }
3135 return 0;
3136
3137 @@ -892,7 +899,11 @@ void __init early_trap_init(void *vectors_base)
3138 kuser_init(vectors_base);
3139
3140 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3141 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3142 +
3143 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3144 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3145 +#endif
3146 +
3147 #else /* ifndef CONFIG_CPU_V7M */
3148 /*
3149 * on V7-M there is no need to copy the vector table to a dedicated
3150 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3151 index 7bcee5c..e2f3249 100644
3152 --- a/arch/arm/kernel/vmlinux.lds.S
3153 +++ b/arch/arm/kernel/vmlinux.lds.S
3154 @@ -8,7 +8,11 @@
3155 #include <asm/thread_info.h>
3156 #include <asm/memory.h>
3157 #include <asm/page.h>
3158 -
3159 +
3160 +#ifdef CONFIG_PAX_KERNEXEC
3161 +#include <asm/pgtable.h>
3162 +#endif
3163 +
3164 #define PROC_INFO \
3165 . = ALIGN(4); \
3166 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3167 @@ -34,7 +38,7 @@
3168 #endif
3169
3170 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3171 - defined(CONFIG_GENERIC_BUG)
3172 + defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3173 #define ARM_EXIT_KEEP(x) x
3174 #define ARM_EXIT_DISCARD(x)
3175 #else
3176 @@ -90,6 +94,11 @@ SECTIONS
3177 _text = .;
3178 HEAD_TEXT
3179 }
3180 +
3181 +#ifdef CONFIG_PAX_KERNEXEC
3182 + . = ALIGN(1<<SECTION_SHIFT);
3183 +#endif
3184 +
3185 .text : { /* Real text segment */
3186 _stext = .; /* Text and read-only data */
3187 __exception_text_start = .;
3188 @@ -112,6 +121,8 @@ SECTIONS
3189 ARM_CPU_KEEP(PROC_INFO)
3190 }
3191
3192 + _etext = .; /* End of text section */
3193 +
3194 RO_DATA(PAGE_SIZE)
3195
3196 . = ALIGN(4);
3197 @@ -142,7 +153,9 @@ SECTIONS
3198
3199 NOTES
3200
3201 - _etext = .; /* End of text and rodata section */
3202 +#ifdef CONFIG_PAX_KERNEXEC
3203 + . = ALIGN(1<<SECTION_SHIFT);
3204 +#endif
3205
3206 #ifndef CONFIG_XIP_KERNEL
3207 . = ALIGN(PAGE_SIZE);
3208 @@ -220,6 +233,11 @@ SECTIONS
3209 . = PAGE_OFFSET + TEXT_OFFSET;
3210 #else
3211 __init_end = .;
3212 +
3213 +#ifdef CONFIG_PAX_KERNEXEC
3214 + . = ALIGN(1<<SECTION_SHIFT);
3215 +#endif
3216 +
3217 . = ALIGN(THREAD_SIZE);
3218 __data_loc = .;
3219 #endif
3220 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3221 index 9c697db..115237f 100644
3222 --- a/arch/arm/kvm/arm.c
3223 +++ b/arch/arm/kvm/arm.c
3224 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3225 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3226
3227 /* The VMID used in the VTTBR */
3228 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3229 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3230 static u8 kvm_next_vmid;
3231 static DEFINE_SPINLOCK(kvm_vmid_lock);
3232
3233 @@ -396,7 +396,7 @@ void force_vm_exit(const cpumask_t *mask)
3234 */
3235 static bool need_new_vmid_gen(struct kvm *kvm)
3236 {
3237 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3238 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3239 }
3240
3241 /**
3242 @@ -429,7 +429,7 @@ static void update_vttbr(struct kvm *kvm)
3243
3244 /* First user of a new VMID generation? */
3245 if (unlikely(kvm_next_vmid == 0)) {
3246 - atomic64_inc(&kvm_vmid_gen);
3247 + atomic64_inc_unchecked(&kvm_vmid_gen);
3248 kvm_next_vmid = 1;
3249
3250 /*
3251 @@ -446,7 +446,7 @@ static void update_vttbr(struct kvm *kvm)
3252 kvm_call_hyp(__kvm_flush_vm_context);
3253 }
3254
3255 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3256 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3257 kvm->arch.vmid = kvm_next_vmid;
3258 kvm_next_vmid++;
3259
3260 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3261 index 14a0d98..7771a7d 100644
3262 --- a/arch/arm/lib/clear_user.S
3263 +++ b/arch/arm/lib/clear_user.S
3264 @@ -12,14 +12,14 @@
3265
3266 .text
3267
3268 -/* Prototype: int __clear_user(void *addr, size_t sz)
3269 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3270 * Purpose : clear some user memory
3271 * Params : addr - user memory address to clear
3272 * : sz - number of bytes to clear
3273 * Returns : number of bytes NOT cleared
3274 */
3275 ENTRY(__clear_user_std)
3276 -WEAK(__clear_user)
3277 +WEAK(___clear_user)
3278 stmfd sp!, {r1, lr}
3279 mov r2, #0
3280 cmp r1, #4
3281 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3282 USER( strnebt r2, [r0])
3283 mov r0, #0
3284 ldmfd sp!, {r1, pc}
3285 -ENDPROC(__clear_user)
3286 +ENDPROC(___clear_user)
3287 ENDPROC(__clear_user_std)
3288
3289 .pushsection .fixup,"ax"
3290 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3291 index 66a477a..bee61d3 100644
3292 --- a/arch/arm/lib/copy_from_user.S
3293 +++ b/arch/arm/lib/copy_from_user.S
3294 @@ -16,7 +16,7 @@
3295 /*
3296 * Prototype:
3297 *
3298 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3299 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3300 *
3301 * Purpose:
3302 *
3303 @@ -84,11 +84,11 @@
3304
3305 .text
3306
3307 -ENTRY(__copy_from_user)
3308 +ENTRY(___copy_from_user)
3309
3310 #include "copy_template.S"
3311
3312 -ENDPROC(__copy_from_user)
3313 +ENDPROC(___copy_from_user)
3314
3315 .pushsection .fixup,"ax"
3316 .align 0
3317 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3318 index 6ee2f67..d1cce76 100644
3319 --- a/arch/arm/lib/copy_page.S
3320 +++ b/arch/arm/lib/copy_page.S
3321 @@ -10,6 +10,7 @@
3322 * ASM optimised string functions
3323 */
3324 #include <linux/linkage.h>
3325 +#include <linux/const.h>
3326 #include <asm/assembler.h>
3327 #include <asm/asm-offsets.h>
3328 #include <asm/cache.h>
3329 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3330 index d066df6..df28194 100644
3331 --- a/arch/arm/lib/copy_to_user.S
3332 +++ b/arch/arm/lib/copy_to_user.S
3333 @@ -16,7 +16,7 @@
3334 /*
3335 * Prototype:
3336 *
3337 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3338 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3339 *
3340 * Purpose:
3341 *
3342 @@ -88,11 +88,11 @@
3343 .text
3344
3345 ENTRY(__copy_to_user_std)
3346 -WEAK(__copy_to_user)
3347 +WEAK(___copy_to_user)
3348
3349 #include "copy_template.S"
3350
3351 -ENDPROC(__copy_to_user)
3352 +ENDPROC(___copy_to_user)
3353 ENDPROC(__copy_to_user_std)
3354
3355 .pushsection .fixup,"ax"
3356 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3357 index 7d08b43..f7ca7ea 100644
3358 --- a/arch/arm/lib/csumpartialcopyuser.S
3359 +++ b/arch/arm/lib/csumpartialcopyuser.S
3360 @@ -57,8 +57,8 @@
3361 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3362 */
3363
3364 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3365 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3366 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3367 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3368
3369 #include "csumpartialcopygeneric.S"
3370
3371 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3372 index 5306de3..aed6d03 100644
3373 --- a/arch/arm/lib/delay.c
3374 +++ b/arch/arm/lib/delay.c
3375 @@ -28,7 +28,7 @@
3376 /*
3377 * Default to the loop-based delay implementation.
3378 */
3379 -struct arm_delay_ops arm_delay_ops = {
3380 +struct arm_delay_ops arm_delay_ops __read_only = {
3381 .delay = __loop_delay,
3382 .const_udelay = __loop_const_udelay,
3383 .udelay = __loop_udelay,
3384 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3385 index 025f742..a9e5b3b 100644
3386 --- a/arch/arm/lib/uaccess_with_memcpy.c
3387 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3388 @@ -104,7 +104,7 @@ out:
3389 }
3390
3391 unsigned long
3392 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3393 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3394 {
3395 /*
3396 * This test is stubbed out of the main function above to keep
3397 @@ -155,7 +155,7 @@ out:
3398 return n;
3399 }
3400
3401 -unsigned long __clear_user(void __user *addr, unsigned long n)
3402 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3403 {
3404 /* See rational for this in __copy_to_user() above. */
3405 if (n < 64)
3406 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3407 index 1767611..d2e7e24 100644
3408 --- a/arch/arm/mach-kirkwood/common.c
3409 +++ b/arch/arm/mach-kirkwood/common.c
3410 @@ -156,7 +156,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3411 clk_gate_ops.disable(hw);
3412 }
3413
3414 -static struct clk_ops clk_gate_fn_ops;
3415 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3416 +{
3417 + return clk_gate_ops.is_enabled(hw);
3418 +}
3419 +
3420 +static struct clk_ops clk_gate_fn_ops = {
3421 + .enable = clk_gate_fn_enable,
3422 + .disable = clk_gate_fn_disable,
3423 + .is_enabled = clk_gate_fn_is_enabled,
3424 +};
3425
3426 static struct clk __init *clk_register_gate_fn(struct device *dev,
3427 const char *name,
3428 @@ -190,14 +199,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3429 gate_fn->fn_en = fn_en;
3430 gate_fn->fn_dis = fn_dis;
3431
3432 - /* ops is the gate ops, but with our enable/disable functions */
3433 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3434 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3435 - clk_gate_fn_ops = clk_gate_ops;
3436 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3437 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3438 - }
3439 -
3440 clk = clk_register(dev, &gate_fn->gate.hw);
3441
3442 if (IS_ERR(clk))
3443 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3444 index 827d1500..2885dc6 100644
3445 --- a/arch/arm/mach-omap2/board-n8x0.c
3446 +++ b/arch/arm/mach-omap2/board-n8x0.c
3447 @@ -627,7 +627,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3448 }
3449 #endif
3450
3451 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3452 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3453 .late_init = n8x0_menelaus_late_init,
3454 };
3455
3456 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3457 index 579697a..1d5a3b2 100644
3458 --- a/arch/arm/mach-omap2/gpmc.c
3459 +++ b/arch/arm/mach-omap2/gpmc.c
3460 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3461 };
3462
3463 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3464 -static struct irq_chip gpmc_irq_chip;
3465 static int gpmc_irq_start;
3466
3467 static struct resource gpmc_mem_root;
3468 @@ -716,6 +715,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3469
3470 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3471
3472 +static struct irq_chip gpmc_irq_chip = {
3473 + .name = "gpmc",
3474 + .irq_startup = gpmc_irq_noop_ret,
3475 + .irq_enable = gpmc_irq_enable,
3476 + .irq_disable = gpmc_irq_disable,
3477 + .irq_shutdown = gpmc_irq_noop,
3478 + .irq_ack = gpmc_irq_noop,
3479 + .irq_mask = gpmc_irq_noop,
3480 + .irq_unmask = gpmc_irq_noop,
3481 +
3482 +};
3483 +
3484 static int gpmc_setup_irq(void)
3485 {
3486 int i;
3487 @@ -730,15 +741,6 @@ static int gpmc_setup_irq(void)
3488 return gpmc_irq_start;
3489 }
3490
3491 - gpmc_irq_chip.name = "gpmc";
3492 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3493 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3494 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3495 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3496 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3497 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3498 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3499 -
3500 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3501 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3502
3503 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3504 index f991016..145ebeb 100644
3505 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3506 +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3507 @@ -84,7 +84,7 @@ struct cpu_pm_ops {
3508 int (*finish_suspend)(unsigned long cpu_state);
3509 void (*resume)(void);
3510 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3511 -};
3512 +} __no_const;
3513
3514 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3515 static struct powerdomain *mpuss_pd;
3516 @@ -102,7 +102,7 @@ static void dummy_cpu_resume(void)
3517 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3518 {}
3519
3520 -struct cpu_pm_ops omap_pm_ops = {
3521 +static struct cpu_pm_ops omap_pm_ops __read_only = {
3522 .finish_suspend = default_finish_suspend,
3523 .resume = dummy_cpu_resume,
3524 .scu_prepare = dummy_scu_prepare,
3525 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3526 index 813c615..ce467c6 100644
3527 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3528 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3529 @@ -339,7 +339,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3530 return NOTIFY_OK;
3531 }
3532
3533 -static struct notifier_block __refdata irq_hotplug_notifier = {
3534 +static struct notifier_block irq_hotplug_notifier = {
3535 .notifier_call = irq_cpu_hotplug_notify,
3536 };
3537
3538 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3539 index 53f0735..5b54eb6 100644
3540 --- a/arch/arm/mach-omap2/omap_device.c
3541 +++ b/arch/arm/mach-omap2/omap_device.c
3542 @@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3543 struct platform_device __init *omap_device_build(const char *pdev_name,
3544 int pdev_id,
3545 struct omap_hwmod *oh,
3546 - void *pdata, int pdata_len)
3547 + const void *pdata, int pdata_len)
3548 {
3549 struct omap_hwmod *ohs[] = { oh };
3550
3551 @@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3552 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3553 int pdev_id,
3554 struct omap_hwmod **ohs,
3555 - int oh_cnt, void *pdata,
3556 + int oh_cnt, const void *pdata,
3557 int pdata_len)
3558 {
3559 int ret = -ENOMEM;
3560 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3561 index 17ca1ae..beba869 100644
3562 --- a/arch/arm/mach-omap2/omap_device.h
3563 +++ b/arch/arm/mach-omap2/omap_device.h
3564 @@ -71,12 +71,12 @@ int omap_device_idle(struct platform_device *pdev);
3565 /* Core code interface */
3566
3567 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3568 - struct omap_hwmod *oh, void *pdata,
3569 + struct omap_hwmod *oh, const void *pdata,
3570 int pdata_len);
3571
3572 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3573 struct omap_hwmod **oh, int oh_cnt,
3574 - void *pdata, int pdata_len);
3575 + const void *pdata, int pdata_len);
3576
3577 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3578 struct omap_hwmod **ohs, int oh_cnt);
3579 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3580 index 832adb1..49b62c4 100644
3581 --- a/arch/arm/mach-omap2/omap_hwmod.c
3582 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3583 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3584 int (*init_clkdm)(struct omap_hwmod *oh);
3585 void (*update_context_lost)(struct omap_hwmod *oh);
3586 int (*get_context_lost)(struct omap_hwmod *oh);
3587 -};
3588 +} __no_const;
3589
3590 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3591 -static struct omap_hwmod_soc_ops soc_ops;
3592 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3593
3594 /* omap_hwmod_list contains all registered struct omap_hwmods */
3595 static LIST_HEAD(omap_hwmod_list);
3596 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3597 index d15c7bb..b2d1f0c 100644
3598 --- a/arch/arm/mach-omap2/wd_timer.c
3599 +++ b/arch/arm/mach-omap2/wd_timer.c
3600 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3601 struct omap_hwmod *oh;
3602 char *oh_name = "wd_timer2";
3603 char *dev_name = "omap_wdt";
3604 - struct omap_wd_timer_platform_data pdata;
3605 + static struct omap_wd_timer_platform_data pdata = {
3606 + .read_reset_sources = prm_read_reset_sources
3607 + };
3608
3609 if (!cpu_class_is_omap2() || of_have_populated_dt())
3610 return 0;
3611 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3612 return -EINVAL;
3613 }
3614
3615 - pdata.read_reset_sources = prm_read_reset_sources;
3616 -
3617 pdev = omap_device_build(dev_name, id, oh, &pdata,
3618 sizeof(struct omap_wd_timer_platform_data));
3619 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3620 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3621 index b82dcae..44ee5b6 100644
3622 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3623 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3624 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3625 bool entered_lp2 = false;
3626
3627 if (tegra_pending_sgi())
3628 - ACCESS_ONCE(abort_flag) = true;
3629 + ACCESS_ONCE_RW(abort_flag) = true;
3630
3631 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3632
3633 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3634 index 656324a..0beba28 100644
3635 --- a/arch/arm/mach-ux500/setup.h
3636 +++ b/arch/arm/mach-ux500/setup.h
3637 @@ -40,13 +40,6 @@ extern void ux500_timer_init(void);
3638 .type = MT_DEVICE, \
3639 }
3640
3641 -#define __MEM_DEV_DESC(x, sz) { \
3642 - .virtual = IO_ADDRESS(x), \
3643 - .pfn = __phys_to_pfn(x), \
3644 - .length = sz, \
3645 - .type = MT_MEMORY, \
3646 -}
3647 -
3648 extern struct smp_operations ux500_smp_ops;
3649 extern void ux500_cpu_die(unsigned int cpu);
3650
3651 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3652 index cd2c88e..4dd9b67 100644
3653 --- a/arch/arm/mm/Kconfig
3654 +++ b/arch/arm/mm/Kconfig
3655 @@ -446,7 +446,7 @@ config CPU_32v5
3656
3657 config CPU_32v6
3658 bool
3659 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3660 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3661 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3662
3663 config CPU_32v6K
3664 @@ -601,6 +601,7 @@ config CPU_CP15_MPU
3665
3666 config CPU_USE_DOMAINS
3667 bool
3668 + depends on !ARM_LPAE && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3669 help
3670 This option enables or disables the use of domain switching
3671 via the set_fs() function.
3672 @@ -800,6 +801,7 @@ config NEED_KUSER_HELPERS
3673 config KUSER_HELPERS
3674 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3675 default y
3676 + depends on !(CPU_V6 || CPU_V6K || CPU_V7) || GRKERNSEC_OLD_ARM_USERLAND
3677 help
3678 Warning: disabling this option may break user programs.
3679
3680 @@ -812,7 +814,7 @@ config KUSER_HELPERS
3681 See Documentation/arm/kernel_user_helpers.txt for details.
3682
3683 However, the fixed address nature of these helpers can be used
3684 - by ROP (return orientated programming) authors when creating
3685 + by ROP (Return Oriented Programming) authors when creating
3686 exploits.
3687
3688 If all of the binaries and libraries which run on your platform
3689 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3690 index 6f4585b..7b6f52b 100644
3691 --- a/arch/arm/mm/alignment.c
3692 +++ b/arch/arm/mm/alignment.c
3693 @@ -211,10 +211,12 @@ union offset_union {
3694 #define __get16_unaligned_check(ins,val,addr) \
3695 do { \
3696 unsigned int err = 0, v, a = addr; \
3697 + pax_open_userland(); \
3698 __get8_unaligned_check(ins,v,a,err); \
3699 val = v << ((BE) ? 8 : 0); \
3700 __get8_unaligned_check(ins,v,a,err); \
3701 val |= v << ((BE) ? 0 : 8); \
3702 + pax_close_userland(); \
3703 if (err) \
3704 goto fault; \
3705 } while (0)
3706 @@ -228,6 +230,7 @@ union offset_union {
3707 #define __get32_unaligned_check(ins,val,addr) \
3708 do { \
3709 unsigned int err = 0, v, a = addr; \
3710 + pax_open_userland(); \
3711 __get8_unaligned_check(ins,v,a,err); \
3712 val = v << ((BE) ? 24 : 0); \
3713 __get8_unaligned_check(ins,v,a,err); \
3714 @@ -236,6 +239,7 @@ union offset_union {
3715 val |= v << ((BE) ? 8 : 16); \
3716 __get8_unaligned_check(ins,v,a,err); \
3717 val |= v << ((BE) ? 0 : 24); \
3718 + pax_close_userland(); \
3719 if (err) \
3720 goto fault; \
3721 } while (0)
3722 @@ -249,6 +253,7 @@ union offset_union {
3723 #define __put16_unaligned_check(ins,val,addr) \
3724 do { \
3725 unsigned int err = 0, v = val, a = addr; \
3726 + pax_open_userland(); \
3727 __asm__( FIRST_BYTE_16 \
3728 ARM( "1: "ins" %1, [%2], #1\n" ) \
3729 THUMB( "1: "ins" %1, [%2]\n" ) \
3730 @@ -268,6 +273,7 @@ union offset_union {
3731 " .popsection\n" \
3732 : "=r" (err), "=&r" (v), "=&r" (a) \
3733 : "0" (err), "1" (v), "2" (a)); \
3734 + pax_close_userland(); \
3735 if (err) \
3736 goto fault; \
3737 } while (0)
3738 @@ -281,6 +287,7 @@ union offset_union {
3739 #define __put32_unaligned_check(ins,val,addr) \
3740 do { \
3741 unsigned int err = 0, v = val, a = addr; \
3742 + pax_open_userland(); \
3743 __asm__( FIRST_BYTE_32 \
3744 ARM( "1: "ins" %1, [%2], #1\n" ) \
3745 THUMB( "1: "ins" %1, [%2]\n" ) \
3746 @@ -310,6 +317,7 @@ union offset_union {
3747 " .popsection\n" \
3748 : "=r" (err), "=&r" (v), "=&r" (a) \
3749 : "0" (err), "1" (v), "2" (a)); \
3750 + pax_close_userland(); \
3751 if (err) \
3752 goto fault; \
3753 } while (0)
3754 diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
3755 index 447da6f..77a5057 100644
3756 --- a/arch/arm/mm/cache-l2x0.c
3757 +++ b/arch/arm/mm/cache-l2x0.c
3758 @@ -45,7 +45,7 @@ struct l2x0_of_data {
3759 void (*setup)(const struct device_node *, u32 *, u32 *);
3760 void (*save)(void);
3761 struct outer_cache_fns outer_cache;
3762 -};
3763 +} __do_const;
3764
3765 static bool of_init = false;
3766
3767 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3768 index 84e6f77..0b52f31 100644
3769 --- a/arch/arm/mm/context.c
3770 +++ b/arch/arm/mm/context.c
3771 @@ -43,7 +43,7 @@
3772 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3773
3774 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3775 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3776 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3777 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3778
3779 static DEFINE_PER_CPU(atomic64_t, active_asids);
3780 @@ -180,7 +180,7 @@ static int is_reserved_asid(u64 asid)
3781 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3782 {
3783 u64 asid = atomic64_read(&mm->context.id);
3784 - u64 generation = atomic64_read(&asid_generation);
3785 + u64 generation = atomic64_read_unchecked(&asid_generation);
3786
3787 if (asid != 0 && is_reserved_asid(asid)) {
3788 /*
3789 @@ -198,7 +198,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3790 */
3791 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3792 if (asid == NUM_USER_ASIDS) {
3793 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3794 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3795 &asid_generation);
3796 flush_context(cpu);
3797 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3798 @@ -227,14 +227,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3799 cpu_set_reserved_ttbr0();
3800
3801 asid = atomic64_read(&mm->context.id);
3802 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3803 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3804 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3805 goto switch_mm_fastpath;
3806
3807 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3808 /* Check that our ASID belongs to the current generation. */
3809 asid = atomic64_read(&mm->context.id);
3810 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3811 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3812 asid = new_context(mm, cpu);
3813 atomic64_set(&mm->context.id, asid);
3814 }
3815 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3816 index eb8830a..5360ce7 100644
3817 --- a/arch/arm/mm/fault.c
3818 +++ b/arch/arm/mm/fault.c
3819 @@ -25,6 +25,7 @@
3820 #include <asm/system_misc.h>
3821 #include <asm/system_info.h>
3822 #include <asm/tlbflush.h>
3823 +#include <asm/sections.h>
3824
3825 #include "fault.h"
3826
3827 @@ -138,6 +139,31 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3828 if (fixup_exception(regs))
3829 return;
3830
3831 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3832 + if (addr < TASK_SIZE) {
3833 + if (current->signal->curr_ip)
3834 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3835 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3836 + else
3837 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3838 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3839 + }
3840 +#endif
3841 +
3842 +#ifdef CONFIG_PAX_KERNEXEC
3843 + if ((fsr & FSR_WRITE) &&
3844 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3845 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3846 + {
3847 + if (current->signal->curr_ip)
3848 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3849 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3850 + else
3851 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3852 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3853 + }
3854 +#endif
3855 +
3856 /*
3857 * No handler, we'll have to terminate things with extreme prejudice.
3858 */
3859 @@ -174,6 +200,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3860 }
3861 #endif
3862
3863 +#ifdef CONFIG_PAX_PAGEEXEC
3864 + if (fsr & FSR_LNX_PF) {
3865 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3866 + do_group_exit(SIGKILL);
3867 + }
3868 +#endif
3869 +
3870 tsk->thread.address = addr;
3871 tsk->thread.error_code = fsr;
3872 tsk->thread.trap_no = 14;
3873 @@ -401,6 +434,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3874 }
3875 #endif /* CONFIG_MMU */
3876
3877 +#ifdef CONFIG_PAX_PAGEEXEC
3878 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3879 +{
3880 + long i;
3881 +
3882 + printk(KERN_ERR "PAX: bytes at PC: ");
3883 + for (i = 0; i < 20; i++) {
3884 + unsigned char c;
3885 + if (get_user(c, (__force unsigned char __user *)pc+i))
3886 + printk(KERN_CONT "?? ");
3887 + else
3888 + printk(KERN_CONT "%02x ", c);
3889 + }
3890 + printk("\n");
3891 +
3892 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3893 + for (i = -1; i < 20; i++) {
3894 + unsigned long c;
3895 + if (get_user(c, (__force unsigned long __user *)sp+i))
3896 + printk(KERN_CONT "???????? ");
3897 + else
3898 + printk(KERN_CONT "%08lx ", c);
3899 + }
3900 + printk("\n");
3901 +}
3902 +#endif
3903 +
3904 /*
3905 * First Level Translation Fault Handler
3906 *
3907 @@ -548,9 +608,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3908 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3909 struct siginfo info;
3910
3911 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3912 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3913 + if (current->signal->curr_ip)
3914 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3915 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3916 + else
3917 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3918 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3919 + goto die;
3920 + }
3921 +#endif
3922 +
3923 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3924 return;
3925
3926 +die:
3927 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3928 inf->name, fsr, addr);
3929
3930 @@ -574,15 +647,98 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3931 ifsr_info[nr].name = name;
3932 }
3933
3934 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3935 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3936 +
3937 asmlinkage void __exception
3938 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3939 {
3940 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3941 struct siginfo info;
3942 + unsigned long pc = instruction_pointer(regs);
3943 +
3944 + if (user_mode(regs)) {
3945 + unsigned long sigpage = current->mm->context.sigpage;
3946 +
3947 + if (sigpage <= pc && pc < sigpage + 7*4) {
3948 + if (pc < sigpage + 3*4)
3949 + sys_sigreturn(regs);
3950 + else
3951 + sys_rt_sigreturn(regs);
3952 + return;
3953 + }
3954 + if (pc == 0xffff0f60UL) {
3955 + /*
3956 + * PaX: __kuser_cmpxchg64 emulation
3957 + */
3958 + // TODO
3959 + //regs->ARM_pc = regs->ARM_lr;
3960 + //return;
3961 + }
3962 + if (pc == 0xffff0fa0UL) {
3963 + /*
3964 + * PaX: __kuser_memory_barrier emulation
3965 + */
3966 + // dmb(); implied by the exception
3967 + regs->ARM_pc = regs->ARM_lr;
3968 + return;
3969 + }
3970 + if (pc == 0xffff0fc0UL) {
3971 + /*
3972 + * PaX: __kuser_cmpxchg emulation
3973 + */
3974 + // TODO
3975 + //long new;
3976 + //int op;
3977 +
3978 + //op = FUTEX_OP_SET << 28;
3979 + //new = futex_atomic_op_inuser(op, regs->ARM_r2);
3980 + //regs->ARM_r0 = old != new;
3981 + //regs->ARM_pc = regs->ARM_lr;
3982 + //return;
3983 + }
3984 + if (pc == 0xffff0fe0UL) {
3985 + /*
3986 + * PaX: __kuser_get_tls emulation
3987 + */
3988 + regs->ARM_r0 = current_thread_info()->tp_value[0];
3989 + regs->ARM_pc = regs->ARM_lr;
3990 + return;
3991 + }
3992 + }
3993 +
3994 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3995 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3996 + if (current->signal->curr_ip)
3997 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3998 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3999 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
4000 + else
4001 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
4002 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
4003 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
4004 + goto die;
4005 + }
4006 +#endif
4007 +
4008 +#ifdef CONFIG_PAX_REFCOUNT
4009 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
4010 + unsigned int bkpt;
4011 +
4012 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
4013 + current->thread.error_code = ifsr;
4014 + current->thread.trap_no = 0;
4015 + pax_report_refcount_overflow(regs);
4016 + fixup_exception(regs);
4017 + return;
4018 + }
4019 + }
4020 +#endif
4021
4022 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
4023 return;
4024
4025 +die:
4026 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
4027 inf->name, ifsr, addr);
4028
4029 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
4030 index cf08bdf..772656c 100644
4031 --- a/arch/arm/mm/fault.h
4032 +++ b/arch/arm/mm/fault.h
4033 @@ -3,6 +3,7 @@
4034
4035 /*
4036 * Fault status register encodings. We steal bit 31 for our own purposes.
4037 + * Set when the FSR value is from an instruction fault.
4038 */
4039 #define FSR_LNX_PF (1 << 31)
4040 #define FSR_WRITE (1 << 11)
4041 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4042 }
4043 #endif
4044
4045 +/* valid for LPAE and !LPAE */
4046 +static inline int is_xn_fault(unsigned int fsr)
4047 +{
4048 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4049 +}
4050 +
4051 +static inline int is_domain_fault(unsigned int fsr)
4052 +{
4053 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4054 +}
4055 +
4056 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4057 unsigned long search_exception_table(unsigned long addr);
4058
4059 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4060 index 18ec4c5..479bb6a 100644
4061 --- a/arch/arm/mm/init.c
4062 +++ b/arch/arm/mm/init.c
4063 @@ -30,6 +30,8 @@
4064 #include <asm/setup.h>
4065 #include <asm/tlb.h>
4066 #include <asm/fixmap.h>
4067 +#include <asm/system_info.h>
4068 +#include <asm/cp15.h>
4069
4070 #include <asm/mach/arch.h>
4071 #include <asm/mach/map.h>
4072 @@ -684,7 +686,46 @@ void free_initmem(void)
4073 {
4074 #ifdef CONFIG_HAVE_TCM
4075 extern char __tcm_start, __tcm_end;
4076 +#endif
4077
4078 +#ifdef CONFIG_PAX_KERNEXEC
4079 + unsigned long addr;
4080 + pgd_t *pgd;
4081 + pud_t *pud;
4082 + pmd_t *pmd;
4083 + int cpu_arch = cpu_architecture();
4084 + unsigned int cr = get_cr();
4085 +
4086 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4087 + /* make pages tables, etc before .text NX */
4088 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4089 + pgd = pgd_offset_k(addr);
4090 + pud = pud_offset(pgd, addr);
4091 + pmd = pmd_offset(pud, addr);
4092 + __section_update(pmd, addr, PMD_SECT_XN);
4093 + }
4094 + /* make init NX */
4095 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4096 + pgd = pgd_offset_k(addr);
4097 + pud = pud_offset(pgd, addr);
4098 + pmd = pmd_offset(pud, addr);
4099 + __section_update(pmd, addr, PMD_SECT_XN);
4100 + }
4101 + /* make kernel code/rodata RX */
4102 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4103 + pgd = pgd_offset_k(addr);
4104 + pud = pud_offset(pgd, addr);
4105 + pmd = pmd_offset(pud, addr);
4106 +#ifdef CONFIG_ARM_LPAE
4107 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4108 +#else
4109 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4110 +#endif
4111 + }
4112 + }
4113 +#endif
4114 +
4115 +#ifdef CONFIG_HAVE_TCM
4116 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4117 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4118 #endif
4119 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4120 index f123d6e..04bf569 100644
4121 --- a/arch/arm/mm/ioremap.c
4122 +++ b/arch/arm/mm/ioremap.c
4123 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4124 unsigned int mtype;
4125
4126 if (cached)
4127 - mtype = MT_MEMORY;
4128 + mtype = MT_MEMORY_RX;
4129 else
4130 - mtype = MT_MEMORY_NONCACHED;
4131 + mtype = MT_MEMORY_NONCACHED_RX;
4132
4133 return __arm_ioremap_caller(phys_addr, size, mtype,
4134 __builtin_return_address(0));
4135 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4136 index 304661d..53a6b19 100644
4137 --- a/arch/arm/mm/mmap.c
4138 +++ b/arch/arm/mm/mmap.c
4139 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4140 struct vm_area_struct *vma;
4141 int do_align = 0;
4142 int aliasing = cache_is_vipt_aliasing();
4143 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4144 struct vm_unmapped_area_info info;
4145
4146 /*
4147 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4148 if (len > TASK_SIZE)
4149 return -ENOMEM;
4150
4151 +#ifdef CONFIG_PAX_RANDMMAP
4152 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4153 +#endif
4154 +
4155 if (addr) {
4156 if (do_align)
4157 addr = COLOUR_ALIGN(addr, pgoff);
4158 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4159 addr = PAGE_ALIGN(addr);
4160
4161 vma = find_vma(mm, addr);
4162 - if (TASK_SIZE - len >= addr &&
4163 - (!vma || addr + len <= vma->vm_start))
4164 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4165 return addr;
4166 }
4167
4168 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4169 info.high_limit = TASK_SIZE;
4170 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4171 info.align_offset = pgoff << PAGE_SHIFT;
4172 + info.threadstack_offset = offset;
4173 return vm_unmapped_area(&info);
4174 }
4175
4176 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4177 unsigned long addr = addr0;
4178 int do_align = 0;
4179 int aliasing = cache_is_vipt_aliasing();
4180 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4181 struct vm_unmapped_area_info info;
4182
4183 /*
4184 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4185 return addr;
4186 }
4187
4188 +#ifdef CONFIG_PAX_RANDMMAP
4189 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4190 +#endif
4191 +
4192 /* requesting a specific address */
4193 if (addr) {
4194 if (do_align)
4195 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4196 else
4197 addr = PAGE_ALIGN(addr);
4198 vma = find_vma(mm, addr);
4199 - if (TASK_SIZE - len >= addr &&
4200 - (!vma || addr + len <= vma->vm_start))
4201 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4202 return addr;
4203 }
4204
4205 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4206 info.high_limit = mm->mmap_base;
4207 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4208 info.align_offset = pgoff << PAGE_SHIFT;
4209 + info.threadstack_offset = offset;
4210 addr = vm_unmapped_area(&info);
4211
4212 /*
4213 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4214 {
4215 unsigned long random_factor = 0UL;
4216
4217 +#ifdef CONFIG_PAX_RANDMMAP
4218 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4219 +#endif
4220 +
4221 /* 8 bits of randomness in 20 address space bits */
4222 if ((current->flags & PF_RANDOMIZE) &&
4223 !(current->personality & ADDR_NO_RANDOMIZE))
4224 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4225
4226 if (mmap_is_legacy()) {
4227 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4228 +
4229 +#ifdef CONFIG_PAX_RANDMMAP
4230 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4231 + mm->mmap_base += mm->delta_mmap;
4232 +#endif
4233 +
4234 mm->get_unmapped_area = arch_get_unmapped_area;
4235 } else {
4236 mm->mmap_base = mmap_base(random_factor);
4237 +
4238 +#ifdef CONFIG_PAX_RANDMMAP
4239 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4240 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4241 +#endif
4242 +
4243 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4244 }
4245 }
4246 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4247 index b1d17ee..7a6f4d3 100644
4248 --- a/arch/arm/mm/mmu.c
4249 +++ b/arch/arm/mm/mmu.c
4250 @@ -36,6 +36,22 @@
4251 #include "mm.h"
4252 #include "tcm.h"
4253
4254 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4255 +void modify_domain(unsigned int dom, unsigned int type)
4256 +{
4257 + struct thread_info *thread = current_thread_info();
4258 + unsigned int domain = thread->cpu_domain;
4259 + /*
4260 + * DOMAIN_MANAGER might be defined to some other value,
4261 + * use the arch-defined constant
4262 + */
4263 + domain &= ~domain_val(dom, 3);
4264 + thread->cpu_domain = domain | domain_val(dom, type);
4265 + set_domain(thread->cpu_domain);
4266 +}
4267 +EXPORT_SYMBOL(modify_domain);
4268 +#endif
4269 +
4270 /*
4271 * empty_zero_page is a special page that is used for
4272 * zero-initialized data and COW.
4273 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4274
4275 #endif /* ifdef CONFIG_CPU_CP15 / else */
4276
4277 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4278 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4279 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4280
4281 -static struct mem_type mem_types[] = {
4282 +#ifdef CONFIG_PAX_KERNEXEC
4283 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4284 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4285 +#else
4286 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4287 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4288 +#endif
4289 +
4290 +static struct mem_type mem_types[] __read_only = {
4291 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4292 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4293 L_PTE_SHARED,
4294 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4295 [MT_UNCACHED] = {
4296 .prot_pte = PROT_PTE_DEVICE,
4297 .prot_l1 = PMD_TYPE_TABLE,
4298 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4299 + .prot_sect = PROT_SECT_DEVICE,
4300 .domain = DOMAIN_IO,
4301 },
4302 [MT_CACHECLEAN] = {
4303 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4304 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4305 .domain = DOMAIN_KERNEL,
4306 },
4307 #ifndef CONFIG_ARM_LPAE
4308 [MT_MINICLEAN] = {
4309 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4310 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4311 .domain = DOMAIN_KERNEL,
4312 },
4313 #endif
4314 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4315 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4316 L_PTE_RDONLY,
4317 .prot_l1 = PMD_TYPE_TABLE,
4318 - .domain = DOMAIN_USER,
4319 + .domain = DOMAIN_VECTORS,
4320 },
4321 [MT_HIGH_VECTORS] = {
4322 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4323 L_PTE_USER | L_PTE_RDONLY,
4324 .prot_l1 = PMD_TYPE_TABLE,
4325 - .domain = DOMAIN_USER,
4326 + .domain = DOMAIN_VECTORS,
4327 },
4328 - [MT_MEMORY] = {
4329 + [MT_MEMORY_RWX] = {
4330 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4331 .prot_l1 = PMD_TYPE_TABLE,
4332 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4333 .domain = DOMAIN_KERNEL,
4334 },
4335 + [MT_MEMORY_RW] = {
4336 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4337 + .prot_l1 = PMD_TYPE_TABLE,
4338 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4339 + .domain = DOMAIN_KERNEL,
4340 + },
4341 + [MT_MEMORY_RX] = {
4342 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4343 + .prot_l1 = PMD_TYPE_TABLE,
4344 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4345 + .domain = DOMAIN_KERNEL,
4346 + },
4347 [MT_ROM] = {
4348 - .prot_sect = PMD_TYPE_SECT,
4349 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4350 .domain = DOMAIN_KERNEL,
4351 },
4352 - [MT_MEMORY_NONCACHED] = {
4353 + [MT_MEMORY_NONCACHED_RW] = {
4354 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4355 L_PTE_MT_BUFFERABLE,
4356 .prot_l1 = PMD_TYPE_TABLE,
4357 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4358 .domain = DOMAIN_KERNEL,
4359 },
4360 + [MT_MEMORY_NONCACHED_RX] = {
4361 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4362 + L_PTE_MT_BUFFERABLE,
4363 + .prot_l1 = PMD_TYPE_TABLE,
4364 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4365 + .domain = DOMAIN_KERNEL,
4366 + },
4367 [MT_MEMORY_DTCM] = {
4368 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4369 - L_PTE_XN,
4370 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4371 .prot_l1 = PMD_TYPE_TABLE,
4372 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4373 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4374 .domain = DOMAIN_KERNEL,
4375 },
4376 [MT_MEMORY_ITCM] = {
4377 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4378 },
4379 [MT_MEMORY_SO] = {
4380 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4381 - L_PTE_MT_UNCACHED | L_PTE_XN,
4382 + L_PTE_MT_UNCACHED,
4383 .prot_l1 = PMD_TYPE_TABLE,
4384 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4385 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4386 + PMD_SECT_UNCACHED,
4387 .domain = DOMAIN_KERNEL,
4388 },
4389 [MT_MEMORY_DMA_READY] = {
4390 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4391 * to prevent speculative instruction fetches.
4392 */
4393 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4394 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4395 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4396 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4397 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4398 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4399 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4400 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4401 +
4402 + /* Mark other regions on ARMv6+ as execute-never */
4403 +
4404 +#ifdef CONFIG_PAX_KERNEXEC
4405 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4406 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4407 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4408 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4409 +#ifndef CONFIG_ARM_LPAE
4410 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4411 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4412 +#endif
4413 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4414 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4415 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4416 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4417 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4418 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4419 +#endif
4420 +
4421 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4422 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4423 }
4424 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4425 /*
4426 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4427 * from SVC mode and no access from userspace.
4428 */
4429 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4430 +#ifdef CONFIG_PAX_KERNEXEC
4431 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4432 +#endif
4433 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4434 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4435 #endif
4436 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4437 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4438 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4439 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4440 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4441 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4442 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4443 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4444 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4445 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4446 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4447 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4448 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4449 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4450 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4451 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4452 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4453 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4454 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4455 }
4456 }
4457
4458 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4459 if (cpu_arch >= CPU_ARCH_ARMv6) {
4460 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4461 /* Non-cacheable Normal is XCB = 001 */
4462 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4463 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4464 + PMD_SECT_BUFFERED;
4465 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4466 PMD_SECT_BUFFERED;
4467 } else {
4468 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4469 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4470 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4471 + PMD_SECT_TEX(1);
4472 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4473 PMD_SECT_TEX(1);
4474 }
4475 } else {
4476 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4477 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4478 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4479 }
4480
4481 #ifdef CONFIG_ARM_LPAE
4482 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4483 vecs_pgprot |= PTE_EXT_AF;
4484 #endif
4485
4486 + user_pgprot |= __supported_pte_mask;
4487 +
4488 for (i = 0; i < 16; i++) {
4489 pteval_t v = pgprot_val(protection_map[i]);
4490 protection_map[i] = __pgprot(v | user_pgprot);
4491 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4492
4493 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4494 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4495 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4496 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4497 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4498 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4499 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4500 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4501 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4502 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4503 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4504 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4505 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4506 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4507 mem_types[MT_ROM].prot_sect |= cp->pmd;
4508
4509 switch (cp->pmd) {
4510 @@ -1186,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4511 * called function. This means you can't use any function or debugging
4512 * method which may touch any device, otherwise the kernel _will_ crash.
4513 */
4514 +
4515 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4516 +
4517 static void __init devicemaps_init(const struct machine_desc *mdesc)
4518 {
4519 struct map_desc map;
4520 unsigned long addr;
4521 - void *vectors;
4522
4523 - /*
4524 - * Allocate the vector page early.
4525 - */
4526 - vectors = early_alloc(PAGE_SIZE * 2);
4527 -
4528 - early_trap_init(vectors);
4529 + early_trap_init(&vectors);
4530
4531 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4532 pmd_clear(pmd_off_k(addr));
4533 @@ -1237,7 +1323,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4534 * location (0xffff0000). If we aren't using high-vectors, also
4535 * create a mapping at the low-vectors virtual address.
4536 */
4537 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4538 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4539 map.virtual = 0xffff0000;
4540 map.length = PAGE_SIZE;
4541 #ifdef CONFIG_KUSER_HELPERS
4542 @@ -1309,8 +1395,39 @@ static void __init map_lowmem(void)
4543 map.pfn = __phys_to_pfn(start);
4544 map.virtual = __phys_to_virt(start);
4545 map.length = end - start;
4546 - map.type = MT_MEMORY;
4547
4548 +#ifdef CONFIG_PAX_KERNEXEC
4549 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4550 + struct map_desc kernel;
4551 + struct map_desc initmap;
4552 +
4553 + /* when freeing initmem we will make this RW */
4554 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4555 + initmap.virtual = (unsigned long)__init_begin;
4556 + initmap.length = _sdata - __init_begin;
4557 + initmap.type = MT_MEMORY_RWX;
4558 + create_mapping(&initmap);
4559 +
4560 + /* when freeing initmem we will make this RX */
4561 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4562 + kernel.virtual = (unsigned long)_stext;
4563 + kernel.length = __init_begin - _stext;
4564 + kernel.type = MT_MEMORY_RWX;
4565 + create_mapping(&kernel);
4566 +
4567 + if (map.virtual < (unsigned long)_stext) {
4568 + map.length = (unsigned long)_stext - map.virtual;
4569 + map.type = MT_MEMORY_RWX;
4570 + create_mapping(&map);
4571 + }
4572 +
4573 + map.pfn = __phys_to_pfn(__pa(_sdata));
4574 + map.virtual = (unsigned long)_sdata;
4575 + map.length = end - __pa(_sdata);
4576 + }
4577 +#endif
4578 +
4579 + map.type = MT_MEMORY_RW;
4580 create_mapping(&map);
4581 }
4582 }
4583 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4584 index a5bc92d..0bb4730 100644
4585 --- a/arch/arm/plat-omap/sram.c
4586 +++ b/arch/arm/plat-omap/sram.c
4587 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4588 * Looks like we need to preserve some bootloader code at the
4589 * beginning of SRAM for jumping to flash for reboot to work...
4590 */
4591 + pax_open_kernel();
4592 memset_io(omap_sram_base + omap_sram_skip, 0,
4593 omap_sram_size - omap_sram_skip);
4594 + pax_close_kernel();
4595 }
4596 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4597 index ce6d763..cfea917 100644
4598 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4599 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4600 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4601 int (*started)(unsigned ch);
4602 int (*flush)(unsigned ch);
4603 int (*stop)(unsigned ch);
4604 -};
4605 +} __no_const;
4606
4607 extern void *samsung_dmadev_get_ops(void);
4608 extern void *s3c_dma_get_ops(void);
4609 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4610 index c3a58a1..78fbf54 100644
4611 --- a/arch/avr32/include/asm/cache.h
4612 +++ b/arch/avr32/include/asm/cache.h
4613 @@ -1,8 +1,10 @@
4614 #ifndef __ASM_AVR32_CACHE_H
4615 #define __ASM_AVR32_CACHE_H
4616
4617 +#include <linux/const.h>
4618 +
4619 #define L1_CACHE_SHIFT 5
4620 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4621 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4622
4623 /*
4624 * Memory returned by kmalloc() may be used for DMA, so we must make
4625 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4626 index d232888..87c8df1 100644
4627 --- a/arch/avr32/include/asm/elf.h
4628 +++ b/arch/avr32/include/asm/elf.h
4629 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4630 the loader. We need to make sure that it is out of the way of the program
4631 that it will "exec", and that there is sufficient room for the brk. */
4632
4633 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4634 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4635
4636 +#ifdef CONFIG_PAX_ASLR
4637 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4638 +
4639 +#define PAX_DELTA_MMAP_LEN 15
4640 +#define PAX_DELTA_STACK_LEN 15
4641 +#endif
4642
4643 /* This yields a mask that user programs can use to figure out what
4644 instruction set this CPU supports. This could be done in user space,
4645 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4646 index 479330b..53717a8 100644
4647 --- a/arch/avr32/include/asm/kmap_types.h
4648 +++ b/arch/avr32/include/asm/kmap_types.h
4649 @@ -2,9 +2,9 @@
4650 #define __ASM_AVR32_KMAP_TYPES_H
4651
4652 #ifdef CONFIG_DEBUG_HIGHMEM
4653 -# define KM_TYPE_NR 29
4654 +# define KM_TYPE_NR 30
4655 #else
4656 -# define KM_TYPE_NR 14
4657 +# define KM_TYPE_NR 15
4658 #endif
4659
4660 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4661 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4662 index 0eca933..eb78c7b 100644
4663 --- a/arch/avr32/mm/fault.c
4664 +++ b/arch/avr32/mm/fault.c
4665 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4666
4667 int exception_trace = 1;
4668
4669 +#ifdef CONFIG_PAX_PAGEEXEC
4670 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4671 +{
4672 + unsigned long i;
4673 +
4674 + printk(KERN_ERR "PAX: bytes at PC: ");
4675 + for (i = 0; i < 20; i++) {
4676 + unsigned char c;
4677 + if (get_user(c, (unsigned char *)pc+i))
4678 + printk(KERN_CONT "???????? ");
4679 + else
4680 + printk(KERN_CONT "%02x ", c);
4681 + }
4682 + printk("\n");
4683 +}
4684 +#endif
4685 +
4686 /*
4687 * This routine handles page faults. It determines the address and the
4688 * problem, and then passes it off to one of the appropriate routines.
4689 @@ -176,6 +193,16 @@ bad_area:
4690 up_read(&mm->mmap_sem);
4691
4692 if (user_mode(regs)) {
4693 +
4694 +#ifdef CONFIG_PAX_PAGEEXEC
4695 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4696 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4697 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4698 + do_group_exit(SIGKILL);
4699 + }
4700 + }
4701 +#endif
4702 +
4703 if (exception_trace && printk_ratelimit())
4704 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4705 "sp %08lx ecr %lu\n",
4706 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4707 index 568885a..f8008df 100644
4708 --- a/arch/blackfin/include/asm/cache.h
4709 +++ b/arch/blackfin/include/asm/cache.h
4710 @@ -7,6 +7,7 @@
4711 #ifndef __ARCH_BLACKFIN_CACHE_H
4712 #define __ARCH_BLACKFIN_CACHE_H
4713
4714 +#include <linux/const.h>
4715 #include <linux/linkage.h> /* for asmlinkage */
4716
4717 /*
4718 @@ -14,7 +15,7 @@
4719 * Blackfin loads 32 bytes for cache
4720 */
4721 #define L1_CACHE_SHIFT 5
4722 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4723 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4724 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4725
4726 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4727 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4728 index aea2718..3639a60 100644
4729 --- a/arch/cris/include/arch-v10/arch/cache.h
4730 +++ b/arch/cris/include/arch-v10/arch/cache.h
4731 @@ -1,8 +1,9 @@
4732 #ifndef _ASM_ARCH_CACHE_H
4733 #define _ASM_ARCH_CACHE_H
4734
4735 +#include <linux/const.h>
4736 /* Etrax 100LX have 32-byte cache-lines. */
4737 -#define L1_CACHE_BYTES 32
4738 #define L1_CACHE_SHIFT 5
4739 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4740
4741 #endif /* _ASM_ARCH_CACHE_H */
4742 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4743 index 7caf25d..ee65ac5 100644
4744 --- a/arch/cris/include/arch-v32/arch/cache.h
4745 +++ b/arch/cris/include/arch-v32/arch/cache.h
4746 @@ -1,11 +1,12 @@
4747 #ifndef _ASM_CRIS_ARCH_CACHE_H
4748 #define _ASM_CRIS_ARCH_CACHE_H
4749
4750 +#include <linux/const.h>
4751 #include <arch/hwregs/dma.h>
4752
4753 /* A cache-line is 32 bytes. */
4754 -#define L1_CACHE_BYTES 32
4755 #define L1_CACHE_SHIFT 5
4756 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4757
4758 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4759
4760 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4761 index b86329d..6709906 100644
4762 --- a/arch/frv/include/asm/atomic.h
4763 +++ b/arch/frv/include/asm/atomic.h
4764 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4765 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4766 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4767
4768 +#define atomic64_read_unchecked(v) atomic64_read(v)
4769 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4770 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4771 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4772 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4773 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4774 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4775 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4776 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4777 +
4778 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4779 {
4780 int c, old;
4781 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4782 index 2797163..c2a401d 100644
4783 --- a/arch/frv/include/asm/cache.h
4784 +++ b/arch/frv/include/asm/cache.h
4785 @@ -12,10 +12,11 @@
4786 #ifndef __ASM_CACHE_H
4787 #define __ASM_CACHE_H
4788
4789 +#include <linux/const.h>
4790
4791 /* bytes per L1 cache line */
4792 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4793 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4794 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4795
4796 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4797 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4798 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4799 index 43901f2..0d8b865 100644
4800 --- a/arch/frv/include/asm/kmap_types.h
4801 +++ b/arch/frv/include/asm/kmap_types.h
4802 @@ -2,6 +2,6 @@
4803 #ifndef _ASM_KMAP_TYPES_H
4804 #define _ASM_KMAP_TYPES_H
4805
4806 -#define KM_TYPE_NR 17
4807 +#define KM_TYPE_NR 18
4808
4809 #endif
4810 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4811 index 836f147..4cf23f5 100644
4812 --- a/arch/frv/mm/elf-fdpic.c
4813 +++ b/arch/frv/mm/elf-fdpic.c
4814 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4815 {
4816 struct vm_area_struct *vma;
4817 struct vm_unmapped_area_info info;
4818 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4819
4820 if (len > TASK_SIZE)
4821 return -ENOMEM;
4822 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4823 if (addr) {
4824 addr = PAGE_ALIGN(addr);
4825 vma = find_vma(current->mm, addr);
4826 - if (TASK_SIZE - len >= addr &&
4827 - (!vma || addr + len <= vma->vm_start))
4828 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4829 goto success;
4830 }
4831
4832 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4833 info.high_limit = (current->mm->start_stack - 0x00200000);
4834 info.align_mask = 0;
4835 info.align_offset = 0;
4836 + info.threadstack_offset = offset;
4837 addr = vm_unmapped_area(&info);
4838 if (!(addr & ~PAGE_MASK))
4839 goto success;
4840 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4841 index f4ca594..adc72fd6 100644
4842 --- a/arch/hexagon/include/asm/cache.h
4843 +++ b/arch/hexagon/include/asm/cache.h
4844 @@ -21,9 +21,11 @@
4845 #ifndef __ASM_CACHE_H
4846 #define __ASM_CACHE_H
4847
4848 +#include <linux/const.h>
4849 +
4850 /* Bytes per L1 cache line */
4851 -#define L1_CACHE_SHIFT (5)
4852 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4853 +#define L1_CACHE_SHIFT 5
4854 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4855
4856 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4857 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4858 diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
4859 index 7740ab1..17fa8c5 100644
4860 --- a/arch/ia64/Kconfig
4861 +++ b/arch/ia64/Kconfig
4862 @@ -554,6 +554,7 @@ source "drivers/sn/Kconfig"
4863 config KEXEC
4864 bool "kexec system call"
4865 depends on !IA64_HP_SIM && (!SMP || HOTPLUG_CPU)
4866 + depends on !GRKERNSEC_KMEM
4867 help
4868 kexec is a system call that implements the ability to shutdown your
4869 current kernel, and to start another kernel. It is like a reboot
4870 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4871 index 6e6fe18..a6ae668 100644
4872 --- a/arch/ia64/include/asm/atomic.h
4873 +++ b/arch/ia64/include/asm/atomic.h
4874 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4875 #define atomic64_inc(v) atomic64_add(1, (v))
4876 #define atomic64_dec(v) atomic64_sub(1, (v))
4877
4878 +#define atomic64_read_unchecked(v) atomic64_read(v)
4879 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4880 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4881 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4882 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4883 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4884 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4885 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4886 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4887 +
4888 /* Atomic operations are already serializing */
4889 #define smp_mb__before_atomic_dec() barrier()
4890 #define smp_mb__after_atomic_dec() barrier()
4891 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4892 index 988254a..e1ee885 100644
4893 --- a/arch/ia64/include/asm/cache.h
4894 +++ b/arch/ia64/include/asm/cache.h
4895 @@ -1,6 +1,7 @@
4896 #ifndef _ASM_IA64_CACHE_H
4897 #define _ASM_IA64_CACHE_H
4898
4899 +#include <linux/const.h>
4900
4901 /*
4902 * Copyright (C) 1998-2000 Hewlett-Packard Co
4903 @@ -9,7 +10,7 @@
4904
4905 /* Bytes per L1 (data) cache line. */
4906 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4907 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4908 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4909
4910 #ifdef CONFIG_SMP
4911 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4912 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4913 index 5a83c5c..4d7f553 100644
4914 --- a/arch/ia64/include/asm/elf.h
4915 +++ b/arch/ia64/include/asm/elf.h
4916 @@ -42,6 +42,13 @@
4917 */
4918 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4919
4920 +#ifdef CONFIG_PAX_ASLR
4921 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4922 +
4923 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4924 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4925 +#endif
4926 +
4927 #define PT_IA_64_UNWIND 0x70000001
4928
4929 /* IA-64 relocations: */
4930 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4931 index 96a8d92..617a1cf 100644
4932 --- a/arch/ia64/include/asm/pgalloc.h
4933 +++ b/arch/ia64/include/asm/pgalloc.h
4934 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4935 pgd_val(*pgd_entry) = __pa(pud);
4936 }
4937
4938 +static inline void
4939 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4940 +{
4941 + pgd_populate(mm, pgd_entry, pud);
4942 +}
4943 +
4944 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4945 {
4946 return quicklist_alloc(0, GFP_KERNEL, NULL);
4947 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4948 pud_val(*pud_entry) = __pa(pmd);
4949 }
4950
4951 +static inline void
4952 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4953 +{
4954 + pud_populate(mm, pud_entry, pmd);
4955 +}
4956 +
4957 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4958 {
4959 return quicklist_alloc(0, GFP_KERNEL, NULL);
4960 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4961 index 7935115..c0eca6a 100644
4962 --- a/arch/ia64/include/asm/pgtable.h
4963 +++ b/arch/ia64/include/asm/pgtable.h
4964 @@ -12,7 +12,7 @@
4965 * David Mosberger-Tang <davidm@hpl.hp.com>
4966 */
4967
4968 -
4969 +#include <linux/const.h>
4970 #include <asm/mman.h>
4971 #include <asm/page.h>
4972 #include <asm/processor.h>
4973 @@ -142,6 +142,17 @@
4974 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4975 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4976 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4977 +
4978 +#ifdef CONFIG_PAX_PAGEEXEC
4979 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4980 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4981 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4982 +#else
4983 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4984 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4985 +# define PAGE_COPY_NOEXEC PAGE_COPY
4986 +#endif
4987 +
4988 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4989 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4990 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4991 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4992 index 45698cd..e8e2dbc 100644
4993 --- a/arch/ia64/include/asm/spinlock.h
4994 +++ b/arch/ia64/include/asm/spinlock.h
4995 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4996 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4997
4998 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4999 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
5000 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
5001 }
5002
5003 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
5004 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
5005 index 449c8c0..18965fb 100644
5006 --- a/arch/ia64/include/asm/uaccess.h
5007 +++ b/arch/ia64/include/asm/uaccess.h
5008 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
5009 static inline unsigned long
5010 __copy_to_user (void __user *to, const void *from, unsigned long count)
5011 {
5012 + if (count > INT_MAX)
5013 + return count;
5014 +
5015 + if (!__builtin_constant_p(count))
5016 + check_object_size(from, count, true);
5017 +
5018 return __copy_user(to, (__force void __user *) from, count);
5019 }
5020
5021 static inline unsigned long
5022 __copy_from_user (void *to, const void __user *from, unsigned long count)
5023 {
5024 + if (count > INT_MAX)
5025 + return count;
5026 +
5027 + if (!__builtin_constant_p(count))
5028 + check_object_size(to, count, false);
5029 +
5030 return __copy_user((__force void __user *) to, from, count);
5031 }
5032
5033 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5034 ({ \
5035 void __user *__cu_to = (to); \
5036 const void *__cu_from = (from); \
5037 - long __cu_len = (n); \
5038 + unsigned long __cu_len = (n); \
5039 \
5040 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5041 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5042 + if (!__builtin_constant_p(n)) \
5043 + check_object_size(__cu_from, __cu_len, true); \
5044 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5045 + } \
5046 __cu_len; \
5047 })
5048
5049 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5050 ({ \
5051 void *__cu_to = (to); \
5052 const void __user *__cu_from = (from); \
5053 - long __cu_len = (n); \
5054 + unsigned long __cu_len = (n); \
5055 \
5056 __chk_user_ptr(__cu_from); \
5057 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5058 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5059 + if (!__builtin_constant_p(n)) \
5060 + check_object_size(__cu_to, __cu_len, false); \
5061 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5062 + } \
5063 __cu_len; \
5064 })
5065
5066 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5067 index 24603be..948052d 100644
5068 --- a/arch/ia64/kernel/module.c
5069 +++ b/arch/ia64/kernel/module.c
5070 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5071 void
5072 module_free (struct module *mod, void *module_region)
5073 {
5074 - if (mod && mod->arch.init_unw_table &&
5075 - module_region == mod->module_init) {
5076 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5077 unw_remove_unwind_table(mod->arch.init_unw_table);
5078 mod->arch.init_unw_table = NULL;
5079 }
5080 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5081 }
5082
5083 static inline int
5084 +in_init_rx (const struct module *mod, uint64_t addr)
5085 +{
5086 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5087 +}
5088 +
5089 +static inline int
5090 +in_init_rw (const struct module *mod, uint64_t addr)
5091 +{
5092 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5093 +}
5094 +
5095 +static inline int
5096 in_init (const struct module *mod, uint64_t addr)
5097 {
5098 - return addr - (uint64_t) mod->module_init < mod->init_size;
5099 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5100 +}
5101 +
5102 +static inline int
5103 +in_core_rx (const struct module *mod, uint64_t addr)
5104 +{
5105 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5106 +}
5107 +
5108 +static inline int
5109 +in_core_rw (const struct module *mod, uint64_t addr)
5110 +{
5111 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5112 }
5113
5114 static inline int
5115 in_core (const struct module *mod, uint64_t addr)
5116 {
5117 - return addr - (uint64_t) mod->module_core < mod->core_size;
5118 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5119 }
5120
5121 static inline int
5122 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5123 break;
5124
5125 case RV_BDREL:
5126 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5127 + if (in_init_rx(mod, val))
5128 + val -= (uint64_t) mod->module_init_rx;
5129 + else if (in_init_rw(mod, val))
5130 + val -= (uint64_t) mod->module_init_rw;
5131 + else if (in_core_rx(mod, val))
5132 + val -= (uint64_t) mod->module_core_rx;
5133 + else if (in_core_rw(mod, val))
5134 + val -= (uint64_t) mod->module_core_rw;
5135 break;
5136
5137 case RV_LTV:
5138 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5139 * addresses have been selected...
5140 */
5141 uint64_t gp;
5142 - if (mod->core_size > MAX_LTOFF)
5143 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5144 /*
5145 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5146 * at the end of the module.
5147 */
5148 - gp = mod->core_size - MAX_LTOFF / 2;
5149 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5150 else
5151 - gp = mod->core_size / 2;
5152 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5153 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5154 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5155 mod->arch.gp = gp;
5156 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5157 }
5158 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5159 index ab33328..f39506c 100644
5160 --- a/arch/ia64/kernel/palinfo.c
5161 +++ b/arch/ia64/kernel/palinfo.c
5162 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5163 return NOTIFY_OK;
5164 }
5165
5166 -static struct notifier_block __refdata palinfo_cpu_notifier =
5167 +static struct notifier_block palinfo_cpu_notifier =
5168 {
5169 .notifier_call = palinfo_cpu_callback,
5170 .priority = 0,
5171 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5172 index 41e33f8..65180b2a 100644
5173 --- a/arch/ia64/kernel/sys_ia64.c
5174 +++ b/arch/ia64/kernel/sys_ia64.c
5175 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5176 unsigned long align_mask = 0;
5177 struct mm_struct *mm = current->mm;
5178 struct vm_unmapped_area_info info;
5179 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5180
5181 if (len > RGN_MAP_LIMIT)
5182 return -ENOMEM;
5183 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5184 if (REGION_NUMBER(addr) == RGN_HPAGE)
5185 addr = 0;
5186 #endif
5187 +
5188 +#ifdef CONFIG_PAX_RANDMMAP
5189 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5190 + addr = mm->free_area_cache;
5191 + else
5192 +#endif
5193 +
5194 if (!addr)
5195 addr = TASK_UNMAPPED_BASE;
5196
5197 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5198 info.high_limit = TASK_SIZE;
5199 info.align_mask = align_mask;
5200 info.align_offset = 0;
5201 + info.threadstack_offset = offset;
5202 return vm_unmapped_area(&info);
5203 }
5204
5205 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5206 index 0ccb28f..8992469 100644
5207 --- a/arch/ia64/kernel/vmlinux.lds.S
5208 +++ b/arch/ia64/kernel/vmlinux.lds.S
5209 @@ -198,7 +198,7 @@ SECTIONS {
5210 /* Per-cpu data: */
5211 . = ALIGN(PERCPU_PAGE_SIZE);
5212 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5213 - __phys_per_cpu_start = __per_cpu_load;
5214 + __phys_per_cpu_start = per_cpu_load;
5215 /*
5216 * ensure percpu data fits
5217 * into percpu page size
5218 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5219 index 7225dad..2a7c8256 100644
5220 --- a/arch/ia64/mm/fault.c
5221 +++ b/arch/ia64/mm/fault.c
5222 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5223 return pte_present(pte);
5224 }
5225
5226 +#ifdef CONFIG_PAX_PAGEEXEC
5227 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5228 +{
5229 + unsigned long i;
5230 +
5231 + printk(KERN_ERR "PAX: bytes at PC: ");
5232 + for (i = 0; i < 8; i++) {
5233 + unsigned int c;
5234 + if (get_user(c, (unsigned int *)pc+i))
5235 + printk(KERN_CONT "???????? ");
5236 + else
5237 + printk(KERN_CONT "%08x ", c);
5238 + }
5239 + printk("\n");
5240 +}
5241 +#endif
5242 +
5243 # define VM_READ_BIT 0
5244 # define VM_WRITE_BIT 1
5245 # define VM_EXEC_BIT 2
5246 @@ -151,8 +168,21 @@ retry:
5247 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5248 goto bad_area;
5249
5250 - if ((vma->vm_flags & mask) != mask)
5251 + if ((vma->vm_flags & mask) != mask) {
5252 +
5253 +#ifdef CONFIG_PAX_PAGEEXEC
5254 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5255 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5256 + goto bad_area;
5257 +
5258 + up_read(&mm->mmap_sem);
5259 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5260 + do_group_exit(SIGKILL);
5261 + }
5262 +#endif
5263 +
5264 goto bad_area;
5265 + }
5266
5267 /*
5268 * If for any reason at all we couldn't handle the fault, make
5269 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5270 index 68232db..6ca80af 100644
5271 --- a/arch/ia64/mm/hugetlbpage.c
5272 +++ b/arch/ia64/mm/hugetlbpage.c
5273 @@ -154,6 +154,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5274 unsigned long pgoff, unsigned long flags)
5275 {
5276 struct vm_unmapped_area_info info;
5277 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5278
5279 if (len > RGN_MAP_LIMIT)
5280 return -ENOMEM;
5281 @@ -177,6 +178,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5282 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5283 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5284 info.align_offset = 0;
5285 + info.threadstack_offset = offset;
5286 return vm_unmapped_area(&info);
5287 }
5288
5289 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5290 index b6f7f43..c04320d 100644
5291 --- a/arch/ia64/mm/init.c
5292 +++ b/arch/ia64/mm/init.c
5293 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5294 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5295 vma->vm_end = vma->vm_start + PAGE_SIZE;
5296 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5297 +
5298 +#ifdef CONFIG_PAX_PAGEEXEC
5299 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5300 + vma->vm_flags &= ~VM_EXEC;
5301 +
5302 +#ifdef CONFIG_PAX_MPROTECT
5303 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5304 + vma->vm_flags &= ~VM_MAYEXEC;
5305 +#endif
5306 +
5307 + }
5308 +#endif
5309 +
5310 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5311 down_write(&current->mm->mmap_sem);
5312 if (insert_vm_struct(current->mm, vma)) {
5313 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5314 index 40b3ee9..8c2c112 100644
5315 --- a/arch/m32r/include/asm/cache.h
5316 +++ b/arch/m32r/include/asm/cache.h
5317 @@ -1,8 +1,10 @@
5318 #ifndef _ASM_M32R_CACHE_H
5319 #define _ASM_M32R_CACHE_H
5320
5321 +#include <linux/const.h>
5322 +
5323 /* L1 cache line size */
5324 #define L1_CACHE_SHIFT 4
5325 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5326 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5327
5328 #endif /* _ASM_M32R_CACHE_H */
5329 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5330 index 82abd15..d95ae5d 100644
5331 --- a/arch/m32r/lib/usercopy.c
5332 +++ b/arch/m32r/lib/usercopy.c
5333 @@ -14,6 +14,9 @@
5334 unsigned long
5335 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5336 {
5337 + if ((long)n < 0)
5338 + return n;
5339 +
5340 prefetch(from);
5341 if (access_ok(VERIFY_WRITE, to, n))
5342 __copy_user(to,from,n);
5343 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5344 unsigned long
5345 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5346 {
5347 + if ((long)n < 0)
5348 + return n;
5349 +
5350 prefetchw(to);
5351 if (access_ok(VERIFY_READ, from, n))
5352 __copy_user_zeroing(to,from,n);
5353 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5354 index 0395c51..5f26031 100644
5355 --- a/arch/m68k/include/asm/cache.h
5356 +++ b/arch/m68k/include/asm/cache.h
5357 @@ -4,9 +4,11 @@
5358 #ifndef __ARCH_M68K_CACHE_H
5359 #define __ARCH_M68K_CACHE_H
5360
5361 +#include <linux/const.h>
5362 +
5363 /* bytes per L1 cache line */
5364 #define L1_CACHE_SHIFT 4
5365 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5366 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5367
5368 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5369
5370 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5371 index 0424315..defcca9 100644
5372 --- a/arch/metag/mm/hugetlbpage.c
5373 +++ b/arch/metag/mm/hugetlbpage.c
5374 @@ -205,6 +205,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5375 info.high_limit = TASK_SIZE;
5376 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5377 info.align_offset = 0;
5378 + info.threadstack_offset = 0;
5379 return vm_unmapped_area(&info);
5380 }
5381
5382 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5383 index 4efe96a..60e8699 100644
5384 --- a/arch/microblaze/include/asm/cache.h
5385 +++ b/arch/microblaze/include/asm/cache.h
5386 @@ -13,11 +13,12 @@
5387 #ifndef _ASM_MICROBLAZE_CACHE_H
5388 #define _ASM_MICROBLAZE_CACHE_H
5389
5390 +#include <linux/const.h>
5391 #include <asm/registers.h>
5392
5393 #define L1_CACHE_SHIFT 5
5394 /* word-granular cache in microblaze */
5395 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5396 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5397
5398 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5399
5400 diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
5401 index f75ab4a..adc6968 100644
5402 --- a/arch/mips/Kconfig
5403 +++ b/arch/mips/Kconfig
5404 @@ -2283,6 +2283,7 @@ source "kernel/Kconfig.preempt"
5405
5406 config KEXEC
5407 bool "Kexec system call"
5408 + depends on !GRKERNSEC_KMEM
5409 help
5410 kexec is a system call that implements the ability to shutdown your
5411 current kernel, and to start another kernel. It is like a reboot
5412 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5413 index 08b6079..8b554d2 100644
5414 --- a/arch/mips/include/asm/atomic.h
5415 +++ b/arch/mips/include/asm/atomic.h
5416 @@ -21,15 +21,39 @@
5417 #include <asm/cmpxchg.h>
5418 #include <asm/war.h>
5419
5420 +#ifdef CONFIG_GENERIC_ATOMIC64
5421 +#include <asm-generic/atomic64.h>
5422 +#endif
5423 +
5424 #define ATOMIC_INIT(i) { (i) }
5425
5426 +#ifdef CONFIG_64BIT
5427 +#define _ASM_EXTABLE(from, to) \
5428 +" .section __ex_table,\"a\"\n" \
5429 +" .dword " #from ", " #to"\n" \
5430 +" .previous\n"
5431 +#else
5432 +#define _ASM_EXTABLE(from, to) \
5433 +" .section __ex_table,\"a\"\n" \
5434 +" .word " #from ", " #to"\n" \
5435 +" .previous\n"
5436 +#endif
5437 +
5438 /*
5439 * atomic_read - read atomic variable
5440 * @v: pointer of type atomic_t
5441 *
5442 * Atomically reads the value of @v.
5443 */
5444 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5445 +static inline int atomic_read(const atomic_t *v)
5446 +{
5447 + return (*(volatile const int *) &v->counter);
5448 +}
5449 +
5450 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5451 +{
5452 + return (*(volatile const int *) &v->counter);
5453 +}
5454
5455 /*
5456 * atomic_set - set atomic variable
5457 @@ -38,7 +62,15 @@
5458 *
5459 * Atomically sets the value of @v to @i.
5460 */
5461 -#define atomic_set(v, i) ((v)->counter = (i))
5462 +static inline void atomic_set(atomic_t *v, int i)
5463 +{
5464 + v->counter = i;
5465 +}
5466 +
5467 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5468 +{
5469 + v->counter = i;
5470 +}
5471
5472 /*
5473 * atomic_add - add integer to atomic variable
5474 @@ -47,7 +79,67 @@
5475 *
5476 * Atomically adds @i to @v.
5477 */
5478 -static __inline__ void atomic_add(int i, atomic_t * v)
5479 +static __inline__ void atomic_add(int i, atomic_t *v)
5480 +{
5481 + int temp;
5482 +
5483 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5484 + __asm__ __volatile__(
5485 + " .set mips3 \n"
5486 + "1: ll %0, %1 # atomic_add \n"
5487 +#ifdef CONFIG_PAX_REFCOUNT
5488 + /* Exception on overflow. */
5489 + "2: add %0, %2 \n"
5490 +#else
5491 + " addu %0, %2 \n"
5492 +#endif
5493 + " sc %0, %1 \n"
5494 + " beqzl %0, 1b \n"
5495 +#ifdef CONFIG_PAX_REFCOUNT
5496 + "3: \n"
5497 + _ASM_EXTABLE(2b, 3b)
5498 +#endif
5499 + " .set mips0 \n"
5500 + : "=&r" (temp), "+m" (v->counter)
5501 + : "Ir" (i));
5502 + } else if (kernel_uses_llsc) {
5503 + __asm__ __volatile__(
5504 + " .set mips3 \n"
5505 + "1: ll %0, %1 # atomic_add \n"
5506 +#ifdef CONFIG_PAX_REFCOUNT
5507 + /* Exception on overflow. */
5508 + "2: add %0, %2 \n"
5509 +#else
5510 + " addu %0, %2 \n"
5511 +#endif
5512 + " sc %0, %1 \n"
5513 + " beqz %0, 1b \n"
5514 +#ifdef CONFIG_PAX_REFCOUNT
5515 + "3: \n"
5516 + _ASM_EXTABLE(2b, 3b)
5517 +#endif
5518 + " .set mips0 \n"
5519 + : "=&r" (temp), "+m" (v->counter)
5520 + : "Ir" (i));
5521 + } else {
5522 + unsigned long flags;
5523 +
5524 + raw_local_irq_save(flags);
5525 + __asm__ __volatile__(
5526 +#ifdef CONFIG_PAX_REFCOUNT
5527 + /* Exception on overflow. */
5528 + "1: add %0, %1 \n"
5529 + "2: \n"
5530 + _ASM_EXTABLE(1b, 2b)
5531 +#else
5532 + " addu %0, %1 \n"
5533 +#endif
5534 + : "+r" (v->counter) : "Ir" (i));
5535 + raw_local_irq_restore(flags);
5536 + }
5537 +}
5538 +
5539 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5540 {
5541 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5542 int temp;
5543 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5544 *
5545 * Atomically subtracts @i from @v.
5546 */
5547 -static __inline__ void atomic_sub(int i, atomic_t * v)
5548 +static __inline__ void atomic_sub(int i, atomic_t *v)
5549 +{
5550 + int temp;
5551 +
5552 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5553 + __asm__ __volatile__(
5554 + " .set mips3 \n"
5555 + "1: ll %0, %1 # atomic64_sub \n"
5556 +#ifdef CONFIG_PAX_REFCOUNT
5557 + /* Exception on overflow. */
5558 + "2: sub %0, %2 \n"
5559 +#else
5560 + " subu %0, %2 \n"
5561 +#endif
5562 + " sc %0, %1 \n"
5563 + " beqzl %0, 1b \n"
5564 +#ifdef CONFIG_PAX_REFCOUNT
5565 + "3: \n"
5566 + _ASM_EXTABLE(2b, 3b)
5567 +#endif
5568 + " .set mips0 \n"
5569 + : "=&r" (temp), "+m" (v->counter)
5570 + : "Ir" (i));
5571 + } else if (kernel_uses_llsc) {
5572 + __asm__ __volatile__(
5573 + " .set mips3 \n"
5574 + "1: ll %0, %1 # atomic64_sub \n"
5575 +#ifdef CONFIG_PAX_REFCOUNT
5576 + /* Exception on overflow. */
5577 + "2: sub %0, %2 \n"
5578 +#else
5579 + " subu %0, %2 \n"
5580 +#endif
5581 + " sc %0, %1 \n"
5582 + " beqz %0, 1b \n"
5583 +#ifdef CONFIG_PAX_REFCOUNT
5584 + "3: \n"
5585 + _ASM_EXTABLE(2b, 3b)
5586 +#endif
5587 + " .set mips0 \n"
5588 + : "=&r" (temp), "+m" (v->counter)
5589 + : "Ir" (i));
5590 + } else {
5591 + unsigned long flags;
5592 +
5593 + raw_local_irq_save(flags);
5594 + __asm__ __volatile__(
5595 +#ifdef CONFIG_PAX_REFCOUNT
5596 + /* Exception on overflow. */
5597 + "1: sub %0, %1 \n"
5598 + "2: \n"
5599 + _ASM_EXTABLE(1b, 2b)
5600 +#else
5601 + " subu %0, %1 \n"
5602 +#endif
5603 + : "+r" (v->counter) : "Ir" (i));
5604 + raw_local_irq_restore(flags);
5605 + }
5606 +}
5607 +
5608 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5609 {
5610 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5611 int temp;
5612 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5613 /*
5614 * Same as above, but return the result value
5615 */
5616 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5617 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5618 +{
5619 + int result;
5620 + int temp;
5621 +
5622 + smp_mb__before_llsc();
5623 +
5624 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5625 + __asm__ __volatile__(
5626 + " .set mips3 \n"
5627 + "1: ll %1, %2 # atomic_add_return \n"
5628 +#ifdef CONFIG_PAX_REFCOUNT
5629 + "2: add %0, %1, %3 \n"
5630 +#else
5631 + " addu %0, %1, %3 \n"
5632 +#endif
5633 + " sc %0, %2 \n"
5634 + " beqzl %0, 1b \n"
5635 +#ifdef CONFIG_PAX_REFCOUNT
5636 + " b 4f \n"
5637 + " .set noreorder \n"
5638 + "3: b 5f \n"
5639 + " move %0, %1 \n"
5640 + " .set reorder \n"
5641 + _ASM_EXTABLE(2b, 3b)
5642 +#endif
5643 + "4: addu %0, %1, %3 \n"
5644 +#ifdef CONFIG_PAX_REFCOUNT
5645 + "5: \n"
5646 +#endif
5647 + " .set mips0 \n"
5648 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5649 + : "Ir" (i));
5650 + } else if (kernel_uses_llsc) {
5651 + __asm__ __volatile__(
5652 + " .set mips3 \n"
5653 + "1: ll %1, %2 # atomic_add_return \n"
5654 +#ifdef CONFIG_PAX_REFCOUNT
5655 + "2: add %0, %1, %3 \n"
5656 +#else
5657 + " addu %0, %1, %3 \n"
5658 +#endif
5659 + " sc %0, %2 \n"
5660 + " bnez %0, 4f \n"
5661 + " b 1b \n"
5662 +#ifdef CONFIG_PAX_REFCOUNT
5663 + " .set noreorder \n"
5664 + "3: b 5f \n"
5665 + " move %0, %1 \n"
5666 + " .set reorder \n"
5667 + _ASM_EXTABLE(2b, 3b)
5668 +#endif
5669 + "4: addu %0, %1, %3 \n"
5670 +#ifdef CONFIG_PAX_REFCOUNT
5671 + "5: \n"
5672 +#endif
5673 + " .set mips0 \n"
5674 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5675 + : "Ir" (i));
5676 + } else {
5677 + unsigned long flags;
5678 +
5679 + raw_local_irq_save(flags);
5680 + __asm__ __volatile__(
5681 + " lw %0, %1 \n"
5682 +#ifdef CONFIG_PAX_REFCOUNT
5683 + /* Exception on overflow. */
5684 + "1: add %0, %2 \n"
5685 +#else
5686 + " addu %0, %2 \n"
5687 +#endif
5688 + " sw %0, %1 \n"
5689 +#ifdef CONFIG_PAX_REFCOUNT
5690 + /* Note: Dest reg is not modified on overflow */
5691 + "2: \n"
5692 + _ASM_EXTABLE(1b, 2b)
5693 +#endif
5694 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5695 + raw_local_irq_restore(flags);
5696 + }
5697 +
5698 + smp_llsc_mb();
5699 +
5700 + return result;
5701 +}
5702 +
5703 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5704 {
5705 int result;
5706
5707 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5708 return result;
5709 }
5710
5711 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5712 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5713 +{
5714 + int result;
5715 + int temp;
5716 +
5717 + smp_mb__before_llsc();
5718 +
5719 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5720 + __asm__ __volatile__(
5721 + " .set mips3 \n"
5722 + "1: ll %1, %2 # atomic_sub_return \n"
5723 +#ifdef CONFIG_PAX_REFCOUNT
5724 + "2: sub %0, %1, %3 \n"
5725 +#else
5726 + " subu %0, %1, %3 \n"
5727 +#endif
5728 + " sc %0, %2 \n"
5729 + " beqzl %0, 1b \n"
5730 +#ifdef CONFIG_PAX_REFCOUNT
5731 + " b 4f \n"
5732 + " .set noreorder \n"
5733 + "3: b 5f \n"
5734 + " move %0, %1 \n"
5735 + " .set reorder \n"
5736 + _ASM_EXTABLE(2b, 3b)
5737 +#endif
5738 + "4: subu %0, %1, %3 \n"
5739 +#ifdef CONFIG_PAX_REFCOUNT
5740 + "5: \n"
5741 +#endif
5742 + " .set mips0 \n"
5743 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5744 + : "Ir" (i), "m" (v->counter)
5745 + : "memory");
5746 + } else if (kernel_uses_llsc) {
5747 + __asm__ __volatile__(
5748 + " .set mips3 \n"
5749 + "1: ll %1, %2 # atomic_sub_return \n"
5750 +#ifdef CONFIG_PAX_REFCOUNT
5751 + "2: sub %0, %1, %3 \n"
5752 +#else
5753 + " subu %0, %1, %3 \n"
5754 +#endif
5755 + " sc %0, %2 \n"
5756 + " bnez %0, 4f \n"
5757 + " b 1b \n"
5758 +#ifdef CONFIG_PAX_REFCOUNT
5759 + " .set noreorder \n"
5760 + "3: b 5f \n"
5761 + " move %0, %1 \n"
5762 + " .set reorder \n"
5763 + _ASM_EXTABLE(2b, 3b)
5764 +#endif
5765 + "4: subu %0, %1, %3 \n"
5766 +#ifdef CONFIG_PAX_REFCOUNT
5767 + "5: \n"
5768 +#endif
5769 + " .set mips0 \n"
5770 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5771 + : "Ir" (i));
5772 + } else {
5773 + unsigned long flags;
5774 +
5775 + raw_local_irq_save(flags);
5776 + __asm__ __volatile__(
5777 + " lw %0, %1 \n"
5778 +#ifdef CONFIG_PAX_REFCOUNT
5779 + /* Exception on overflow. */
5780 + "1: sub %0, %2 \n"
5781 +#else
5782 + " subu %0, %2 \n"
5783 +#endif
5784 + " sw %0, %1 \n"
5785 +#ifdef CONFIG_PAX_REFCOUNT
5786 + /* Note: Dest reg is not modified on overflow */
5787 + "2: \n"
5788 + _ASM_EXTABLE(1b, 2b)
5789 +#endif
5790 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5791 + raw_local_irq_restore(flags);
5792 + }
5793 +
5794 + smp_llsc_mb();
5795 +
5796 + return result;
5797 +}
5798 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5799 {
5800 int result;
5801
5802 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5803 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5804 * The function returns the old value of @v minus @i.
5805 */
5806 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5807 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5808 {
5809 int result;
5810
5811 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5812 return result;
5813 }
5814
5815 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5816 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5817 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5818 +{
5819 + return cmpxchg(&v->counter, old, new);
5820 +}
5821 +
5822 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5823 + int new)
5824 +{
5825 + return cmpxchg(&(v->counter), old, new);
5826 +}
5827 +
5828 +static inline int atomic_xchg(atomic_t *v, int new)
5829 +{
5830 + return xchg(&v->counter, new);
5831 +}
5832 +
5833 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5834 +{
5835 + return xchg(&(v->counter), new);
5836 +}
5837
5838 /**
5839 * __atomic_add_unless - add unless the number is a given value
5840 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5841
5842 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5843 #define atomic_inc_return(v) atomic_add_return(1, (v))
5844 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5845 +{
5846 + return atomic_add_return_unchecked(1, v);
5847 +}
5848
5849 /*
5850 * atomic_sub_and_test - subtract value from variable and test result
5851 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5852 * other cases.
5853 */
5854 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5855 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5856 +{
5857 + return atomic_add_return_unchecked(1, v) == 0;
5858 +}
5859
5860 /*
5861 * atomic_dec_and_test - decrement by 1 and test
5862 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5863 * Atomically increments @v by 1.
5864 */
5865 #define atomic_inc(v) atomic_add(1, (v))
5866 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5867 +{
5868 + atomic_add_unchecked(1, v);
5869 +}
5870
5871 /*
5872 * atomic_dec - decrement and test
5873 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5874 * Atomically decrements @v by 1.
5875 */
5876 #define atomic_dec(v) atomic_sub(1, (v))
5877 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5878 +{
5879 + atomic_sub_unchecked(1, v);
5880 +}
5881
5882 /*
5883 * atomic_add_negative - add and test if negative
5884 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5885 * @v: pointer of type atomic64_t
5886 *
5887 */
5888 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5889 +static inline long atomic64_read(const atomic64_t *v)
5890 +{
5891 + return (*(volatile const long *) &v->counter);
5892 +}
5893 +
5894 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5895 +{
5896 + return (*(volatile const long *) &v->counter);
5897 +}
5898
5899 /*
5900 * atomic64_set - set atomic variable
5901 * @v: pointer of type atomic64_t
5902 * @i: required value
5903 */
5904 -#define atomic64_set(v, i) ((v)->counter = (i))
5905 +static inline void atomic64_set(atomic64_t *v, long i)
5906 +{
5907 + v->counter = i;
5908 +}
5909 +
5910 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5911 +{
5912 + v->counter = i;
5913 +}
5914
5915 /*
5916 * atomic64_add - add integer to atomic variable
5917 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5918 *
5919 * Atomically adds @i to @v.
5920 */
5921 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5922 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5923 +{
5924 + long temp;
5925 +
5926 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5927 + __asm__ __volatile__(
5928 + " .set mips3 \n"
5929 + "1: lld %0, %1 # atomic64_add \n"
5930 +#ifdef CONFIG_PAX_REFCOUNT
5931 + /* Exception on overflow. */
5932 + "2: dadd %0, %2 \n"
5933 +#else
5934 + " daddu %0, %2 \n"
5935 +#endif
5936 + " scd %0, %1 \n"
5937 + " beqzl %0, 1b \n"
5938 +#ifdef CONFIG_PAX_REFCOUNT
5939 + "3: \n"
5940 + _ASM_EXTABLE(2b, 3b)
5941 +#endif
5942 + " .set mips0 \n"
5943 + : "=&r" (temp), "+m" (v->counter)
5944 + : "Ir" (i));
5945 + } else if (kernel_uses_llsc) {
5946 + __asm__ __volatile__(
5947 + " .set mips3 \n"
5948 + "1: lld %0, %1 # atomic64_add \n"
5949 +#ifdef CONFIG_PAX_REFCOUNT
5950 + /* Exception on overflow. */
5951 + "2: dadd %0, %2 \n"
5952 +#else
5953 + " daddu %0, %2 \n"
5954 +#endif
5955 + " scd %0, %1 \n"
5956 + " beqz %0, 1b \n"
5957 +#ifdef CONFIG_PAX_REFCOUNT
5958 + "3: \n"
5959 + _ASM_EXTABLE(2b, 3b)
5960 +#endif
5961 + " .set mips0 \n"
5962 + : "=&r" (temp), "+m" (v->counter)
5963 + : "Ir" (i));
5964 + } else {
5965 + unsigned long flags;
5966 +
5967 + raw_local_irq_save(flags);
5968 + __asm__ __volatile__(
5969 +#ifdef CONFIG_PAX_REFCOUNT
5970 + /* Exception on overflow. */
5971 + "1: dadd %0, %1 \n"
5972 + "2: \n"
5973 + _ASM_EXTABLE(1b, 2b)
5974 +#else
5975 + " daddu %0, %1 \n"
5976 +#endif
5977 + : "+r" (v->counter) : "Ir" (i));
5978 + raw_local_irq_restore(flags);
5979 + }
5980 +}
5981 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
5982 {
5983 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5984 long temp;
5985 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
5986 *
5987 * Atomically subtracts @i from @v.
5988 */
5989 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
5990 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
5991 +{
5992 + long temp;
5993 +
5994 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5995 + __asm__ __volatile__(
5996 + " .set mips3 \n"
5997 + "1: lld %0, %1 # atomic64_sub \n"
5998 +#ifdef CONFIG_PAX_REFCOUNT
5999 + /* Exception on overflow. */
6000 + "2: dsub %0, %2 \n"
6001 +#else
6002 + " dsubu %0, %2 \n"
6003 +#endif
6004 + " scd %0, %1 \n"
6005 + " beqzl %0, 1b \n"
6006 +#ifdef CONFIG_PAX_REFCOUNT
6007 + "3: \n"
6008 + _ASM_EXTABLE(2b, 3b)
6009 +#endif
6010 + " .set mips0 \n"
6011 + : "=&r" (temp), "+m" (v->counter)
6012 + : "Ir" (i));
6013 + } else if (kernel_uses_llsc) {
6014 + __asm__ __volatile__(
6015 + " .set mips3 \n"
6016 + "1: lld %0, %1 # atomic64_sub \n"
6017 +#ifdef CONFIG_PAX_REFCOUNT
6018 + /* Exception on overflow. */
6019 + "2: dsub %0, %2 \n"
6020 +#else
6021 + " dsubu %0, %2 \n"
6022 +#endif
6023 + " scd %0, %1 \n"
6024 + " beqz %0, 1b \n"
6025 +#ifdef CONFIG_PAX_REFCOUNT
6026 + "3: \n"
6027 + _ASM_EXTABLE(2b, 3b)
6028 +#endif
6029 + " .set mips0 \n"
6030 + : "=&r" (temp), "+m" (v->counter)
6031 + : "Ir" (i));
6032 + } else {
6033 + unsigned long flags;
6034 +
6035 + raw_local_irq_save(flags);
6036 + __asm__ __volatile__(
6037 +#ifdef CONFIG_PAX_REFCOUNT
6038 + /* Exception on overflow. */
6039 + "1: dsub %0, %1 \n"
6040 + "2: \n"
6041 + _ASM_EXTABLE(1b, 2b)
6042 +#else
6043 + " dsubu %0, %1 \n"
6044 +#endif
6045 + : "+r" (v->counter) : "Ir" (i));
6046 + raw_local_irq_restore(flags);
6047 + }
6048 +}
6049 +
6050 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
6051 {
6052 if (kernel_uses_llsc && R10000_LLSC_WAR) {
6053 long temp;
6054 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
6055 /*
6056 * Same as above, but return the result value
6057 */
6058 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6059 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
6060 +{
6061 + long result;
6062 + long temp;
6063 +
6064 + smp_mb__before_llsc();
6065 +
6066 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6067 + __asm__ __volatile__(
6068 + " .set mips3 \n"
6069 + "1: lld %1, %2 # atomic64_add_return \n"
6070 +#ifdef CONFIG_PAX_REFCOUNT
6071 + "2: dadd %0, %1, %3 \n"
6072 +#else
6073 + " daddu %0, %1, %3 \n"
6074 +#endif
6075 + " scd %0, %2 \n"
6076 + " beqzl %0, 1b \n"
6077 +#ifdef CONFIG_PAX_REFCOUNT
6078 + " b 4f \n"
6079 + " .set noreorder \n"
6080 + "3: b 5f \n"
6081 + " move %0, %1 \n"
6082 + " .set reorder \n"
6083 + _ASM_EXTABLE(2b, 3b)
6084 +#endif
6085 + "4: daddu %0, %1, %3 \n"
6086 +#ifdef CONFIG_PAX_REFCOUNT
6087 + "5: \n"
6088 +#endif
6089 + " .set mips0 \n"
6090 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6091 + : "Ir" (i));
6092 + } else if (kernel_uses_llsc) {
6093 + __asm__ __volatile__(
6094 + " .set mips3 \n"
6095 + "1: lld %1, %2 # atomic64_add_return \n"
6096 +#ifdef CONFIG_PAX_REFCOUNT
6097 + "2: dadd %0, %1, %3 \n"
6098 +#else
6099 + " daddu %0, %1, %3 \n"
6100 +#endif
6101 + " scd %0, %2 \n"
6102 + " bnez %0, 4f \n"
6103 + " b 1b \n"
6104 +#ifdef CONFIG_PAX_REFCOUNT
6105 + " .set noreorder \n"
6106 + "3: b 5f \n"
6107 + " move %0, %1 \n"
6108 + " .set reorder \n"
6109 + _ASM_EXTABLE(2b, 3b)
6110 +#endif
6111 + "4: daddu %0, %1, %3 \n"
6112 +#ifdef CONFIG_PAX_REFCOUNT
6113 + "5: \n"
6114 +#endif
6115 + " .set mips0 \n"
6116 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6117 + : "Ir" (i), "m" (v->counter)
6118 + : "memory");
6119 + } else {
6120 + unsigned long flags;
6121 +
6122 + raw_local_irq_save(flags);
6123 + __asm__ __volatile__(
6124 + " ld %0, %1 \n"
6125 +#ifdef CONFIG_PAX_REFCOUNT
6126 + /* Exception on overflow. */
6127 + "1: dadd %0, %2 \n"
6128 +#else
6129 + " daddu %0, %2 \n"
6130 +#endif
6131 + " sd %0, %1 \n"
6132 +#ifdef CONFIG_PAX_REFCOUNT
6133 + /* Note: Dest reg is not modified on overflow */
6134 + "2: \n"
6135 + _ASM_EXTABLE(1b, 2b)
6136 +#endif
6137 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6138 + raw_local_irq_restore(flags);
6139 + }
6140 +
6141 + smp_llsc_mb();
6142 +
6143 + return result;
6144 +}
6145 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6146 {
6147 long result;
6148
6149 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6150 return result;
6151 }
6152
6153 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6154 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6155 +{
6156 + long result;
6157 + long temp;
6158 +
6159 + smp_mb__before_llsc();
6160 +
6161 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6162 + long temp;
6163 +
6164 + __asm__ __volatile__(
6165 + " .set mips3 \n"
6166 + "1: lld %1, %2 # atomic64_sub_return \n"
6167 +#ifdef CONFIG_PAX_REFCOUNT
6168 + "2: dsub %0, %1, %3 \n"
6169 +#else
6170 + " dsubu %0, %1, %3 \n"
6171 +#endif
6172 + " scd %0, %2 \n"
6173 + " beqzl %0, 1b \n"
6174 +#ifdef CONFIG_PAX_REFCOUNT
6175 + " b 4f \n"
6176 + " .set noreorder \n"
6177 + "3: b 5f \n"
6178 + " move %0, %1 \n"
6179 + " .set reorder \n"
6180 + _ASM_EXTABLE(2b, 3b)
6181 +#endif
6182 + "4: dsubu %0, %1, %3 \n"
6183 +#ifdef CONFIG_PAX_REFCOUNT
6184 + "5: \n"
6185 +#endif
6186 + " .set mips0 \n"
6187 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6188 + : "Ir" (i), "m" (v->counter)
6189 + : "memory");
6190 + } else if (kernel_uses_llsc) {
6191 + __asm__ __volatile__(
6192 + " .set mips3 \n"
6193 + "1: lld %1, %2 # atomic64_sub_return \n"
6194 +#ifdef CONFIG_PAX_REFCOUNT
6195 + "2: dsub %0, %1, %3 \n"
6196 +#else
6197 + " dsubu %0, %1, %3 \n"
6198 +#endif
6199 + " scd %0, %2 \n"
6200 + " bnez %0, 4f \n"
6201 + " b 1b \n"
6202 +#ifdef CONFIG_PAX_REFCOUNT
6203 + " .set noreorder \n"
6204 + "3: b 5f \n"
6205 + " move %0, %1 \n"
6206 + " .set reorder \n"
6207 + _ASM_EXTABLE(2b, 3b)
6208 +#endif
6209 + "4: dsubu %0, %1, %3 \n"
6210 +#ifdef CONFIG_PAX_REFCOUNT
6211 + "5: \n"
6212 +#endif
6213 + " .set mips0 \n"
6214 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6215 + : "Ir" (i), "m" (v->counter)
6216 + : "memory");
6217 + } else {
6218 + unsigned long flags;
6219 +
6220 + raw_local_irq_save(flags);
6221 + __asm__ __volatile__(
6222 + " ld %0, %1 \n"
6223 +#ifdef CONFIG_PAX_REFCOUNT
6224 + /* Exception on overflow. */
6225 + "1: dsub %0, %2 \n"
6226 +#else
6227 + " dsubu %0, %2 \n"
6228 +#endif
6229 + " sd %0, %1 \n"
6230 +#ifdef CONFIG_PAX_REFCOUNT
6231 + /* Note: Dest reg is not modified on overflow */
6232 + "2: \n"
6233 + _ASM_EXTABLE(1b, 2b)
6234 +#endif
6235 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6236 + raw_local_irq_restore(flags);
6237 + }
6238 +
6239 + smp_llsc_mb();
6240 +
6241 + return result;
6242 +}
6243 +
6244 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6245 {
6246 long result;
6247
6248 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6249 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6250 * The function returns the old value of @v minus @i.
6251 */
6252 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6253 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6254 {
6255 long result;
6256
6257 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6258 return result;
6259 }
6260
6261 -#define atomic64_cmpxchg(v, o, n) \
6262 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6263 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6264 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6265 +{
6266 + return cmpxchg(&v->counter, old, new);
6267 +}
6268 +
6269 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6270 + long new)
6271 +{
6272 + return cmpxchg(&(v->counter), old, new);
6273 +}
6274 +
6275 +static inline long atomic64_xchg(atomic64_t *v, long new)
6276 +{
6277 + return xchg(&v->counter, new);
6278 +}
6279 +
6280 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6281 +{
6282 + return xchg(&(v->counter), new);
6283 +}
6284
6285 /**
6286 * atomic64_add_unless - add unless the number is a given value
6287 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6288
6289 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6290 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6291 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6292
6293 /*
6294 * atomic64_sub_and_test - subtract value from variable and test result
6295 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6296 * other cases.
6297 */
6298 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6299 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6300
6301 /*
6302 * atomic64_dec_and_test - decrement by 1 and test
6303 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6304 * Atomically increments @v by 1.
6305 */
6306 #define atomic64_inc(v) atomic64_add(1, (v))
6307 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6308
6309 /*
6310 * atomic64_dec - decrement and test
6311 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6312 * Atomically decrements @v by 1.
6313 */
6314 #define atomic64_dec(v) atomic64_sub(1, (v))
6315 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6316
6317 /*
6318 * atomic64_add_negative - add and test if negative
6319 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6320 index b4db69f..8f3b093 100644
6321 --- a/arch/mips/include/asm/cache.h
6322 +++ b/arch/mips/include/asm/cache.h
6323 @@ -9,10 +9,11 @@
6324 #ifndef _ASM_CACHE_H
6325 #define _ASM_CACHE_H
6326
6327 +#include <linux/const.h>
6328 #include <kmalloc.h>
6329
6330 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6331 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6332 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6333
6334 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6335 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6336 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6337 index cf3ae24..238d22f 100644
6338 --- a/arch/mips/include/asm/elf.h
6339 +++ b/arch/mips/include/asm/elf.h
6340 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6341 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6342 #endif
6343
6344 +#ifdef CONFIG_PAX_ASLR
6345 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6346 +
6347 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6348 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6349 +#endif
6350 +
6351 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6352 struct linux_binprm;
6353 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6354 int uses_interp);
6355
6356 -struct mm_struct;
6357 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6358 -#define arch_randomize_brk arch_randomize_brk
6359 -
6360 #endif /* _ASM_ELF_H */
6361 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6362 index c1f6afa..38cc6e9 100644
6363 --- a/arch/mips/include/asm/exec.h
6364 +++ b/arch/mips/include/asm/exec.h
6365 @@ -12,6 +12,6 @@
6366 #ifndef _ASM_EXEC_H
6367 #define _ASM_EXEC_H
6368
6369 -extern unsigned long arch_align_stack(unsigned long sp);
6370 +#define arch_align_stack(x) ((x) & ~0xfUL)
6371
6372 #endif /* _ASM_EXEC_H */
6373 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6374 index d44622c..64990d2 100644
6375 --- a/arch/mips/include/asm/local.h
6376 +++ b/arch/mips/include/asm/local.h
6377 @@ -12,15 +12,25 @@ typedef struct
6378 atomic_long_t a;
6379 } local_t;
6380
6381 +typedef struct {
6382 + atomic_long_unchecked_t a;
6383 +} local_unchecked_t;
6384 +
6385 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6386
6387 #define local_read(l) atomic_long_read(&(l)->a)
6388 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6389 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6390 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6391
6392 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6393 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6394 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6395 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6396 #define local_inc(l) atomic_long_inc(&(l)->a)
6397 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6398 #define local_dec(l) atomic_long_dec(&(l)->a)
6399 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6400
6401 /*
6402 * Same as above, but return the result value
6403 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6404 return result;
6405 }
6406
6407 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6408 +{
6409 + unsigned long result;
6410 +
6411 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6412 + unsigned long temp;
6413 +
6414 + __asm__ __volatile__(
6415 + " .set mips3 \n"
6416 + "1:" __LL "%1, %2 # local_add_return \n"
6417 + " addu %0, %1, %3 \n"
6418 + __SC "%0, %2 \n"
6419 + " beqzl %0, 1b \n"
6420 + " addu %0, %1, %3 \n"
6421 + " .set mips0 \n"
6422 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6423 + : "Ir" (i), "m" (l->a.counter)
6424 + : "memory");
6425 + } else if (kernel_uses_llsc) {
6426 + unsigned long temp;
6427 +
6428 + __asm__ __volatile__(
6429 + " .set mips3 \n"
6430 + "1:" __LL "%1, %2 # local_add_return \n"
6431 + " addu %0, %1, %3 \n"
6432 + __SC "%0, %2 \n"
6433 + " beqz %0, 1b \n"
6434 + " addu %0, %1, %3 \n"
6435 + " .set mips0 \n"
6436 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6437 + : "Ir" (i), "m" (l->a.counter)
6438 + : "memory");
6439 + } else {
6440 + unsigned long flags;
6441 +
6442 + local_irq_save(flags);
6443 + result = l->a.counter;
6444 + result += i;
6445 + l->a.counter = result;
6446 + local_irq_restore(flags);
6447 + }
6448 +
6449 + return result;
6450 +}
6451 +
6452 static __inline__ long local_sub_return(long i, local_t * l)
6453 {
6454 unsigned long result;
6455 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6456
6457 #define local_cmpxchg(l, o, n) \
6458 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6459 +#define local_cmpxchg_unchecked(l, o, n) \
6460 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6461 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6462
6463 /**
6464 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6465 index f6be474..12ad554 100644
6466 --- a/arch/mips/include/asm/page.h
6467 +++ b/arch/mips/include/asm/page.h
6468 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6469 #ifdef CONFIG_CPU_MIPS32
6470 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6471 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6472 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6473 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6474 #else
6475 typedef struct { unsigned long long pte; } pte_t;
6476 #define pte_val(x) ((x).pte)
6477 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6478 index 881d18b..cea38bc 100644
6479 --- a/arch/mips/include/asm/pgalloc.h
6480 +++ b/arch/mips/include/asm/pgalloc.h
6481 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6482 {
6483 set_pud(pud, __pud((unsigned long)pmd));
6484 }
6485 +
6486 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6487 +{
6488 + pud_populate(mm, pud, pmd);
6489 +}
6490 #endif
6491
6492 /*
6493 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6494 index 25da651..ae2a259 100644
6495 --- a/arch/mips/include/asm/smtc_proc.h
6496 +++ b/arch/mips/include/asm/smtc_proc.h
6497 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6498
6499 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6500
6501 -extern atomic_t smtc_fpu_recoveries;
6502 +extern atomic_unchecked_t smtc_fpu_recoveries;
6503
6504 #endif /* __ASM_SMTC_PROC_H */
6505 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6506 index 61215a3..213ee0e 100644
6507 --- a/arch/mips/include/asm/thread_info.h
6508 +++ b/arch/mips/include/asm/thread_info.h
6509 @@ -116,6 +116,8 @@ static inline struct thread_info *current_thread_info(void)
6510 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6511 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6512 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6513 +/* li takes a 32bit immediate */
6514 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6515 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6516
6517 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6518 @@ -132,20 +134,18 @@ static inline struct thread_info *current_thread_info(void)
6519 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6520 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6521 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6522 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6523
6524 -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6525 - _TIF_SYSCALL_AUDIT)
6526 +#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6527
6528 /* work to do in syscall_trace_leave() */
6529 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6530 - _TIF_SYSCALL_AUDIT)
6531 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6532
6533 /* work to do on interrupt/exception return */
6534 #define _TIF_WORK_MASK \
6535 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6536 /* work to do on any return to u-space */
6537 -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6538 - _TIF_WORK_SYSCALL_EXIT)
6539 +#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6540
6541 #endif /* __KERNEL__ */
6542
6543 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6544 index 1188e00..41cf144 100644
6545 --- a/arch/mips/kernel/binfmt_elfn32.c
6546 +++ b/arch/mips/kernel/binfmt_elfn32.c
6547 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6548 #undef ELF_ET_DYN_BASE
6549 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6550
6551 +#ifdef CONFIG_PAX_ASLR
6552 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6553 +
6554 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6555 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6556 +#endif
6557 +
6558 #include <asm/processor.h>
6559 #include <linux/module.h>
6560 #include <linux/elfcore.h>
6561 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6562 index 202e581..689ca79 100644
6563 --- a/arch/mips/kernel/binfmt_elfo32.c
6564 +++ b/arch/mips/kernel/binfmt_elfo32.c
6565 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6566 #undef ELF_ET_DYN_BASE
6567 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6568
6569 +#ifdef CONFIG_PAX_ASLR
6570 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6571 +
6572 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6573 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6574 +#endif
6575 +
6576 #include <asm/processor.h>
6577
6578 /*
6579 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6580 index d1fea7a..45602ea 100644
6581 --- a/arch/mips/kernel/irq.c
6582 +++ b/arch/mips/kernel/irq.c
6583 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6584 printk("unexpected IRQ # %d\n", irq);
6585 }
6586
6587 -atomic_t irq_err_count;
6588 +atomic_unchecked_t irq_err_count;
6589
6590 int arch_show_interrupts(struct seq_file *p, int prec)
6591 {
6592 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6593 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6594 return 0;
6595 }
6596
6597 asmlinkage void spurious_interrupt(void)
6598 {
6599 - atomic_inc(&irq_err_count);
6600 + atomic_inc_unchecked(&irq_err_count);
6601 }
6602
6603 void __init init_IRQ(void)
6604 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6605 index ddc7610..8c58f17 100644
6606 --- a/arch/mips/kernel/process.c
6607 +++ b/arch/mips/kernel/process.c
6608 @@ -566,15 +566,3 @@ unsigned long get_wchan(struct task_struct *task)
6609 out:
6610 return pc;
6611 }
6612 -
6613 -/*
6614 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6615 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6616 - */
6617 -unsigned long arch_align_stack(unsigned long sp)
6618 -{
6619 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6620 - sp -= get_random_int() & ~PAGE_MASK;
6621 -
6622 - return sp & ALMASK;
6623 -}
6624 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6625 index 8ae1ebe..1bcbf47 100644
6626 --- a/arch/mips/kernel/ptrace.c
6627 +++ b/arch/mips/kernel/ptrace.c
6628 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
6629 return arch;
6630 }
6631
6632 +#ifdef CONFIG_GRKERNSEC_SETXID
6633 +extern void gr_delayed_cred_worker(void);
6634 +#endif
6635 +
6636 /*
6637 * Notification of system call entry/exit
6638 * - triggered by current->work.syscall_trace
6639 @@ -540,6 +544,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6640 /* do the secure computing check first */
6641 secure_computing_strict(regs->regs[2]);
6642
6643 +#ifdef CONFIG_GRKERNSEC_SETXID
6644 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6645 + gr_delayed_cred_worker();
6646 +#endif
6647 +
6648 if (!(current->ptrace & PT_PTRACED))
6649 goto out;
6650
6651 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
6652 index c10aa84..9ec2e60 100644
6653 --- a/arch/mips/kernel/smtc-proc.c
6654 +++ b/arch/mips/kernel/smtc-proc.c
6655 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
6656
6657 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6658
6659 -atomic_t smtc_fpu_recoveries;
6660 +atomic_unchecked_t smtc_fpu_recoveries;
6661
6662 static int smtc_proc_show(struct seq_file *m, void *v)
6663 {
6664 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
6665 for(i = 0; i < NR_CPUS; i++)
6666 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
6667 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
6668 - atomic_read(&smtc_fpu_recoveries));
6669 + atomic_read_unchecked(&smtc_fpu_recoveries));
6670 return 0;
6671 }
6672
6673 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
6674 smtc_cpu_stats[i].selfipis = 0;
6675 }
6676
6677 - atomic_set(&smtc_fpu_recoveries, 0);
6678 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
6679
6680 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
6681 }
6682 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
6683 index dfc1b91..11a2c07 100644
6684 --- a/arch/mips/kernel/smtc.c
6685 +++ b/arch/mips/kernel/smtc.c
6686 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
6687 }
6688 smtc_ipi_qdump();
6689 printk("%d Recoveries of \"stolen\" FPU\n",
6690 - atomic_read(&smtc_fpu_recoveries));
6691 + atomic_read_unchecked(&smtc_fpu_recoveries));
6692 }
6693
6694
6695 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6696 index 84536bf..79caa4d 100644
6697 --- a/arch/mips/kernel/sync-r4k.c
6698 +++ b/arch/mips/kernel/sync-r4k.c
6699 @@ -21,8 +21,8 @@
6700 #include <asm/mipsregs.h>
6701
6702 static atomic_t count_start_flag = ATOMIC_INIT(0);
6703 -static atomic_t count_count_start = ATOMIC_INIT(0);
6704 -static atomic_t count_count_stop = ATOMIC_INIT(0);
6705 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6706 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6707 static atomic_t count_reference = ATOMIC_INIT(0);
6708
6709 #define COUNTON 100
6710 @@ -69,13 +69,13 @@ void synchronise_count_master(int cpu)
6711
6712 for (i = 0; i < NR_LOOPS; i++) {
6713 /* slaves loop on '!= 2' */
6714 - while (atomic_read(&count_count_start) != 1)
6715 + while (atomic_read_unchecked(&count_count_start) != 1)
6716 mb();
6717 - atomic_set(&count_count_stop, 0);
6718 + atomic_set_unchecked(&count_count_stop, 0);
6719 smp_wmb();
6720
6721 /* this lets the slaves write their count register */
6722 - atomic_inc(&count_count_start);
6723 + atomic_inc_unchecked(&count_count_start);
6724
6725 /*
6726 * Everyone initialises count in the last loop:
6727 @@ -86,11 +86,11 @@ void synchronise_count_master(int cpu)
6728 /*
6729 * Wait for all slaves to leave the synchronization point:
6730 */
6731 - while (atomic_read(&count_count_stop) != 1)
6732 + while (atomic_read_unchecked(&count_count_stop) != 1)
6733 mb();
6734 - atomic_set(&count_count_start, 0);
6735 + atomic_set_unchecked(&count_count_start, 0);
6736 smp_wmb();
6737 - atomic_inc(&count_count_stop);
6738 + atomic_inc_unchecked(&count_count_stop);
6739 }
6740 /* Arrange for an interrupt in a short while */
6741 write_c0_compare(read_c0_count() + COUNTON);
6742 @@ -131,8 +131,8 @@ void synchronise_count_slave(int cpu)
6743 initcount = atomic_read(&count_reference);
6744
6745 for (i = 0; i < NR_LOOPS; i++) {
6746 - atomic_inc(&count_count_start);
6747 - while (atomic_read(&count_count_start) != 2)
6748 + atomic_inc_unchecked(&count_count_start);
6749 + while (atomic_read_unchecked(&count_count_start) != 2)
6750 mb();
6751
6752 /*
6753 @@ -141,8 +141,8 @@ void synchronise_count_slave(int cpu)
6754 if (i == NR_LOOPS-1)
6755 write_c0_count(initcount);
6756
6757 - atomic_inc(&count_count_stop);
6758 - while (atomic_read(&count_count_stop) != 2)
6759 + atomic_inc_unchecked(&count_count_stop);
6760 + while (atomic_read_unchecked(&count_count_stop) != 2)
6761 mb();
6762 }
6763 /* Arrange for an interrupt in a short while */
6764 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6765 index 524841f..3eef41e 100644
6766 --- a/arch/mips/kernel/traps.c
6767 +++ b/arch/mips/kernel/traps.c
6768 @@ -684,7 +684,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6769 siginfo_t info;
6770
6771 prev_state = exception_enter();
6772 - die_if_kernel("Integer overflow", regs);
6773 + if (unlikely(!user_mode(regs))) {
6774 +
6775 +#ifdef CONFIG_PAX_REFCOUNT
6776 + if (fixup_exception(regs)) {
6777 + pax_report_refcount_overflow(regs);
6778 + exception_exit(prev_state);
6779 + return;
6780 + }
6781 +#endif
6782 +
6783 + die("Integer overflow", regs);
6784 + }
6785
6786 info.si_code = FPE_INTOVF;
6787 info.si_signo = SIGFPE;
6788 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6789 index becc42b..9e43d4b 100644
6790 --- a/arch/mips/mm/fault.c
6791 +++ b/arch/mips/mm/fault.c
6792 @@ -28,6 +28,23 @@
6793 #include <asm/highmem.h> /* For VMALLOC_END */
6794 #include <linux/kdebug.h>
6795
6796 +#ifdef CONFIG_PAX_PAGEEXEC
6797 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6798 +{
6799 + unsigned long i;
6800 +
6801 + printk(KERN_ERR "PAX: bytes at PC: ");
6802 + for (i = 0; i < 5; i++) {
6803 + unsigned int c;
6804 + if (get_user(c, (unsigned int *)pc+i))
6805 + printk(KERN_CONT "???????? ");
6806 + else
6807 + printk(KERN_CONT "%08x ", c);
6808 + }
6809 + printk("\n");
6810 +}
6811 +#endif
6812 +
6813 /*
6814 * This routine handles page faults. It determines the address,
6815 * and the problem, and then passes it off to one of the appropriate
6816 @@ -199,6 +216,14 @@ bad_area:
6817 bad_area_nosemaphore:
6818 /* User mode accesses just cause a SIGSEGV */
6819 if (user_mode(regs)) {
6820 +
6821 +#ifdef CONFIG_PAX_PAGEEXEC
6822 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6823 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6824 + do_group_exit(SIGKILL);
6825 + }
6826 +#endif
6827 +
6828 tsk->thread.cp0_badvaddr = address;
6829 tsk->thread.error_code = write;
6830 #if 0
6831 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6832 index f1baadd..8537544 100644
6833 --- a/arch/mips/mm/mmap.c
6834 +++ b/arch/mips/mm/mmap.c
6835 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6836 struct vm_area_struct *vma;
6837 unsigned long addr = addr0;
6838 int do_color_align;
6839 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6840 struct vm_unmapped_area_info info;
6841
6842 if (unlikely(len > TASK_SIZE))
6843 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6844 do_color_align = 1;
6845
6846 /* requesting a specific address */
6847 +
6848 +#ifdef CONFIG_PAX_RANDMMAP
6849 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6850 +#endif
6851 +
6852 if (addr) {
6853 if (do_color_align)
6854 addr = COLOUR_ALIGN(addr, pgoff);
6855 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6856 addr = PAGE_ALIGN(addr);
6857
6858 vma = find_vma(mm, addr);
6859 - if (TASK_SIZE - len >= addr &&
6860 - (!vma || addr + len <= vma->vm_start))
6861 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6862 return addr;
6863 }
6864
6865 info.length = len;
6866 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6867 info.align_offset = pgoff << PAGE_SHIFT;
6868 + info.threadstack_offset = offset;
6869
6870 if (dir == DOWN) {
6871 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6872 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6873 {
6874 unsigned long random_factor = 0UL;
6875
6876 +#ifdef CONFIG_PAX_RANDMMAP
6877 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6878 +#endif
6879 +
6880 if (current->flags & PF_RANDOMIZE) {
6881 random_factor = get_random_int();
6882 random_factor = random_factor << PAGE_SHIFT;
6883 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6884
6885 if (mmap_is_legacy()) {
6886 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6887 +
6888 +#ifdef CONFIG_PAX_RANDMMAP
6889 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6890 + mm->mmap_base += mm->delta_mmap;
6891 +#endif
6892 +
6893 mm->get_unmapped_area = arch_get_unmapped_area;
6894 } else {
6895 mm->mmap_base = mmap_base(random_factor);
6896 +
6897 +#ifdef CONFIG_PAX_RANDMMAP
6898 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6899 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6900 +#endif
6901 +
6902 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6903 }
6904 }
6905
6906 -static inline unsigned long brk_rnd(void)
6907 -{
6908 - unsigned long rnd = get_random_int();
6909 -
6910 - rnd = rnd << PAGE_SHIFT;
6911 - /* 8MB for 32bit, 256MB for 64bit */
6912 - if (TASK_IS_32BIT_ADDR)
6913 - rnd = rnd & 0x7ffffful;
6914 - else
6915 - rnd = rnd & 0xffffffful;
6916 -
6917 - return rnd;
6918 -}
6919 -
6920 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6921 -{
6922 - unsigned long base = mm->brk;
6923 - unsigned long ret;
6924 -
6925 - ret = PAGE_ALIGN(base + brk_rnd());
6926 -
6927 - if (ret < mm->brk)
6928 - return mm->brk;
6929 -
6930 - return ret;
6931 -}
6932 -
6933 int __virt_addr_valid(const volatile void *kaddr)
6934 {
6935 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6936 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6937 index a2358b4..7cead4f 100644
6938 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6939 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6940 @@ -187,9 +187,9 @@ void
6941 cont_nmi_dump(void)
6942 {
6943 #ifndef REAL_NMI_SIGNAL
6944 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6945 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6946
6947 - atomic_inc(&nmied_cpus);
6948 + atomic_inc_unchecked(&nmied_cpus);
6949 #endif
6950 /*
6951 * Only allow 1 cpu to proceed
6952 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6953 udelay(10000);
6954 }
6955 #else
6956 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6957 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6958 #endif
6959
6960 /*
6961 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6962 index 967d144..db12197 100644
6963 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6964 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6965 @@ -11,12 +11,14 @@
6966 #ifndef _ASM_PROC_CACHE_H
6967 #define _ASM_PROC_CACHE_H
6968
6969 +#include <linux/const.h>
6970 +
6971 /* L1 cache */
6972
6973 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6974 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6975 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6976 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6977 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6978 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6979
6980 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6981 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6982 index bcb5df2..84fabd2 100644
6983 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6984 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6985 @@ -16,13 +16,15 @@
6986 #ifndef _ASM_PROC_CACHE_H
6987 #define _ASM_PROC_CACHE_H
6988
6989 +#include <linux/const.h>
6990 +
6991 /*
6992 * L1 cache
6993 */
6994 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6995 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
6996 -#define L1_CACHE_BYTES 32 /* bytes per entry */
6997 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
6998 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6999 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
7000
7001 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
7002 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
7003 index 4ce7a01..449202a 100644
7004 --- a/arch/openrisc/include/asm/cache.h
7005 +++ b/arch/openrisc/include/asm/cache.h
7006 @@ -19,11 +19,13 @@
7007 #ifndef __ASM_OPENRISC_CACHE_H
7008 #define __ASM_OPENRISC_CACHE_H
7009
7010 +#include <linux/const.h>
7011 +
7012 /* FIXME: How can we replace these with values from the CPU...
7013 * they shouldn't be hard-coded!
7014 */
7015
7016 -#define L1_CACHE_BYTES 16
7017 #define L1_CACHE_SHIFT 4
7018 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7019
7020 #endif /* __ASM_OPENRISC_CACHE_H */
7021 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
7022 index 472886c..00e7df9 100644
7023 --- a/arch/parisc/include/asm/atomic.h
7024 +++ b/arch/parisc/include/asm/atomic.h
7025 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
7026 return dec;
7027 }
7028
7029 +#define atomic64_read_unchecked(v) atomic64_read(v)
7030 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7031 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7032 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7033 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7034 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7035 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7036 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7037 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7038 +
7039 #endif /* !CONFIG_64BIT */
7040
7041
7042 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
7043 index 47f11c7..3420df2 100644
7044 --- a/arch/parisc/include/asm/cache.h
7045 +++ b/arch/parisc/include/asm/cache.h
7046 @@ -5,6 +5,7 @@
7047 #ifndef __ARCH_PARISC_CACHE_H
7048 #define __ARCH_PARISC_CACHE_H
7049
7050 +#include <linux/const.h>
7051
7052 /*
7053 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
7054 @@ -15,13 +16,13 @@
7055 * just ruin performance.
7056 */
7057 #ifdef CONFIG_PA20
7058 -#define L1_CACHE_BYTES 64
7059 #define L1_CACHE_SHIFT 6
7060 #else
7061 -#define L1_CACHE_BYTES 32
7062 #define L1_CACHE_SHIFT 5
7063 #endif
7064
7065 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7066 +
7067 #ifndef __ASSEMBLY__
7068
7069 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7070 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
7071 index ad2b503..bdf1651 100644
7072 --- a/arch/parisc/include/asm/elf.h
7073 +++ b/arch/parisc/include/asm/elf.h
7074 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7075
7076 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7077
7078 +#ifdef CONFIG_PAX_ASLR
7079 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7080 +
7081 +#define PAX_DELTA_MMAP_LEN 16
7082 +#define PAX_DELTA_STACK_LEN 16
7083 +#endif
7084 +
7085 /* This yields a mask that user programs can use to figure out what
7086 instruction set this CPU supports. This could be done in user space,
7087 but it's not easy, and we've already done it here. */
7088 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7089 index fc987a1..6e068ef 100644
7090 --- a/arch/parisc/include/asm/pgalloc.h
7091 +++ b/arch/parisc/include/asm/pgalloc.h
7092 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7093 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7094 }
7095
7096 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7097 +{
7098 + pgd_populate(mm, pgd, pmd);
7099 +}
7100 +
7101 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7102 {
7103 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7104 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7105 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7106 #define pmd_free(mm, x) do { } while (0)
7107 #define pgd_populate(mm, pmd, pte) BUG()
7108 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7109
7110 #endif
7111
7112 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7113 index 34899b5..02dd060 100644
7114 --- a/arch/parisc/include/asm/pgtable.h
7115 +++ b/arch/parisc/include/asm/pgtable.h
7116 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7117 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7118 #define PAGE_COPY PAGE_EXECREAD
7119 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7120 +
7121 +#ifdef CONFIG_PAX_PAGEEXEC
7122 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7123 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7124 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7125 +#else
7126 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7127 +# define PAGE_COPY_NOEXEC PAGE_COPY
7128 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7129 +#endif
7130 +
7131 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7132 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7133 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7134 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7135 index e0a8235..ce2f1e1 100644
7136 --- a/arch/parisc/include/asm/uaccess.h
7137 +++ b/arch/parisc/include/asm/uaccess.h
7138 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7139 const void __user *from,
7140 unsigned long n)
7141 {
7142 - int sz = __compiletime_object_size(to);
7143 + size_t sz = __compiletime_object_size(to);
7144 int ret = -EFAULT;
7145
7146 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7147 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7148 ret = __copy_from_user(to, from, n);
7149 else
7150 copy_from_user_overflow();
7151 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7152 index 2a625fb..9908930 100644
7153 --- a/arch/parisc/kernel/module.c
7154 +++ b/arch/parisc/kernel/module.c
7155 @@ -98,16 +98,38 @@
7156
7157 /* three functions to determine where in the module core
7158 * or init pieces the location is */
7159 +static inline int in_init_rx(struct module *me, void *loc)
7160 +{
7161 + return (loc >= me->module_init_rx &&
7162 + loc < (me->module_init_rx + me->init_size_rx));
7163 +}
7164 +
7165 +static inline int in_init_rw(struct module *me, void *loc)
7166 +{
7167 + return (loc >= me->module_init_rw &&
7168 + loc < (me->module_init_rw + me->init_size_rw));
7169 +}
7170 +
7171 static inline int in_init(struct module *me, void *loc)
7172 {
7173 - return (loc >= me->module_init &&
7174 - loc <= (me->module_init + me->init_size));
7175 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7176 +}
7177 +
7178 +static inline int in_core_rx(struct module *me, void *loc)
7179 +{
7180 + return (loc >= me->module_core_rx &&
7181 + loc < (me->module_core_rx + me->core_size_rx));
7182 +}
7183 +
7184 +static inline int in_core_rw(struct module *me, void *loc)
7185 +{
7186 + return (loc >= me->module_core_rw &&
7187 + loc < (me->module_core_rw + me->core_size_rw));
7188 }
7189
7190 static inline int in_core(struct module *me, void *loc)
7191 {
7192 - return (loc >= me->module_core &&
7193 - loc <= (me->module_core + me->core_size));
7194 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7195 }
7196
7197 static inline int in_local(struct module *me, void *loc)
7198 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7199 }
7200
7201 /* align things a bit */
7202 - me->core_size = ALIGN(me->core_size, 16);
7203 - me->arch.got_offset = me->core_size;
7204 - me->core_size += gots * sizeof(struct got_entry);
7205 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7206 + me->arch.got_offset = me->core_size_rw;
7207 + me->core_size_rw += gots * sizeof(struct got_entry);
7208
7209 - me->core_size = ALIGN(me->core_size, 16);
7210 - me->arch.fdesc_offset = me->core_size;
7211 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7212 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7213 + me->arch.fdesc_offset = me->core_size_rw;
7214 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7215
7216 me->arch.got_max = gots;
7217 me->arch.fdesc_max = fdescs;
7218 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7219
7220 BUG_ON(value == 0);
7221
7222 - got = me->module_core + me->arch.got_offset;
7223 + got = me->module_core_rw + me->arch.got_offset;
7224 for (i = 0; got[i].addr; i++)
7225 if (got[i].addr == value)
7226 goto out;
7227 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7228 #ifdef CONFIG_64BIT
7229 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7230 {
7231 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7232 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7233
7234 if (!value) {
7235 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7236 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7237
7238 /* Create new one */
7239 fdesc->addr = value;
7240 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7241 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7242 return (Elf_Addr)fdesc;
7243 }
7244 #endif /* CONFIG_64BIT */
7245 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7246
7247 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7248 end = table + sechdrs[me->arch.unwind_section].sh_size;
7249 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7250 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7251
7252 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7253 me->arch.unwind_section, table, end, gp);
7254 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7255 index 0d3a9d4..44975d0 100644
7256 --- a/arch/parisc/kernel/sys_parisc.c
7257 +++ b/arch/parisc/kernel/sys_parisc.c
7258 @@ -33,9 +33,11 @@
7259 #include <linux/utsname.h>
7260 #include <linux/personality.h>
7261
7262 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7263 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7264 + unsigned long flags)
7265 {
7266 struct vm_unmapped_area_info info;
7267 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7268
7269 info.flags = 0;
7270 info.length = len;
7271 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7272 info.high_limit = TASK_SIZE;
7273 info.align_mask = 0;
7274 info.align_offset = 0;
7275 + info.threadstack_offset = offset;
7276 return vm_unmapped_area(&info);
7277 }
7278
7279 @@ -69,15 +72,17 @@ static unsigned long shared_align_offset(struct file *filp, unsigned long pgoff)
7280 }
7281
7282 static unsigned long get_shared_area(struct file *filp, unsigned long addr,
7283 - unsigned long len, unsigned long pgoff)
7284 + unsigned long len, unsigned long pgoff, unsigned long flags)
7285 {
7286 struct vm_unmapped_area_info info;
7287 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7288
7289 info.flags = 0;
7290 info.length = len;
7291 info.low_limit = PAGE_ALIGN(addr);
7292 info.high_limit = TASK_SIZE;
7293 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7294 + info.threadstack_offset = offset;
7295 info.align_offset = shared_align_offset(filp, pgoff);
7296 return vm_unmapped_area(&info);
7297 }
7298 @@ -93,13 +98,20 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7299 return -EINVAL;
7300 return addr;
7301 }
7302 - if (!addr)
7303 + if (!addr) {
7304 addr = TASK_UNMAPPED_BASE;
7305
7306 +#ifdef CONFIG_PAX_RANDMMAP
7307 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7308 + addr += current->mm->delta_mmap;
7309 +#endif
7310 +
7311 + }
7312 +
7313 if (filp || (flags & MAP_SHARED))
7314 - addr = get_shared_area(filp, addr, len, pgoff);
7315 + addr = get_shared_area(filp, addr, len, pgoff, flags);
7316 else
7317 - addr = get_unshared_area(addr, len);
7318 + addr = get_unshared_area(addr, len, flags);
7319
7320 return addr;
7321 }
7322 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7323 index 1cd1d0c..44ec918 100644
7324 --- a/arch/parisc/kernel/traps.c
7325 +++ b/arch/parisc/kernel/traps.c
7326 @@ -722,9 +722,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7327
7328 down_read(&current->mm->mmap_sem);
7329 vma = find_vma(current->mm,regs->iaoq[0]);
7330 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7331 - && (vma->vm_flags & VM_EXEC)) {
7332 -
7333 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7334 fault_address = regs->iaoq[0];
7335 fault_space = regs->iasq[0];
7336
7337 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7338 index 0293588..3b229aa 100644
7339 --- a/arch/parisc/mm/fault.c
7340 +++ b/arch/parisc/mm/fault.c
7341 @@ -15,6 +15,7 @@
7342 #include <linux/sched.h>
7343 #include <linux/interrupt.h>
7344 #include <linux/module.h>
7345 +#include <linux/unistd.h>
7346
7347 #include <asm/uaccess.h>
7348 #include <asm/traps.h>
7349 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7350 static unsigned long
7351 parisc_acctyp(unsigned long code, unsigned int inst)
7352 {
7353 - if (code == 6 || code == 16)
7354 + if (code == 6 || code == 7 || code == 16)
7355 return VM_EXEC;
7356
7357 switch (inst & 0xf0000000) {
7358 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7359 }
7360 #endif
7361
7362 +#ifdef CONFIG_PAX_PAGEEXEC
7363 +/*
7364 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7365 + *
7366 + * returns 1 when task should be killed
7367 + * 2 when rt_sigreturn trampoline was detected
7368 + * 3 when unpatched PLT trampoline was detected
7369 + */
7370 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7371 +{
7372 +
7373 +#ifdef CONFIG_PAX_EMUPLT
7374 + int err;
7375 +
7376 + do { /* PaX: unpatched PLT emulation */
7377 + unsigned int bl, depwi;
7378 +
7379 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7380 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7381 +
7382 + if (err)
7383 + break;
7384 +
7385 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7386 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7387 +
7388 + err = get_user(ldw, (unsigned int *)addr);
7389 + err |= get_user(bv, (unsigned int *)(addr+4));
7390 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7391 +
7392 + if (err)
7393 + break;
7394 +
7395 + if (ldw == 0x0E801096U &&
7396 + bv == 0xEAC0C000U &&
7397 + ldw2 == 0x0E881095U)
7398 + {
7399 + unsigned int resolver, map;
7400 +
7401 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7402 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7403 + if (err)
7404 + break;
7405 +
7406 + regs->gr[20] = instruction_pointer(regs)+8;
7407 + regs->gr[21] = map;
7408 + regs->gr[22] = resolver;
7409 + regs->iaoq[0] = resolver | 3UL;
7410 + regs->iaoq[1] = regs->iaoq[0] + 4;
7411 + return 3;
7412 + }
7413 + }
7414 + } while (0);
7415 +#endif
7416 +
7417 +#ifdef CONFIG_PAX_EMUTRAMP
7418 +
7419 +#ifndef CONFIG_PAX_EMUSIGRT
7420 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7421 + return 1;
7422 +#endif
7423 +
7424 + do { /* PaX: rt_sigreturn emulation */
7425 + unsigned int ldi1, ldi2, bel, nop;
7426 +
7427 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7428 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7429 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7430 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7431 +
7432 + if (err)
7433 + break;
7434 +
7435 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7436 + ldi2 == 0x3414015AU &&
7437 + bel == 0xE4008200U &&
7438 + nop == 0x08000240U)
7439 + {
7440 + regs->gr[25] = (ldi1 & 2) >> 1;
7441 + regs->gr[20] = __NR_rt_sigreturn;
7442 + regs->gr[31] = regs->iaoq[1] + 16;
7443 + regs->sr[0] = regs->iasq[1];
7444 + regs->iaoq[0] = 0x100UL;
7445 + regs->iaoq[1] = regs->iaoq[0] + 4;
7446 + regs->iasq[0] = regs->sr[2];
7447 + regs->iasq[1] = regs->sr[2];
7448 + return 2;
7449 + }
7450 + } while (0);
7451 +#endif
7452 +
7453 + return 1;
7454 +}
7455 +
7456 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7457 +{
7458 + unsigned long i;
7459 +
7460 + printk(KERN_ERR "PAX: bytes at PC: ");
7461 + for (i = 0; i < 5; i++) {
7462 + unsigned int c;
7463 + if (get_user(c, (unsigned int *)pc+i))
7464 + printk(KERN_CONT "???????? ");
7465 + else
7466 + printk(KERN_CONT "%08x ", c);
7467 + }
7468 + printk("\n");
7469 +}
7470 +#endif
7471 +
7472 int fixup_exception(struct pt_regs *regs)
7473 {
7474 const struct exception_table_entry *fix;
7475 @@ -204,8 +315,33 @@ retry:
7476
7477 good_area:
7478
7479 - if ((vma->vm_flags & acc_type) != acc_type)
7480 + if ((vma->vm_flags & acc_type) != acc_type) {
7481 +
7482 +#ifdef CONFIG_PAX_PAGEEXEC
7483 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7484 + (address & ~3UL) == instruction_pointer(regs))
7485 + {
7486 + up_read(&mm->mmap_sem);
7487 + switch (pax_handle_fetch_fault(regs)) {
7488 +
7489 +#ifdef CONFIG_PAX_EMUPLT
7490 + case 3:
7491 + return;
7492 +#endif
7493 +
7494 +#ifdef CONFIG_PAX_EMUTRAMP
7495 + case 2:
7496 + return;
7497 +#endif
7498 +
7499 + }
7500 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7501 + do_group_exit(SIGKILL);
7502 + }
7503 +#endif
7504 +
7505 goto bad_area;
7506 + }
7507
7508 /*
7509 * If for any reason at all we couldn't handle the fault, make
7510 diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
7511 index 38f3b7e..7e485c0 100644
7512 --- a/arch/powerpc/Kconfig
7513 +++ b/arch/powerpc/Kconfig
7514 @@ -378,6 +378,7 @@ config ARCH_ENABLE_MEMORY_HOTREMOVE
7515 config KEXEC
7516 bool "kexec system call"
7517 depends on (PPC_BOOK3S || FSL_BOOKE || (44x && !SMP))
7518 + depends on !GRKERNSEC_KMEM
7519 help
7520 kexec is a system call that implements the ability to shutdown your
7521 current kernel, and to start another kernel. It is like a reboot
7522 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7523 index e3b1d41..8e81edf 100644
7524 --- a/arch/powerpc/include/asm/atomic.h
7525 +++ b/arch/powerpc/include/asm/atomic.h
7526 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7527 return t1;
7528 }
7529
7530 +#define atomic64_read_unchecked(v) atomic64_read(v)
7531 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7532 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7533 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7534 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7535 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7536 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7537 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7538 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7539 +
7540 #endif /* __powerpc64__ */
7541
7542 #endif /* __KERNEL__ */
7543 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7544 index 9e495c9..b6878e5 100644
7545 --- a/arch/powerpc/include/asm/cache.h
7546 +++ b/arch/powerpc/include/asm/cache.h
7547 @@ -3,6 +3,7 @@
7548
7549 #ifdef __KERNEL__
7550
7551 +#include <linux/const.h>
7552
7553 /* bytes per L1 cache line */
7554 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7555 @@ -22,7 +23,7 @@
7556 #define L1_CACHE_SHIFT 7
7557 #endif
7558
7559 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7560 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7561
7562 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7563
7564 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7565 index cc0655a..13eac2e 100644
7566 --- a/arch/powerpc/include/asm/elf.h
7567 +++ b/arch/powerpc/include/asm/elf.h
7568 @@ -28,8 +28,19 @@
7569 the loader. We need to make sure that it is out of the way of the program
7570 that it will "exec", and that there is sufficient room for the brk. */
7571
7572 -extern unsigned long randomize_et_dyn(unsigned long base);
7573 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7574 +#define ELF_ET_DYN_BASE (0x20000000)
7575 +
7576 +#ifdef CONFIG_PAX_ASLR
7577 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7578 +
7579 +#ifdef __powerpc64__
7580 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7581 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7582 +#else
7583 +#define PAX_DELTA_MMAP_LEN 15
7584 +#define PAX_DELTA_STACK_LEN 15
7585 +#endif
7586 +#endif
7587
7588 /*
7589 * Our registers are always unsigned longs, whether we're a 32 bit
7590 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7591 (0x7ff >> (PAGE_SHIFT - 12)) : \
7592 (0x3ffff >> (PAGE_SHIFT - 12)))
7593
7594 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7595 -#define arch_randomize_brk arch_randomize_brk
7596 -
7597 -
7598 #ifdef CONFIG_SPU_BASE
7599 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7600 #define NT_SPU 1
7601 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7602 index 8196e9c..d83a9f3 100644
7603 --- a/arch/powerpc/include/asm/exec.h
7604 +++ b/arch/powerpc/include/asm/exec.h
7605 @@ -4,6 +4,6 @@
7606 #ifndef _ASM_POWERPC_EXEC_H
7607 #define _ASM_POWERPC_EXEC_H
7608
7609 -extern unsigned long arch_align_stack(unsigned long sp);
7610 +#define arch_align_stack(x) ((x) & ~0xfUL)
7611
7612 #endif /* _ASM_POWERPC_EXEC_H */
7613 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7614 index 5acabbd..7ea14fa 100644
7615 --- a/arch/powerpc/include/asm/kmap_types.h
7616 +++ b/arch/powerpc/include/asm/kmap_types.h
7617 @@ -10,7 +10,7 @@
7618 * 2 of the License, or (at your option) any later version.
7619 */
7620
7621 -#define KM_TYPE_NR 16
7622 +#define KM_TYPE_NR 17
7623
7624 #endif /* __KERNEL__ */
7625 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7626 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7627 index 8565c25..2865190 100644
7628 --- a/arch/powerpc/include/asm/mman.h
7629 +++ b/arch/powerpc/include/asm/mman.h
7630 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7631 }
7632 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7633
7634 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7635 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7636 {
7637 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7638 }
7639 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7640 index b9f4262..dcf04f7 100644
7641 --- a/arch/powerpc/include/asm/page.h
7642 +++ b/arch/powerpc/include/asm/page.h
7643 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7644 * and needs to be executable. This means the whole heap ends
7645 * up being executable.
7646 */
7647 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7648 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7649 +#define VM_DATA_DEFAULT_FLAGS32 \
7650 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7651 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7652
7653 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7654 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7655 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7656 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7657 #endif
7658
7659 +#define ktla_ktva(addr) (addr)
7660 +#define ktva_ktla(addr) (addr)
7661 +
7662 #ifndef CONFIG_PPC_BOOK3S_64
7663 /*
7664 * Use the top bit of the higher-level page table entries to indicate whether
7665 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7666 index 88693ce..ac6f9ab 100644
7667 --- a/arch/powerpc/include/asm/page_64.h
7668 +++ b/arch/powerpc/include/asm/page_64.h
7669 @@ -153,15 +153,18 @@ do { \
7670 * stack by default, so in the absence of a PT_GNU_STACK program header
7671 * we turn execute permission off.
7672 */
7673 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7674 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7675 +#define VM_STACK_DEFAULT_FLAGS32 \
7676 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7677 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7678
7679 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7680 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7681
7682 +#ifndef CONFIG_PAX_PAGEEXEC
7683 #define VM_STACK_DEFAULT_FLAGS \
7684 (is_32bit_task() ? \
7685 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7686 +#endif
7687
7688 #include <asm-generic/getorder.h>
7689
7690 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7691 index 256d6f8..b0166a7 100644
7692 --- a/arch/powerpc/include/asm/pgalloc-64.h
7693 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7694 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7695 #ifndef CONFIG_PPC_64K_PAGES
7696
7697 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7698 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7699
7700 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7701 {
7702 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7703 pud_set(pud, (unsigned long)pmd);
7704 }
7705
7706 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7707 +{
7708 + pud_populate(mm, pud, pmd);
7709 +}
7710 +
7711 #define pmd_populate(mm, pmd, pte_page) \
7712 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7713 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7714 @@ -169,6 +175,7 @@ extern void __tlb_remove_table(void *_table);
7715 #endif
7716
7717 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7718 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7719
7720 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7721 pte_t *pte)
7722 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7723 index 7d6eacf..14c0240 100644
7724 --- a/arch/powerpc/include/asm/pgtable.h
7725 +++ b/arch/powerpc/include/asm/pgtable.h
7726 @@ -2,6 +2,7 @@
7727 #define _ASM_POWERPC_PGTABLE_H
7728 #ifdef __KERNEL__
7729
7730 +#include <linux/const.h>
7731 #ifndef __ASSEMBLY__
7732 #include <asm/processor.h> /* For TASK_SIZE */
7733 #include <asm/mmu.h>
7734 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7735 index 4aad413..85d86bf 100644
7736 --- a/arch/powerpc/include/asm/pte-hash32.h
7737 +++ b/arch/powerpc/include/asm/pte-hash32.h
7738 @@ -21,6 +21,7 @@
7739 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7740 #define _PAGE_USER 0x004 /* usermode access allowed */
7741 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7742 +#define _PAGE_EXEC _PAGE_GUARDED
7743 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7744 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7745 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7746 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7747 index 10d1ef0..8f83abc 100644
7748 --- a/arch/powerpc/include/asm/reg.h
7749 +++ b/arch/powerpc/include/asm/reg.h
7750 @@ -234,6 +234,7 @@
7751 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7752 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7753 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7754 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7755 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7756 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7757 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7758 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7759 index 98da78e..dc68271 100644
7760 --- a/arch/powerpc/include/asm/smp.h
7761 +++ b/arch/powerpc/include/asm/smp.h
7762 @@ -50,7 +50,7 @@ struct smp_ops_t {
7763 int (*cpu_disable)(void);
7764 void (*cpu_die)(unsigned int nr);
7765 int (*cpu_bootable)(unsigned int nr);
7766 -};
7767 +} __no_const;
7768
7769 extern void smp_send_debugger_break(void);
7770 extern void start_secondary_resume(void);
7771 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7772 index ba7b197..d292e26 100644
7773 --- a/arch/powerpc/include/asm/thread_info.h
7774 +++ b/arch/powerpc/include/asm/thread_info.h
7775 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7776 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7777 TIF_NEED_RESCHED */
7778 #define TIF_32BIT 4 /* 32 bit binary */
7779 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7780 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7781 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7782 #define TIF_SINGLESTEP 8 /* singlestepping active */
7783 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7784 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7785 for stack store? */
7786 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7787 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7788 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7789 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7790
7791 /* as above, but as bit values */
7792 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7793 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7794 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7795 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7796 #define _TIF_NOHZ (1<<TIF_NOHZ)
7797 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7798 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7799 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7800 - _TIF_NOHZ)
7801 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7802
7803 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7804 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7805 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7806 index 9485b43..4718d50 100644
7807 --- a/arch/powerpc/include/asm/uaccess.h
7808 +++ b/arch/powerpc/include/asm/uaccess.h
7809 @@ -318,52 +318,6 @@ do { \
7810 extern unsigned long __copy_tofrom_user(void __user *to,
7811 const void __user *from, unsigned long size);
7812
7813 -#ifndef __powerpc64__
7814 -
7815 -static inline unsigned long copy_from_user(void *to,
7816 - const void __user *from, unsigned long n)
7817 -{
7818 - unsigned long over;
7819 -
7820 - if (access_ok(VERIFY_READ, from, n))
7821 - return __copy_tofrom_user((__force void __user *)to, from, n);
7822 - if ((unsigned long)from < TASK_SIZE) {
7823 - over = (unsigned long)from + n - TASK_SIZE;
7824 - return __copy_tofrom_user((__force void __user *)to, from,
7825 - n - over) + over;
7826 - }
7827 - return n;
7828 -}
7829 -
7830 -static inline unsigned long copy_to_user(void __user *to,
7831 - const void *from, unsigned long n)
7832 -{
7833 - unsigned long over;
7834 -
7835 - if (access_ok(VERIFY_WRITE, to, n))
7836 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7837 - if ((unsigned long)to < TASK_SIZE) {
7838 - over = (unsigned long)to + n - TASK_SIZE;
7839 - return __copy_tofrom_user(to, (__force void __user *)from,
7840 - n - over) + over;
7841 - }
7842 - return n;
7843 -}
7844 -
7845 -#else /* __powerpc64__ */
7846 -
7847 -#define __copy_in_user(to, from, size) \
7848 - __copy_tofrom_user((to), (from), (size))
7849 -
7850 -extern unsigned long copy_from_user(void *to, const void __user *from,
7851 - unsigned long n);
7852 -extern unsigned long copy_to_user(void __user *to, const void *from,
7853 - unsigned long n);
7854 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7855 - unsigned long n);
7856 -
7857 -#endif /* __powerpc64__ */
7858 -
7859 static inline unsigned long __copy_from_user_inatomic(void *to,
7860 const void __user *from, unsigned long n)
7861 {
7862 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7863 if (ret == 0)
7864 return 0;
7865 }
7866 +
7867 + if (!__builtin_constant_p(n))
7868 + check_object_size(to, n, false);
7869 +
7870 return __copy_tofrom_user((__force void __user *)to, from, n);
7871 }
7872
7873 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7874 if (ret == 0)
7875 return 0;
7876 }
7877 +
7878 + if (!__builtin_constant_p(n))
7879 + check_object_size(from, n, true);
7880 +
7881 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7882 }
7883
7884 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7885 return __copy_to_user_inatomic(to, from, size);
7886 }
7887
7888 +#ifndef __powerpc64__
7889 +
7890 +static inline unsigned long __must_check copy_from_user(void *to,
7891 + const void __user *from, unsigned long n)
7892 +{
7893 + unsigned long over;
7894 +
7895 + if ((long)n < 0)
7896 + return n;
7897 +
7898 + if (access_ok(VERIFY_READ, from, n)) {
7899 + if (!__builtin_constant_p(n))
7900 + check_object_size(to, n, false);
7901 + return __copy_tofrom_user((__force void __user *)to, from, n);
7902 + }
7903 + if ((unsigned long)from < TASK_SIZE) {
7904 + over = (unsigned long)from + n - TASK_SIZE;
7905 + if (!__builtin_constant_p(n - over))
7906 + check_object_size(to, n - over, false);
7907 + return __copy_tofrom_user((__force void __user *)to, from,
7908 + n - over) + over;
7909 + }
7910 + return n;
7911 +}
7912 +
7913 +static inline unsigned long __must_check copy_to_user(void __user *to,
7914 + const void *from, unsigned long n)
7915 +{
7916 + unsigned long over;
7917 +
7918 + if ((long)n < 0)
7919 + return n;
7920 +
7921 + if (access_ok(VERIFY_WRITE, to, n)) {
7922 + if (!__builtin_constant_p(n))
7923 + check_object_size(from, n, true);
7924 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7925 + }
7926 + if ((unsigned long)to < TASK_SIZE) {
7927 + over = (unsigned long)to + n - TASK_SIZE;
7928 + if (!__builtin_constant_p(n))
7929 + check_object_size(from, n - over, true);
7930 + return __copy_tofrom_user(to, (__force void __user *)from,
7931 + n - over) + over;
7932 + }
7933 + return n;
7934 +}
7935 +
7936 +#else /* __powerpc64__ */
7937 +
7938 +#define __copy_in_user(to, from, size) \
7939 + __copy_tofrom_user((to), (from), (size))
7940 +
7941 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7942 +{
7943 + if ((long)n < 0 || n > INT_MAX)
7944 + return n;
7945 +
7946 + if (!__builtin_constant_p(n))
7947 + check_object_size(to, n, false);
7948 +
7949 + if (likely(access_ok(VERIFY_READ, from, n)))
7950 + n = __copy_from_user(to, from, n);
7951 + else
7952 + memset(to, 0, n);
7953 + return n;
7954 +}
7955 +
7956 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7957 +{
7958 + if ((long)n < 0 || n > INT_MAX)
7959 + return n;
7960 +
7961 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7962 + if (!__builtin_constant_p(n))
7963 + check_object_size(from, n, true);
7964 + n = __copy_to_user(to, from, n);
7965 + }
7966 + return n;
7967 +}
7968 +
7969 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7970 + unsigned long n);
7971 +
7972 +#endif /* __powerpc64__ */
7973 +
7974 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7975
7976 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7977 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7978 index 2d06704..1616f1b 100644
7979 --- a/arch/powerpc/kernel/exceptions-64e.S
7980 +++ b/arch/powerpc/kernel/exceptions-64e.S
7981 @@ -757,6 +757,7 @@ storage_fault_common:
7982 std r14,_DAR(r1)
7983 std r15,_DSISR(r1)
7984 addi r3,r1,STACK_FRAME_OVERHEAD
7985 + bl .save_nvgprs
7986 mr r4,r14
7987 mr r5,r15
7988 ld r14,PACA_EXGEN+EX_R14(r13)
7989 @@ -765,8 +766,7 @@ storage_fault_common:
7990 cmpdi r3,0
7991 bne- 1f
7992 b .ret_from_except_lite
7993 -1: bl .save_nvgprs
7994 - mr r5,r3
7995 +1: mr r5,r3
7996 addi r3,r1,STACK_FRAME_OVERHEAD
7997 ld r4,_DAR(r1)
7998 bl .bad_page_fault
7999 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
8000 index 3a9ed6a..b534681 100644
8001 --- a/arch/powerpc/kernel/exceptions-64s.S
8002 +++ b/arch/powerpc/kernel/exceptions-64s.S
8003 @@ -1364,10 +1364,10 @@ handle_page_fault:
8004 11: ld r4,_DAR(r1)
8005 ld r5,_DSISR(r1)
8006 addi r3,r1,STACK_FRAME_OVERHEAD
8007 + bl .save_nvgprs
8008 bl .do_page_fault
8009 cmpdi r3,0
8010 beq+ 12f
8011 - bl .save_nvgprs
8012 mr r5,r3
8013 addi r3,r1,STACK_FRAME_OVERHEAD
8014 lwz r4,_DAR(r1)
8015 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
8016 index 2e3200c..7118986 100644
8017 --- a/arch/powerpc/kernel/module_32.c
8018 +++ b/arch/powerpc/kernel/module_32.c
8019 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
8020 me->arch.core_plt_section = i;
8021 }
8022 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
8023 - printk("Module doesn't contain .plt or .init.plt sections.\n");
8024 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
8025 return -ENOEXEC;
8026 }
8027
8028 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
8029
8030 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
8031 /* Init, or core PLT? */
8032 - if (location >= mod->module_core
8033 - && location < mod->module_core + mod->core_size)
8034 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
8035 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
8036 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
8037 - else
8038 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
8039 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
8040 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
8041 + else {
8042 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
8043 + return ~0UL;
8044 + }
8045
8046 /* Find this entry, or if that fails, the next avail. entry */
8047 while (entry->jump[0]) {
8048 @@ -300,7 +305,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
8049 }
8050 #ifdef CONFIG_DYNAMIC_FTRACE
8051 module->arch.tramp =
8052 - do_plt_call(module->module_core,
8053 + do_plt_call(module->module_core_rx,
8054 (unsigned long)ftrace_caller,
8055 sechdrs, module);
8056 #endif
8057 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
8058 index 96d2fdf..f6d10c8 100644
8059 --- a/arch/powerpc/kernel/process.c
8060 +++ b/arch/powerpc/kernel/process.c
8061 @@ -886,8 +886,8 @@ void show_regs(struct pt_regs * regs)
8062 * Lookup NIP late so we have the best change of getting the
8063 * above info out without failing
8064 */
8065 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
8066 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
8067 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
8068 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
8069 #endif
8070 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
8071 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
8072 @@ -1352,10 +1352,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8073 newsp = stack[0];
8074 ip = stack[STACK_FRAME_LR_SAVE];
8075 if (!firstframe || ip != lr) {
8076 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
8077 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
8078 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8079 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
8080 - printk(" (%pS)",
8081 + printk(" (%pA)",
8082 (void *)current->ret_stack[curr_frame].ret);
8083 curr_frame--;
8084 }
8085 @@ -1375,7 +1375,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8086 struct pt_regs *regs = (struct pt_regs *)
8087 (sp + STACK_FRAME_OVERHEAD);
8088 lr = regs->link;
8089 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8090 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8091 regs->trap, (void *)regs->nip, (void *)lr);
8092 firstframe = 1;
8093 }
8094 @@ -1411,58 +1411,3 @@ void notrace __ppc64_runlatch_off(void)
8095 mtspr(SPRN_CTRLT, ctrl);
8096 }
8097 #endif /* CONFIG_PPC64 */
8098 -
8099 -unsigned long arch_align_stack(unsigned long sp)
8100 -{
8101 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8102 - sp -= get_random_int() & ~PAGE_MASK;
8103 - return sp & ~0xf;
8104 -}
8105 -
8106 -static inline unsigned long brk_rnd(void)
8107 -{
8108 - unsigned long rnd = 0;
8109 -
8110 - /* 8MB for 32bit, 1GB for 64bit */
8111 - if (is_32bit_task())
8112 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8113 - else
8114 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8115 -
8116 - return rnd << PAGE_SHIFT;
8117 -}
8118 -
8119 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8120 -{
8121 - unsigned long base = mm->brk;
8122 - unsigned long ret;
8123 -
8124 -#ifdef CONFIG_PPC_STD_MMU_64
8125 - /*
8126 - * If we are using 1TB segments and we are allowed to randomise
8127 - * the heap, we can put it above 1TB so it is backed by a 1TB
8128 - * segment. Otherwise the heap will be in the bottom 1TB
8129 - * which always uses 256MB segments and this may result in a
8130 - * performance penalty.
8131 - */
8132 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8133 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8134 -#endif
8135 -
8136 - ret = PAGE_ALIGN(base + brk_rnd());
8137 -
8138 - if (ret < mm->brk)
8139 - return mm->brk;
8140 -
8141 - return ret;
8142 -}
8143 -
8144 -unsigned long randomize_et_dyn(unsigned long base)
8145 -{
8146 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8147 -
8148 - if (ret < base)
8149 - return base;
8150 -
8151 - return ret;
8152 -}
8153 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8154 index 9a0d24c..e7fbedf 100644
8155 --- a/arch/powerpc/kernel/ptrace.c
8156 +++ b/arch/powerpc/kernel/ptrace.c
8157 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8158 return ret;
8159 }
8160
8161 +#ifdef CONFIG_GRKERNSEC_SETXID
8162 +extern void gr_delayed_cred_worker(void);
8163 +#endif
8164 +
8165 /*
8166 * We must return the syscall number to actually look up in the table.
8167 * This can be -1L to skip running any syscall at all.
8168 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8169
8170 secure_computing_strict(regs->gpr[0]);
8171
8172 +#ifdef CONFIG_GRKERNSEC_SETXID
8173 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8174 + gr_delayed_cred_worker();
8175 +#endif
8176 +
8177 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8178 tracehook_report_syscall_entry(regs))
8179 /*
8180 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8181 {
8182 int step;
8183
8184 +#ifdef CONFIG_GRKERNSEC_SETXID
8185 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8186 + gr_delayed_cred_worker();
8187 +#endif
8188 +
8189 audit_syscall_exit(regs);
8190
8191 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8192 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8193 index fea2dba..a779f6b 100644
8194 --- a/arch/powerpc/kernel/signal_32.c
8195 +++ b/arch/powerpc/kernel/signal_32.c
8196 @@ -1002,7 +1002,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8197 /* Save user registers on the stack */
8198 frame = &rt_sf->uc.uc_mcontext;
8199 addr = frame;
8200 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8201 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8202 sigret = 0;
8203 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8204 } else {
8205 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8206 index 1e7ba88..17afb1b 100644
8207 --- a/arch/powerpc/kernel/signal_64.c
8208 +++ b/arch/powerpc/kernel/signal_64.c
8209 @@ -763,7 +763,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8210 #endif
8211
8212 /* Set up to return from userspace. */
8213 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8214 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8215 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8216 } else {
8217 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8218 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8219 index f783c93..619baf1 100644
8220 --- a/arch/powerpc/kernel/traps.c
8221 +++ b/arch/powerpc/kernel/traps.c
8222 @@ -142,6 +142,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8223 return flags;
8224 }
8225
8226 +extern void gr_handle_kernel_exploit(void);
8227 +
8228 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8229 int signr)
8230 {
8231 @@ -191,6 +193,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8232 panic("Fatal exception in interrupt");
8233 if (panic_on_oops)
8234 panic("Fatal exception");
8235 +
8236 + gr_handle_kernel_exploit();
8237 +
8238 do_exit(signr);
8239 }
8240
8241 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8242 index 1d9c926..25f4741 100644
8243 --- a/arch/powerpc/kernel/vdso.c
8244 +++ b/arch/powerpc/kernel/vdso.c
8245 @@ -34,6 +34,7 @@
8246 #include <asm/firmware.h>
8247 #include <asm/vdso.h>
8248 #include <asm/vdso_datapage.h>
8249 +#include <asm/mman.h>
8250
8251 #include "setup.h"
8252
8253 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8254 vdso_base = VDSO32_MBASE;
8255 #endif
8256
8257 - current->mm->context.vdso_base = 0;
8258 + current->mm->context.vdso_base = ~0UL;
8259
8260 /* vDSO has a problem and was disabled, just don't "enable" it for the
8261 * process
8262 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8263 vdso_base = get_unmapped_area(NULL, vdso_base,
8264 (vdso_pages << PAGE_SHIFT) +
8265 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8266 - 0, 0);
8267 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8268 if (IS_ERR_VALUE(vdso_base)) {
8269 rc = vdso_base;
8270 goto fail_mmapsem;
8271 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8272 index 5eea6f3..5d10396 100644
8273 --- a/arch/powerpc/lib/usercopy_64.c
8274 +++ b/arch/powerpc/lib/usercopy_64.c
8275 @@ -9,22 +9,6 @@
8276 #include <linux/module.h>
8277 #include <asm/uaccess.h>
8278
8279 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8280 -{
8281 - if (likely(access_ok(VERIFY_READ, from, n)))
8282 - n = __copy_from_user(to, from, n);
8283 - else
8284 - memset(to, 0, n);
8285 - return n;
8286 -}
8287 -
8288 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8289 -{
8290 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8291 - n = __copy_to_user(to, from, n);
8292 - return n;
8293 -}
8294 -
8295 unsigned long copy_in_user(void __user *to, const void __user *from,
8296 unsigned long n)
8297 {
8298 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8299 return n;
8300 }
8301
8302 -EXPORT_SYMBOL(copy_from_user);
8303 -EXPORT_SYMBOL(copy_to_user);
8304 EXPORT_SYMBOL(copy_in_user);
8305
8306 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8307 index 51ab9e7..7d3c78b 100644
8308 --- a/arch/powerpc/mm/fault.c
8309 +++ b/arch/powerpc/mm/fault.c
8310 @@ -33,6 +33,10 @@
8311 #include <linux/magic.h>
8312 #include <linux/ratelimit.h>
8313 #include <linux/context_tracking.h>
8314 +#include <linux/slab.h>
8315 +#include <linux/pagemap.h>
8316 +#include <linux/compiler.h>
8317 +#include <linux/unistd.h>
8318
8319 #include <asm/firmware.h>
8320 #include <asm/page.h>
8321 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8322 }
8323 #endif
8324
8325 +#ifdef CONFIG_PAX_PAGEEXEC
8326 +/*
8327 + * PaX: decide what to do with offenders (regs->nip = fault address)
8328 + *
8329 + * returns 1 when task should be killed
8330 + */
8331 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8332 +{
8333 + return 1;
8334 +}
8335 +
8336 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8337 +{
8338 + unsigned long i;
8339 +
8340 + printk(KERN_ERR "PAX: bytes at PC: ");
8341 + for (i = 0; i < 5; i++) {
8342 + unsigned int c;
8343 + if (get_user(c, (unsigned int __user *)pc+i))
8344 + printk(KERN_CONT "???????? ");
8345 + else
8346 + printk(KERN_CONT "%08x ", c);
8347 + }
8348 + printk("\n");
8349 +}
8350 +#endif
8351 +
8352 /*
8353 * Check whether the instruction at regs->nip is a store using
8354 * an update addressing form which will update r1.
8355 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8356 * indicate errors in DSISR but can validly be set in SRR1.
8357 */
8358 if (trap == 0x400)
8359 - error_code &= 0x48200000;
8360 + error_code &= 0x58200000;
8361 else
8362 is_write = error_code & DSISR_ISSTORE;
8363 #else
8364 @@ -378,7 +409,7 @@ good_area:
8365 * "undefined". Of those that can be set, this is the only
8366 * one which seems bad.
8367 */
8368 - if (error_code & 0x10000000)
8369 + if (error_code & DSISR_GUARDED)
8370 /* Guarded storage error. */
8371 goto bad_area;
8372 #endif /* CONFIG_8xx */
8373 @@ -393,7 +424,7 @@ good_area:
8374 * processors use the same I/D cache coherency mechanism
8375 * as embedded.
8376 */
8377 - if (error_code & DSISR_PROTFAULT)
8378 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8379 goto bad_area;
8380 #endif /* CONFIG_PPC_STD_MMU */
8381
8382 @@ -483,6 +514,23 @@ bad_area:
8383 bad_area_nosemaphore:
8384 /* User mode accesses cause a SIGSEGV */
8385 if (user_mode(regs)) {
8386 +
8387 +#ifdef CONFIG_PAX_PAGEEXEC
8388 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8389 +#ifdef CONFIG_PPC_STD_MMU
8390 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8391 +#else
8392 + if (is_exec && regs->nip == address) {
8393 +#endif
8394 + switch (pax_handle_fetch_fault(regs)) {
8395 + }
8396 +
8397 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8398 + do_group_exit(SIGKILL);
8399 + }
8400 + }
8401 +#endif
8402 +
8403 _exception(SIGSEGV, regs, code, address);
8404 goto bail;
8405 }
8406 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8407 index cb8bdbe..d770680 100644
8408 --- a/arch/powerpc/mm/mmap.c
8409 +++ b/arch/powerpc/mm/mmap.c
8410 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8411 {
8412 unsigned long rnd = 0;
8413
8414 +#ifdef CONFIG_PAX_RANDMMAP
8415 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8416 +#endif
8417 +
8418 if (current->flags & PF_RANDOMIZE) {
8419 /* 8MB for 32bit, 1GB for 64bit */
8420 if (is_32bit_task())
8421 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8422 */
8423 if (mmap_is_legacy()) {
8424 mm->mmap_base = TASK_UNMAPPED_BASE;
8425 +
8426 +#ifdef CONFIG_PAX_RANDMMAP
8427 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8428 + mm->mmap_base += mm->delta_mmap;
8429 +#endif
8430 +
8431 mm->get_unmapped_area = arch_get_unmapped_area;
8432 } else {
8433 mm->mmap_base = mmap_base();
8434 +
8435 +#ifdef CONFIG_PAX_RANDMMAP
8436 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8437 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8438 +#endif
8439 +
8440 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8441 }
8442 }
8443 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8444 index 7ce9cf3..a964087 100644
8445 --- a/arch/powerpc/mm/slice.c
8446 +++ b/arch/powerpc/mm/slice.c
8447 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8448 if ((mm->task_size - len) < addr)
8449 return 0;
8450 vma = find_vma(mm, addr);
8451 - return (!vma || (addr + len) <= vma->vm_start);
8452 + return check_heap_stack_gap(vma, addr, len, 0);
8453 }
8454
8455 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8456 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8457 info.align_offset = 0;
8458
8459 addr = TASK_UNMAPPED_BASE;
8460 +
8461 +#ifdef CONFIG_PAX_RANDMMAP
8462 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8463 + addr += mm->delta_mmap;
8464 +#endif
8465 +
8466 while (addr < TASK_SIZE) {
8467 info.low_limit = addr;
8468 if (!slice_scan_available(addr, available, 1, &addr))
8469 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8470 if (fixed && addr > (mm->task_size - len))
8471 return -EINVAL;
8472
8473 +#ifdef CONFIG_PAX_RANDMMAP
8474 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8475 + addr = 0;
8476 +#endif
8477 +
8478 /* If hint, make sure it matches our alignment restrictions */
8479 if (!fixed && addr) {
8480 addr = _ALIGN_UP(addr, 1ul << pshift);
8481 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8482 index 9098692..3d54cd1 100644
8483 --- a/arch/powerpc/platforms/cell/spufs/file.c
8484 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8485 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8486 return VM_FAULT_NOPAGE;
8487 }
8488
8489 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8490 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8491 unsigned long address,
8492 - void *buf, int len, int write)
8493 + void *buf, size_t len, int write)
8494 {
8495 struct spu_context *ctx = vma->vm_file->private_data;
8496 unsigned long offset = address - vma->vm_start;
8497 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8498 index c797832..ce575c8 100644
8499 --- a/arch/s390/include/asm/atomic.h
8500 +++ b/arch/s390/include/asm/atomic.h
8501 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8502 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8503 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8504
8505 +#define atomic64_read_unchecked(v) atomic64_read(v)
8506 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8507 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8508 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8509 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8510 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8511 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8512 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8513 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8514 +
8515 #define smp_mb__before_atomic_dec() smp_mb()
8516 #define smp_mb__after_atomic_dec() smp_mb()
8517 #define smp_mb__before_atomic_inc() smp_mb()
8518 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8519 index 4d7ccac..d03d0ad 100644
8520 --- a/arch/s390/include/asm/cache.h
8521 +++ b/arch/s390/include/asm/cache.h
8522 @@ -9,8 +9,10 @@
8523 #ifndef __ARCH_S390_CACHE_H
8524 #define __ARCH_S390_CACHE_H
8525
8526 -#define L1_CACHE_BYTES 256
8527 +#include <linux/const.h>
8528 +
8529 #define L1_CACHE_SHIFT 8
8530 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8531 #define NET_SKB_PAD 32
8532
8533 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8534 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8535 index 78f4f87..598ce39 100644
8536 --- a/arch/s390/include/asm/elf.h
8537 +++ b/arch/s390/include/asm/elf.h
8538 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8539 the loader. We need to make sure that it is out of the way of the program
8540 that it will "exec", and that there is sufficient room for the brk. */
8541
8542 -extern unsigned long randomize_et_dyn(unsigned long base);
8543 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8544 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8545 +
8546 +#ifdef CONFIG_PAX_ASLR
8547 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8548 +
8549 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8550 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8551 +#endif
8552
8553 /* This yields a mask that user programs can use to figure out what
8554 instruction set this CPU supports. */
8555 @@ -222,9 +228,6 @@ struct linux_binprm;
8556 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8557 int arch_setup_additional_pages(struct linux_binprm *, int);
8558
8559 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8560 -#define arch_randomize_brk arch_randomize_brk
8561 -
8562 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8563
8564 #endif
8565 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8566 index c4a93d6..4d2a9b4 100644
8567 --- a/arch/s390/include/asm/exec.h
8568 +++ b/arch/s390/include/asm/exec.h
8569 @@ -7,6 +7,6 @@
8570 #ifndef __ASM_EXEC_H
8571 #define __ASM_EXEC_H
8572
8573 -extern unsigned long arch_align_stack(unsigned long sp);
8574 +#define arch_align_stack(x) ((x) & ~0xfUL)
8575
8576 #endif /* __ASM_EXEC_H */
8577 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8578 index 9c33ed4..e40cbef 100644
8579 --- a/arch/s390/include/asm/uaccess.h
8580 +++ b/arch/s390/include/asm/uaccess.h
8581 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8582 copy_to_user(void __user *to, const void *from, unsigned long n)
8583 {
8584 might_fault();
8585 +
8586 + if ((long)n < 0)
8587 + return n;
8588 +
8589 return __copy_to_user(to, from, n);
8590 }
8591
8592 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8593 static inline unsigned long __must_check
8594 __copy_from_user(void *to, const void __user *from, unsigned long n)
8595 {
8596 + if ((long)n < 0)
8597 + return n;
8598 +
8599 if (__builtin_constant_p(n) && (n <= 256))
8600 return uaccess.copy_from_user_small(n, from, to);
8601 else
8602 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8603 static inline unsigned long __must_check
8604 copy_from_user(void *to, const void __user *from, unsigned long n)
8605 {
8606 - unsigned int sz = __compiletime_object_size(to);
8607 + size_t sz = __compiletime_object_size(to);
8608
8609 might_fault();
8610 - if (unlikely(sz != -1 && sz < n)) {
8611 +
8612 + if ((long)n < 0)
8613 + return n;
8614 +
8615 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8616 copy_from_user_overflow();
8617 return n;
8618 }
8619 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8620 index 7845e15..59c4353 100644
8621 --- a/arch/s390/kernel/module.c
8622 +++ b/arch/s390/kernel/module.c
8623 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8624
8625 /* Increase core size by size of got & plt and set start
8626 offsets for got and plt. */
8627 - me->core_size = ALIGN(me->core_size, 4);
8628 - me->arch.got_offset = me->core_size;
8629 - me->core_size += me->arch.got_size;
8630 - me->arch.plt_offset = me->core_size;
8631 - me->core_size += me->arch.plt_size;
8632 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8633 + me->arch.got_offset = me->core_size_rw;
8634 + me->core_size_rw += me->arch.got_size;
8635 + me->arch.plt_offset = me->core_size_rx;
8636 + me->core_size_rx += me->arch.plt_size;
8637 return 0;
8638 }
8639
8640 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8641 if (info->got_initialized == 0) {
8642 Elf_Addr *gotent;
8643
8644 - gotent = me->module_core + me->arch.got_offset +
8645 + gotent = me->module_core_rw + me->arch.got_offset +
8646 info->got_offset;
8647 *gotent = val;
8648 info->got_initialized = 1;
8649 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8650 rc = apply_rela_bits(loc, val, 0, 64, 0);
8651 else if (r_type == R_390_GOTENT ||
8652 r_type == R_390_GOTPLTENT) {
8653 - val += (Elf_Addr) me->module_core - loc;
8654 + val += (Elf_Addr) me->module_core_rw - loc;
8655 rc = apply_rela_bits(loc, val, 1, 32, 1);
8656 }
8657 break;
8658 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8659 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8660 if (info->plt_initialized == 0) {
8661 unsigned int *ip;
8662 - ip = me->module_core + me->arch.plt_offset +
8663 + ip = me->module_core_rx + me->arch.plt_offset +
8664 info->plt_offset;
8665 #ifndef CONFIG_64BIT
8666 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8667 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8668 val - loc + 0xffffUL < 0x1ffffeUL) ||
8669 (r_type == R_390_PLT32DBL &&
8670 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8671 - val = (Elf_Addr) me->module_core +
8672 + val = (Elf_Addr) me->module_core_rx +
8673 me->arch.plt_offset +
8674 info->plt_offset;
8675 val += rela->r_addend - loc;
8676 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8677 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8678 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8679 val = val + rela->r_addend -
8680 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8681 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8682 if (r_type == R_390_GOTOFF16)
8683 rc = apply_rela_bits(loc, val, 0, 16, 0);
8684 else if (r_type == R_390_GOTOFF32)
8685 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8686 break;
8687 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8688 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8689 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8690 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8691 rela->r_addend - loc;
8692 if (r_type == R_390_GOTPC)
8693 rc = apply_rela_bits(loc, val, 1, 32, 0);
8694 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8695 index c5dbb33..b41f4ee 100644
8696 --- a/arch/s390/kernel/process.c
8697 +++ b/arch/s390/kernel/process.c
8698 @@ -237,39 +237,3 @@ unsigned long get_wchan(struct task_struct *p)
8699 }
8700 return 0;
8701 }
8702 -
8703 -unsigned long arch_align_stack(unsigned long sp)
8704 -{
8705 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8706 - sp -= get_random_int() & ~PAGE_MASK;
8707 - return sp & ~0xf;
8708 -}
8709 -
8710 -static inline unsigned long brk_rnd(void)
8711 -{
8712 - /* 8MB for 32bit, 1GB for 64bit */
8713 - if (is_32bit_task())
8714 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8715 - else
8716 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8717 -}
8718 -
8719 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8720 -{
8721 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8722 -
8723 - if (ret < mm->brk)
8724 - return mm->brk;
8725 - return ret;
8726 -}
8727 -
8728 -unsigned long randomize_et_dyn(unsigned long base)
8729 -{
8730 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8731 -
8732 - if (!(current->flags & PF_RANDOMIZE))
8733 - return base;
8734 - if (ret < base)
8735 - return base;
8736 - return ret;
8737 -}
8738 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8739 index 4002329..99b67cb 100644
8740 --- a/arch/s390/mm/mmap.c
8741 +++ b/arch/s390/mm/mmap.c
8742 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8743 */
8744 if (mmap_is_legacy()) {
8745 mm->mmap_base = TASK_UNMAPPED_BASE;
8746 +
8747 +#ifdef CONFIG_PAX_RANDMMAP
8748 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8749 + mm->mmap_base += mm->delta_mmap;
8750 +#endif
8751 +
8752 mm->get_unmapped_area = arch_get_unmapped_area;
8753 } else {
8754 mm->mmap_base = mmap_base();
8755 +
8756 +#ifdef CONFIG_PAX_RANDMMAP
8757 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8758 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8759 +#endif
8760 +
8761 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8762 }
8763 }
8764 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8765 */
8766 if (mmap_is_legacy()) {
8767 mm->mmap_base = TASK_UNMAPPED_BASE;
8768 +
8769 +#ifdef CONFIG_PAX_RANDMMAP
8770 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8771 + mm->mmap_base += mm->delta_mmap;
8772 +#endif
8773 +
8774 mm->get_unmapped_area = s390_get_unmapped_area;
8775 } else {
8776 mm->mmap_base = mmap_base();
8777 +
8778 +#ifdef CONFIG_PAX_RANDMMAP
8779 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8780 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8781 +#endif
8782 +
8783 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8784 }
8785 }
8786 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8787 index ae3d59f..f65f075 100644
8788 --- a/arch/score/include/asm/cache.h
8789 +++ b/arch/score/include/asm/cache.h
8790 @@ -1,7 +1,9 @@
8791 #ifndef _ASM_SCORE_CACHE_H
8792 #define _ASM_SCORE_CACHE_H
8793
8794 +#include <linux/const.h>
8795 +
8796 #define L1_CACHE_SHIFT 4
8797 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8798 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8799
8800 #endif /* _ASM_SCORE_CACHE_H */
8801 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8802 index f9f3cd5..58ff438 100644
8803 --- a/arch/score/include/asm/exec.h
8804 +++ b/arch/score/include/asm/exec.h
8805 @@ -1,6 +1,6 @@
8806 #ifndef _ASM_SCORE_EXEC_H
8807 #define _ASM_SCORE_EXEC_H
8808
8809 -extern unsigned long arch_align_stack(unsigned long sp);
8810 +#define arch_align_stack(x) (x)
8811
8812 #endif /* _ASM_SCORE_EXEC_H */
8813 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8814 index a1519ad3..e8ac1ff 100644
8815 --- a/arch/score/kernel/process.c
8816 +++ b/arch/score/kernel/process.c
8817 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8818
8819 return task_pt_regs(task)->cp0_epc;
8820 }
8821 -
8822 -unsigned long arch_align_stack(unsigned long sp)
8823 -{
8824 - return sp;
8825 -}
8826 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8827 index ef9e555..331bd29 100644
8828 --- a/arch/sh/include/asm/cache.h
8829 +++ b/arch/sh/include/asm/cache.h
8830 @@ -9,10 +9,11 @@
8831 #define __ASM_SH_CACHE_H
8832 #ifdef __KERNEL__
8833
8834 +#include <linux/const.h>
8835 #include <linux/init.h>
8836 #include <cpu/cache.h>
8837
8838 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8839 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8840
8841 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8842
8843 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8844 index 6777177..cb5e44f 100644
8845 --- a/arch/sh/mm/mmap.c
8846 +++ b/arch/sh/mm/mmap.c
8847 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8848 struct mm_struct *mm = current->mm;
8849 struct vm_area_struct *vma;
8850 int do_colour_align;
8851 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8852 struct vm_unmapped_area_info info;
8853
8854 if (flags & MAP_FIXED) {
8855 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8856 if (filp || (flags & MAP_SHARED))
8857 do_colour_align = 1;
8858
8859 +#ifdef CONFIG_PAX_RANDMMAP
8860 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8861 +#endif
8862 +
8863 if (addr) {
8864 if (do_colour_align)
8865 addr = COLOUR_ALIGN(addr, pgoff);
8866 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8867 addr = PAGE_ALIGN(addr);
8868
8869 vma = find_vma(mm, addr);
8870 - if (TASK_SIZE - len >= addr &&
8871 - (!vma || addr + len <= vma->vm_start))
8872 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8873 return addr;
8874 }
8875
8876 info.flags = 0;
8877 info.length = len;
8878 - info.low_limit = TASK_UNMAPPED_BASE;
8879 + info.low_limit = mm->mmap_base;
8880 info.high_limit = TASK_SIZE;
8881 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8882 info.align_offset = pgoff << PAGE_SHIFT;
8883 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8884 struct mm_struct *mm = current->mm;
8885 unsigned long addr = addr0;
8886 int do_colour_align;
8887 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8888 struct vm_unmapped_area_info info;
8889
8890 if (flags & MAP_FIXED) {
8891 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8892 if (filp || (flags & MAP_SHARED))
8893 do_colour_align = 1;
8894
8895 +#ifdef CONFIG_PAX_RANDMMAP
8896 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8897 +#endif
8898 +
8899 /* requesting a specific address */
8900 if (addr) {
8901 if (do_colour_align)
8902 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8903 addr = PAGE_ALIGN(addr);
8904
8905 vma = find_vma(mm, addr);
8906 - if (TASK_SIZE - len >= addr &&
8907 - (!vma || addr + len <= vma->vm_start))
8908 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8909 return addr;
8910 }
8911
8912 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8913 VM_BUG_ON(addr != -ENOMEM);
8914 info.flags = 0;
8915 info.low_limit = TASK_UNMAPPED_BASE;
8916 +
8917 +#ifdef CONFIG_PAX_RANDMMAP
8918 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8919 + info.low_limit += mm->delta_mmap;
8920 +#endif
8921 +
8922 info.high_limit = TASK_SIZE;
8923 addr = vm_unmapped_area(&info);
8924 }
8925 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8926 index be56a24..443328f 100644
8927 --- a/arch/sparc/include/asm/atomic_64.h
8928 +++ b/arch/sparc/include/asm/atomic_64.h
8929 @@ -14,18 +14,40 @@
8930 #define ATOMIC64_INIT(i) { (i) }
8931
8932 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8933 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8934 +{
8935 + return v->counter;
8936 +}
8937 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8938 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8939 +{
8940 + return v->counter;
8941 +}
8942
8943 #define atomic_set(v, i) (((v)->counter) = i)
8944 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8945 +{
8946 + v->counter = i;
8947 +}
8948 #define atomic64_set(v, i) (((v)->counter) = i)
8949 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8950 +{
8951 + v->counter = i;
8952 +}
8953
8954 extern void atomic_add(int, atomic_t *);
8955 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8956 extern void atomic64_add(long, atomic64_t *);
8957 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8958 extern void atomic_sub(int, atomic_t *);
8959 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8960 extern void atomic64_sub(long, atomic64_t *);
8961 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8962
8963 extern int atomic_add_ret(int, atomic_t *);
8964 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8965 extern long atomic64_add_ret(long, atomic64_t *);
8966 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8967 extern int atomic_sub_ret(int, atomic_t *);
8968 extern long atomic64_sub_ret(long, atomic64_t *);
8969
8970 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8971 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8972
8973 #define atomic_inc_return(v) atomic_add_ret(1, v)
8974 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8975 +{
8976 + return atomic_add_ret_unchecked(1, v);
8977 +}
8978 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8979 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8980 +{
8981 + return atomic64_add_ret_unchecked(1, v);
8982 +}
8983
8984 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8985 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8986
8987 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8988 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8989 +{
8990 + return atomic_add_ret_unchecked(i, v);
8991 +}
8992 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8993 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8994 +{
8995 + return atomic64_add_ret_unchecked(i, v);
8996 +}
8997
8998 /*
8999 * atomic_inc_and_test - increment and test
9000 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
9001 * other cases.
9002 */
9003 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
9004 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
9005 +{
9006 + return atomic_inc_return_unchecked(v) == 0;
9007 +}
9008 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
9009
9010 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
9011 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
9012 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
9013
9014 #define atomic_inc(v) atomic_add(1, v)
9015 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
9016 +{
9017 + atomic_add_unchecked(1, v);
9018 +}
9019 #define atomic64_inc(v) atomic64_add(1, v)
9020 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
9021 +{
9022 + atomic64_add_unchecked(1, v);
9023 +}
9024
9025 #define atomic_dec(v) atomic_sub(1, v)
9026 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
9027 +{
9028 + atomic_sub_unchecked(1, v);
9029 +}
9030 #define atomic64_dec(v) atomic64_sub(1, v)
9031 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
9032 +{
9033 + atomic64_sub_unchecked(1, v);
9034 +}
9035
9036 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
9037 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
9038
9039 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
9040 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
9041 +{
9042 + return cmpxchg(&v->counter, old, new);
9043 +}
9044 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
9045 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
9046 +{
9047 + return xchg(&v->counter, new);
9048 +}
9049
9050 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9051 {
9052 - int c, old;
9053 + int c, old, new;
9054 c = atomic_read(v);
9055 for (;;) {
9056 - if (unlikely(c == (u)))
9057 + if (unlikely(c == u))
9058 break;
9059 - old = atomic_cmpxchg((v), c, c + (a));
9060 +
9061 + asm volatile("addcc %2, %0, %0\n"
9062 +
9063 +#ifdef CONFIG_PAX_REFCOUNT
9064 + "tvs %%icc, 6\n"
9065 +#endif
9066 +
9067 + : "=r" (new)
9068 + : "0" (c), "ir" (a)
9069 + : "cc");
9070 +
9071 + old = atomic_cmpxchg(v, c, new);
9072 if (likely(old == c))
9073 break;
9074 c = old;
9075 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9076 #define atomic64_cmpxchg(v, o, n) \
9077 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
9078 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
9079 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
9080 +{
9081 + return xchg(&v->counter, new);
9082 +}
9083
9084 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9085 {
9086 - long c, old;
9087 + long c, old, new;
9088 c = atomic64_read(v);
9089 for (;;) {
9090 - if (unlikely(c == (u)))
9091 + if (unlikely(c == u))
9092 break;
9093 - old = atomic64_cmpxchg((v), c, c + (a));
9094 +
9095 + asm volatile("addcc %2, %0, %0\n"
9096 +
9097 +#ifdef CONFIG_PAX_REFCOUNT
9098 + "tvs %%xcc, 6\n"
9099 +#endif
9100 +
9101 + : "=r" (new)
9102 + : "0" (c), "ir" (a)
9103 + : "cc");
9104 +
9105 + old = atomic64_cmpxchg(v, c, new);
9106 if (likely(old == c))
9107 break;
9108 c = old;
9109 }
9110 - return c != (u);
9111 + return c != u;
9112 }
9113
9114 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9115 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9116 index 5bb6991..5c2132e 100644
9117 --- a/arch/sparc/include/asm/cache.h
9118 +++ b/arch/sparc/include/asm/cache.h
9119 @@ -7,10 +7,12 @@
9120 #ifndef _SPARC_CACHE_H
9121 #define _SPARC_CACHE_H
9122
9123 +#include <linux/const.h>
9124 +
9125 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9126
9127 #define L1_CACHE_SHIFT 5
9128 -#define L1_CACHE_BYTES 32
9129 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9130
9131 #ifdef CONFIG_SPARC32
9132 #define SMP_CACHE_BYTES_SHIFT 5
9133 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9134 index a24e41f..47677ff 100644
9135 --- a/arch/sparc/include/asm/elf_32.h
9136 +++ b/arch/sparc/include/asm/elf_32.h
9137 @@ -114,6 +114,13 @@ typedef struct {
9138
9139 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9140
9141 +#ifdef CONFIG_PAX_ASLR
9142 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9143 +
9144 +#define PAX_DELTA_MMAP_LEN 16
9145 +#define PAX_DELTA_STACK_LEN 16
9146 +#endif
9147 +
9148 /* This yields a mask that user programs can use to figure out what
9149 instruction set this cpu supports. This can NOT be done in userspace
9150 on Sparc. */
9151 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9152 index 370ca1e..d4f4a98 100644
9153 --- a/arch/sparc/include/asm/elf_64.h
9154 +++ b/arch/sparc/include/asm/elf_64.h
9155 @@ -189,6 +189,13 @@ typedef struct {
9156 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9157 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9158
9159 +#ifdef CONFIG_PAX_ASLR
9160 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9161 +
9162 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9163 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9164 +#endif
9165 +
9166 extern unsigned long sparc64_elf_hwcap;
9167 #define ELF_HWCAP sparc64_elf_hwcap
9168
9169 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9170 index 9b1c36d..209298b 100644
9171 --- a/arch/sparc/include/asm/pgalloc_32.h
9172 +++ b/arch/sparc/include/asm/pgalloc_32.h
9173 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9174 }
9175
9176 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9177 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9178
9179 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9180 unsigned long address)
9181 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9182 index bcfe063..b333142 100644
9183 --- a/arch/sparc/include/asm/pgalloc_64.h
9184 +++ b/arch/sparc/include/asm/pgalloc_64.h
9185 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9186 }
9187
9188 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9189 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9190
9191 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9192 {
9193 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9194 index 502f632..da1917f 100644
9195 --- a/arch/sparc/include/asm/pgtable_32.h
9196 +++ b/arch/sparc/include/asm/pgtable_32.h
9197 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9198 #define PAGE_SHARED SRMMU_PAGE_SHARED
9199 #define PAGE_COPY SRMMU_PAGE_COPY
9200 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9201 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9202 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9203 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9204 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9205
9206 /* Top-level page directory - dummy used by init-mm.
9207 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9208
9209 /* xwr */
9210 #define __P000 PAGE_NONE
9211 -#define __P001 PAGE_READONLY
9212 -#define __P010 PAGE_COPY
9213 -#define __P011 PAGE_COPY
9214 +#define __P001 PAGE_READONLY_NOEXEC
9215 +#define __P010 PAGE_COPY_NOEXEC
9216 +#define __P011 PAGE_COPY_NOEXEC
9217 #define __P100 PAGE_READONLY
9218 #define __P101 PAGE_READONLY
9219 #define __P110 PAGE_COPY
9220 #define __P111 PAGE_COPY
9221
9222 #define __S000 PAGE_NONE
9223 -#define __S001 PAGE_READONLY
9224 -#define __S010 PAGE_SHARED
9225 -#define __S011 PAGE_SHARED
9226 +#define __S001 PAGE_READONLY_NOEXEC
9227 +#define __S010 PAGE_SHARED_NOEXEC
9228 +#define __S011 PAGE_SHARED_NOEXEC
9229 #define __S100 PAGE_READONLY
9230 #define __S101 PAGE_READONLY
9231 #define __S110 PAGE_SHARED
9232 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9233 index 79da178..c2eede8 100644
9234 --- a/arch/sparc/include/asm/pgtsrmmu.h
9235 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9236 @@ -115,6 +115,11 @@
9237 SRMMU_EXEC | SRMMU_REF)
9238 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9239 SRMMU_EXEC | SRMMU_REF)
9240 +
9241 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9242 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9243 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9244 +
9245 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9246 SRMMU_DIRTY | SRMMU_REF)
9247
9248 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9249 index 9689176..63c18ea 100644
9250 --- a/arch/sparc/include/asm/spinlock_64.h
9251 +++ b/arch/sparc/include/asm/spinlock_64.h
9252 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9253
9254 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9255
9256 -static void inline arch_read_lock(arch_rwlock_t *lock)
9257 +static inline void arch_read_lock(arch_rwlock_t *lock)
9258 {
9259 unsigned long tmp1, tmp2;
9260
9261 __asm__ __volatile__ (
9262 "1: ldsw [%2], %0\n"
9263 " brlz,pn %0, 2f\n"
9264 -"4: add %0, 1, %1\n"
9265 +"4: addcc %0, 1, %1\n"
9266 +
9267 +#ifdef CONFIG_PAX_REFCOUNT
9268 +" tvs %%icc, 6\n"
9269 +#endif
9270 +
9271 " cas [%2], %0, %1\n"
9272 " cmp %0, %1\n"
9273 " bne,pn %%icc, 1b\n"
9274 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9275 " .previous"
9276 : "=&r" (tmp1), "=&r" (tmp2)
9277 : "r" (lock)
9278 - : "memory");
9279 + : "memory", "cc");
9280 }
9281
9282 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9283 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9284 {
9285 int tmp1, tmp2;
9286
9287 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9288 "1: ldsw [%2], %0\n"
9289 " brlz,a,pn %0, 2f\n"
9290 " mov 0, %0\n"
9291 -" add %0, 1, %1\n"
9292 +" addcc %0, 1, %1\n"
9293 +
9294 +#ifdef CONFIG_PAX_REFCOUNT
9295 +" tvs %%icc, 6\n"
9296 +#endif
9297 +
9298 " cas [%2], %0, %1\n"
9299 " cmp %0, %1\n"
9300 " bne,pn %%icc, 1b\n"
9301 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9302 return tmp1;
9303 }
9304
9305 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9306 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9307 {
9308 unsigned long tmp1, tmp2;
9309
9310 __asm__ __volatile__(
9311 "1: lduw [%2], %0\n"
9312 -" sub %0, 1, %1\n"
9313 +" subcc %0, 1, %1\n"
9314 +
9315 +#ifdef CONFIG_PAX_REFCOUNT
9316 +" tvs %%icc, 6\n"
9317 +#endif
9318 +
9319 " cas [%2], %0, %1\n"
9320 " cmp %0, %1\n"
9321 " bne,pn %%xcc, 1b\n"
9322 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9323 : "memory");
9324 }
9325
9326 -static void inline arch_write_lock(arch_rwlock_t *lock)
9327 +static inline void arch_write_lock(arch_rwlock_t *lock)
9328 {
9329 unsigned long mask, tmp1, tmp2;
9330
9331 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9332 : "memory");
9333 }
9334
9335 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9336 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9337 {
9338 __asm__ __volatile__(
9339 " stw %%g0, [%0]"
9340 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9341 : "memory");
9342 }
9343
9344 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9345 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9346 {
9347 unsigned long mask, tmp1, tmp2, result;
9348
9349 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9350 index dd38075..e7cac83 100644
9351 --- a/arch/sparc/include/asm/thread_info_32.h
9352 +++ b/arch/sparc/include/asm/thread_info_32.h
9353 @@ -49,6 +49,8 @@ struct thread_info {
9354 unsigned long w_saved;
9355
9356 struct restart_block restart_block;
9357 +
9358 + unsigned long lowest_stack;
9359 };
9360
9361 /*
9362 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9363 index d5e5042..9bfee76 100644
9364 --- a/arch/sparc/include/asm/thread_info_64.h
9365 +++ b/arch/sparc/include/asm/thread_info_64.h
9366 @@ -63,6 +63,8 @@ struct thread_info {
9367 struct pt_regs *kern_una_regs;
9368 unsigned int kern_una_insn;
9369
9370 + unsigned long lowest_stack;
9371 +
9372 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9373 };
9374
9375 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9376 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9377 /* flag bit 6 is available */
9378 #define TIF_32BIT 7 /* 32-bit binary */
9379 -/* flag bit 8 is available */
9380 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9381 #define TIF_SECCOMP 9 /* secure computing */
9382 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9383 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9384 +
9385 /* NOTE: Thread flags >= 12 should be ones we have no interest
9386 * in using in assembly, else we can't use the mask as
9387 * an immediate value in instructions such as andcc.
9388 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9389 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9390 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9391 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9392 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9393
9394 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9395 _TIF_DO_NOTIFY_RESUME_MASK | \
9396 _TIF_NEED_RESCHED)
9397 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9398
9399 +#define _TIF_WORK_SYSCALL \
9400 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9401 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9402 +
9403 +
9404 /*
9405 * Thread-synchronous status.
9406 *
9407 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9408 index 0167d26..767bb0c 100644
9409 --- a/arch/sparc/include/asm/uaccess.h
9410 +++ b/arch/sparc/include/asm/uaccess.h
9411 @@ -1,5 +1,6 @@
9412 #ifndef ___ASM_SPARC_UACCESS_H
9413 #define ___ASM_SPARC_UACCESS_H
9414 +
9415 #if defined(__sparc__) && defined(__arch64__)
9416 #include <asm/uaccess_64.h>
9417 #else
9418 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9419 index 53a28dd..50c38c3 100644
9420 --- a/arch/sparc/include/asm/uaccess_32.h
9421 +++ b/arch/sparc/include/asm/uaccess_32.h
9422 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9423
9424 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9425 {
9426 - if (n && __access_ok((unsigned long) to, n))
9427 + if ((long)n < 0)
9428 + return n;
9429 +
9430 + if (n && __access_ok((unsigned long) to, n)) {
9431 + if (!__builtin_constant_p(n))
9432 + check_object_size(from, n, true);
9433 return __copy_user(to, (__force void __user *) from, n);
9434 - else
9435 + } else
9436 return n;
9437 }
9438
9439 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9440 {
9441 + if ((long)n < 0)
9442 + return n;
9443 +
9444 + if (!__builtin_constant_p(n))
9445 + check_object_size(from, n, true);
9446 +
9447 return __copy_user(to, (__force void __user *) from, n);
9448 }
9449
9450 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9451 {
9452 - if (n && __access_ok((unsigned long) from, n))
9453 + if ((long)n < 0)
9454 + return n;
9455 +
9456 + if (n && __access_ok((unsigned long) from, n)) {
9457 + if (!__builtin_constant_p(n))
9458 + check_object_size(to, n, false);
9459 return __copy_user((__force void __user *) to, from, n);
9460 - else
9461 + } else
9462 return n;
9463 }
9464
9465 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9466 {
9467 + if ((long)n < 0)
9468 + return n;
9469 +
9470 return __copy_user((__force void __user *) to, from, n);
9471 }
9472
9473 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9474 index e562d3c..191f176 100644
9475 --- a/arch/sparc/include/asm/uaccess_64.h
9476 +++ b/arch/sparc/include/asm/uaccess_64.h
9477 @@ -10,6 +10,7 @@
9478 #include <linux/compiler.h>
9479 #include <linux/string.h>
9480 #include <linux/thread_info.h>
9481 +#include <linux/kernel.h>
9482 #include <asm/asi.h>
9483 #include <asm/spitfire.h>
9484 #include <asm-generic/uaccess-unaligned.h>
9485 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9486 static inline unsigned long __must_check
9487 copy_from_user(void *to, const void __user *from, unsigned long size)
9488 {
9489 - unsigned long ret = ___copy_from_user(to, from, size);
9490 + unsigned long ret;
9491
9492 + if ((long)size < 0 || size > INT_MAX)
9493 + return size;
9494 +
9495 + if (!__builtin_constant_p(size))
9496 + check_object_size(to, size, false);
9497 +
9498 + ret = ___copy_from_user(to, from, size);
9499 if (unlikely(ret))
9500 ret = copy_from_user_fixup(to, from, size);
9501
9502 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9503 static inline unsigned long __must_check
9504 copy_to_user(void __user *to, const void *from, unsigned long size)
9505 {
9506 - unsigned long ret = ___copy_to_user(to, from, size);
9507 + unsigned long ret;
9508
9509 + if ((long)size < 0 || size > INT_MAX)
9510 + return size;
9511 +
9512 + if (!__builtin_constant_p(size))
9513 + check_object_size(from, size, true);
9514 +
9515 + ret = ___copy_to_user(to, from, size);
9516 if (unlikely(ret))
9517 ret = copy_to_user_fixup(to, from, size);
9518 return ret;
9519 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9520 index d15cc17..d0ae796 100644
9521 --- a/arch/sparc/kernel/Makefile
9522 +++ b/arch/sparc/kernel/Makefile
9523 @@ -4,7 +4,7 @@
9524 #
9525
9526 asflags-y := -ansi
9527 -ccflags-y := -Werror
9528 +#ccflags-y := -Werror
9529
9530 extra-y := head_$(BITS).o
9531
9532 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9533 index fdd819d..5af08c8 100644
9534 --- a/arch/sparc/kernel/process_32.c
9535 +++ b/arch/sparc/kernel/process_32.c
9536 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9537
9538 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9539 r->psr, r->pc, r->npc, r->y, print_tainted());
9540 - printk("PC: <%pS>\n", (void *) r->pc);
9541 + printk("PC: <%pA>\n", (void *) r->pc);
9542 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9543 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9544 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9545 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9546 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9547 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9548 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9549 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9550
9551 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9552 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9553 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9554 rw = (struct reg_window32 *) fp;
9555 pc = rw->ins[7];
9556 printk("[%08lx : ", pc);
9557 - printk("%pS ] ", (void *) pc);
9558 + printk("%pA ] ", (void *) pc);
9559 fp = rw->ins[6];
9560 } while (++count < 16);
9561 printk("\n");
9562 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9563 index baebab2..9cd13b1 100644
9564 --- a/arch/sparc/kernel/process_64.c
9565 +++ b/arch/sparc/kernel/process_64.c
9566 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9567 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9568 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9569 if (regs->tstate & TSTATE_PRIV)
9570 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9571 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9572 }
9573
9574 void show_regs(struct pt_regs *regs)
9575 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9576
9577 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9578 regs->tpc, regs->tnpc, regs->y, print_tainted());
9579 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9580 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9581 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9582 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9583 regs->u_regs[3]);
9584 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9585 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9586 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9587 regs->u_regs[15]);
9588 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9589 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9590 show_regwindow(regs);
9591 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9592 }
9593 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9594 ((tp && tp->task) ? tp->task->pid : -1));
9595
9596 if (gp->tstate & TSTATE_PRIV) {
9597 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9598 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9599 (void *) gp->tpc,
9600 (void *) gp->o7,
9601 (void *) gp->i7,
9602 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9603 index 79cc0d1..ec62734 100644
9604 --- a/arch/sparc/kernel/prom_common.c
9605 +++ b/arch/sparc/kernel/prom_common.c
9606 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9607
9608 unsigned int prom_early_allocated __initdata;
9609
9610 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9611 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9612 .nextprop = prom_common_nextprop,
9613 .getproplen = prom_getproplen,
9614 .getproperty = prom_getproperty,
9615 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9616 index 773c1f2..a8bdd87 100644
9617 --- a/arch/sparc/kernel/ptrace_64.c
9618 +++ b/arch/sparc/kernel/ptrace_64.c
9619 @@ -1059,6 +1059,10 @@ long arch_ptrace(struct task_struct *child, long request,
9620 return ret;
9621 }
9622
9623 +#ifdef CONFIG_GRKERNSEC_SETXID
9624 +extern void gr_delayed_cred_worker(void);
9625 +#endif
9626 +
9627 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9628 {
9629 int ret = 0;
9630 @@ -1066,6 +1070,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9631 /* do the secure computing check first */
9632 secure_computing_strict(regs->u_regs[UREG_G1]);
9633
9634 +#ifdef CONFIG_GRKERNSEC_SETXID
9635 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9636 + gr_delayed_cred_worker();
9637 +#endif
9638 +
9639 if (test_thread_flag(TIF_SYSCALL_TRACE))
9640 ret = tracehook_report_syscall_entry(regs);
9641
9642 @@ -1086,6 +1095,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9643
9644 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9645 {
9646 +#ifdef CONFIG_GRKERNSEC_SETXID
9647 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9648 + gr_delayed_cred_worker();
9649 +#endif
9650 +
9651 audit_syscall_exit(regs);
9652
9653 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9654 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9655 index e142545..fd29654 100644
9656 --- a/arch/sparc/kernel/smp_64.c
9657 +++ b/arch/sparc/kernel/smp_64.c
9658 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9659 extern unsigned long xcall_flush_dcache_page_spitfire;
9660
9661 #ifdef CONFIG_DEBUG_DCFLUSH
9662 -extern atomic_t dcpage_flushes;
9663 -extern atomic_t dcpage_flushes_xcall;
9664 +extern atomic_unchecked_t dcpage_flushes;
9665 +extern atomic_unchecked_t dcpage_flushes_xcall;
9666 #endif
9667
9668 static inline void __local_flush_dcache_page(struct page *page)
9669 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9670 return;
9671
9672 #ifdef CONFIG_DEBUG_DCFLUSH
9673 - atomic_inc(&dcpage_flushes);
9674 + atomic_inc_unchecked(&dcpage_flushes);
9675 #endif
9676
9677 this_cpu = get_cpu();
9678 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9679 xcall_deliver(data0, __pa(pg_addr),
9680 (u64) pg_addr, cpumask_of(cpu));
9681 #ifdef CONFIG_DEBUG_DCFLUSH
9682 - atomic_inc(&dcpage_flushes_xcall);
9683 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9684 #endif
9685 }
9686 }
9687 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9688 preempt_disable();
9689
9690 #ifdef CONFIG_DEBUG_DCFLUSH
9691 - atomic_inc(&dcpage_flushes);
9692 + atomic_inc_unchecked(&dcpage_flushes);
9693 #endif
9694 data0 = 0;
9695 pg_addr = page_address(page);
9696 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9697 xcall_deliver(data0, __pa(pg_addr),
9698 (u64) pg_addr, cpu_online_mask);
9699 #ifdef CONFIG_DEBUG_DCFLUSH
9700 - atomic_inc(&dcpage_flushes_xcall);
9701 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9702 #endif
9703 }
9704 __local_flush_dcache_page(page);
9705 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9706 index 3a8d184..49498a8 100644
9707 --- a/arch/sparc/kernel/sys_sparc_32.c
9708 +++ b/arch/sparc/kernel/sys_sparc_32.c
9709 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9710 if (len > TASK_SIZE - PAGE_SIZE)
9711 return -ENOMEM;
9712 if (!addr)
9713 - addr = TASK_UNMAPPED_BASE;
9714 + addr = current->mm->mmap_base;
9715
9716 info.flags = 0;
9717 info.length = len;
9718 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9719 index 51561b8..8256764 100644
9720 --- a/arch/sparc/kernel/sys_sparc_64.c
9721 +++ b/arch/sparc/kernel/sys_sparc_64.c
9722 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9723 struct vm_area_struct * vma;
9724 unsigned long task_size = TASK_SIZE;
9725 int do_color_align;
9726 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9727 struct vm_unmapped_area_info info;
9728
9729 if (flags & MAP_FIXED) {
9730 /* We do not accept a shared mapping if it would violate
9731 * cache aliasing constraints.
9732 */
9733 - if ((flags & MAP_SHARED) &&
9734 + if ((filp || (flags & MAP_SHARED)) &&
9735 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9736 return -EINVAL;
9737 return addr;
9738 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9739 if (filp || (flags & MAP_SHARED))
9740 do_color_align = 1;
9741
9742 +#ifdef CONFIG_PAX_RANDMMAP
9743 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9744 +#endif
9745 +
9746 if (addr) {
9747 if (do_color_align)
9748 addr = COLOR_ALIGN(addr, pgoff);
9749 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9750 addr = PAGE_ALIGN(addr);
9751
9752 vma = find_vma(mm, addr);
9753 - if (task_size - len >= addr &&
9754 - (!vma || addr + len <= vma->vm_start))
9755 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9756 return addr;
9757 }
9758
9759 info.flags = 0;
9760 info.length = len;
9761 - info.low_limit = TASK_UNMAPPED_BASE;
9762 + info.low_limit = mm->mmap_base;
9763 info.high_limit = min(task_size, VA_EXCLUDE_START);
9764 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9765 info.align_offset = pgoff << PAGE_SHIFT;
9766 + info.threadstack_offset = offset;
9767 addr = vm_unmapped_area(&info);
9768
9769 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9770 VM_BUG_ON(addr != -ENOMEM);
9771 info.low_limit = VA_EXCLUDE_END;
9772 +
9773 +#ifdef CONFIG_PAX_RANDMMAP
9774 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9775 + info.low_limit += mm->delta_mmap;
9776 +#endif
9777 +
9778 info.high_limit = task_size;
9779 addr = vm_unmapped_area(&info);
9780 }
9781 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9782 unsigned long task_size = STACK_TOP32;
9783 unsigned long addr = addr0;
9784 int do_color_align;
9785 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9786 struct vm_unmapped_area_info info;
9787
9788 /* This should only ever run for 32-bit processes. */
9789 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9790 /* We do not accept a shared mapping if it would violate
9791 * cache aliasing constraints.
9792 */
9793 - if ((flags & MAP_SHARED) &&
9794 + if ((filp || (flags & MAP_SHARED)) &&
9795 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9796 return -EINVAL;
9797 return addr;
9798 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9799 if (filp || (flags & MAP_SHARED))
9800 do_color_align = 1;
9801
9802 +#ifdef CONFIG_PAX_RANDMMAP
9803 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9804 +#endif
9805 +
9806 /* requesting a specific address */
9807 if (addr) {
9808 if (do_color_align)
9809 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9810 addr = PAGE_ALIGN(addr);
9811
9812 vma = find_vma(mm, addr);
9813 - if (task_size - len >= addr &&
9814 - (!vma || addr + len <= vma->vm_start))
9815 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9816 return addr;
9817 }
9818
9819 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9820 info.high_limit = mm->mmap_base;
9821 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9822 info.align_offset = pgoff << PAGE_SHIFT;
9823 + info.threadstack_offset = offset;
9824 addr = vm_unmapped_area(&info);
9825
9826 /*
9827 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9828 VM_BUG_ON(addr != -ENOMEM);
9829 info.flags = 0;
9830 info.low_limit = TASK_UNMAPPED_BASE;
9831 +
9832 +#ifdef CONFIG_PAX_RANDMMAP
9833 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9834 + info.low_limit += mm->delta_mmap;
9835 +#endif
9836 +
9837 info.high_limit = STACK_TOP32;
9838 addr = vm_unmapped_area(&info);
9839 }
9840 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9841 EXPORT_SYMBOL(get_fb_unmapped_area);
9842
9843 /* Essentially the same as PowerPC. */
9844 -static unsigned long mmap_rnd(void)
9845 +static unsigned long mmap_rnd(struct mm_struct *mm)
9846 {
9847 unsigned long rnd = 0UL;
9848
9849 +#ifdef CONFIG_PAX_RANDMMAP
9850 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9851 +#endif
9852 +
9853 if (current->flags & PF_RANDOMIZE) {
9854 unsigned long val = get_random_int();
9855 if (test_thread_flag(TIF_32BIT))
9856 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9857
9858 void arch_pick_mmap_layout(struct mm_struct *mm)
9859 {
9860 - unsigned long random_factor = mmap_rnd();
9861 + unsigned long random_factor = mmap_rnd(mm);
9862 unsigned long gap;
9863
9864 /*
9865 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9866 gap == RLIM_INFINITY ||
9867 sysctl_legacy_va_layout) {
9868 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9869 +
9870 +#ifdef CONFIG_PAX_RANDMMAP
9871 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9872 + mm->mmap_base += mm->delta_mmap;
9873 +#endif
9874 +
9875 mm->get_unmapped_area = arch_get_unmapped_area;
9876 } else {
9877 /* We know it's 32-bit */
9878 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9879 gap = (task_size / 6 * 5);
9880
9881 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9882 +
9883 +#ifdef CONFIG_PAX_RANDMMAP
9884 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9885 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9886 +#endif
9887 +
9888 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9889 }
9890 }
9891 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9892 index d950197..192f9d8 100644
9893 --- a/arch/sparc/kernel/syscalls.S
9894 +++ b/arch/sparc/kernel/syscalls.S
9895 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9896 #endif
9897 .align 32
9898 1: ldx [%g6 + TI_FLAGS], %l5
9899 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9900 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9901 be,pt %icc, rtrap
9902 nop
9903 call syscall_trace_leave
9904 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9905
9906 srl %i3, 0, %o3 ! IEU0
9907 srl %i2, 0, %o2 ! IEU0 Group
9908 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9909 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9910 bne,pn %icc, linux_syscall_trace32 ! CTI
9911 mov %i0, %l5 ! IEU1
9912 5: call %l7 ! CTI Group brk forced
9913 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9914
9915 mov %i3, %o3 ! IEU1
9916 mov %i4, %o4 ! IEU0 Group
9917 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9918 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9919 bne,pn %icc, linux_syscall_trace ! CTI Group
9920 mov %i0, %l5 ! IEU0
9921 2: call %l7 ! CTI Group brk forced
9922 @@ -223,7 +223,7 @@ ret_sys_call:
9923
9924 cmp %o0, -ERESTART_RESTARTBLOCK
9925 bgeu,pn %xcc, 1f
9926 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9927 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9928 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9929
9930 2:
9931 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9932 index 6629829..036032d 100644
9933 --- a/arch/sparc/kernel/traps_32.c
9934 +++ b/arch/sparc/kernel/traps_32.c
9935 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9936 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9937 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9938
9939 +extern void gr_handle_kernel_exploit(void);
9940 +
9941 void die_if_kernel(char *str, struct pt_regs *regs)
9942 {
9943 static int die_counter;
9944 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9945 count++ < 30 &&
9946 (((unsigned long) rw) >= PAGE_OFFSET) &&
9947 !(((unsigned long) rw) & 0x7)) {
9948 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9949 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9950 (void *) rw->ins[7]);
9951 rw = (struct reg_window32 *)rw->ins[6];
9952 }
9953 }
9954 printk("Instruction DUMP:");
9955 instruction_dump ((unsigned long *) regs->pc);
9956 - if(regs->psr & PSR_PS)
9957 + if(regs->psr & PSR_PS) {
9958 + gr_handle_kernel_exploit();
9959 do_exit(SIGKILL);
9960 + }
9961 do_exit(SIGSEGV);
9962 }
9963
9964 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9965 index b3f833a..f485f80 100644
9966 --- a/arch/sparc/kernel/traps_64.c
9967 +++ b/arch/sparc/kernel/traps_64.c
9968 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9969 i + 1,
9970 p->trapstack[i].tstate, p->trapstack[i].tpc,
9971 p->trapstack[i].tnpc, p->trapstack[i].tt);
9972 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9973 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9974 }
9975 }
9976
9977 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9978
9979 lvl -= 0x100;
9980 if (regs->tstate & TSTATE_PRIV) {
9981 +
9982 +#ifdef CONFIG_PAX_REFCOUNT
9983 + if (lvl == 6)
9984 + pax_report_refcount_overflow(regs);
9985 +#endif
9986 +
9987 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9988 die_if_kernel(buffer, regs);
9989 }
9990 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9991 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9992 {
9993 char buffer[32];
9994 -
9995 +
9996 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9997 0, lvl, SIGTRAP) == NOTIFY_STOP)
9998 return;
9999
10000 +#ifdef CONFIG_PAX_REFCOUNT
10001 + if (lvl == 6)
10002 + pax_report_refcount_overflow(regs);
10003 +#endif
10004 +
10005 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
10006
10007 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
10008 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
10009 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
10010 printk("%s" "ERROR(%d): ",
10011 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
10012 - printk("TPC<%pS>\n", (void *) regs->tpc);
10013 + printk("TPC<%pA>\n", (void *) regs->tpc);
10014 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
10015 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
10016 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
10017 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
10018 smp_processor_id(),
10019 (type & 0x1) ? 'I' : 'D',
10020 regs->tpc);
10021 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
10022 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
10023 panic("Irrecoverable Cheetah+ parity error.");
10024 }
10025
10026 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
10027 smp_processor_id(),
10028 (type & 0x1) ? 'I' : 'D',
10029 regs->tpc);
10030 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
10031 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
10032 }
10033
10034 struct sun4v_error_entry {
10035 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
10036 /*0x38*/u64 reserved_5;
10037 };
10038
10039 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
10040 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
10041 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
10042 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
10043
10044 static const char *sun4v_err_type_to_str(u8 type)
10045 {
10046 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
10047 }
10048
10049 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
10050 - int cpu, const char *pfx, atomic_t *ocnt)
10051 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
10052 {
10053 u64 *raw_ptr = (u64 *) ent;
10054 u32 attrs;
10055 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
10056
10057 show_regs(regs);
10058
10059 - if ((cnt = atomic_read(ocnt)) != 0) {
10060 - atomic_set(ocnt, 0);
10061 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
10062 + atomic_set_unchecked(ocnt, 0);
10063 wmb();
10064 printk("%s: Queue overflowed %d times.\n",
10065 pfx, cnt);
10066 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
10067 */
10068 void sun4v_resum_overflow(struct pt_regs *regs)
10069 {
10070 - atomic_inc(&sun4v_resum_oflow_cnt);
10071 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
10072 }
10073
10074 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
10075 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
10076 /* XXX Actually even this can make not that much sense. Perhaps
10077 * XXX we should just pull the plug and panic directly from here?
10078 */
10079 - atomic_inc(&sun4v_nonresum_oflow_cnt);
10080 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
10081 }
10082
10083 unsigned long sun4v_err_itlb_vaddr;
10084 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
10085
10086 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10087 regs->tpc, tl);
10088 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10089 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10090 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10091 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10092 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10093 (void *) regs->u_regs[UREG_I7]);
10094 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10095 "pte[%lx] error[%lx]\n",
10096 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10097
10098 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10099 regs->tpc, tl);
10100 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10101 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10102 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10103 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10104 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10105 (void *) regs->u_regs[UREG_I7]);
10106 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10107 "pte[%lx] error[%lx]\n",
10108 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10109 fp = (unsigned long)sf->fp + STACK_BIAS;
10110 }
10111
10112 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10113 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10114 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10115 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10116 int index = tsk->curr_ret_stack;
10117 if (tsk->ret_stack && index >= graph) {
10118 pc = tsk->ret_stack[index - graph].ret;
10119 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10120 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10121 graph++;
10122 }
10123 }
10124 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10125 return (struct reg_window *) (fp + STACK_BIAS);
10126 }
10127
10128 +extern void gr_handle_kernel_exploit(void);
10129 +
10130 void die_if_kernel(char *str, struct pt_regs *regs)
10131 {
10132 static int die_counter;
10133 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10134 while (rw &&
10135 count++ < 30 &&
10136 kstack_valid(tp, (unsigned long) rw)) {
10137 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10138 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10139 (void *) rw->ins[7]);
10140
10141 rw = kernel_stack_up(rw);
10142 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10143 }
10144 user_instruction_dump ((unsigned int __user *) regs->tpc);
10145 }
10146 - if (regs->tstate & TSTATE_PRIV)
10147 + if (regs->tstate & TSTATE_PRIV) {
10148 + gr_handle_kernel_exploit();
10149 do_exit(SIGKILL);
10150 + }
10151 do_exit(SIGSEGV);
10152 }
10153 EXPORT_SYMBOL(die_if_kernel);
10154 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10155 index 8201c25e..072a2a7 100644
10156 --- a/arch/sparc/kernel/unaligned_64.c
10157 +++ b/arch/sparc/kernel/unaligned_64.c
10158 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10159 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10160
10161 if (__ratelimit(&ratelimit)) {
10162 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10163 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10164 regs->tpc, (void *) regs->tpc);
10165 }
10166 }
10167 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10168 index dbe119b..089c7c1 100644
10169 --- a/arch/sparc/lib/Makefile
10170 +++ b/arch/sparc/lib/Makefile
10171 @@ -2,7 +2,7 @@
10172 #
10173
10174 asflags-y := -ansi -DST_DIV0=0x02
10175 -ccflags-y := -Werror
10176 +#ccflags-y := -Werror
10177
10178 lib-$(CONFIG_SPARC32) += ashrdi3.o
10179 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10180 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10181 index 85c233d..68500e0 100644
10182 --- a/arch/sparc/lib/atomic_64.S
10183 +++ b/arch/sparc/lib/atomic_64.S
10184 @@ -17,7 +17,12 @@
10185 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10186 BACKOFF_SETUP(%o2)
10187 1: lduw [%o1], %g1
10188 - add %g1, %o0, %g7
10189 + addcc %g1, %o0, %g7
10190 +
10191 +#ifdef CONFIG_PAX_REFCOUNT
10192 + tvs %icc, 6
10193 +#endif
10194 +
10195 cas [%o1], %g1, %g7
10196 cmp %g1, %g7
10197 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10198 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10199 2: BACKOFF_SPIN(%o2, %o3, 1b)
10200 ENDPROC(atomic_add)
10201
10202 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10203 + BACKOFF_SETUP(%o2)
10204 +1: lduw [%o1], %g1
10205 + add %g1, %o0, %g7
10206 + cas [%o1], %g1, %g7
10207 + cmp %g1, %g7
10208 + bne,pn %icc, 2f
10209 + nop
10210 + retl
10211 + nop
10212 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10213 +ENDPROC(atomic_add_unchecked)
10214 +
10215 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10216 BACKOFF_SETUP(%o2)
10217 1: lduw [%o1], %g1
10218 - sub %g1, %o0, %g7
10219 + subcc %g1, %o0, %g7
10220 +
10221 +#ifdef CONFIG_PAX_REFCOUNT
10222 + tvs %icc, 6
10223 +#endif
10224 +
10225 cas [%o1], %g1, %g7
10226 cmp %g1, %g7
10227 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10228 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10229 2: BACKOFF_SPIN(%o2, %o3, 1b)
10230 ENDPROC(atomic_sub)
10231
10232 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10233 + BACKOFF_SETUP(%o2)
10234 +1: lduw [%o1], %g1
10235 + sub %g1, %o0, %g7
10236 + cas [%o1], %g1, %g7
10237 + cmp %g1, %g7
10238 + bne,pn %icc, 2f
10239 + nop
10240 + retl
10241 + nop
10242 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10243 +ENDPROC(atomic_sub_unchecked)
10244 +
10245 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10246 BACKOFF_SETUP(%o2)
10247 1: lduw [%o1], %g1
10248 - add %g1, %o0, %g7
10249 + addcc %g1, %o0, %g7
10250 +
10251 +#ifdef CONFIG_PAX_REFCOUNT
10252 + tvs %icc, 6
10253 +#endif
10254 +
10255 cas [%o1], %g1, %g7
10256 cmp %g1, %g7
10257 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10258 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10259 2: BACKOFF_SPIN(%o2, %o3, 1b)
10260 ENDPROC(atomic_add_ret)
10261
10262 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10263 + BACKOFF_SETUP(%o2)
10264 +1: lduw [%o1], %g1
10265 + addcc %g1, %o0, %g7
10266 + cas [%o1], %g1, %g7
10267 + cmp %g1, %g7
10268 + bne,pn %icc, 2f
10269 + add %g7, %o0, %g7
10270 + sra %g7, 0, %o0
10271 + retl
10272 + nop
10273 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10274 +ENDPROC(atomic_add_ret_unchecked)
10275 +
10276 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10277 BACKOFF_SETUP(%o2)
10278 1: lduw [%o1], %g1
10279 - sub %g1, %o0, %g7
10280 + subcc %g1, %o0, %g7
10281 +
10282 +#ifdef CONFIG_PAX_REFCOUNT
10283 + tvs %icc, 6
10284 +#endif
10285 +
10286 cas [%o1], %g1, %g7
10287 cmp %g1, %g7
10288 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10289 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10290 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10291 BACKOFF_SETUP(%o2)
10292 1: ldx [%o1], %g1
10293 - add %g1, %o0, %g7
10294 + addcc %g1, %o0, %g7
10295 +
10296 +#ifdef CONFIG_PAX_REFCOUNT
10297 + tvs %xcc, 6
10298 +#endif
10299 +
10300 casx [%o1], %g1, %g7
10301 cmp %g1, %g7
10302 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10303 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10304 2: BACKOFF_SPIN(%o2, %o3, 1b)
10305 ENDPROC(atomic64_add)
10306
10307 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10308 + BACKOFF_SETUP(%o2)
10309 +1: ldx [%o1], %g1
10310 + addcc %g1, %o0, %g7
10311 + casx [%o1], %g1, %g7
10312 + cmp %g1, %g7
10313 + bne,pn %xcc, 2f
10314 + nop
10315 + retl
10316 + nop
10317 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10318 +ENDPROC(atomic64_add_unchecked)
10319 +
10320 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10321 BACKOFF_SETUP(%o2)
10322 1: ldx [%o1], %g1
10323 - sub %g1, %o0, %g7
10324 + subcc %g1, %o0, %g7
10325 +
10326 +#ifdef CONFIG_PAX_REFCOUNT
10327 + tvs %xcc, 6
10328 +#endif
10329 +
10330 casx [%o1], %g1, %g7
10331 cmp %g1, %g7
10332 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10333 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10334 2: BACKOFF_SPIN(%o2, %o3, 1b)
10335 ENDPROC(atomic64_sub)
10336
10337 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10338 + BACKOFF_SETUP(%o2)
10339 +1: ldx [%o1], %g1
10340 + subcc %g1, %o0, %g7
10341 + casx [%o1], %g1, %g7
10342 + cmp %g1, %g7
10343 + bne,pn %xcc, 2f
10344 + nop
10345 + retl
10346 + nop
10347 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10348 +ENDPROC(atomic64_sub_unchecked)
10349 +
10350 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10351 BACKOFF_SETUP(%o2)
10352 1: ldx [%o1], %g1
10353 - add %g1, %o0, %g7
10354 + addcc %g1, %o0, %g7
10355 +
10356 +#ifdef CONFIG_PAX_REFCOUNT
10357 + tvs %xcc, 6
10358 +#endif
10359 +
10360 casx [%o1], %g1, %g7
10361 cmp %g1, %g7
10362 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10363 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10364 2: BACKOFF_SPIN(%o2, %o3, 1b)
10365 ENDPROC(atomic64_add_ret)
10366
10367 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10368 + BACKOFF_SETUP(%o2)
10369 +1: ldx [%o1], %g1
10370 + addcc %g1, %o0, %g7
10371 + casx [%o1], %g1, %g7
10372 + cmp %g1, %g7
10373 + bne,pn %xcc, 2f
10374 + add %g7, %o0, %g7
10375 + mov %g7, %o0
10376 + retl
10377 + nop
10378 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10379 +ENDPROC(atomic64_add_ret_unchecked)
10380 +
10381 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10382 BACKOFF_SETUP(%o2)
10383 1: ldx [%o1], %g1
10384 - sub %g1, %o0, %g7
10385 + subcc %g1, %o0, %g7
10386 +
10387 +#ifdef CONFIG_PAX_REFCOUNT
10388 + tvs %xcc, 6
10389 +#endif
10390 +
10391 casx [%o1], %g1, %g7
10392 cmp %g1, %g7
10393 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10394 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10395 index 323335b..ed85ea2 100644
10396 --- a/arch/sparc/lib/ksyms.c
10397 +++ b/arch/sparc/lib/ksyms.c
10398 @@ -100,12 +100,18 @@ EXPORT_SYMBOL(__clear_user);
10399
10400 /* Atomic counter implementation. */
10401 EXPORT_SYMBOL(atomic_add);
10402 +EXPORT_SYMBOL(atomic_add_unchecked);
10403 EXPORT_SYMBOL(atomic_add_ret);
10404 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10405 EXPORT_SYMBOL(atomic_sub);
10406 +EXPORT_SYMBOL(atomic_sub_unchecked);
10407 EXPORT_SYMBOL(atomic_sub_ret);
10408 EXPORT_SYMBOL(atomic64_add);
10409 +EXPORT_SYMBOL(atomic64_add_unchecked);
10410 EXPORT_SYMBOL(atomic64_add_ret);
10411 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10412 EXPORT_SYMBOL(atomic64_sub);
10413 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10414 EXPORT_SYMBOL(atomic64_sub_ret);
10415 EXPORT_SYMBOL(atomic64_dec_if_positive);
10416
10417 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10418 index 30c3ecc..736f015 100644
10419 --- a/arch/sparc/mm/Makefile
10420 +++ b/arch/sparc/mm/Makefile
10421 @@ -2,7 +2,7 @@
10422 #
10423
10424 asflags-y := -ansi
10425 -ccflags-y := -Werror
10426 +#ccflags-y := -Werror
10427
10428 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10429 obj-y += fault_$(BITS).o
10430 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10431 index 59dbd46..1dd7f5e 100644
10432 --- a/arch/sparc/mm/fault_32.c
10433 +++ b/arch/sparc/mm/fault_32.c
10434 @@ -21,6 +21,9 @@
10435 #include <linux/perf_event.h>
10436 #include <linux/interrupt.h>
10437 #include <linux/kdebug.h>
10438 +#include <linux/slab.h>
10439 +#include <linux/pagemap.h>
10440 +#include <linux/compiler.h>
10441
10442 #include <asm/page.h>
10443 #include <asm/pgtable.h>
10444 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10445 return safe_compute_effective_address(regs, insn);
10446 }
10447
10448 +#ifdef CONFIG_PAX_PAGEEXEC
10449 +#ifdef CONFIG_PAX_DLRESOLVE
10450 +static void pax_emuplt_close(struct vm_area_struct *vma)
10451 +{
10452 + vma->vm_mm->call_dl_resolve = 0UL;
10453 +}
10454 +
10455 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10456 +{
10457 + unsigned int *kaddr;
10458 +
10459 + vmf->page = alloc_page(GFP_HIGHUSER);
10460 + if (!vmf->page)
10461 + return VM_FAULT_OOM;
10462 +
10463 + kaddr = kmap(vmf->page);
10464 + memset(kaddr, 0, PAGE_SIZE);
10465 + kaddr[0] = 0x9DE3BFA8U; /* save */
10466 + flush_dcache_page(vmf->page);
10467 + kunmap(vmf->page);
10468 + return VM_FAULT_MAJOR;
10469 +}
10470 +
10471 +static const struct vm_operations_struct pax_vm_ops = {
10472 + .close = pax_emuplt_close,
10473 + .fault = pax_emuplt_fault
10474 +};
10475 +
10476 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10477 +{
10478 + int ret;
10479 +
10480 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10481 + vma->vm_mm = current->mm;
10482 + vma->vm_start = addr;
10483 + vma->vm_end = addr + PAGE_SIZE;
10484 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10485 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10486 + vma->vm_ops = &pax_vm_ops;
10487 +
10488 + ret = insert_vm_struct(current->mm, vma);
10489 + if (ret)
10490 + return ret;
10491 +
10492 + ++current->mm->total_vm;
10493 + return 0;
10494 +}
10495 +#endif
10496 +
10497 +/*
10498 + * PaX: decide what to do with offenders (regs->pc = fault address)
10499 + *
10500 + * returns 1 when task should be killed
10501 + * 2 when patched PLT trampoline was detected
10502 + * 3 when unpatched PLT trampoline was detected
10503 + */
10504 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10505 +{
10506 +
10507 +#ifdef CONFIG_PAX_EMUPLT
10508 + int err;
10509 +
10510 + do { /* PaX: patched PLT emulation #1 */
10511 + unsigned int sethi1, sethi2, jmpl;
10512 +
10513 + err = get_user(sethi1, (unsigned int *)regs->pc);
10514 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10515 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10516 +
10517 + if (err)
10518 + break;
10519 +
10520 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10521 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10522 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10523 + {
10524 + unsigned int addr;
10525 +
10526 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10527 + addr = regs->u_regs[UREG_G1];
10528 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10529 + regs->pc = addr;
10530 + regs->npc = addr+4;
10531 + return 2;
10532 + }
10533 + } while (0);
10534 +
10535 + do { /* PaX: patched PLT emulation #2 */
10536 + unsigned int ba;
10537 +
10538 + err = get_user(ba, (unsigned int *)regs->pc);
10539 +
10540 + if (err)
10541 + break;
10542 +
10543 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10544 + unsigned int addr;
10545 +
10546 + if ((ba & 0xFFC00000U) == 0x30800000U)
10547 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10548 + else
10549 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10550 + regs->pc = addr;
10551 + regs->npc = addr+4;
10552 + return 2;
10553 + }
10554 + } while (0);
10555 +
10556 + do { /* PaX: patched PLT emulation #3 */
10557 + unsigned int sethi, bajmpl, nop;
10558 +
10559 + err = get_user(sethi, (unsigned int *)regs->pc);
10560 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10561 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10562 +
10563 + if (err)
10564 + break;
10565 +
10566 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10567 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10568 + nop == 0x01000000U)
10569 + {
10570 + unsigned int addr;
10571 +
10572 + addr = (sethi & 0x003FFFFFU) << 10;
10573 + regs->u_regs[UREG_G1] = addr;
10574 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10575 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10576 + else
10577 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10578 + regs->pc = addr;
10579 + regs->npc = addr+4;
10580 + return 2;
10581 + }
10582 + } while (0);
10583 +
10584 + do { /* PaX: unpatched PLT emulation step 1 */
10585 + unsigned int sethi, ba, nop;
10586 +
10587 + err = get_user(sethi, (unsigned int *)regs->pc);
10588 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10589 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10590 +
10591 + if (err)
10592 + break;
10593 +
10594 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10595 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10596 + nop == 0x01000000U)
10597 + {
10598 + unsigned int addr, save, call;
10599 +
10600 + if ((ba & 0xFFC00000U) == 0x30800000U)
10601 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10602 + else
10603 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10604 +
10605 + err = get_user(save, (unsigned int *)addr);
10606 + err |= get_user(call, (unsigned int *)(addr+4));
10607 + err |= get_user(nop, (unsigned int *)(addr+8));
10608 + if (err)
10609 + break;
10610 +
10611 +#ifdef CONFIG_PAX_DLRESOLVE
10612 + if (save == 0x9DE3BFA8U &&
10613 + (call & 0xC0000000U) == 0x40000000U &&
10614 + nop == 0x01000000U)
10615 + {
10616 + struct vm_area_struct *vma;
10617 + unsigned long call_dl_resolve;
10618 +
10619 + down_read(&current->mm->mmap_sem);
10620 + call_dl_resolve = current->mm->call_dl_resolve;
10621 + up_read(&current->mm->mmap_sem);
10622 + if (likely(call_dl_resolve))
10623 + goto emulate;
10624 +
10625 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10626 +
10627 + down_write(&current->mm->mmap_sem);
10628 + if (current->mm->call_dl_resolve) {
10629 + call_dl_resolve = current->mm->call_dl_resolve;
10630 + up_write(&current->mm->mmap_sem);
10631 + if (vma)
10632 + kmem_cache_free(vm_area_cachep, vma);
10633 + goto emulate;
10634 + }
10635 +
10636 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10637 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10638 + up_write(&current->mm->mmap_sem);
10639 + if (vma)
10640 + kmem_cache_free(vm_area_cachep, vma);
10641 + return 1;
10642 + }
10643 +
10644 + if (pax_insert_vma(vma, call_dl_resolve)) {
10645 + up_write(&current->mm->mmap_sem);
10646 + kmem_cache_free(vm_area_cachep, vma);
10647 + return 1;
10648 + }
10649 +
10650 + current->mm->call_dl_resolve = call_dl_resolve;
10651 + up_write(&current->mm->mmap_sem);
10652 +
10653 +emulate:
10654 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10655 + regs->pc = call_dl_resolve;
10656 + regs->npc = addr+4;
10657 + return 3;
10658 + }
10659 +#endif
10660 +
10661 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10662 + if ((save & 0xFFC00000U) == 0x05000000U &&
10663 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10664 + nop == 0x01000000U)
10665 + {
10666 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10667 + regs->u_regs[UREG_G2] = addr + 4;
10668 + addr = (save & 0x003FFFFFU) << 10;
10669 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10670 + regs->pc = addr;
10671 + regs->npc = addr+4;
10672 + return 3;
10673 + }
10674 + }
10675 + } while (0);
10676 +
10677 + do { /* PaX: unpatched PLT emulation step 2 */
10678 + unsigned int save, call, nop;
10679 +
10680 + err = get_user(save, (unsigned int *)(regs->pc-4));
10681 + err |= get_user(call, (unsigned int *)regs->pc);
10682 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10683 + if (err)
10684 + break;
10685 +
10686 + if (save == 0x9DE3BFA8U &&
10687 + (call & 0xC0000000U) == 0x40000000U &&
10688 + nop == 0x01000000U)
10689 + {
10690 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10691 +
10692 + regs->u_regs[UREG_RETPC] = regs->pc;
10693 + regs->pc = dl_resolve;
10694 + regs->npc = dl_resolve+4;
10695 + return 3;
10696 + }
10697 + } while (0);
10698 +#endif
10699 +
10700 + return 1;
10701 +}
10702 +
10703 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10704 +{
10705 + unsigned long i;
10706 +
10707 + printk(KERN_ERR "PAX: bytes at PC: ");
10708 + for (i = 0; i < 8; i++) {
10709 + unsigned int c;
10710 + if (get_user(c, (unsigned int *)pc+i))
10711 + printk(KERN_CONT "???????? ");
10712 + else
10713 + printk(KERN_CONT "%08x ", c);
10714 + }
10715 + printk("\n");
10716 +}
10717 +#endif
10718 +
10719 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10720 int text_fault)
10721 {
10722 @@ -229,6 +503,24 @@ good_area:
10723 if (!(vma->vm_flags & VM_WRITE))
10724 goto bad_area;
10725 } else {
10726 +
10727 +#ifdef CONFIG_PAX_PAGEEXEC
10728 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10729 + up_read(&mm->mmap_sem);
10730 + switch (pax_handle_fetch_fault(regs)) {
10731 +
10732 +#ifdef CONFIG_PAX_EMUPLT
10733 + case 2:
10734 + case 3:
10735 + return;
10736 +#endif
10737 +
10738 + }
10739 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10740 + do_group_exit(SIGKILL);
10741 + }
10742 +#endif
10743 +
10744 /* Allow reads even for write-only mappings */
10745 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10746 goto bad_area;
10747 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10748 index 2ebec26..b212598 100644
10749 --- a/arch/sparc/mm/fault_64.c
10750 +++ b/arch/sparc/mm/fault_64.c
10751 @@ -21,6 +21,9 @@
10752 #include <linux/kprobes.h>
10753 #include <linux/kdebug.h>
10754 #include <linux/percpu.h>
10755 +#include <linux/slab.h>
10756 +#include <linux/pagemap.h>
10757 +#include <linux/compiler.h>
10758
10759 #include <asm/page.h>
10760 #include <asm/pgtable.h>
10761 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10762 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10763 regs->tpc);
10764 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10765 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10766 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10767 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10768 dump_stack();
10769 unhandled_fault(regs->tpc, current, regs);
10770 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10771 show_regs(regs);
10772 }
10773
10774 +#ifdef CONFIG_PAX_PAGEEXEC
10775 +#ifdef CONFIG_PAX_DLRESOLVE
10776 +static void pax_emuplt_close(struct vm_area_struct *vma)
10777 +{
10778 + vma->vm_mm->call_dl_resolve = 0UL;
10779 +}
10780 +
10781 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10782 +{
10783 + unsigned int *kaddr;
10784 +
10785 + vmf->page = alloc_page(GFP_HIGHUSER);
10786 + if (!vmf->page)
10787 + return VM_FAULT_OOM;
10788 +
10789 + kaddr = kmap(vmf->page);
10790 + memset(kaddr, 0, PAGE_SIZE);
10791 + kaddr[0] = 0x9DE3BFA8U; /* save */
10792 + flush_dcache_page(vmf->page);
10793 + kunmap(vmf->page);
10794 + return VM_FAULT_MAJOR;
10795 +}
10796 +
10797 +static const struct vm_operations_struct pax_vm_ops = {
10798 + .close = pax_emuplt_close,
10799 + .fault = pax_emuplt_fault
10800 +};
10801 +
10802 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10803 +{
10804 + int ret;
10805 +
10806 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10807 + vma->vm_mm = current->mm;
10808 + vma->vm_start = addr;
10809 + vma->vm_end = addr + PAGE_SIZE;
10810 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10811 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10812 + vma->vm_ops = &pax_vm_ops;
10813 +
10814 + ret = insert_vm_struct(current->mm, vma);
10815 + if (ret)
10816 + return ret;
10817 +
10818 + ++current->mm->total_vm;
10819 + return 0;
10820 +}
10821 +#endif
10822 +
10823 +/*
10824 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10825 + *
10826 + * returns 1 when task should be killed
10827 + * 2 when patched PLT trampoline was detected
10828 + * 3 when unpatched PLT trampoline was detected
10829 + */
10830 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10831 +{
10832 +
10833 +#ifdef CONFIG_PAX_EMUPLT
10834 + int err;
10835 +
10836 + do { /* PaX: patched PLT emulation #1 */
10837 + unsigned int sethi1, sethi2, jmpl;
10838 +
10839 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10840 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10841 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10842 +
10843 + if (err)
10844 + break;
10845 +
10846 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10847 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10848 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10849 + {
10850 + unsigned long addr;
10851 +
10852 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10853 + addr = regs->u_regs[UREG_G1];
10854 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10855 +
10856 + if (test_thread_flag(TIF_32BIT))
10857 + addr &= 0xFFFFFFFFUL;
10858 +
10859 + regs->tpc = addr;
10860 + regs->tnpc = addr+4;
10861 + return 2;
10862 + }
10863 + } while (0);
10864 +
10865 + do { /* PaX: patched PLT emulation #2 */
10866 + unsigned int ba;
10867 +
10868 + err = get_user(ba, (unsigned int *)regs->tpc);
10869 +
10870 + if (err)
10871 + break;
10872 +
10873 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10874 + unsigned long addr;
10875 +
10876 + if ((ba & 0xFFC00000U) == 0x30800000U)
10877 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10878 + else
10879 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10880 +
10881 + if (test_thread_flag(TIF_32BIT))
10882 + addr &= 0xFFFFFFFFUL;
10883 +
10884 + regs->tpc = addr;
10885 + regs->tnpc = addr+4;
10886 + return 2;
10887 + }
10888 + } while (0);
10889 +
10890 + do { /* PaX: patched PLT emulation #3 */
10891 + unsigned int sethi, bajmpl, nop;
10892 +
10893 + err = get_user(sethi, (unsigned int *)regs->tpc);
10894 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10895 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10896 +
10897 + if (err)
10898 + break;
10899 +
10900 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10901 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10902 + nop == 0x01000000U)
10903 + {
10904 + unsigned long addr;
10905 +
10906 + addr = (sethi & 0x003FFFFFU) << 10;
10907 + regs->u_regs[UREG_G1] = addr;
10908 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10909 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10910 + else
10911 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10912 +
10913 + if (test_thread_flag(TIF_32BIT))
10914 + addr &= 0xFFFFFFFFUL;
10915 +
10916 + regs->tpc = addr;
10917 + regs->tnpc = addr+4;
10918 + return 2;
10919 + }
10920 + } while (0);
10921 +
10922 + do { /* PaX: patched PLT emulation #4 */
10923 + unsigned int sethi, mov1, call, mov2;
10924 +
10925 + err = get_user(sethi, (unsigned int *)regs->tpc);
10926 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10927 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10928 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10929 +
10930 + if (err)
10931 + break;
10932 +
10933 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10934 + mov1 == 0x8210000FU &&
10935 + (call & 0xC0000000U) == 0x40000000U &&
10936 + mov2 == 0x9E100001U)
10937 + {
10938 + unsigned long addr;
10939 +
10940 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10941 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10942 +
10943 + if (test_thread_flag(TIF_32BIT))
10944 + addr &= 0xFFFFFFFFUL;
10945 +
10946 + regs->tpc = addr;
10947 + regs->tnpc = addr+4;
10948 + return 2;
10949 + }
10950 + } while (0);
10951 +
10952 + do { /* PaX: patched PLT emulation #5 */
10953 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10954 +
10955 + err = get_user(sethi, (unsigned int *)regs->tpc);
10956 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10957 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10958 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10959 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10960 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10961 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10962 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10963 +
10964 + if (err)
10965 + break;
10966 +
10967 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10968 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10969 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10970 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10971 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10972 + sllx == 0x83287020U &&
10973 + jmpl == 0x81C04005U &&
10974 + nop == 0x01000000U)
10975 + {
10976 + unsigned long addr;
10977 +
10978 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10979 + regs->u_regs[UREG_G1] <<= 32;
10980 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10981 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10982 + regs->tpc = addr;
10983 + regs->tnpc = addr+4;
10984 + return 2;
10985 + }
10986 + } while (0);
10987 +
10988 + do { /* PaX: patched PLT emulation #6 */
10989 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10990 +
10991 + err = get_user(sethi, (unsigned int *)regs->tpc);
10992 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10993 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10994 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10995 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10996 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10997 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10998 +
10999 + if (err)
11000 + break;
11001 +
11002 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11003 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
11004 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11005 + sllx == 0x83287020U &&
11006 + (or & 0xFFFFE000U) == 0x8A116000U &&
11007 + jmpl == 0x81C04005U &&
11008 + nop == 0x01000000U)
11009 + {
11010 + unsigned long addr;
11011 +
11012 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
11013 + regs->u_regs[UREG_G1] <<= 32;
11014 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
11015 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
11016 + regs->tpc = addr;
11017 + regs->tnpc = addr+4;
11018 + return 2;
11019 + }
11020 + } while (0);
11021 +
11022 + do { /* PaX: unpatched PLT emulation step 1 */
11023 + unsigned int sethi, ba, nop;
11024 +
11025 + err = get_user(sethi, (unsigned int *)regs->tpc);
11026 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11027 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11028 +
11029 + if (err)
11030 + break;
11031 +
11032 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11033 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
11034 + nop == 0x01000000U)
11035 + {
11036 + unsigned long addr;
11037 + unsigned int save, call;
11038 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
11039 +
11040 + if ((ba & 0xFFC00000U) == 0x30800000U)
11041 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
11042 + else
11043 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11044 +
11045 + if (test_thread_flag(TIF_32BIT))
11046 + addr &= 0xFFFFFFFFUL;
11047 +
11048 + err = get_user(save, (unsigned int *)addr);
11049 + err |= get_user(call, (unsigned int *)(addr+4));
11050 + err |= get_user(nop, (unsigned int *)(addr+8));
11051 + if (err)
11052 + break;
11053 +
11054 +#ifdef CONFIG_PAX_DLRESOLVE
11055 + if (save == 0x9DE3BFA8U &&
11056 + (call & 0xC0000000U) == 0x40000000U &&
11057 + nop == 0x01000000U)
11058 + {
11059 + struct vm_area_struct *vma;
11060 + unsigned long call_dl_resolve;
11061 +
11062 + down_read(&current->mm->mmap_sem);
11063 + call_dl_resolve = current->mm->call_dl_resolve;
11064 + up_read(&current->mm->mmap_sem);
11065 + if (likely(call_dl_resolve))
11066 + goto emulate;
11067 +
11068 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
11069 +
11070 + down_write(&current->mm->mmap_sem);
11071 + if (current->mm->call_dl_resolve) {
11072 + call_dl_resolve = current->mm->call_dl_resolve;
11073 + up_write(&current->mm->mmap_sem);
11074 + if (vma)
11075 + kmem_cache_free(vm_area_cachep, vma);
11076 + goto emulate;
11077 + }
11078 +
11079 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11080 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11081 + up_write(&current->mm->mmap_sem);
11082 + if (vma)
11083 + kmem_cache_free(vm_area_cachep, vma);
11084 + return 1;
11085 + }
11086 +
11087 + if (pax_insert_vma(vma, call_dl_resolve)) {
11088 + up_write(&current->mm->mmap_sem);
11089 + kmem_cache_free(vm_area_cachep, vma);
11090 + return 1;
11091 + }
11092 +
11093 + current->mm->call_dl_resolve = call_dl_resolve;
11094 + up_write(&current->mm->mmap_sem);
11095 +
11096 +emulate:
11097 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11098 + regs->tpc = call_dl_resolve;
11099 + regs->tnpc = addr+4;
11100 + return 3;
11101 + }
11102 +#endif
11103 +
11104 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11105 + if ((save & 0xFFC00000U) == 0x05000000U &&
11106 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11107 + nop == 0x01000000U)
11108 + {
11109 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11110 + regs->u_regs[UREG_G2] = addr + 4;
11111 + addr = (save & 0x003FFFFFU) << 10;
11112 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11113 +
11114 + if (test_thread_flag(TIF_32BIT))
11115 + addr &= 0xFFFFFFFFUL;
11116 +
11117 + regs->tpc = addr;
11118 + regs->tnpc = addr+4;
11119 + return 3;
11120 + }
11121 +
11122 + /* PaX: 64-bit PLT stub */
11123 + err = get_user(sethi1, (unsigned int *)addr);
11124 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11125 + err |= get_user(or1, (unsigned int *)(addr+8));
11126 + err |= get_user(or2, (unsigned int *)(addr+12));
11127 + err |= get_user(sllx, (unsigned int *)(addr+16));
11128 + err |= get_user(add, (unsigned int *)(addr+20));
11129 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11130 + err |= get_user(nop, (unsigned int *)(addr+28));
11131 + if (err)
11132 + break;
11133 +
11134 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11135 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11136 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11137 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11138 + sllx == 0x89293020U &&
11139 + add == 0x8A010005U &&
11140 + jmpl == 0x89C14000U &&
11141 + nop == 0x01000000U)
11142 + {
11143 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11144 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11145 + regs->u_regs[UREG_G4] <<= 32;
11146 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11147 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11148 + regs->u_regs[UREG_G4] = addr + 24;
11149 + addr = regs->u_regs[UREG_G5];
11150 + regs->tpc = addr;
11151 + regs->tnpc = addr+4;
11152 + return 3;
11153 + }
11154 + }
11155 + } while (0);
11156 +
11157 +#ifdef CONFIG_PAX_DLRESOLVE
11158 + do { /* PaX: unpatched PLT emulation step 2 */
11159 + unsigned int save, call, nop;
11160 +
11161 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11162 + err |= get_user(call, (unsigned int *)regs->tpc);
11163 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11164 + if (err)
11165 + break;
11166 +
11167 + if (save == 0x9DE3BFA8U &&
11168 + (call & 0xC0000000U) == 0x40000000U &&
11169 + nop == 0x01000000U)
11170 + {
11171 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11172 +
11173 + if (test_thread_flag(TIF_32BIT))
11174 + dl_resolve &= 0xFFFFFFFFUL;
11175 +
11176 + regs->u_regs[UREG_RETPC] = regs->tpc;
11177 + regs->tpc = dl_resolve;
11178 + regs->tnpc = dl_resolve+4;
11179 + return 3;
11180 + }
11181 + } while (0);
11182 +#endif
11183 +
11184 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11185 + unsigned int sethi, ba, nop;
11186 +
11187 + err = get_user(sethi, (unsigned int *)regs->tpc);
11188 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11189 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11190 +
11191 + if (err)
11192 + break;
11193 +
11194 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11195 + (ba & 0xFFF00000U) == 0x30600000U &&
11196 + nop == 0x01000000U)
11197 + {
11198 + unsigned long addr;
11199 +
11200 + addr = (sethi & 0x003FFFFFU) << 10;
11201 + regs->u_regs[UREG_G1] = addr;
11202 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11203 +
11204 + if (test_thread_flag(TIF_32BIT))
11205 + addr &= 0xFFFFFFFFUL;
11206 +
11207 + regs->tpc = addr;
11208 + regs->tnpc = addr+4;
11209 + return 2;
11210 + }
11211 + } while (0);
11212 +
11213 +#endif
11214 +
11215 + return 1;
11216 +}
11217 +
11218 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11219 +{
11220 + unsigned long i;
11221 +
11222 + printk(KERN_ERR "PAX: bytes at PC: ");
11223 + for (i = 0; i < 8; i++) {
11224 + unsigned int c;
11225 + if (get_user(c, (unsigned int *)pc+i))
11226 + printk(KERN_CONT "???????? ");
11227 + else
11228 + printk(KERN_CONT "%08x ", c);
11229 + }
11230 + printk("\n");
11231 +}
11232 +#endif
11233 +
11234 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11235 {
11236 struct mm_struct *mm = current->mm;
11237 @@ -342,6 +805,29 @@ retry:
11238 if (!vma)
11239 goto bad_area;
11240
11241 +#ifdef CONFIG_PAX_PAGEEXEC
11242 + /* PaX: detect ITLB misses on non-exec pages */
11243 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11244 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11245 + {
11246 + if (address != regs->tpc)
11247 + goto good_area;
11248 +
11249 + up_read(&mm->mmap_sem);
11250 + switch (pax_handle_fetch_fault(regs)) {
11251 +
11252 +#ifdef CONFIG_PAX_EMUPLT
11253 + case 2:
11254 + case 3:
11255 + return;
11256 +#endif
11257 +
11258 + }
11259 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11260 + do_group_exit(SIGKILL);
11261 + }
11262 +#endif
11263 +
11264 /* Pure DTLB misses do not tell us whether the fault causing
11265 * load/store/atomic was a write or not, it only says that there
11266 * was no match. So in such a case we (carefully) read the
11267 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11268 index 9639964..806cd0c 100644
11269 --- a/arch/sparc/mm/hugetlbpage.c
11270 +++ b/arch/sparc/mm/hugetlbpage.c
11271 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11272 unsigned long addr,
11273 unsigned long len,
11274 unsigned long pgoff,
11275 - unsigned long flags)
11276 + unsigned long flags,
11277 + unsigned long offset)
11278 {
11279 unsigned long task_size = TASK_SIZE;
11280 struct vm_unmapped_area_info info;
11281 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11282
11283 info.flags = 0;
11284 info.length = len;
11285 - info.low_limit = TASK_UNMAPPED_BASE;
11286 + info.low_limit = mm->mmap_base;
11287 info.high_limit = min(task_size, VA_EXCLUDE_START);
11288 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11289 info.align_offset = 0;
11290 + info.threadstack_offset = offset;
11291 addr = vm_unmapped_area(&info);
11292
11293 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11294 VM_BUG_ON(addr != -ENOMEM);
11295 info.low_limit = VA_EXCLUDE_END;
11296 +
11297 +#ifdef CONFIG_PAX_RANDMMAP
11298 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11299 + info.low_limit += mm->delta_mmap;
11300 +#endif
11301 +
11302 info.high_limit = task_size;
11303 addr = vm_unmapped_area(&info);
11304 }
11305 @@ -58,7 +66,8 @@ static unsigned long
11306 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11307 const unsigned long len,
11308 const unsigned long pgoff,
11309 - const unsigned long flags)
11310 + const unsigned long flags,
11311 + const unsigned long offset)
11312 {
11313 struct mm_struct *mm = current->mm;
11314 unsigned long addr = addr0;
11315 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11316 info.high_limit = mm->mmap_base;
11317 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11318 info.align_offset = 0;
11319 + info.threadstack_offset = offset;
11320 addr = vm_unmapped_area(&info);
11321
11322 /*
11323 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11324 VM_BUG_ON(addr != -ENOMEM);
11325 info.flags = 0;
11326 info.low_limit = TASK_UNMAPPED_BASE;
11327 +
11328 +#ifdef CONFIG_PAX_RANDMMAP
11329 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11330 + info.low_limit += mm->delta_mmap;
11331 +#endif
11332 +
11333 info.high_limit = STACK_TOP32;
11334 addr = vm_unmapped_area(&info);
11335 }
11336 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11337 struct mm_struct *mm = current->mm;
11338 struct vm_area_struct *vma;
11339 unsigned long task_size = TASK_SIZE;
11340 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11341
11342 if (test_thread_flag(TIF_32BIT))
11343 task_size = STACK_TOP32;
11344 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11345 return addr;
11346 }
11347
11348 +#ifdef CONFIG_PAX_RANDMMAP
11349 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11350 +#endif
11351 +
11352 if (addr) {
11353 addr = ALIGN(addr, HPAGE_SIZE);
11354 vma = find_vma(mm, addr);
11355 - if (task_size - len >= addr &&
11356 - (!vma || addr + len <= vma->vm_start))
11357 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11358 return addr;
11359 }
11360 if (mm->get_unmapped_area == arch_get_unmapped_area)
11361 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11362 - pgoff, flags);
11363 + pgoff, flags, offset);
11364 else
11365 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11366 - pgoff, flags);
11367 + pgoff, flags, offset);
11368 }
11369
11370 pte_t *huge_pte_alloc(struct mm_struct *mm,
11371 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11372 index ed82eda..0d80e77 100644
11373 --- a/arch/sparc/mm/init_64.c
11374 +++ b/arch/sparc/mm/init_64.c
11375 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11376 int num_kernel_image_mappings;
11377
11378 #ifdef CONFIG_DEBUG_DCFLUSH
11379 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11380 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11381 #ifdef CONFIG_SMP
11382 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11383 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11384 #endif
11385 #endif
11386
11387 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11388 {
11389 BUG_ON(tlb_type == hypervisor);
11390 #ifdef CONFIG_DEBUG_DCFLUSH
11391 - atomic_inc(&dcpage_flushes);
11392 + atomic_inc_unchecked(&dcpage_flushes);
11393 #endif
11394
11395 #ifdef DCACHE_ALIASING_POSSIBLE
11396 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11397
11398 #ifdef CONFIG_DEBUG_DCFLUSH
11399 seq_printf(m, "DCPageFlushes\t: %d\n",
11400 - atomic_read(&dcpage_flushes));
11401 + atomic_read_unchecked(&dcpage_flushes));
11402 #ifdef CONFIG_SMP
11403 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11404 - atomic_read(&dcpage_flushes_xcall));
11405 + atomic_read_unchecked(&dcpage_flushes_xcall));
11406 #endif /* CONFIG_SMP */
11407 #endif /* CONFIG_DEBUG_DCFLUSH */
11408 }
11409 diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
11410 index d45a2c4..3c05a78 100644
11411 --- a/arch/tile/Kconfig
11412 +++ b/arch/tile/Kconfig
11413 @@ -185,6 +185,7 @@ source "kernel/Kconfig.hz"
11414
11415 config KEXEC
11416 bool "kexec system call"
11417 + depends on !GRKERNSEC_KMEM
11418 ---help---
11419 kexec is a system call that implements the ability to shutdown your
11420 current kernel, and to start another kernel. It is like a reboot
11421 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11422 index ad220ee..2f537b3 100644
11423 --- a/arch/tile/include/asm/atomic_64.h
11424 +++ b/arch/tile/include/asm/atomic_64.h
11425 @@ -105,6 +105,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11426
11427 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11428
11429 +#define atomic64_read_unchecked(v) atomic64_read(v)
11430 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11431 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11432 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11433 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11434 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11435 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11436 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11437 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11438 +
11439 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11440 #define smp_mb__before_atomic_dec() smp_mb()
11441 #define smp_mb__after_atomic_dec() smp_mb()
11442 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11443 index 6160761..00cac88 100644
11444 --- a/arch/tile/include/asm/cache.h
11445 +++ b/arch/tile/include/asm/cache.h
11446 @@ -15,11 +15,12 @@
11447 #ifndef _ASM_TILE_CACHE_H
11448 #define _ASM_TILE_CACHE_H
11449
11450 +#include <linux/const.h>
11451 #include <arch/chip.h>
11452
11453 /* bytes per L1 data cache line */
11454 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11455 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11456 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11457
11458 /* bytes per L2 cache line */
11459 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11460 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11461 index b6cde32..c0cb736 100644
11462 --- a/arch/tile/include/asm/uaccess.h
11463 +++ b/arch/tile/include/asm/uaccess.h
11464 @@ -414,9 +414,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11465 const void __user *from,
11466 unsigned long n)
11467 {
11468 - int sz = __compiletime_object_size(to);
11469 + size_t sz = __compiletime_object_size(to);
11470
11471 - if (likely(sz == -1 || sz >= n))
11472 + if (likely(sz == (size_t)-1 || sz >= n))
11473 n = _copy_from_user(to, from, n);
11474 else
11475 copy_from_user_overflow();
11476 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11477 index 0cb3bba..7338b2d 100644
11478 --- a/arch/tile/mm/hugetlbpage.c
11479 +++ b/arch/tile/mm/hugetlbpage.c
11480 @@ -212,6 +212,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11481 info.high_limit = TASK_SIZE;
11482 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11483 info.align_offset = 0;
11484 + info.threadstack_offset = 0;
11485 return vm_unmapped_area(&info);
11486 }
11487
11488 @@ -229,6 +230,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11489 info.high_limit = current->mm->mmap_base;
11490 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11491 info.align_offset = 0;
11492 + info.threadstack_offset = 0;
11493 addr = vm_unmapped_area(&info);
11494
11495 /*
11496 diff --git a/arch/um/Makefile b/arch/um/Makefile
11497 index 133f7de..1d6f2f1 100644
11498 --- a/arch/um/Makefile
11499 +++ b/arch/um/Makefile
11500 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11501 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11502 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11503
11504 +ifdef CONSTIFY_PLUGIN
11505 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11506 +endif
11507 +
11508 #This will adjust *FLAGS accordingly to the platform.
11509 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11510
11511 diff --git a/arch/um/defconfig b/arch/um/defconfig
11512 index 2665e6b..3e3822b 100644
11513 --- a/arch/um/defconfig
11514 +++ b/arch/um/defconfig
11515 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11516 CONFIG_X86_L1_CACHE_SHIFT=5
11517 CONFIG_X86_XADD=y
11518 CONFIG_X86_PPRO_FENCE=y
11519 -CONFIG_X86_WP_WORKS_OK=y
11520 CONFIG_X86_INVLPG=y
11521 CONFIG_X86_BSWAP=y
11522 CONFIG_X86_POPAD_OK=y
11523 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11524 index 19e1bdd..3665b77 100644
11525 --- a/arch/um/include/asm/cache.h
11526 +++ b/arch/um/include/asm/cache.h
11527 @@ -1,6 +1,7 @@
11528 #ifndef __UM_CACHE_H
11529 #define __UM_CACHE_H
11530
11531 +#include <linux/const.h>
11532
11533 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11534 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11535 @@ -12,6 +13,6 @@
11536 # define L1_CACHE_SHIFT 5
11537 #endif
11538
11539 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11540 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11541
11542 #endif
11543 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11544 index 2e0a6b1..a64d0f5 100644
11545 --- a/arch/um/include/asm/kmap_types.h
11546 +++ b/arch/um/include/asm/kmap_types.h
11547 @@ -8,6 +8,6 @@
11548
11549 /* No more #include "asm/arch/kmap_types.h" ! */
11550
11551 -#define KM_TYPE_NR 14
11552 +#define KM_TYPE_NR 15
11553
11554 #endif
11555 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11556 index 5ff53d9..5850cdf 100644
11557 --- a/arch/um/include/asm/page.h
11558 +++ b/arch/um/include/asm/page.h
11559 @@ -14,6 +14,9 @@
11560 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11561 #define PAGE_MASK (~(PAGE_SIZE-1))
11562
11563 +#define ktla_ktva(addr) (addr)
11564 +#define ktva_ktla(addr) (addr)
11565 +
11566 #ifndef __ASSEMBLY__
11567
11568 struct page;
11569 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11570 index 0032f92..cd151e0 100644
11571 --- a/arch/um/include/asm/pgtable-3level.h
11572 +++ b/arch/um/include/asm/pgtable-3level.h
11573 @@ -58,6 +58,7 @@
11574 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11575 #define pud_populate(mm, pud, pmd) \
11576 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11577 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11578
11579 #ifdef CONFIG_64BIT
11580 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11581 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11582 index bbcef52..6a2a483 100644
11583 --- a/arch/um/kernel/process.c
11584 +++ b/arch/um/kernel/process.c
11585 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11586 return 2;
11587 }
11588
11589 -/*
11590 - * Only x86 and x86_64 have an arch_align_stack().
11591 - * All other arches have "#define arch_align_stack(x) (x)"
11592 - * in their asm/system.h
11593 - * As this is included in UML from asm-um/system-generic.h,
11594 - * we can use it to behave as the subarch does.
11595 - */
11596 -#ifndef arch_align_stack
11597 -unsigned long arch_align_stack(unsigned long sp)
11598 -{
11599 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11600 - sp -= get_random_int() % 8192;
11601 - return sp & ~0xf;
11602 -}
11603 -#endif
11604 -
11605 unsigned long get_wchan(struct task_struct *p)
11606 {
11607 unsigned long stack_page, sp, ip;
11608 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11609 index ad8f795..2c7eec6 100644
11610 --- a/arch/unicore32/include/asm/cache.h
11611 +++ b/arch/unicore32/include/asm/cache.h
11612 @@ -12,8 +12,10 @@
11613 #ifndef __UNICORE_CACHE_H__
11614 #define __UNICORE_CACHE_H__
11615
11616 -#define L1_CACHE_SHIFT (5)
11617 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11618 +#include <linux/const.h>
11619 +
11620 +#define L1_CACHE_SHIFT 5
11621 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11622
11623 /*
11624 * Memory returned by kmalloc() may be used for DMA, so we must make
11625 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11626 index f67e839..bfd4748 100644
11627 --- a/arch/x86/Kconfig
11628 +++ b/arch/x86/Kconfig
11629 @@ -247,7 +247,7 @@ config X86_HT
11630
11631 config X86_32_LAZY_GS
11632 def_bool y
11633 - depends on X86_32 && !CC_STACKPROTECTOR
11634 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11635
11636 config ARCH_HWEIGHT_CFLAGS
11637 string
11638 @@ -1099,6 +1099,7 @@ config MICROCODE_EARLY
11639
11640 config X86_MSR
11641 tristate "/dev/cpu/*/msr - Model-specific register support"
11642 + depends on !GRKERNSEC_KMEM
11643 ---help---
11644 This device gives privileged processes access to the x86
11645 Model-Specific Registers (MSRs). It is a character device with
11646 @@ -1122,7 +1123,7 @@ choice
11647
11648 config NOHIGHMEM
11649 bool "off"
11650 - depends on !X86_NUMAQ
11651 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11652 ---help---
11653 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11654 However, the address space of 32-bit x86 processors is only 4
11655 @@ -1159,7 +1160,7 @@ config NOHIGHMEM
11656
11657 config HIGHMEM4G
11658 bool "4GB"
11659 - depends on !X86_NUMAQ
11660 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11661 ---help---
11662 Select this if you have a 32-bit processor and between 1 and 4
11663 gigabytes of physical RAM.
11664 @@ -1212,7 +1213,7 @@ config PAGE_OFFSET
11665 hex
11666 default 0xB0000000 if VMSPLIT_3G_OPT
11667 default 0x80000000 if VMSPLIT_2G
11668 - default 0x78000000 if VMSPLIT_2G_OPT
11669 + default 0x70000000 if VMSPLIT_2G_OPT
11670 default 0x40000000 if VMSPLIT_1G
11671 default 0xC0000000
11672 depends on X86_32
11673 @@ -1614,6 +1615,7 @@ config SECCOMP
11674
11675 config CC_STACKPROTECTOR
11676 bool "Enable -fstack-protector buffer overflow detection"
11677 + depends on X86_64 || !PAX_MEMORY_UDEREF
11678 ---help---
11679 This option turns on the -fstack-protector GCC feature. This
11680 feature puts, at the beginning of functions, a canary value on
11681 @@ -1632,6 +1634,7 @@ source kernel/Kconfig.hz
11682
11683 config KEXEC
11684 bool "kexec system call"
11685 + depends on !GRKERNSEC_KMEM
11686 ---help---
11687 kexec is a system call that implements the ability to shutdown your
11688 current kernel, and to start another kernel. It is like a reboot
11689 @@ -1733,6 +1736,8 @@ config X86_NEED_RELOCS
11690 config PHYSICAL_ALIGN
11691 hex "Alignment value to which kernel should be aligned"
11692 default "0x1000000"
11693 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11694 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11695 range 0x2000 0x1000000 if X86_32
11696 range 0x200000 0x1000000 if X86_64
11697 ---help---
11698 @@ -1812,9 +1817,10 @@ config DEBUG_HOTPLUG_CPU0
11699 If unsure, say N.
11700
11701 config COMPAT_VDSO
11702 - def_bool y
11703 + def_bool n
11704 prompt "Compat VDSO support"
11705 depends on X86_32 || IA32_EMULATION
11706 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11707 ---help---
11708 Map the 32-bit VDSO to the predictable old-style address too.
11709
11710 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11711 index c026cca..14657ae 100644
11712 --- a/arch/x86/Kconfig.cpu
11713 +++ b/arch/x86/Kconfig.cpu
11714 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11715
11716 config X86_F00F_BUG
11717 def_bool y
11718 - depends on M586MMX || M586TSC || M586 || M486
11719 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11720
11721 config X86_INVD_BUG
11722 def_bool y
11723 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11724
11725 config X86_ALIGNMENT_16
11726 def_bool y
11727 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11728 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11729
11730 config X86_INTEL_USERCOPY
11731 def_bool y
11732 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11733 # generates cmov.
11734 config X86_CMOV
11735 def_bool y
11736 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11737 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11738
11739 config X86_MINIMUM_CPU_FAMILY
11740 int
11741 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11742 index 78d91af..8ceb94b 100644
11743 --- a/arch/x86/Kconfig.debug
11744 +++ b/arch/x86/Kconfig.debug
11745 @@ -74,7 +74,7 @@ config X86_PTDUMP
11746 config DEBUG_RODATA
11747 bool "Write protect kernel read-only data structures"
11748 default y
11749 - depends on DEBUG_KERNEL
11750 + depends on DEBUG_KERNEL && BROKEN
11751 ---help---
11752 Mark the kernel read-only data as write-protected in the pagetables,
11753 in order to catch accidental (and incorrect) writes to such const
11754 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11755
11756 config DEBUG_SET_MODULE_RONX
11757 bool "Set loadable kernel module data as NX and text as RO"
11758 - depends on MODULES
11759 + depends on MODULES && BROKEN
11760 ---help---
11761 This option helps catch unintended modifications to loadable
11762 kernel module's text and read-only data. It also prevents execution
11763 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11764 index 57d0215..b4373fb 100644
11765 --- a/arch/x86/Makefile
11766 +++ b/arch/x86/Makefile
11767 @@ -49,14 +49,12 @@ ifeq ($(CONFIG_X86_32),y)
11768 # CPU-specific tuning. Anything which can be shared with UML should go here.
11769 include $(srctree)/arch/x86/Makefile_32.cpu
11770 KBUILD_CFLAGS += $(cflags-y)
11771 -
11772 - # temporary until string.h is fixed
11773 - KBUILD_CFLAGS += -ffreestanding
11774 else
11775 BITS := 64
11776 UTS_MACHINE := x86_64
11777 CHECKFLAGS += -D__x86_64__ -m64
11778
11779 + biarch := $(call cc-option,-m64)
11780 KBUILD_AFLAGS += -m64
11781 KBUILD_CFLAGS += -m64
11782
11783 @@ -89,6 +87,9 @@ else
11784 KBUILD_CFLAGS += -maccumulate-outgoing-args
11785 endif
11786
11787 +# temporary until string.h is fixed
11788 +KBUILD_CFLAGS += -ffreestanding
11789 +
11790 ifdef CONFIG_CC_STACKPROTECTOR
11791 cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
11792 ifeq ($(shell $(CONFIG_SHELL) $(cc_has_sp) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y)
11793 @@ -247,3 +248,12 @@ define archhelp
11794 echo ' FDINITRD=file initrd for the booted kernel'
11795 echo ' kvmconfig - Enable additional options for guest kernel support'
11796 endef
11797 +
11798 +define OLD_LD
11799 +
11800 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11801 +*** Please upgrade your binutils to 2.18 or newer
11802 +endef
11803 +
11804 +archprepare:
11805 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11806 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11807 index 6cf0111..f2e2398 100644
11808 --- a/arch/x86/boot/Makefile
11809 +++ b/arch/x86/boot/Makefile
11810 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ \
11811 $(call cc-option, -fno-unit-at-a-time)) \
11812 $(call cc-option, -fno-stack-protector) \
11813 $(call cc-option, -mpreferred-stack-boundary=2)
11814 +ifdef CONSTIFY_PLUGIN
11815 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11816 +endif
11817 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11818 GCOV_PROFILE := n
11819
11820 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11821 index 878e4b9..20537ab 100644
11822 --- a/arch/x86/boot/bitops.h
11823 +++ b/arch/x86/boot/bitops.h
11824 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11825 u8 v;
11826 const u32 *p = (const u32 *)addr;
11827
11828 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11829 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11830 return v;
11831 }
11832
11833 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11834
11835 static inline void set_bit(int nr, void *addr)
11836 {
11837 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11838 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11839 }
11840
11841 #endif /* BOOT_BITOPS_H */
11842 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11843 index ef72bae..353a184 100644
11844 --- a/arch/x86/boot/boot.h
11845 +++ b/arch/x86/boot/boot.h
11846 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11847 static inline u16 ds(void)
11848 {
11849 u16 seg;
11850 - asm("movw %%ds,%0" : "=rm" (seg));
11851 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11852 return seg;
11853 }
11854
11855 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11856 static inline int memcmp(const void *s1, const void *s2, size_t len)
11857 {
11858 u8 diff;
11859 - asm("repe; cmpsb; setnz %0"
11860 + asm volatile("repe; cmpsb; setnz %0"
11861 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11862 return diff;
11863 }
11864 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11865 index c8a6792..2402765 100644
11866 --- a/arch/x86/boot/compressed/Makefile
11867 +++ b/arch/x86/boot/compressed/Makefile
11868 @@ -16,6 +16,9 @@ KBUILD_CFLAGS += $(cflags-y)
11869 KBUILD_CFLAGS += -mno-mmx -mno-sse
11870 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11871 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11872 +ifdef CONSTIFY_PLUGIN
11873 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11874 +endif
11875
11876 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11877 GCOV_PROFILE := n
11878 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11879 index b7388a4..03844ec 100644
11880 --- a/arch/x86/boot/compressed/eboot.c
11881 +++ b/arch/x86/boot/compressed/eboot.c
11882 @@ -150,7 +150,6 @@ again:
11883 *addr = max_addr;
11884 }
11885
11886 -free_pool:
11887 efi_call_phys1(sys_table->boottime->free_pool, map);
11888
11889 fail:
11890 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11891 if (i == map_size / desc_size)
11892 status = EFI_NOT_FOUND;
11893
11894 -free_pool:
11895 efi_call_phys1(sys_table->boottime->free_pool, map);
11896 fail:
11897 return status;
11898 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11899 index a53440e..c3dbf1e 100644
11900 --- a/arch/x86/boot/compressed/efi_stub_32.S
11901 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11902 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11903 * parameter 2, ..., param n. To make things easy, we save the return
11904 * address of efi_call_phys in a global variable.
11905 */
11906 - popl %ecx
11907 - movl %ecx, saved_return_addr(%edx)
11908 - /* get the function pointer into ECX*/
11909 - popl %ecx
11910 - movl %ecx, efi_rt_function_ptr(%edx)
11911 + popl saved_return_addr(%edx)
11912 + popl efi_rt_function_ptr(%edx)
11913
11914 /*
11915 * 3. Call the physical function.
11916 */
11917 - call *%ecx
11918 + call *efi_rt_function_ptr(%edx)
11919
11920 /*
11921 * 4. Balance the stack. And because EAX contain the return value,
11922 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11923 1: popl %edx
11924 subl $1b, %edx
11925
11926 - movl efi_rt_function_ptr(%edx), %ecx
11927 - pushl %ecx
11928 + pushl efi_rt_function_ptr(%edx)
11929
11930 /*
11931 * 10. Push the saved return address onto the stack and return.
11932 */
11933 - movl saved_return_addr(%edx), %ecx
11934 - pushl %ecx
11935 - ret
11936 + jmpl *saved_return_addr(%edx)
11937 ENDPROC(efi_call_phys)
11938 .previous
11939
11940 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11941 index 5d6f689..9d06730 100644
11942 --- a/arch/x86/boot/compressed/head_32.S
11943 +++ b/arch/x86/boot/compressed/head_32.S
11944 @@ -118,7 +118,7 @@ preferred_addr:
11945 notl %eax
11946 andl %eax, %ebx
11947 #else
11948 - movl $LOAD_PHYSICAL_ADDR, %ebx
11949 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11950 #endif
11951
11952 /* Target address to relocate to for decompression */
11953 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11954 index c337422..2c5be72 100644
11955 --- a/arch/x86/boot/compressed/head_64.S
11956 +++ b/arch/x86/boot/compressed/head_64.S
11957 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11958 notl %eax
11959 andl %eax, %ebx
11960 #else
11961 - movl $LOAD_PHYSICAL_ADDR, %ebx
11962 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11963 #endif
11964
11965 /* Target address to relocate to for decompression */
11966 @@ -270,7 +270,7 @@ preferred_addr:
11967 notq %rax
11968 andq %rax, %rbp
11969 #else
11970 - movq $LOAD_PHYSICAL_ADDR, %rbp
11971 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11972 #endif
11973
11974 /* Target address to relocate to for decompression */
11975 @@ -362,8 +362,8 @@ gdt:
11976 .long gdt
11977 .word 0
11978 .quad 0x0000000000000000 /* NULL descriptor */
11979 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11980 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11981 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11982 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11983 .quad 0x0080890000000000 /* TS descriptor */
11984 .quad 0x0000000000000000 /* TS continued */
11985 gdt_end:
11986 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11987 index 434f077..b6b4b38 100644
11988 --- a/arch/x86/boot/compressed/misc.c
11989 +++ b/arch/x86/boot/compressed/misc.c
11990 @@ -283,7 +283,7 @@ static void handle_relocations(void *output, unsigned long output_len)
11991 * Calculate the delta between where vmlinux was linked to load
11992 * and where it was actually loaded.
11993 */
11994 - delta = min_addr - LOAD_PHYSICAL_ADDR;
11995 + delta = min_addr - ____LOAD_PHYSICAL_ADDR;
11996 if (!delta) {
11997 debug_putstr("No relocation needed... ");
11998 return;
11999 @@ -380,7 +380,7 @@ static void parse_elf(void *output)
12000 case PT_LOAD:
12001 #ifdef CONFIG_RELOCATABLE
12002 dest = output;
12003 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
12004 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
12005 #else
12006 dest = (void *)(phdr->p_paddr);
12007 #endif
12008 @@ -432,7 +432,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
12009 error("Destination address too large");
12010 #endif
12011 #ifndef CONFIG_RELOCATABLE
12012 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
12013 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
12014 error("Wrong destination address");
12015 #endif
12016
12017 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
12018 index 4d3ff03..e4972ff 100644
12019 --- a/arch/x86/boot/cpucheck.c
12020 +++ b/arch/x86/boot/cpucheck.c
12021 @@ -74,7 +74,7 @@ static int has_fpu(void)
12022 u16 fcw = -1, fsw = -1;
12023 u32 cr0;
12024
12025 - asm("movl %%cr0,%0" : "=r" (cr0));
12026 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
12027 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
12028 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
12029 asm volatile("movl %0,%%cr0" : : "r" (cr0));
12030 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
12031 {
12032 u32 f0, f1;
12033
12034 - asm("pushfl ; "
12035 + asm volatile("pushfl ; "
12036 "pushfl ; "
12037 "popl %0 ; "
12038 "movl %0,%1 ; "
12039 @@ -115,7 +115,7 @@ static void get_flags(void)
12040 set_bit(X86_FEATURE_FPU, cpu.flags);
12041
12042 if (has_eflag(X86_EFLAGS_ID)) {
12043 - asm("cpuid"
12044 + asm volatile("cpuid"
12045 : "=a" (max_intel_level),
12046 "=b" (cpu_vendor[0]),
12047 "=d" (cpu_vendor[1]),
12048 @@ -124,7 +124,7 @@ static void get_flags(void)
12049
12050 if (max_intel_level >= 0x00000001 &&
12051 max_intel_level <= 0x0000ffff) {
12052 - asm("cpuid"
12053 + asm volatile("cpuid"
12054 : "=a" (tfms),
12055 "=c" (cpu.flags[4]),
12056 "=d" (cpu.flags[0])
12057 @@ -136,7 +136,7 @@ static void get_flags(void)
12058 cpu.model += ((tfms >> 16) & 0xf) << 4;
12059 }
12060
12061 - asm("cpuid"
12062 + asm volatile("cpuid"
12063 : "=a" (max_amd_level)
12064 : "a" (0x80000000)
12065 : "ebx", "ecx", "edx");
12066 @@ -144,7 +144,7 @@ static void get_flags(void)
12067 if (max_amd_level >= 0x80000001 &&
12068 max_amd_level <= 0x8000ffff) {
12069 u32 eax = 0x80000001;
12070 - asm("cpuid"
12071 + asm volatile("cpuid"
12072 : "+a" (eax),
12073 "=c" (cpu.flags[6]),
12074 "=d" (cpu.flags[1])
12075 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12076 u32 ecx = MSR_K7_HWCR;
12077 u32 eax, edx;
12078
12079 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12080 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12081 eax &= ~(1 << 15);
12082 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12083 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12084
12085 get_flags(); /* Make sure it really did something */
12086 err = check_flags();
12087 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12088 u32 ecx = MSR_VIA_FCR;
12089 u32 eax, edx;
12090
12091 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12092 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12093 eax |= (1<<1)|(1<<7);
12094 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12095 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12096
12097 set_bit(X86_FEATURE_CX8, cpu.flags);
12098 err = check_flags();
12099 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12100 u32 eax, edx;
12101 u32 level = 1;
12102
12103 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12104 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12105 - asm("cpuid"
12106 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12107 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12108 + asm volatile("cpuid"
12109 : "+a" (level), "=d" (cpu.flags[0])
12110 : : "ecx", "ebx");
12111 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12112 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12113
12114 err = check_flags();
12115 }
12116 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12117 index 9ec06a1..2c25e79 100644
12118 --- a/arch/x86/boot/header.S
12119 +++ b/arch/x86/boot/header.S
12120 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12121 # single linked list of
12122 # struct setup_data
12123
12124 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12125 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12126
12127 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12128 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12129 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12130 +#else
12131 #define VO_INIT_SIZE (VO__end - VO__text)
12132 +#endif
12133 #if ZO_INIT_SIZE > VO_INIT_SIZE
12134 #define INIT_SIZE ZO_INIT_SIZE
12135 #else
12136 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12137 index db75d07..8e6d0af 100644
12138 --- a/arch/x86/boot/memory.c
12139 +++ b/arch/x86/boot/memory.c
12140 @@ -19,7 +19,7 @@
12141
12142 static int detect_memory_e820(void)
12143 {
12144 - int count = 0;
12145 + unsigned int count = 0;
12146 struct biosregs ireg, oreg;
12147 struct e820entry *desc = boot_params.e820_map;
12148 static struct e820entry buf; /* static so it is zeroed */
12149 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12150 index 11e8c6e..fdbb1ed 100644
12151 --- a/arch/x86/boot/video-vesa.c
12152 +++ b/arch/x86/boot/video-vesa.c
12153 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12154
12155 boot_params.screen_info.vesapm_seg = oreg.es;
12156 boot_params.screen_info.vesapm_off = oreg.di;
12157 + boot_params.screen_info.vesapm_size = oreg.cx;
12158 }
12159
12160 /*
12161 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12162 index 43eda28..5ab5fdb 100644
12163 --- a/arch/x86/boot/video.c
12164 +++ b/arch/x86/boot/video.c
12165 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12166 static unsigned int get_entry(void)
12167 {
12168 char entry_buf[4];
12169 - int i, len = 0;
12170 + unsigned int i, len = 0;
12171 int key;
12172 unsigned int v;
12173
12174 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12175 index 9105655..41779c1 100644
12176 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12177 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12178 @@ -8,6 +8,8 @@
12179 * including this sentence is retained in full.
12180 */
12181
12182 +#include <asm/alternative-asm.h>
12183 +
12184 .extern crypto_ft_tab
12185 .extern crypto_it_tab
12186 .extern crypto_fl_tab
12187 @@ -70,6 +72,8 @@
12188 je B192; \
12189 leaq 32(r9),r9;
12190
12191 +#define ret pax_force_retaddr; ret
12192 +
12193 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12194 movq r1,r2; \
12195 movq r3,r4; \
12196 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12197 index 477e9d7..c92c7d8 100644
12198 --- a/arch/x86/crypto/aesni-intel_asm.S
12199 +++ b/arch/x86/crypto/aesni-intel_asm.S
12200 @@ -31,6 +31,7 @@
12201
12202 #include <linux/linkage.h>
12203 #include <asm/inst.h>
12204 +#include <asm/alternative-asm.h>
12205
12206 #ifdef __x86_64__
12207 .data
12208 @@ -205,7 +206,7 @@ enc: .octa 0x2
12209 * num_initial_blocks = b mod 4
12210 * encrypt the initial num_initial_blocks blocks and apply ghash on
12211 * the ciphertext
12212 -* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12213 +* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12214 * are clobbered
12215 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
12216 */
12217 @@ -214,8 +215,8 @@ enc: .octa 0x2
12218 .macro INITIAL_BLOCKS_DEC num_initial_blocks TMP1 TMP2 TMP3 TMP4 TMP5 XMM0 XMM1 \
12219 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
12220 mov arg7, %r10 # %r10 = AAD
12221 - mov arg8, %r12 # %r12 = aadLen
12222 - mov %r12, %r11
12223 + mov arg8, %r15 # %r15 = aadLen
12224 + mov %r15, %r11
12225 pxor %xmm\i, %xmm\i
12226 _get_AAD_loop\num_initial_blocks\operation:
12227 movd (%r10), \TMP1
12228 @@ -223,15 +224,15 @@ _get_AAD_loop\num_initial_blocks\operation:
12229 psrldq $4, %xmm\i
12230 pxor \TMP1, %xmm\i
12231 add $4, %r10
12232 - sub $4, %r12
12233 + sub $4, %r15
12234 jne _get_AAD_loop\num_initial_blocks\operation
12235 cmp $16, %r11
12236 je _get_AAD_loop2_done\num_initial_blocks\operation
12237 - mov $16, %r12
12238 + mov $16, %r15
12239 _get_AAD_loop2\num_initial_blocks\operation:
12240 psrldq $4, %xmm\i
12241 - sub $4, %r12
12242 - cmp %r11, %r12
12243 + sub $4, %r15
12244 + cmp %r11, %r15
12245 jne _get_AAD_loop2\num_initial_blocks\operation
12246 _get_AAD_loop2_done\num_initial_blocks\operation:
12247 movdqa SHUF_MASK(%rip), %xmm14
12248 @@ -443,7 +444,7 @@ _initial_blocks_done\num_initial_blocks\operation:
12249 * num_initial_blocks = b mod 4
12250 * encrypt the initial num_initial_blocks blocks and apply ghash on
12251 * the ciphertext
12252 -* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12253 +* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12254 * are clobbered
12255 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
12256 */
12257 @@ -452,8 +453,8 @@ _initial_blocks_done\num_initial_blocks\operation:
12258 .macro INITIAL_BLOCKS_ENC num_initial_blocks TMP1 TMP2 TMP3 TMP4 TMP5 XMM0 XMM1 \
12259 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
12260 mov arg7, %r10 # %r10 = AAD
12261 - mov arg8, %r12 # %r12 = aadLen
12262 - mov %r12, %r11
12263 + mov arg8, %r15 # %r15 = aadLen
12264 + mov %r15, %r11
12265 pxor %xmm\i, %xmm\i
12266 _get_AAD_loop\num_initial_blocks\operation:
12267 movd (%r10), \TMP1
12268 @@ -461,15 +462,15 @@ _get_AAD_loop\num_initial_blocks\operation:
12269 psrldq $4, %xmm\i
12270 pxor \TMP1, %xmm\i
12271 add $4, %r10
12272 - sub $4, %r12
12273 + sub $4, %r15
12274 jne _get_AAD_loop\num_initial_blocks\operation
12275 cmp $16, %r11
12276 je _get_AAD_loop2_done\num_initial_blocks\operation
12277 - mov $16, %r12
12278 + mov $16, %r15
12279 _get_AAD_loop2\num_initial_blocks\operation:
12280 psrldq $4, %xmm\i
12281 - sub $4, %r12
12282 - cmp %r11, %r12
12283 + sub $4, %r15
12284 + cmp %r11, %r15
12285 jne _get_AAD_loop2\num_initial_blocks\operation
12286 _get_AAD_loop2_done\num_initial_blocks\operation:
12287 movdqa SHUF_MASK(%rip), %xmm14
12288 @@ -1269,7 +1270,7 @@ TMP7 XMM1 XMM2 XMM3 XMM4 XMMDst
12289 *
12290 *****************************************************************************/
12291 ENTRY(aesni_gcm_dec)
12292 - push %r12
12293 + push %r15
12294 push %r13
12295 push %r14
12296 mov %rsp, %r14
12297 @@ -1279,8 +1280,8 @@ ENTRY(aesni_gcm_dec)
12298 */
12299 sub $VARIABLE_OFFSET, %rsp
12300 and $~63, %rsp # align rsp to 64 bytes
12301 - mov %arg6, %r12
12302 - movdqu (%r12), %xmm13 # %xmm13 = HashKey
12303 + mov %arg6, %r15
12304 + movdqu (%r15), %xmm13 # %xmm13 = HashKey
12305 movdqa SHUF_MASK(%rip), %xmm2
12306 PSHUFB_XMM %xmm2, %xmm13
12307
12308 @@ -1308,10 +1309,10 @@ ENTRY(aesni_gcm_dec)
12309 movdqa %xmm13, HashKey(%rsp) # store HashKey<<1 (mod poly)
12310 mov %arg4, %r13 # save the number of bytes of plaintext/ciphertext
12311 and $-16, %r13 # %r13 = %r13 - (%r13 mod 16)
12312 - mov %r13, %r12
12313 - and $(3<<4), %r12
12314 + mov %r13, %r15
12315 + and $(3<<4), %r15
12316 jz _initial_num_blocks_is_0_decrypt
12317 - cmp $(2<<4), %r12
12318 + cmp $(2<<4), %r15
12319 jb _initial_num_blocks_is_1_decrypt
12320 je _initial_num_blocks_is_2_decrypt
12321 _initial_num_blocks_is_3_decrypt:
12322 @@ -1361,16 +1362,16 @@ _zero_cipher_left_decrypt:
12323 sub $16, %r11
12324 add %r13, %r11
12325 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte block
12326 - lea SHIFT_MASK+16(%rip), %r12
12327 - sub %r13, %r12
12328 + lea SHIFT_MASK+16(%rip), %r15
12329 + sub %r13, %r15
12330 # adjust the shuffle mask pointer to be able to shift 16-%r13 bytes
12331 # (%r13 is the number of bytes in plaintext mod 16)
12332 - movdqu (%r12), %xmm2 # get the appropriate shuffle mask
12333 + movdqu (%r15), %xmm2 # get the appropriate shuffle mask
12334 PSHUFB_XMM %xmm2, %xmm1 # right shift 16-%r13 butes
12335
12336 movdqa %xmm1, %xmm2
12337 pxor %xmm1, %xmm0 # Ciphertext XOR E(K, Yn)
12338 - movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
12339 + movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
12340 # get the appropriate mask to mask out top 16-%r13 bytes of %xmm0
12341 pand %xmm1, %xmm0 # mask out top 16-%r13 bytes of %xmm0
12342 pand %xmm1, %xmm2
12343 @@ -1399,9 +1400,9 @@ _less_than_8_bytes_left_decrypt:
12344 sub $1, %r13
12345 jne _less_than_8_bytes_left_decrypt
12346 _multiple_of_16_bytes_decrypt:
12347 - mov arg8, %r12 # %r13 = aadLen (number of bytes)
12348 - shl $3, %r12 # convert into number of bits
12349 - movd %r12d, %xmm15 # len(A) in %xmm15
12350 + mov arg8, %r15 # %r13 = aadLen (number of bytes)
12351 + shl $3, %r15 # convert into number of bits
12352 + movd %r15d, %xmm15 # len(A) in %xmm15
12353 shl $3, %arg4 # len(C) in bits (*128)
12354 MOVQ_R64_XMM %arg4, %xmm1
12355 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
12356 @@ -1440,7 +1441,8 @@ _return_T_done_decrypt:
12357 mov %r14, %rsp
12358 pop %r14
12359 pop %r13
12360 - pop %r12
12361 + pop %r15
12362 + pax_force_retaddr
12363 ret
12364 ENDPROC(aesni_gcm_dec)
12365
12366 @@ -1529,7 +1531,7 @@ ENDPROC(aesni_gcm_dec)
12367 * poly = x^128 + x^127 + x^126 + x^121 + 1
12368 ***************************************************************************/
12369 ENTRY(aesni_gcm_enc)
12370 - push %r12
12371 + push %r15
12372 push %r13
12373 push %r14
12374 mov %rsp, %r14
12375 @@ -1539,8 +1541,8 @@ ENTRY(aesni_gcm_enc)
12376 #
12377 sub $VARIABLE_OFFSET, %rsp
12378 and $~63, %rsp
12379 - mov %arg6, %r12
12380 - movdqu (%r12), %xmm13
12381 + mov %arg6, %r15
12382 + movdqu (%r15), %xmm13
12383 movdqa SHUF_MASK(%rip), %xmm2
12384 PSHUFB_XMM %xmm2, %xmm13
12385
12386 @@ -1564,13 +1566,13 @@ ENTRY(aesni_gcm_enc)
12387 movdqa %xmm13, HashKey(%rsp)
12388 mov %arg4, %r13 # %xmm13 holds HashKey<<1 (mod poly)
12389 and $-16, %r13
12390 - mov %r13, %r12
12391 + mov %r13, %r15
12392
12393 # Encrypt first few blocks
12394
12395 - and $(3<<4), %r12
12396 + and $(3<<4), %r15
12397 jz _initial_num_blocks_is_0_encrypt
12398 - cmp $(2<<4), %r12
12399 + cmp $(2<<4), %r15
12400 jb _initial_num_blocks_is_1_encrypt
12401 je _initial_num_blocks_is_2_encrypt
12402 _initial_num_blocks_is_3_encrypt:
12403 @@ -1623,14 +1625,14 @@ _zero_cipher_left_encrypt:
12404 sub $16, %r11
12405 add %r13, %r11
12406 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte blocks
12407 - lea SHIFT_MASK+16(%rip), %r12
12408 - sub %r13, %r12
12409 + lea SHIFT_MASK+16(%rip), %r15
12410 + sub %r13, %r15
12411 # adjust the shuffle mask pointer to be able to shift 16-r13 bytes
12412 # (%r13 is the number of bytes in plaintext mod 16)
12413 - movdqu (%r12), %xmm2 # get the appropriate shuffle mask
12414 + movdqu (%r15), %xmm2 # get the appropriate shuffle mask
12415 PSHUFB_XMM %xmm2, %xmm1 # shift right 16-r13 byte
12416 pxor %xmm1, %xmm0 # Plaintext XOR Encrypt(K, Yn)
12417 - movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
12418 + movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
12419 # get the appropriate mask to mask out top 16-r13 bytes of xmm0
12420 pand %xmm1, %xmm0 # mask out top 16-r13 bytes of xmm0
12421 movdqa SHUF_MASK(%rip), %xmm10
12422 @@ -1663,9 +1665,9 @@ _less_than_8_bytes_left_encrypt:
12423 sub $1, %r13
12424 jne _less_than_8_bytes_left_encrypt
12425 _multiple_of_16_bytes_encrypt:
12426 - mov arg8, %r12 # %r12 = addLen (number of bytes)
12427 - shl $3, %r12
12428 - movd %r12d, %xmm15 # len(A) in %xmm15
12429 + mov arg8, %r15 # %r15 = addLen (number of bytes)
12430 + shl $3, %r15
12431 + movd %r15d, %xmm15 # len(A) in %xmm15
12432 shl $3, %arg4 # len(C) in bits (*128)
12433 MOVQ_R64_XMM %arg4, %xmm1
12434 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
12435 @@ -1704,7 +1706,8 @@ _return_T_done_encrypt:
12436 mov %r14, %rsp
12437 pop %r14
12438 pop %r13
12439 - pop %r12
12440 + pop %r15
12441 + pax_force_retaddr
12442 ret
12443 ENDPROC(aesni_gcm_enc)
12444
12445 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12446 pxor %xmm1, %xmm0
12447 movaps %xmm0, (TKEYP)
12448 add $0x10, TKEYP
12449 + pax_force_retaddr
12450 ret
12451 ENDPROC(_key_expansion_128)
12452 ENDPROC(_key_expansion_256a)
12453 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12454 shufps $0b01001110, %xmm2, %xmm1
12455 movaps %xmm1, 0x10(TKEYP)
12456 add $0x20, TKEYP
12457 + pax_force_retaddr
12458 ret
12459 ENDPROC(_key_expansion_192a)
12460
12461 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12462
12463 movaps %xmm0, (TKEYP)
12464 add $0x10, TKEYP
12465 + pax_force_retaddr
12466 ret
12467 ENDPROC(_key_expansion_192b)
12468
12469 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12470 pxor %xmm1, %xmm2
12471 movaps %xmm2, (TKEYP)
12472 add $0x10, TKEYP
12473 + pax_force_retaddr
12474 ret
12475 ENDPROC(_key_expansion_256b)
12476
12477 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12478 #ifndef __x86_64__
12479 popl KEYP
12480 #endif
12481 + pax_force_retaddr
12482 ret
12483 ENDPROC(aesni_set_key)
12484
12485 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12486 popl KLEN
12487 popl KEYP
12488 #endif
12489 + pax_force_retaddr
12490 ret
12491 ENDPROC(aesni_enc)
12492
12493 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12494 AESENC KEY STATE
12495 movaps 0x70(TKEYP), KEY
12496 AESENCLAST KEY STATE
12497 + pax_force_retaddr
12498 ret
12499 ENDPROC(_aesni_enc1)
12500
12501 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12502 AESENCLAST KEY STATE2
12503 AESENCLAST KEY STATE3
12504 AESENCLAST KEY STATE4
12505 + pax_force_retaddr
12506 ret
12507 ENDPROC(_aesni_enc4)
12508
12509 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12510 popl KLEN
12511 popl KEYP
12512 #endif
12513 + pax_force_retaddr
12514 ret
12515 ENDPROC(aesni_dec)
12516
12517 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12518 AESDEC KEY STATE
12519 movaps 0x70(TKEYP), KEY
12520 AESDECLAST KEY STATE
12521 + pax_force_retaddr
12522 ret
12523 ENDPROC(_aesni_dec1)
12524
12525 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12526 AESDECLAST KEY STATE2
12527 AESDECLAST KEY STATE3
12528 AESDECLAST KEY STATE4
12529 + pax_force_retaddr
12530 ret
12531 ENDPROC(_aesni_dec4)
12532
12533 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12534 popl KEYP
12535 popl LEN
12536 #endif
12537 + pax_force_retaddr
12538 ret
12539 ENDPROC(aesni_ecb_enc)
12540
12541 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12542 popl KEYP
12543 popl LEN
12544 #endif
12545 + pax_force_retaddr
12546 ret
12547 ENDPROC(aesni_ecb_dec)
12548
12549 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12550 popl LEN
12551 popl IVP
12552 #endif
12553 + pax_force_retaddr
12554 ret
12555 ENDPROC(aesni_cbc_enc)
12556
12557 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12558 popl LEN
12559 popl IVP
12560 #endif
12561 + pax_force_retaddr
12562 ret
12563 ENDPROC(aesni_cbc_dec)
12564
12565 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12566 mov $1, TCTR_LOW
12567 MOVQ_R64_XMM TCTR_LOW INC
12568 MOVQ_R64_XMM CTR TCTR_LOW
12569 + pax_force_retaddr
12570 ret
12571 ENDPROC(_aesni_inc_init)
12572
12573 @@ -2579,6 +2598,7 @@ _aesni_inc:
12574 .Linc_low:
12575 movaps CTR, IV
12576 PSHUFB_XMM BSWAP_MASK IV
12577 + pax_force_retaddr
12578 ret
12579 ENDPROC(_aesni_inc)
12580
12581 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12582 .Lctr_enc_ret:
12583 movups IV, (IVP)
12584 .Lctr_enc_just_ret:
12585 + pax_force_retaddr
12586 ret
12587 ENDPROC(aesni_ctr_enc)
12588
12589 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12590 pxor INC, STATE4
12591 movdqu STATE4, 0x70(OUTP)
12592
12593 + pax_force_retaddr
12594 ret
12595 ENDPROC(aesni_xts_crypt8)
12596
12597 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12598 index 246c670..466e2d6 100644
12599 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12600 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12601 @@ -21,6 +21,7 @@
12602 */
12603
12604 #include <linux/linkage.h>
12605 +#include <asm/alternative-asm.h>
12606
12607 .file "blowfish-x86_64-asm.S"
12608 .text
12609 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12610 jnz .L__enc_xor;
12611
12612 write_block();
12613 + pax_force_retaddr
12614 ret;
12615 .L__enc_xor:
12616 xor_block();
12617 + pax_force_retaddr
12618 ret;
12619 ENDPROC(__blowfish_enc_blk)
12620
12621 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12622
12623 movq %r11, %rbp;
12624
12625 + pax_force_retaddr
12626 ret;
12627 ENDPROC(blowfish_dec_blk)
12628
12629 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12630
12631 popq %rbx;
12632 popq %rbp;
12633 + pax_force_retaddr
12634 ret;
12635
12636 .L__enc_xor4:
12637 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12638
12639 popq %rbx;
12640 popq %rbp;
12641 + pax_force_retaddr
12642 ret;
12643 ENDPROC(__blowfish_enc_blk_4way)
12644
12645 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12646 popq %rbx;
12647 popq %rbp;
12648
12649 + pax_force_retaddr
12650 ret;
12651 ENDPROC(blowfish_dec_blk_4way)
12652 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12653 index ce71f92..1dce7ec 100644
12654 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12655 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12656 @@ -16,6 +16,7 @@
12657 */
12658
12659 #include <linux/linkage.h>
12660 +#include <asm/alternative-asm.h>
12661
12662 #define CAMELLIA_TABLE_BYTE_LEN 272
12663
12664 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12665 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12666 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12667 %rcx, (%r9));
12668 + pax_force_retaddr
12669 ret;
12670 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12671
12672 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12673 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12674 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12675 %rax, (%r9));
12676 + pax_force_retaddr
12677 ret;
12678 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12679
12680 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12681 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12682 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12683
12684 + pax_force_retaddr
12685 ret;
12686
12687 .align 8
12688 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12689 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12690 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12691
12692 + pax_force_retaddr
12693 ret;
12694
12695 .align 8
12696 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12697 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12698 %xmm8, %rsi);
12699
12700 + pax_force_retaddr
12701 ret;
12702 ENDPROC(camellia_ecb_enc_16way)
12703
12704 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12705 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12706 %xmm8, %rsi);
12707
12708 + pax_force_retaddr
12709 ret;
12710 ENDPROC(camellia_ecb_dec_16way)
12711
12712 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12713 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12714 %xmm8, %rsi);
12715
12716 + pax_force_retaddr
12717 ret;
12718 ENDPROC(camellia_cbc_dec_16way)
12719
12720 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12721 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12722 %xmm8, %rsi);
12723
12724 + pax_force_retaddr
12725 ret;
12726 ENDPROC(camellia_ctr_16way)
12727
12728 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12729 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12730 %xmm8, %rsi);
12731
12732 + pax_force_retaddr
12733 ret;
12734 ENDPROC(camellia_xts_crypt_16way)
12735
12736 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12737 index 0e0b886..5a3123c 100644
12738 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12739 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12740 @@ -11,6 +11,7 @@
12741 */
12742
12743 #include <linux/linkage.h>
12744 +#include <asm/alternative-asm.h>
12745
12746 #define CAMELLIA_TABLE_BYTE_LEN 272
12747
12748 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12749 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12750 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12751 %rcx, (%r9));
12752 + pax_force_retaddr
12753 ret;
12754 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12755
12756 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12757 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12758 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12759 %rax, (%r9));
12760 + pax_force_retaddr
12761 ret;
12762 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12763
12764 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12765 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12766 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12767
12768 + pax_force_retaddr
12769 ret;
12770
12771 .align 8
12772 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12773 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12774 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12775
12776 + pax_force_retaddr
12777 ret;
12778
12779 .align 8
12780 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12781
12782 vzeroupper;
12783
12784 + pax_force_retaddr
12785 ret;
12786 ENDPROC(camellia_ecb_enc_32way)
12787
12788 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12789
12790 vzeroupper;
12791
12792 + pax_force_retaddr
12793 ret;
12794 ENDPROC(camellia_ecb_dec_32way)
12795
12796 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12797
12798 vzeroupper;
12799
12800 + pax_force_retaddr
12801 ret;
12802 ENDPROC(camellia_cbc_dec_32way)
12803
12804 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12805
12806 vzeroupper;
12807
12808 + pax_force_retaddr
12809 ret;
12810 ENDPROC(camellia_ctr_32way)
12811
12812 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12813
12814 vzeroupper;
12815
12816 + pax_force_retaddr
12817 ret;
12818 ENDPROC(camellia_xts_crypt_32way)
12819
12820 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12821 index 310319c..db3d7b5 100644
12822 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12823 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12824 @@ -21,6 +21,7 @@
12825 */
12826
12827 #include <linux/linkage.h>
12828 +#include <asm/alternative-asm.h>
12829
12830 .file "camellia-x86_64-asm_64.S"
12831 .text
12832 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12833 enc_outunpack(mov, RT1);
12834
12835 movq RRBP, %rbp;
12836 + pax_force_retaddr
12837 ret;
12838
12839 .L__enc_xor:
12840 enc_outunpack(xor, RT1);
12841
12842 movq RRBP, %rbp;
12843 + pax_force_retaddr
12844 ret;
12845 ENDPROC(__camellia_enc_blk)
12846
12847 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12848 dec_outunpack();
12849
12850 movq RRBP, %rbp;
12851 + pax_force_retaddr
12852 ret;
12853 ENDPROC(camellia_dec_blk)
12854
12855 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12856
12857 movq RRBP, %rbp;
12858 popq %rbx;
12859 + pax_force_retaddr
12860 ret;
12861
12862 .L__enc2_xor:
12863 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12864
12865 movq RRBP, %rbp;
12866 popq %rbx;
12867 + pax_force_retaddr
12868 ret;
12869 ENDPROC(__camellia_enc_blk_2way)
12870
12871 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12872
12873 movq RRBP, %rbp;
12874 movq RXOR, %rbx;
12875 + pax_force_retaddr
12876 ret;
12877 ENDPROC(camellia_dec_blk_2way)
12878 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12879 index c35fd5d..2d8c7db 100644
12880 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12881 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12882 @@ -24,6 +24,7 @@
12883 */
12884
12885 #include <linux/linkage.h>
12886 +#include <asm/alternative-asm.h>
12887
12888 .file "cast5-avx-x86_64-asm_64.S"
12889
12890 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12891 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12892 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12893
12894 + pax_force_retaddr
12895 ret;
12896 ENDPROC(__cast5_enc_blk16)
12897
12898 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12899 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12900 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12901
12902 + pax_force_retaddr
12903 ret;
12904
12905 .L__skip_dec:
12906 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12907 vmovdqu RR4, (6*4*4)(%r11);
12908 vmovdqu RL4, (7*4*4)(%r11);
12909
12910 + pax_force_retaddr
12911 ret;
12912 ENDPROC(cast5_ecb_enc_16way)
12913
12914 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12915 vmovdqu RR4, (6*4*4)(%r11);
12916 vmovdqu RL4, (7*4*4)(%r11);
12917
12918 + pax_force_retaddr
12919 ret;
12920 ENDPROC(cast5_ecb_dec_16way)
12921
12922 @@ -430,10 +435,10 @@ ENTRY(cast5_cbc_dec_16way)
12923 * %rdx: src
12924 */
12925
12926 - pushq %r12;
12927 + pushq %r14;
12928
12929 movq %rsi, %r11;
12930 - movq %rdx, %r12;
12931 + movq %rdx, %r14;
12932
12933 vmovdqu (0*16)(%rdx), RL1;
12934 vmovdqu (1*16)(%rdx), RR1;
12935 @@ -447,16 +452,16 @@ ENTRY(cast5_cbc_dec_16way)
12936 call __cast5_dec_blk16;
12937
12938 /* xor with src */
12939 - vmovq (%r12), RX;
12940 + vmovq (%r14), RX;
12941 vpshufd $0x4f, RX, RX;
12942 vpxor RX, RR1, RR1;
12943 - vpxor 0*16+8(%r12), RL1, RL1;
12944 - vpxor 1*16+8(%r12), RR2, RR2;
12945 - vpxor 2*16+8(%r12), RL2, RL2;
12946 - vpxor 3*16+8(%r12), RR3, RR3;
12947 - vpxor 4*16+8(%r12), RL3, RL3;
12948 - vpxor 5*16+8(%r12), RR4, RR4;
12949 - vpxor 6*16+8(%r12), RL4, RL4;
12950 + vpxor 0*16+8(%r14), RL1, RL1;
12951 + vpxor 1*16+8(%r14), RR2, RR2;
12952 + vpxor 2*16+8(%r14), RL2, RL2;
12953 + vpxor 3*16+8(%r14), RR3, RR3;
12954 + vpxor 4*16+8(%r14), RL3, RL3;
12955 + vpxor 5*16+8(%r14), RR4, RR4;
12956 + vpxor 6*16+8(%r14), RL4, RL4;
12957
12958 vmovdqu RR1, (0*16)(%r11);
12959 vmovdqu RL1, (1*16)(%r11);
12960 @@ -467,8 +472,9 @@ ENTRY(cast5_cbc_dec_16way)
12961 vmovdqu RR4, (6*16)(%r11);
12962 vmovdqu RL4, (7*16)(%r11);
12963
12964 - popq %r12;
12965 + popq %r14;
12966
12967 + pax_force_retaddr
12968 ret;
12969 ENDPROC(cast5_cbc_dec_16way)
12970
12971 @@ -480,10 +486,10 @@ ENTRY(cast5_ctr_16way)
12972 * %rcx: iv (big endian, 64bit)
12973 */
12974
12975 - pushq %r12;
12976 + pushq %r14;
12977
12978 movq %rsi, %r11;
12979 - movq %rdx, %r12;
12980 + movq %rdx, %r14;
12981
12982 vpcmpeqd RTMP, RTMP, RTMP;
12983 vpsrldq $8, RTMP, RTMP; /* low: -1, high: 0 */
12984 @@ -523,14 +529,14 @@ ENTRY(cast5_ctr_16way)
12985 call __cast5_enc_blk16;
12986
12987 /* dst = src ^ iv */
12988 - vpxor (0*16)(%r12), RR1, RR1;
12989 - vpxor (1*16)(%r12), RL1, RL1;
12990 - vpxor (2*16)(%r12), RR2, RR2;
12991 - vpxor (3*16)(%r12), RL2, RL2;
12992 - vpxor (4*16)(%r12), RR3, RR3;
12993 - vpxor (5*16)(%r12), RL3, RL3;
12994 - vpxor (6*16)(%r12), RR4, RR4;
12995 - vpxor (7*16)(%r12), RL4, RL4;
12996 + vpxor (0*16)(%r14), RR1, RR1;
12997 + vpxor (1*16)(%r14), RL1, RL1;
12998 + vpxor (2*16)(%r14), RR2, RR2;
12999 + vpxor (3*16)(%r14), RL2, RL2;
13000 + vpxor (4*16)(%r14), RR3, RR3;
13001 + vpxor (5*16)(%r14), RL3, RL3;
13002 + vpxor (6*16)(%r14), RR4, RR4;
13003 + vpxor (7*16)(%r14), RL4, RL4;
13004 vmovdqu RR1, (0*16)(%r11);
13005 vmovdqu RL1, (1*16)(%r11);
13006 vmovdqu RR2, (2*16)(%r11);
13007 @@ -540,7 +546,8 @@ ENTRY(cast5_ctr_16way)
13008 vmovdqu RR4, (6*16)(%r11);
13009 vmovdqu RL4, (7*16)(%r11);
13010
13011 - popq %r12;
13012 + popq %r14;
13013
13014 + pax_force_retaddr
13015 ret;
13016 ENDPROC(cast5_ctr_16way)
13017 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13018 index e3531f8..e123f35 100644
13019 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13020 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13021 @@ -24,6 +24,7 @@
13022 */
13023
13024 #include <linux/linkage.h>
13025 +#include <asm/alternative-asm.h>
13026 #include "glue_helper-asm-avx.S"
13027
13028 .file "cast6-avx-x86_64-asm_64.S"
13029 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
13030 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
13031 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
13032
13033 + pax_force_retaddr
13034 ret;
13035 ENDPROC(__cast6_enc_blk8)
13036
13037 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
13038 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
13039 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
13040
13041 + pax_force_retaddr
13042 ret;
13043 ENDPROC(__cast6_dec_blk8)
13044
13045 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
13046
13047 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13048
13049 + pax_force_retaddr
13050 ret;
13051 ENDPROC(cast6_ecb_enc_8way)
13052
13053 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
13054
13055 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13056
13057 + pax_force_retaddr
13058 ret;
13059 ENDPROC(cast6_ecb_dec_8way)
13060
13061 @@ -386,19 +391,20 @@ ENTRY(cast6_cbc_dec_8way)
13062 * %rdx: src
13063 */
13064
13065 - pushq %r12;
13066 + pushq %r14;
13067
13068 movq %rsi, %r11;
13069 - movq %rdx, %r12;
13070 + movq %rdx, %r14;
13071
13072 load_8way(%rdx, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13073
13074 call __cast6_dec_blk8;
13075
13076 - store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13077 + store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13078
13079 - popq %r12;
13080 + popq %r14;
13081
13082 + pax_force_retaddr
13083 ret;
13084 ENDPROC(cast6_cbc_dec_8way)
13085
13086 @@ -410,20 +416,21 @@ ENTRY(cast6_ctr_8way)
13087 * %rcx: iv (little endian, 128bit)
13088 */
13089
13090 - pushq %r12;
13091 + pushq %r14;
13092
13093 movq %rsi, %r11;
13094 - movq %rdx, %r12;
13095 + movq %rdx, %r14;
13096
13097 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
13098 RD2, RX, RKR, RKM);
13099
13100 call __cast6_enc_blk8;
13101
13102 - store_ctr_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13103 + store_ctr_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13104
13105 - popq %r12;
13106 + popq %r14;
13107
13108 + pax_force_retaddr
13109 ret;
13110 ENDPROC(cast6_ctr_8way)
13111
13112 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
13113 /* dst <= regs xor IVs(in dst) */
13114 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13115
13116 + pax_force_retaddr
13117 ret;
13118 ENDPROC(cast6_xts_enc_8way)
13119
13120 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
13121 /* dst <= regs xor IVs(in dst) */
13122 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13123
13124 + pax_force_retaddr
13125 ret;
13126 ENDPROC(cast6_xts_dec_8way)
13127 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
13128 index dbc4339..de6e120 100644
13129 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
13130 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
13131 @@ -45,6 +45,7 @@
13132
13133 #include <asm/inst.h>
13134 #include <linux/linkage.h>
13135 +#include <asm/alternative-asm.h>
13136
13137 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
13138
13139 @@ -312,6 +313,7 @@ do_return:
13140 popq %rsi
13141 popq %rdi
13142 popq %rbx
13143 + pax_force_retaddr
13144 ret
13145
13146 ################################################################
13147 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
13148 index 586f41a..d02851e 100644
13149 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
13150 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
13151 @@ -18,6 +18,7 @@
13152
13153 #include <linux/linkage.h>
13154 #include <asm/inst.h>
13155 +#include <asm/alternative-asm.h>
13156
13157 .data
13158
13159 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
13160 psrlq $1, T2
13161 pxor T2, T1
13162 pxor T1, DATA
13163 + pax_force_retaddr
13164 ret
13165 ENDPROC(__clmul_gf128mul_ble)
13166
13167 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
13168 call __clmul_gf128mul_ble
13169 PSHUFB_XMM BSWAP DATA
13170 movups DATA, (%rdi)
13171 + pax_force_retaddr
13172 ret
13173 ENDPROC(clmul_ghash_mul)
13174
13175 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
13176 PSHUFB_XMM BSWAP DATA
13177 movups DATA, (%rdi)
13178 .Lupdate_just_ret:
13179 + pax_force_retaddr
13180 ret
13181 ENDPROC(clmul_ghash_update)
13182
13183 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
13184 pand .Lpoly, %xmm1
13185 pxor %xmm1, %xmm0
13186 movups %xmm0, (%rdi)
13187 + pax_force_retaddr
13188 ret
13189 ENDPROC(clmul_ghash_setkey)
13190 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
13191 index 9279e0b..c4b3d2c 100644
13192 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
13193 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
13194 @@ -1,4 +1,5 @@
13195 #include <linux/linkage.h>
13196 +#include <asm/alternative-asm.h>
13197
13198 # enter salsa20_encrypt_bytes
13199 ENTRY(salsa20_encrypt_bytes)
13200 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
13201 add %r11,%rsp
13202 mov %rdi,%rax
13203 mov %rsi,%rdx
13204 + pax_force_retaddr
13205 ret
13206 # bytesatleast65:
13207 ._bytesatleast65:
13208 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
13209 add %r11,%rsp
13210 mov %rdi,%rax
13211 mov %rsi,%rdx
13212 + pax_force_retaddr
13213 ret
13214 ENDPROC(salsa20_keysetup)
13215
13216 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
13217 add %r11,%rsp
13218 mov %rdi,%rax
13219 mov %rsi,%rdx
13220 + pax_force_retaddr
13221 ret
13222 ENDPROC(salsa20_ivsetup)
13223 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13224 index 2f202f4..d9164d6 100644
13225 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13226 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13227 @@ -24,6 +24,7 @@
13228 */
13229
13230 #include <linux/linkage.h>
13231 +#include <asm/alternative-asm.h>
13232 #include "glue_helper-asm-avx.S"
13233
13234 .file "serpent-avx-x86_64-asm_64.S"
13235 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
13236 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13237 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13238
13239 + pax_force_retaddr
13240 ret;
13241 ENDPROC(__serpent_enc_blk8_avx)
13242
13243 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
13244 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13245 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13246
13247 + pax_force_retaddr
13248 ret;
13249 ENDPROC(__serpent_dec_blk8_avx)
13250
13251 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
13252
13253 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13254
13255 + pax_force_retaddr
13256 ret;
13257 ENDPROC(serpent_ecb_enc_8way_avx)
13258
13259 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
13260
13261 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13262
13263 + pax_force_retaddr
13264 ret;
13265 ENDPROC(serpent_ecb_dec_8way_avx)
13266
13267 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
13268
13269 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13270
13271 + pax_force_retaddr
13272 ret;
13273 ENDPROC(serpent_cbc_dec_8way_avx)
13274
13275 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
13276
13277 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13278
13279 + pax_force_retaddr
13280 ret;
13281 ENDPROC(serpent_ctr_8way_avx)
13282
13283 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
13284 /* dst <= regs xor IVs(in dst) */
13285 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13286
13287 + pax_force_retaddr
13288 ret;
13289 ENDPROC(serpent_xts_enc_8way_avx)
13290
13291 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
13292 /* dst <= regs xor IVs(in dst) */
13293 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13294
13295 + pax_force_retaddr
13296 ret;
13297 ENDPROC(serpent_xts_dec_8way_avx)
13298 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
13299 index b222085..abd483c 100644
13300 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
13301 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
13302 @@ -15,6 +15,7 @@
13303 */
13304
13305 #include <linux/linkage.h>
13306 +#include <asm/alternative-asm.h>
13307 #include "glue_helper-asm-avx2.S"
13308
13309 .file "serpent-avx2-asm_64.S"
13310 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
13311 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13312 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13313
13314 + pax_force_retaddr
13315 ret;
13316 ENDPROC(__serpent_enc_blk16)
13317
13318 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
13319 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13320 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13321
13322 + pax_force_retaddr
13323 ret;
13324 ENDPROC(__serpent_dec_blk16)
13325
13326 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
13327
13328 vzeroupper;
13329
13330 + pax_force_retaddr
13331 ret;
13332 ENDPROC(serpent_ecb_enc_16way)
13333
13334 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
13335
13336 vzeroupper;
13337
13338 + pax_force_retaddr
13339 ret;
13340 ENDPROC(serpent_ecb_dec_16way)
13341
13342 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
13343
13344 vzeroupper;
13345
13346 + pax_force_retaddr
13347 ret;
13348 ENDPROC(serpent_cbc_dec_16way)
13349
13350 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
13351
13352 vzeroupper;
13353
13354 + pax_force_retaddr
13355 ret;
13356 ENDPROC(serpent_ctr_16way)
13357
13358 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
13359
13360 vzeroupper;
13361
13362 + pax_force_retaddr
13363 ret;
13364 ENDPROC(serpent_xts_enc_16way)
13365
13366 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
13367
13368 vzeroupper;
13369
13370 + pax_force_retaddr
13371 ret;
13372 ENDPROC(serpent_xts_dec_16way)
13373 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13374 index acc066c..1559cc4 100644
13375 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13376 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13377 @@ -25,6 +25,7 @@
13378 */
13379
13380 #include <linux/linkage.h>
13381 +#include <asm/alternative-asm.h>
13382
13383 .file "serpent-sse2-x86_64-asm_64.S"
13384 .text
13385 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
13386 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13387 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13388
13389 + pax_force_retaddr
13390 ret;
13391
13392 .L__enc_xor8:
13393 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13394 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13395
13396 + pax_force_retaddr
13397 ret;
13398 ENDPROC(__serpent_enc_blk_8way)
13399
13400 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
13401 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13402 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13403
13404 + pax_force_retaddr
13405 ret;
13406 ENDPROC(serpent_dec_blk_8way)
13407 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
13408 index a410950..9dfe7ad 100644
13409 --- a/arch/x86/crypto/sha1_ssse3_asm.S
13410 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
13411 @@ -29,6 +29,7 @@
13412 */
13413
13414 #include <linux/linkage.h>
13415 +#include <asm/alternative-asm.h>
13416
13417 #define CTX %rdi // arg1
13418 #define BUF %rsi // arg2
13419 @@ -75,9 +76,9 @@
13420
13421 push %rbx
13422 push %rbp
13423 - push %r12
13424 + push %r14
13425
13426 - mov %rsp, %r12
13427 + mov %rsp, %r14
13428 sub $64, %rsp # allocate workspace
13429 and $~15, %rsp # align stack
13430
13431 @@ -99,11 +100,12 @@
13432 xor %rax, %rax
13433 rep stosq
13434
13435 - mov %r12, %rsp # deallocate workspace
13436 + mov %r14, %rsp # deallocate workspace
13437
13438 - pop %r12
13439 + pop %r14
13440 pop %rbp
13441 pop %rbx
13442 + pax_force_retaddr
13443 ret
13444
13445 ENDPROC(\name)
13446 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
13447 index 642f156..51a513c 100644
13448 --- a/arch/x86/crypto/sha256-avx-asm.S
13449 +++ b/arch/x86/crypto/sha256-avx-asm.S
13450 @@ -49,6 +49,7 @@
13451
13452 #ifdef CONFIG_AS_AVX
13453 #include <linux/linkage.h>
13454 +#include <asm/alternative-asm.h>
13455
13456 ## assume buffers not aligned
13457 #define VMOVDQ vmovdqu
13458 @@ -460,6 +461,7 @@ done_hash:
13459 popq %r13
13460 popq %rbp
13461 popq %rbx
13462 + pax_force_retaddr
13463 ret
13464 ENDPROC(sha256_transform_avx)
13465
13466 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
13467 index 9e86944..3795e6a 100644
13468 --- a/arch/x86/crypto/sha256-avx2-asm.S
13469 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13470 @@ -50,6 +50,7 @@
13471
13472 #ifdef CONFIG_AS_AVX2
13473 #include <linux/linkage.h>
13474 +#include <asm/alternative-asm.h>
13475
13476 ## assume buffers not aligned
13477 #define VMOVDQ vmovdqu
13478 @@ -720,6 +721,7 @@ done_hash:
13479 popq %r12
13480 popq %rbp
13481 popq %rbx
13482 + pax_force_retaddr
13483 ret
13484 ENDPROC(sha256_transform_rorx)
13485
13486 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13487 index f833b74..8c62a9e 100644
13488 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13489 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13490 @@ -47,6 +47,7 @@
13491 ########################################################################
13492
13493 #include <linux/linkage.h>
13494 +#include <asm/alternative-asm.h>
13495
13496 ## assume buffers not aligned
13497 #define MOVDQ movdqu
13498 @@ -471,6 +472,7 @@ done_hash:
13499 popq %rbp
13500 popq %rbx
13501
13502 + pax_force_retaddr
13503 ret
13504 ENDPROC(sha256_transform_ssse3)
13505
13506 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13507 index 974dde9..a823ff9 100644
13508 --- a/arch/x86/crypto/sha512-avx-asm.S
13509 +++ b/arch/x86/crypto/sha512-avx-asm.S
13510 @@ -49,6 +49,7 @@
13511
13512 #ifdef CONFIG_AS_AVX
13513 #include <linux/linkage.h>
13514 +#include <asm/alternative-asm.h>
13515
13516 .text
13517
13518 @@ -364,6 +365,7 @@ updateblock:
13519 mov frame_RSPSAVE(%rsp), %rsp
13520
13521 nowork:
13522 + pax_force_retaddr
13523 ret
13524 ENDPROC(sha512_transform_avx)
13525
13526 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13527 index 568b961..ed20c37 100644
13528 --- a/arch/x86/crypto/sha512-avx2-asm.S
13529 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13530 @@ -51,6 +51,7 @@
13531
13532 #ifdef CONFIG_AS_AVX2
13533 #include <linux/linkage.h>
13534 +#include <asm/alternative-asm.h>
13535
13536 .text
13537
13538 @@ -678,6 +679,7 @@ done_hash:
13539
13540 # Restore Stack Pointer
13541 mov frame_RSPSAVE(%rsp), %rsp
13542 + pax_force_retaddr
13543 ret
13544 ENDPROC(sha512_transform_rorx)
13545
13546 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13547 index fb56855..6edd768 100644
13548 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13549 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13550 @@ -48,6 +48,7 @@
13551 ########################################################################
13552
13553 #include <linux/linkage.h>
13554 +#include <asm/alternative-asm.h>
13555
13556 .text
13557
13558 @@ -363,6 +364,7 @@ updateblock:
13559 mov frame_RSPSAVE(%rsp), %rsp
13560
13561 nowork:
13562 + pax_force_retaddr
13563 ret
13564 ENDPROC(sha512_transform_ssse3)
13565
13566 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13567 index 0505813..b067311 100644
13568 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13569 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13570 @@ -24,6 +24,7 @@
13571 */
13572
13573 #include <linux/linkage.h>
13574 +#include <asm/alternative-asm.h>
13575 #include "glue_helper-asm-avx.S"
13576
13577 .file "twofish-avx-x86_64-asm_64.S"
13578 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13579 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13580 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13581
13582 + pax_force_retaddr
13583 ret;
13584 ENDPROC(__twofish_enc_blk8)
13585
13586 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13587 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13588 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13589
13590 + pax_force_retaddr
13591 ret;
13592 ENDPROC(__twofish_dec_blk8)
13593
13594 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13595
13596 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13597
13598 + pax_force_retaddr
13599 ret;
13600 ENDPROC(twofish_ecb_enc_8way)
13601
13602 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13603
13604 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13605
13606 + pax_force_retaddr
13607 ret;
13608 ENDPROC(twofish_ecb_dec_8way)
13609
13610 @@ -370,19 +375,20 @@ ENTRY(twofish_cbc_dec_8way)
13611 * %rdx: src
13612 */
13613
13614 - pushq %r12;
13615 + pushq %r14;
13616
13617 movq %rsi, %r11;
13618 - movq %rdx, %r12;
13619 + movq %rdx, %r14;
13620
13621 load_8way(%rdx, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13622
13623 call __twofish_dec_blk8;
13624
13625 - store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13626 + store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13627
13628 - popq %r12;
13629 + popq %r14;
13630
13631 + pax_force_retaddr
13632 ret;
13633 ENDPROC(twofish_cbc_dec_8way)
13634
13635 @@ -394,20 +400,21 @@ ENTRY(twofish_ctr_8way)
13636 * %rcx: iv (little endian, 128bit)
13637 */
13638
13639 - pushq %r12;
13640 + pushq %r14;
13641
13642 movq %rsi, %r11;
13643 - movq %rdx, %r12;
13644 + movq %rdx, %r14;
13645
13646 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
13647 RD2, RX0, RX1, RY0);
13648
13649 call __twofish_enc_blk8;
13650
13651 - store_ctr_8way(%r12, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13652 + store_ctr_8way(%r14, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13653
13654 - popq %r12;
13655 + popq %r14;
13656
13657 + pax_force_retaddr
13658 ret;
13659 ENDPROC(twofish_ctr_8way)
13660
13661 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13662 /* dst <= regs xor IVs(in dst) */
13663 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13664
13665 + pax_force_retaddr
13666 ret;
13667 ENDPROC(twofish_xts_enc_8way)
13668
13669 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13670 /* dst <= regs xor IVs(in dst) */
13671 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13672
13673 + pax_force_retaddr
13674 ret;
13675 ENDPROC(twofish_xts_dec_8way)
13676 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13677 index 1c3b7ce..02f578d 100644
13678 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13679 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13680 @@ -21,6 +21,7 @@
13681 */
13682
13683 #include <linux/linkage.h>
13684 +#include <asm/alternative-asm.h>
13685
13686 .file "twofish-x86_64-asm-3way.S"
13687 .text
13688 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13689 popq %r13;
13690 popq %r14;
13691 popq %r15;
13692 + pax_force_retaddr
13693 ret;
13694
13695 .L__enc_xor3:
13696 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13697 popq %r13;
13698 popq %r14;
13699 popq %r15;
13700 + pax_force_retaddr
13701 ret;
13702 ENDPROC(__twofish_enc_blk_3way)
13703
13704 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13705 popq %r13;
13706 popq %r14;
13707 popq %r15;
13708 + pax_force_retaddr
13709 ret;
13710 ENDPROC(twofish_dec_blk_3way)
13711 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13712 index a039d21..524b8b2 100644
13713 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13714 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13715 @@ -22,6 +22,7 @@
13716
13717 #include <linux/linkage.h>
13718 #include <asm/asm-offsets.h>
13719 +#include <asm/alternative-asm.h>
13720
13721 #define a_offset 0
13722 #define b_offset 4
13723 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13724
13725 popq R1
13726 movq $1,%rax
13727 + pax_force_retaddr
13728 ret
13729 ENDPROC(twofish_enc_blk)
13730
13731 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13732
13733 popq R1
13734 movq $1,%rax
13735 + pax_force_retaddr
13736 ret
13737 ENDPROC(twofish_dec_blk)
13738 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13739 index bae3aba..c1788c1 100644
13740 --- a/arch/x86/ia32/ia32_aout.c
13741 +++ b/arch/x86/ia32/ia32_aout.c
13742 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13743 unsigned long dump_start, dump_size;
13744 struct user32 dump;
13745
13746 + memset(&dump, 0, sizeof(dump));
13747 +
13748 fs = get_fs();
13749 set_fs(KERNEL_DS);
13750 has_dumped = 1;
13751 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13752 index 665a730..8e7a67a 100644
13753 --- a/arch/x86/ia32/ia32_signal.c
13754 +++ b/arch/x86/ia32/ia32_signal.c
13755 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13756 sp -= frame_size;
13757 /* Align the stack pointer according to the i386 ABI,
13758 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13759 - sp = ((sp + 4) & -16ul) - 4;
13760 + sp = ((sp - 12) & -16ul) - 4;
13761 return (void __user *) sp;
13762 }
13763
13764 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13765 * These are actually not used anymore, but left because some
13766 * gdb versions depend on them as a marker.
13767 */
13768 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13769 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13770 } put_user_catch(err);
13771
13772 if (err)
13773 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13774 0xb8,
13775 __NR_ia32_rt_sigreturn,
13776 0x80cd,
13777 - 0,
13778 + 0
13779 };
13780
13781 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13782 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13783
13784 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13785 restorer = ksig->ka.sa.sa_restorer;
13786 + else if (current->mm->context.vdso)
13787 + /* Return stub is in 32bit vsyscall page */
13788 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13789 else
13790 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13791 - rt_sigreturn);
13792 + restorer = &frame->retcode;
13793 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13794
13795 /*
13796 * Not actually used anymore, but left because some gdb
13797 * versions need it.
13798 */
13799 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13800 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13801 } put_user_catch(err);
13802
13803 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13804 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13805 index 4299eb0..c0687a7 100644
13806 --- a/arch/x86/ia32/ia32entry.S
13807 +++ b/arch/x86/ia32/ia32entry.S
13808 @@ -15,8 +15,10 @@
13809 #include <asm/irqflags.h>
13810 #include <asm/asm.h>
13811 #include <asm/smap.h>
13812 +#include <asm/pgtable.h>
13813 #include <linux/linkage.h>
13814 #include <linux/err.h>
13815 +#include <asm/alternative-asm.h>
13816
13817 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13818 #include <linux/elf-em.h>
13819 @@ -62,12 +64,12 @@
13820 */
13821 .macro LOAD_ARGS32 offset, _r9=0
13822 .if \_r9
13823 - movl \offset+16(%rsp),%r9d
13824 + movl \offset+R9(%rsp),%r9d
13825 .endif
13826 - movl \offset+40(%rsp),%ecx
13827 - movl \offset+48(%rsp),%edx
13828 - movl \offset+56(%rsp),%esi
13829 - movl \offset+64(%rsp),%edi
13830 + movl \offset+RCX(%rsp),%ecx
13831 + movl \offset+RDX(%rsp),%edx
13832 + movl \offset+RSI(%rsp),%esi
13833 + movl \offset+RDI(%rsp),%edi
13834 movl %eax,%eax /* zero extension */
13835 .endm
13836
13837 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13838 ENDPROC(native_irq_enable_sysexit)
13839 #endif
13840
13841 + .macro pax_enter_kernel_user
13842 + pax_set_fptr_mask
13843 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13844 + call pax_enter_kernel_user
13845 +#endif
13846 + .endm
13847 +
13848 + .macro pax_exit_kernel_user
13849 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13850 + call pax_exit_kernel_user
13851 +#endif
13852 +#ifdef CONFIG_PAX_RANDKSTACK
13853 + pushq %rax
13854 + pushq %r11
13855 + call pax_randomize_kstack
13856 + popq %r11
13857 + popq %rax
13858 +#endif
13859 + .endm
13860 +
13861 + .macro pax_erase_kstack
13862 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13863 + call pax_erase_kstack
13864 +#endif
13865 + .endm
13866 +
13867 /*
13868 * 32bit SYSENTER instruction entry.
13869 *
13870 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13871 CFI_REGISTER rsp,rbp
13872 SWAPGS_UNSAFE_STACK
13873 movq PER_CPU_VAR(kernel_stack), %rsp
13874 - addq $(KERNEL_STACK_OFFSET),%rsp
13875 - /*
13876 - * No need to follow this irqs on/off section: the syscall
13877 - * disabled irqs, here we enable it straight after entry:
13878 - */
13879 - ENABLE_INTERRUPTS(CLBR_NONE)
13880 movl %ebp,%ebp /* zero extension */
13881 pushq_cfi $__USER32_DS
13882 /*CFI_REL_OFFSET ss,0*/
13883 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13884 CFI_REL_OFFSET rsp,0
13885 pushfq_cfi
13886 /*CFI_REL_OFFSET rflags,0*/
13887 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13888 - CFI_REGISTER rip,r10
13889 + orl $X86_EFLAGS_IF,(%rsp)
13890 + GET_THREAD_INFO(%r11)
13891 + movl TI_sysenter_return(%r11), %r11d
13892 + CFI_REGISTER rip,r11
13893 pushq_cfi $__USER32_CS
13894 /*CFI_REL_OFFSET cs,0*/
13895 movl %eax, %eax
13896 - pushq_cfi %r10
13897 + pushq_cfi %r11
13898 CFI_REL_OFFSET rip,0
13899 pushq_cfi %rax
13900 cld
13901 SAVE_ARGS 0,1,0
13902 + pax_enter_kernel_user
13903 +
13904 +#ifdef CONFIG_PAX_RANDKSTACK
13905 + pax_erase_kstack
13906 +#endif
13907 +
13908 + /*
13909 + * No need to follow this irqs on/off section: the syscall
13910 + * disabled irqs, here we enable it straight after entry:
13911 + */
13912 + ENABLE_INTERRUPTS(CLBR_NONE)
13913 /* no need to do an access_ok check here because rbp has been
13914 32bit zero extended */
13915 +
13916 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13917 + addq pax_user_shadow_base,%rbp
13918 + ASM_PAX_OPEN_USERLAND
13919 +#endif
13920 +
13921 ASM_STAC
13922 1: movl (%rbp),%ebp
13923 _ASM_EXTABLE(1b,ia32_badarg)
13924 ASM_CLAC
13925 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13926 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13927 +
13928 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13929 + ASM_PAX_CLOSE_USERLAND
13930 +#endif
13931 +
13932 + GET_THREAD_INFO(%r11)
13933 + orl $TS_COMPAT,TI_status(%r11)
13934 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13935 CFI_REMEMBER_STATE
13936 jnz sysenter_tracesys
13937 cmpq $(IA32_NR_syscalls-1),%rax
13938 @@ -162,15 +209,18 @@ sysenter_do_call:
13939 sysenter_dispatch:
13940 call *ia32_sys_call_table(,%rax,8)
13941 movq %rax,RAX-ARGOFFSET(%rsp)
13942 + GET_THREAD_INFO(%r11)
13943 DISABLE_INTERRUPTS(CLBR_NONE)
13944 TRACE_IRQS_OFF
13945 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13946 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13947 jnz sysexit_audit
13948 sysexit_from_sys_call:
13949 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13950 + pax_exit_kernel_user
13951 + pax_erase_kstack
13952 + andl $~TS_COMPAT,TI_status(%r11)
13953 /* clear IF, that popfq doesn't enable interrupts early */
13954 - andl $~0x200,EFLAGS-R11(%rsp)
13955 - movl RIP-R11(%rsp),%edx /* User %eip */
13956 + andl $~X86_EFLAGS_IF,EFLAGS(%rsp)
13957 + movl RIP(%rsp),%edx /* User %eip */
13958 CFI_REGISTER rip,rdx
13959 RESTORE_ARGS 0,24,0,0,0,0
13960 xorq %r8,%r8
13961 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13962 movl %eax,%esi /* 2nd arg: syscall number */
13963 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13964 call __audit_syscall_entry
13965 +
13966 + pax_erase_kstack
13967 +
13968 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13969 cmpq $(IA32_NR_syscalls-1),%rax
13970 ja ia32_badsys
13971 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13972 .endm
13973
13974 .macro auditsys_exit exit
13975 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13976 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13977 jnz ia32_ret_from_sys_call
13978 TRACE_IRQS_ON
13979 ENABLE_INTERRUPTS(CLBR_NONE)
13980 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13981 1: setbe %al /* 1 if error, 0 if not */
13982 movzbl %al,%edi /* zero-extend that into %edi */
13983 call __audit_syscall_exit
13984 + GET_THREAD_INFO(%r11)
13985 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13986 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13987 DISABLE_INTERRUPTS(CLBR_NONE)
13988 TRACE_IRQS_OFF
13989 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13990 + testl %edi,TI_flags(%r11)
13991 jz \exit
13992 CLEAR_RREGS -ARGOFFSET
13993 jmp int_with_check
13994 @@ -237,7 +291,7 @@ sysexit_audit:
13995
13996 sysenter_tracesys:
13997 #ifdef CONFIG_AUDITSYSCALL
13998 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13999 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
14000 jz sysenter_auditsys
14001 #endif
14002 SAVE_REST
14003 @@ -249,6 +303,9 @@ sysenter_tracesys:
14004 RESTORE_REST
14005 cmpq $(IA32_NR_syscalls-1),%rax
14006 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
14007 +
14008 + pax_erase_kstack
14009 +
14010 jmp sysenter_do_call
14011 CFI_ENDPROC
14012 ENDPROC(ia32_sysenter_target)
14013 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
14014 ENTRY(ia32_cstar_target)
14015 CFI_STARTPROC32 simple
14016 CFI_SIGNAL_FRAME
14017 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
14018 + CFI_DEF_CFA rsp,0
14019 CFI_REGISTER rip,rcx
14020 /*CFI_REGISTER rflags,r11*/
14021 SWAPGS_UNSAFE_STACK
14022 movl %esp,%r8d
14023 CFI_REGISTER rsp,r8
14024 movq PER_CPU_VAR(kernel_stack),%rsp
14025 + SAVE_ARGS 8*6,0,0
14026 + pax_enter_kernel_user
14027 +
14028 +#ifdef CONFIG_PAX_RANDKSTACK
14029 + pax_erase_kstack
14030 +#endif
14031 +
14032 /*
14033 * No need to follow this irqs on/off section: the syscall
14034 * disabled irqs and here we enable it straight after entry:
14035 */
14036 ENABLE_INTERRUPTS(CLBR_NONE)
14037 - SAVE_ARGS 8,0,0
14038 movl %eax,%eax /* zero extension */
14039 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
14040 movq %rcx,RIP-ARGOFFSET(%rsp)
14041 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
14042 /* no need to do an access_ok check here because r8 has been
14043 32bit zero extended */
14044 /* hardware stack frame is complete now */
14045 +
14046 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14047 + ASM_PAX_OPEN_USERLAND
14048 + movq pax_user_shadow_base,%r8
14049 + addq RSP-ARGOFFSET(%rsp),%r8
14050 +#endif
14051 +
14052 ASM_STAC
14053 1: movl (%r8),%r9d
14054 _ASM_EXTABLE(1b,ia32_badarg)
14055 ASM_CLAC
14056 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14057 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14058 +
14059 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14060 + ASM_PAX_CLOSE_USERLAND
14061 +#endif
14062 +
14063 + GET_THREAD_INFO(%r11)
14064 + orl $TS_COMPAT,TI_status(%r11)
14065 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
14066 CFI_REMEMBER_STATE
14067 jnz cstar_tracesys
14068 cmpq $IA32_NR_syscalls-1,%rax
14069 @@ -319,13 +395,16 @@ cstar_do_call:
14070 cstar_dispatch:
14071 call *ia32_sys_call_table(,%rax,8)
14072 movq %rax,RAX-ARGOFFSET(%rsp)
14073 + GET_THREAD_INFO(%r11)
14074 DISABLE_INTERRUPTS(CLBR_NONE)
14075 TRACE_IRQS_OFF
14076 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14077 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
14078 jnz sysretl_audit
14079 sysretl_from_sys_call:
14080 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14081 - RESTORE_ARGS 0,-ARG_SKIP,0,0,0
14082 + pax_exit_kernel_user
14083 + pax_erase_kstack
14084 + andl $~TS_COMPAT,TI_status(%r11)
14085 + RESTORE_ARGS 0,-ORIG_RAX,0,0,0
14086 movl RIP-ARGOFFSET(%rsp),%ecx
14087 CFI_REGISTER rip,rcx
14088 movl EFLAGS-ARGOFFSET(%rsp),%r11d
14089 @@ -352,7 +431,7 @@ sysretl_audit:
14090
14091 cstar_tracesys:
14092 #ifdef CONFIG_AUDITSYSCALL
14093 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14094 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
14095 jz cstar_auditsys
14096 #endif
14097 xchgl %r9d,%ebp
14098 @@ -366,11 +445,19 @@ cstar_tracesys:
14099 xchgl %ebp,%r9d
14100 cmpq $(IA32_NR_syscalls-1),%rax
14101 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
14102 +
14103 + pax_erase_kstack
14104 +
14105 jmp cstar_do_call
14106 END(ia32_cstar_target)
14107
14108 ia32_badarg:
14109 ASM_CLAC
14110 +
14111 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14112 + ASM_PAX_CLOSE_USERLAND
14113 +#endif
14114 +
14115 movq $-EFAULT,%rax
14116 jmp ia32_sysret
14117 CFI_ENDPROC
14118 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
14119 CFI_REL_OFFSET rip,RIP-RIP
14120 PARAVIRT_ADJUST_EXCEPTION_FRAME
14121 SWAPGS
14122 - /*
14123 - * No need to follow this irqs on/off section: the syscall
14124 - * disabled irqs and here we enable it straight after entry:
14125 - */
14126 - ENABLE_INTERRUPTS(CLBR_NONE)
14127 movl %eax,%eax
14128 pushq_cfi %rax
14129 cld
14130 /* note the registers are not zero extended to the sf.
14131 this could be a problem. */
14132 SAVE_ARGS 0,1,0
14133 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14134 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14135 + pax_enter_kernel_user
14136 +
14137 +#ifdef CONFIG_PAX_RANDKSTACK
14138 + pax_erase_kstack
14139 +#endif
14140 +
14141 + /*
14142 + * No need to follow this irqs on/off section: the syscall
14143 + * disabled irqs and here we enable it straight after entry:
14144 + */
14145 + ENABLE_INTERRUPTS(CLBR_NONE)
14146 + GET_THREAD_INFO(%r11)
14147 + orl $TS_COMPAT,TI_status(%r11)
14148 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
14149 jnz ia32_tracesys
14150 cmpq $(IA32_NR_syscalls-1),%rax
14151 ja ia32_badsys
14152 @@ -442,6 +536,9 @@ ia32_tracesys:
14153 RESTORE_REST
14154 cmpq $(IA32_NR_syscalls-1),%rax
14155 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
14156 +
14157 + pax_erase_kstack
14158 +
14159 jmp ia32_do_call
14160 END(ia32_syscall)
14161
14162 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
14163 index 8e0ceec..af13504 100644
14164 --- a/arch/x86/ia32/sys_ia32.c
14165 +++ b/arch/x86/ia32/sys_ia32.c
14166 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
14167 */
14168 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
14169 {
14170 - typeof(ubuf->st_uid) uid = 0;
14171 - typeof(ubuf->st_gid) gid = 0;
14172 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
14173 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
14174 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
14175 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
14176 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
14177 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
14178 index 372231c..51b537d 100644
14179 --- a/arch/x86/include/asm/alternative-asm.h
14180 +++ b/arch/x86/include/asm/alternative-asm.h
14181 @@ -18,6 +18,45 @@
14182 .endm
14183 #endif
14184
14185 +#ifdef KERNEXEC_PLUGIN
14186 + .macro pax_force_retaddr_bts rip=0
14187 + btsq $63,\rip(%rsp)
14188 + .endm
14189 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14190 + .macro pax_force_retaddr rip=0, reload=0
14191 + btsq $63,\rip(%rsp)
14192 + .endm
14193 + .macro pax_force_fptr ptr
14194 + btsq $63,\ptr
14195 + .endm
14196 + .macro pax_set_fptr_mask
14197 + .endm
14198 +#endif
14199 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14200 + .macro pax_force_retaddr rip=0, reload=0
14201 + .if \reload
14202 + pax_set_fptr_mask
14203 + .endif
14204 + orq %r12,\rip(%rsp)
14205 + .endm
14206 + .macro pax_force_fptr ptr
14207 + orq %r12,\ptr
14208 + .endm
14209 + .macro pax_set_fptr_mask
14210 + movabs $0x8000000000000000,%r12
14211 + .endm
14212 +#endif
14213 +#else
14214 + .macro pax_force_retaddr rip=0, reload=0
14215 + .endm
14216 + .macro pax_force_fptr ptr
14217 + .endm
14218 + .macro pax_force_retaddr_bts rip=0
14219 + .endm
14220 + .macro pax_set_fptr_mask
14221 + .endm
14222 +#endif
14223 +
14224 .macro altinstruction_entry orig alt feature orig_len alt_len
14225 .long \orig - .
14226 .long \alt - .
14227 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
14228 index 0a3f9c9..c9d081d 100644
14229 --- a/arch/x86/include/asm/alternative.h
14230 +++ b/arch/x86/include/asm/alternative.h
14231 @@ -106,7 +106,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
14232 ".pushsection .discard,\"aw\",@progbits\n" \
14233 DISCARD_ENTRY(1) \
14234 ".popsection\n" \
14235 - ".pushsection .altinstr_replacement, \"ax\"\n" \
14236 + ".pushsection .altinstr_replacement, \"a\"\n" \
14237 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
14238 ".popsection"
14239
14240 @@ -120,7 +120,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
14241 DISCARD_ENTRY(1) \
14242 DISCARD_ENTRY(2) \
14243 ".popsection\n" \
14244 - ".pushsection .altinstr_replacement, \"ax\"\n" \
14245 + ".pushsection .altinstr_replacement, \"a\"\n" \
14246 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
14247 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
14248 ".popsection"
14249 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
14250 index 1d2091a..f5074c1 100644
14251 --- a/arch/x86/include/asm/apic.h
14252 +++ b/arch/x86/include/asm/apic.h
14253 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
14254
14255 #ifdef CONFIG_X86_LOCAL_APIC
14256
14257 -extern unsigned int apic_verbosity;
14258 +extern int apic_verbosity;
14259 extern int local_apic_timer_c2_ok;
14260
14261 extern int disable_apic;
14262 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
14263 index 20370c6..a2eb9b0 100644
14264 --- a/arch/x86/include/asm/apm.h
14265 +++ b/arch/x86/include/asm/apm.h
14266 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
14267 __asm__ __volatile__(APM_DO_ZERO_SEGS
14268 "pushl %%edi\n\t"
14269 "pushl %%ebp\n\t"
14270 - "lcall *%%cs:apm_bios_entry\n\t"
14271 + "lcall *%%ss:apm_bios_entry\n\t"
14272 "setc %%al\n\t"
14273 "popl %%ebp\n\t"
14274 "popl %%edi\n\t"
14275 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
14276 __asm__ __volatile__(APM_DO_ZERO_SEGS
14277 "pushl %%edi\n\t"
14278 "pushl %%ebp\n\t"
14279 - "lcall *%%cs:apm_bios_entry\n\t"
14280 + "lcall *%%ss:apm_bios_entry\n\t"
14281 "setc %%bl\n\t"
14282 "popl %%ebp\n\t"
14283 "popl %%edi\n\t"
14284 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
14285 index 722aa3b..c392d85 100644
14286 --- a/arch/x86/include/asm/atomic.h
14287 +++ b/arch/x86/include/asm/atomic.h
14288 @@ -22,7 +22,18 @@
14289 */
14290 static inline int atomic_read(const atomic_t *v)
14291 {
14292 - return (*(volatile int *)&(v)->counter);
14293 + return (*(volatile const int *)&(v)->counter);
14294 +}
14295 +
14296 +/**
14297 + * atomic_read_unchecked - read atomic variable
14298 + * @v: pointer of type atomic_unchecked_t
14299 + *
14300 + * Atomically reads the value of @v.
14301 + */
14302 +static inline int __intentional_overflow(-1) atomic_read_unchecked(const atomic_unchecked_t *v)
14303 +{
14304 + return (*(volatile const int *)&(v)->counter);
14305 }
14306
14307 /**
14308 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
14309 }
14310
14311 /**
14312 + * atomic_set_unchecked - set atomic variable
14313 + * @v: pointer of type atomic_unchecked_t
14314 + * @i: required value
14315 + *
14316 + * Atomically sets the value of @v to @i.
14317 + */
14318 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
14319 +{
14320 + v->counter = i;
14321 +}
14322 +
14323 +/**
14324 * atomic_add - add integer to atomic variable
14325 * @i: integer value to add
14326 * @v: pointer of type atomic_t
14327 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
14328 */
14329 static inline void atomic_add(int i, atomic_t *v)
14330 {
14331 - asm volatile(LOCK_PREFIX "addl %1,%0"
14332 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
14333 +
14334 +#ifdef CONFIG_PAX_REFCOUNT
14335 + "jno 0f\n"
14336 + LOCK_PREFIX "subl %1,%0\n"
14337 + "int $4\n0:\n"
14338 + _ASM_EXTABLE(0b, 0b)
14339 +#endif
14340 +
14341 + : "+m" (v->counter)
14342 + : "ir" (i));
14343 +}
14344 +
14345 +/**
14346 + * atomic_add_unchecked - add integer to atomic variable
14347 + * @i: integer value to add
14348 + * @v: pointer of type atomic_unchecked_t
14349 + *
14350 + * Atomically adds @i to @v.
14351 + */
14352 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
14353 +{
14354 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
14355 : "+m" (v->counter)
14356 : "ir" (i));
14357 }
14358 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
14359 */
14360 static inline void atomic_sub(int i, atomic_t *v)
14361 {
14362 - asm volatile(LOCK_PREFIX "subl %1,%0"
14363 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
14364 +
14365 +#ifdef CONFIG_PAX_REFCOUNT
14366 + "jno 0f\n"
14367 + LOCK_PREFIX "addl %1,%0\n"
14368 + "int $4\n0:\n"
14369 + _ASM_EXTABLE(0b, 0b)
14370 +#endif
14371 +
14372 + : "+m" (v->counter)
14373 + : "ir" (i));
14374 +}
14375 +
14376 +/**
14377 + * atomic_sub_unchecked - subtract integer from atomic variable
14378 + * @i: integer value to subtract
14379 + * @v: pointer of type atomic_unchecked_t
14380 + *
14381 + * Atomically subtracts @i from @v.
14382 + */
14383 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
14384 +{
14385 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
14386 : "+m" (v->counter)
14387 : "ir" (i));
14388 }
14389 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
14390 {
14391 unsigned char c;
14392
14393 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
14394 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
14395 +
14396 +#ifdef CONFIG_PAX_REFCOUNT
14397 + "jno 0f\n"
14398 + LOCK_PREFIX "addl %2,%0\n"
14399 + "int $4\n0:\n"
14400 + _ASM_EXTABLE(0b, 0b)
14401 +#endif
14402 +
14403 + "sete %1\n"
14404 : "+m" (v->counter), "=qm" (c)
14405 : "ir" (i) : "memory");
14406 return c;
14407 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
14408 */
14409 static inline void atomic_inc(atomic_t *v)
14410 {
14411 - asm volatile(LOCK_PREFIX "incl %0"
14412 + asm volatile(LOCK_PREFIX "incl %0\n"
14413 +
14414 +#ifdef CONFIG_PAX_REFCOUNT
14415 + "jno 0f\n"
14416 + LOCK_PREFIX "decl %0\n"
14417 + "int $4\n0:\n"
14418 + _ASM_EXTABLE(0b, 0b)
14419 +#endif
14420 +
14421 + : "+m" (v->counter));
14422 +}
14423 +
14424 +/**
14425 + * atomic_inc_unchecked - increment atomic variable
14426 + * @v: pointer of type atomic_unchecked_t
14427 + *
14428 + * Atomically increments @v by 1.
14429 + */
14430 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
14431 +{
14432 + asm volatile(LOCK_PREFIX "incl %0\n"
14433 : "+m" (v->counter));
14434 }
14435
14436 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
14437 */
14438 static inline void atomic_dec(atomic_t *v)
14439 {
14440 - asm volatile(LOCK_PREFIX "decl %0"
14441 + asm volatile(LOCK_PREFIX "decl %0\n"
14442 +
14443 +#ifdef CONFIG_PAX_REFCOUNT
14444 + "jno 0f\n"
14445 + LOCK_PREFIX "incl %0\n"
14446 + "int $4\n0:\n"
14447 + _ASM_EXTABLE(0b, 0b)
14448 +#endif
14449 +
14450 + : "+m" (v->counter));
14451 +}
14452 +
14453 +/**
14454 + * atomic_dec_unchecked - decrement atomic variable
14455 + * @v: pointer of type atomic_unchecked_t
14456 + *
14457 + * Atomically decrements @v by 1.
14458 + */
14459 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
14460 +{
14461 + asm volatile(LOCK_PREFIX "decl %0\n"
14462 : "+m" (v->counter));
14463 }
14464
14465 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
14466 {
14467 unsigned char c;
14468
14469 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
14470 + asm volatile(LOCK_PREFIX "decl %0\n"
14471 +
14472 +#ifdef CONFIG_PAX_REFCOUNT
14473 + "jno 0f\n"
14474 + LOCK_PREFIX "incl %0\n"
14475 + "int $4\n0:\n"
14476 + _ASM_EXTABLE(0b, 0b)
14477 +#endif
14478 +
14479 + "sete %1\n"
14480 : "+m" (v->counter), "=qm" (c)
14481 : : "memory");
14482 return c != 0;
14483 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
14484 {
14485 unsigned char c;
14486
14487 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
14488 + asm volatile(LOCK_PREFIX "incl %0\n"
14489 +
14490 +#ifdef CONFIG_PAX_REFCOUNT
14491 + "jno 0f\n"
14492 + LOCK_PREFIX "decl %0\n"
14493 + "int $4\n0:\n"
14494 + _ASM_EXTABLE(0b, 0b)
14495 +#endif
14496 +
14497 + "sete %1\n"
14498 + : "+m" (v->counter), "=qm" (c)
14499 + : : "memory");
14500 + return c != 0;
14501 +}
14502 +
14503 +/**
14504 + * atomic_inc_and_test_unchecked - increment and test
14505 + * @v: pointer of type atomic_unchecked_t
14506 + *
14507 + * Atomically increments @v by 1
14508 + * and returns true if the result is zero, or false for all
14509 + * other cases.
14510 + */
14511 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
14512 +{
14513 + unsigned char c;
14514 +
14515 + asm volatile(LOCK_PREFIX "incl %0\n"
14516 + "sete %1\n"
14517 : "+m" (v->counter), "=qm" (c)
14518 : : "memory");
14519 return c != 0;
14520 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14521 {
14522 unsigned char c;
14523
14524 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
14525 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
14526 +
14527 +#ifdef CONFIG_PAX_REFCOUNT
14528 + "jno 0f\n"
14529 + LOCK_PREFIX "subl %2,%0\n"
14530 + "int $4\n0:\n"
14531 + _ASM_EXTABLE(0b, 0b)
14532 +#endif
14533 +
14534 + "sets %1\n"
14535 : "+m" (v->counter), "=qm" (c)
14536 : "ir" (i) : "memory");
14537 return c;
14538 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14539 */
14540 static inline int atomic_add_return(int i, atomic_t *v)
14541 {
14542 + return i + xadd_check_overflow(&v->counter, i);
14543 +}
14544 +
14545 +/**
14546 + * atomic_add_return_unchecked - add integer and return
14547 + * @i: integer value to add
14548 + * @v: pointer of type atomic_unchecked_t
14549 + *
14550 + * Atomically adds @i to @v and returns @i + @v
14551 + */
14552 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14553 +{
14554 return i + xadd(&v->counter, i);
14555 }
14556
14557 @@ -188,9 +362,18 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14558 }
14559
14560 #define atomic_inc_return(v) (atomic_add_return(1, v))
14561 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14562 +{
14563 + return atomic_add_return_unchecked(1, v);
14564 +}
14565 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14566
14567 -static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14568 +static inline int __intentional_overflow(-1) atomic_cmpxchg(atomic_t *v, int old, int new)
14569 +{
14570 + return cmpxchg(&v->counter, old, new);
14571 +}
14572 +
14573 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14574 {
14575 return cmpxchg(&v->counter, old, new);
14576 }
14577 @@ -200,6 +383,11 @@ static inline int atomic_xchg(atomic_t *v, int new)
14578 return xchg(&v->counter, new);
14579 }
14580
14581 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14582 +{
14583 + return xchg(&v->counter, new);
14584 +}
14585 +
14586 /**
14587 * __atomic_add_unless - add unless the number is already a given value
14588 * @v: pointer of type atomic_t
14589 @@ -209,14 +397,27 @@ static inline int atomic_xchg(atomic_t *v, int new)
14590 * Atomically adds @a to @v, so long as @v was not already @u.
14591 * Returns the old value of @v.
14592 */
14593 -static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14594 +static inline int __intentional_overflow(-1) __atomic_add_unless(atomic_t *v, int a, int u)
14595 {
14596 - int c, old;
14597 + int c, old, new;
14598 c = atomic_read(v);
14599 for (;;) {
14600 - if (unlikely(c == (u)))
14601 + if (unlikely(c == u))
14602 break;
14603 - old = atomic_cmpxchg((v), c, c + (a));
14604 +
14605 + asm volatile("addl %2,%0\n"
14606 +
14607 +#ifdef CONFIG_PAX_REFCOUNT
14608 + "jno 0f\n"
14609 + "subl %2,%0\n"
14610 + "int $4\n0:\n"
14611 + _ASM_EXTABLE(0b, 0b)
14612 +#endif
14613 +
14614 + : "=r" (new)
14615 + : "0" (c), "ir" (a));
14616 +
14617 + old = atomic_cmpxchg(v, c, new);
14618 if (likely(old == c))
14619 break;
14620 c = old;
14621 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14622 }
14623
14624 /**
14625 + * atomic_inc_not_zero_hint - increment if not null
14626 + * @v: pointer of type atomic_t
14627 + * @hint: probable value of the atomic before the increment
14628 + *
14629 + * This version of atomic_inc_not_zero() gives a hint of probable
14630 + * value of the atomic. This helps processor to not read the memory
14631 + * before doing the atomic read/modify/write cycle, lowering
14632 + * number of bus transactions on some arches.
14633 + *
14634 + * Returns: 0 if increment was not done, 1 otherwise.
14635 + */
14636 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14637 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14638 +{
14639 + int val, c = hint, new;
14640 +
14641 + /* sanity test, should be removed by compiler if hint is a constant */
14642 + if (!hint)
14643 + return __atomic_add_unless(v, 1, 0);
14644 +
14645 + do {
14646 + asm volatile("incl %0\n"
14647 +
14648 +#ifdef CONFIG_PAX_REFCOUNT
14649 + "jno 0f\n"
14650 + "decl %0\n"
14651 + "int $4\n0:\n"
14652 + _ASM_EXTABLE(0b, 0b)
14653 +#endif
14654 +
14655 + : "=r" (new)
14656 + : "0" (c));
14657 +
14658 + val = atomic_cmpxchg(v, c, new);
14659 + if (val == c)
14660 + return 1;
14661 + c = val;
14662 + } while (c);
14663 +
14664 + return 0;
14665 +}
14666 +
14667 +/**
14668 * atomic_inc_short - increment of a short integer
14669 * @v: pointer to type int
14670 *
14671 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14672 #endif
14673
14674 /* These are x86-specific, used by some header files */
14675 -#define atomic_clear_mask(mask, addr) \
14676 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14677 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14678 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14679 +{
14680 + asm volatile(LOCK_PREFIX "andl %1,%0"
14681 + : "+m" (v->counter)
14682 + : "r" (~(mask))
14683 + : "memory");
14684 +}
14685
14686 -#define atomic_set_mask(mask, addr) \
14687 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14688 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14689 - : "memory")
14690 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14691 +{
14692 + asm volatile(LOCK_PREFIX "andl %1,%0"
14693 + : "+m" (v->counter)
14694 + : "r" (~(mask))
14695 + : "memory");
14696 +}
14697 +
14698 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14699 +{
14700 + asm volatile(LOCK_PREFIX "orl %1,%0"
14701 + : "+m" (v->counter)
14702 + : "r" (mask)
14703 + : "memory");
14704 +}
14705 +
14706 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14707 +{
14708 + asm volatile(LOCK_PREFIX "orl %1,%0"
14709 + : "+m" (v->counter)
14710 + : "r" (mask)
14711 + : "memory");
14712 +}
14713
14714 /* Atomic operations are already serializing on x86 */
14715 #define smp_mb__before_atomic_dec() barrier()
14716 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14717 index b154de7..bf18a5a 100644
14718 --- a/arch/x86/include/asm/atomic64_32.h
14719 +++ b/arch/x86/include/asm/atomic64_32.h
14720 @@ -12,6 +12,14 @@ typedef struct {
14721 u64 __aligned(8) counter;
14722 } atomic64_t;
14723
14724 +#ifdef CONFIG_PAX_REFCOUNT
14725 +typedef struct {
14726 + u64 __aligned(8) counter;
14727 +} atomic64_unchecked_t;
14728 +#else
14729 +typedef atomic64_t atomic64_unchecked_t;
14730 +#endif
14731 +
14732 #define ATOMIC64_INIT(val) { (val) }
14733
14734 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14735 @@ -37,21 +45,31 @@ typedef struct {
14736 ATOMIC64_DECL_ONE(sym##_386)
14737
14738 ATOMIC64_DECL_ONE(add_386);
14739 +ATOMIC64_DECL_ONE(add_unchecked_386);
14740 ATOMIC64_DECL_ONE(sub_386);
14741 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14742 ATOMIC64_DECL_ONE(inc_386);
14743 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14744 ATOMIC64_DECL_ONE(dec_386);
14745 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14746 #endif
14747
14748 #define alternative_atomic64(f, out, in...) \
14749 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14750
14751 ATOMIC64_DECL(read);
14752 +ATOMIC64_DECL(read_unchecked);
14753 ATOMIC64_DECL(set);
14754 +ATOMIC64_DECL(set_unchecked);
14755 ATOMIC64_DECL(xchg);
14756 ATOMIC64_DECL(add_return);
14757 +ATOMIC64_DECL(add_return_unchecked);
14758 ATOMIC64_DECL(sub_return);
14759 +ATOMIC64_DECL(sub_return_unchecked);
14760 ATOMIC64_DECL(inc_return);
14761 +ATOMIC64_DECL(inc_return_unchecked);
14762 ATOMIC64_DECL(dec_return);
14763 +ATOMIC64_DECL(dec_return_unchecked);
14764 ATOMIC64_DECL(dec_if_positive);
14765 ATOMIC64_DECL(inc_not_zero);
14766 ATOMIC64_DECL(add_unless);
14767 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14768 }
14769
14770 /**
14771 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14772 + * @p: pointer to type atomic64_unchecked_t
14773 + * @o: expected value
14774 + * @n: new value
14775 + *
14776 + * Atomically sets @v to @n if it was equal to @o and returns
14777 + * the old value.
14778 + */
14779 +
14780 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14781 +{
14782 + return cmpxchg64(&v->counter, o, n);
14783 +}
14784 +
14785 +/**
14786 * atomic64_xchg - xchg atomic64 variable
14787 * @v: pointer to type atomic64_t
14788 * @n: value to assign
14789 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14790 }
14791
14792 /**
14793 + * atomic64_set_unchecked - set atomic64 variable
14794 + * @v: pointer to type atomic64_unchecked_t
14795 + * @n: value to assign
14796 + *
14797 + * Atomically sets the value of @v to @n.
14798 + */
14799 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14800 +{
14801 + unsigned high = (unsigned)(i >> 32);
14802 + unsigned low = (unsigned)i;
14803 + alternative_atomic64(set, /* no output */,
14804 + "S" (v), "b" (low), "c" (high)
14805 + : "eax", "edx", "memory");
14806 +}
14807 +
14808 +/**
14809 * atomic64_read - read atomic64 variable
14810 * @v: pointer to type atomic64_t
14811 *
14812 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14813 }
14814
14815 /**
14816 + * atomic64_read_unchecked - read atomic64 variable
14817 + * @v: pointer to type atomic64_unchecked_t
14818 + *
14819 + * Atomically reads the value of @v and returns it.
14820 + */
14821 +static inline long long __intentional_overflow(-1) atomic64_read_unchecked(atomic64_unchecked_t *v)
14822 +{
14823 + long long r;
14824 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14825 + return r;
14826 + }
14827 +
14828 +/**
14829 * atomic64_add_return - add and return
14830 * @i: integer value to add
14831 * @v: pointer to type atomic64_t
14832 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14833 return i;
14834 }
14835
14836 +/**
14837 + * atomic64_add_return_unchecked - add and return
14838 + * @i: integer value to add
14839 + * @v: pointer to type atomic64_unchecked_t
14840 + *
14841 + * Atomically adds @i to @v and returns @i + *@v
14842 + */
14843 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14844 +{
14845 + alternative_atomic64(add_return_unchecked,
14846 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14847 + ASM_NO_INPUT_CLOBBER("memory"));
14848 + return i;
14849 +}
14850 +
14851 /*
14852 * Other variants with different arithmetic operators:
14853 */
14854 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14855 return a;
14856 }
14857
14858 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14859 +{
14860 + long long a;
14861 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14862 + "S" (v) : "memory", "ecx");
14863 + return a;
14864 +}
14865 +
14866 static inline long long atomic64_dec_return(atomic64_t *v)
14867 {
14868 long long a;
14869 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14870 }
14871
14872 /**
14873 + * atomic64_add_unchecked - add integer to atomic64 variable
14874 + * @i: integer value to add
14875 + * @v: pointer to type atomic64_unchecked_t
14876 + *
14877 + * Atomically adds @i to @v.
14878 + */
14879 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14880 +{
14881 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14882 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14883 + ASM_NO_INPUT_CLOBBER("memory"));
14884 + return i;
14885 +}
14886 +
14887 +/**
14888 * atomic64_sub - subtract the atomic64 variable
14889 * @i: integer value to subtract
14890 * @v: pointer to type atomic64_t
14891 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14892 index 0e1cbfc..a891fc7 100644
14893 --- a/arch/x86/include/asm/atomic64_64.h
14894 +++ b/arch/x86/include/asm/atomic64_64.h
14895 @@ -18,7 +18,19 @@
14896 */
14897 static inline long atomic64_read(const atomic64_t *v)
14898 {
14899 - return (*(volatile long *)&(v)->counter);
14900 + return (*(volatile const long *)&(v)->counter);
14901 +}
14902 +
14903 +/**
14904 + * atomic64_read_unchecked - read atomic64 variable
14905 + * @v: pointer of type atomic64_unchecked_t
14906 + *
14907 + * Atomically reads the value of @v.
14908 + * Doesn't imply a read memory barrier.
14909 + */
14910 +static inline long __intentional_overflow(-1) atomic64_read_unchecked(const atomic64_unchecked_t *v)
14911 +{
14912 + return (*(volatile const long *)&(v)->counter);
14913 }
14914
14915 /**
14916 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14917 }
14918
14919 /**
14920 + * atomic64_set_unchecked - set atomic64 variable
14921 + * @v: pointer to type atomic64_unchecked_t
14922 + * @i: required value
14923 + *
14924 + * Atomically sets the value of @v to @i.
14925 + */
14926 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14927 +{
14928 + v->counter = i;
14929 +}
14930 +
14931 +/**
14932 * atomic64_add - add integer to atomic64 variable
14933 * @i: integer value to add
14934 * @v: pointer to type atomic64_t
14935 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14936 */
14937 static inline void atomic64_add(long i, atomic64_t *v)
14938 {
14939 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14940 +
14941 +#ifdef CONFIG_PAX_REFCOUNT
14942 + "jno 0f\n"
14943 + LOCK_PREFIX "subq %1,%0\n"
14944 + "int $4\n0:\n"
14945 + _ASM_EXTABLE(0b, 0b)
14946 +#endif
14947 +
14948 + : "=m" (v->counter)
14949 + : "er" (i), "m" (v->counter));
14950 +}
14951 +
14952 +/**
14953 + * atomic64_add_unchecked - add integer to atomic64 variable
14954 + * @i: integer value to add
14955 + * @v: pointer to type atomic64_unchecked_t
14956 + *
14957 + * Atomically adds @i to @v.
14958 + */
14959 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14960 +{
14961 asm volatile(LOCK_PREFIX "addq %1,%0"
14962 : "=m" (v->counter)
14963 : "er" (i), "m" (v->counter));
14964 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14965 */
14966 static inline void atomic64_sub(long i, atomic64_t *v)
14967 {
14968 - asm volatile(LOCK_PREFIX "subq %1,%0"
14969 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14970 +
14971 +#ifdef CONFIG_PAX_REFCOUNT
14972 + "jno 0f\n"
14973 + LOCK_PREFIX "addq %1,%0\n"
14974 + "int $4\n0:\n"
14975 + _ASM_EXTABLE(0b, 0b)
14976 +#endif
14977 +
14978 + : "=m" (v->counter)
14979 + : "er" (i), "m" (v->counter));
14980 +}
14981 +
14982 +/**
14983 + * atomic64_sub_unchecked - subtract the atomic64 variable
14984 + * @i: integer value to subtract
14985 + * @v: pointer to type atomic64_unchecked_t
14986 + *
14987 + * Atomically subtracts @i from @v.
14988 + */
14989 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14990 +{
14991 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14992 : "=m" (v->counter)
14993 : "er" (i), "m" (v->counter));
14994 }
14995 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14996 {
14997 unsigned char c;
14998
14999 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
15000 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
15001 +
15002 +#ifdef CONFIG_PAX_REFCOUNT
15003 + "jno 0f\n"
15004 + LOCK_PREFIX "addq %2,%0\n"
15005 + "int $4\n0:\n"
15006 + _ASM_EXTABLE(0b, 0b)
15007 +#endif
15008 +
15009 + "sete %1\n"
15010 : "=m" (v->counter), "=qm" (c)
15011 : "er" (i), "m" (v->counter) : "memory");
15012 return c;
15013 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
15014 */
15015 static inline void atomic64_inc(atomic64_t *v)
15016 {
15017 + asm volatile(LOCK_PREFIX "incq %0\n"
15018 +
15019 +#ifdef CONFIG_PAX_REFCOUNT
15020 + "jno 0f\n"
15021 + LOCK_PREFIX "decq %0\n"
15022 + "int $4\n0:\n"
15023 + _ASM_EXTABLE(0b, 0b)
15024 +#endif
15025 +
15026 + : "=m" (v->counter)
15027 + : "m" (v->counter));
15028 +}
15029 +
15030 +/**
15031 + * atomic64_inc_unchecked - increment atomic64 variable
15032 + * @v: pointer to type atomic64_unchecked_t
15033 + *
15034 + * Atomically increments @v by 1.
15035 + */
15036 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
15037 +{
15038 asm volatile(LOCK_PREFIX "incq %0"
15039 : "=m" (v->counter)
15040 : "m" (v->counter));
15041 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
15042 */
15043 static inline void atomic64_dec(atomic64_t *v)
15044 {
15045 - asm volatile(LOCK_PREFIX "decq %0"
15046 + asm volatile(LOCK_PREFIX "decq %0\n"
15047 +
15048 +#ifdef CONFIG_PAX_REFCOUNT
15049 + "jno 0f\n"
15050 + LOCK_PREFIX "incq %0\n"
15051 + "int $4\n0:\n"
15052 + _ASM_EXTABLE(0b, 0b)
15053 +#endif
15054 +
15055 + : "=m" (v->counter)
15056 + : "m" (v->counter));
15057 +}
15058 +
15059 +/**
15060 + * atomic64_dec_unchecked - decrement atomic64 variable
15061 + * @v: pointer to type atomic64_t
15062 + *
15063 + * Atomically decrements @v by 1.
15064 + */
15065 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
15066 +{
15067 + asm volatile(LOCK_PREFIX "decq %0\n"
15068 : "=m" (v->counter)
15069 : "m" (v->counter));
15070 }
15071 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
15072 {
15073 unsigned char c;
15074
15075 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
15076 + asm volatile(LOCK_PREFIX "decq %0\n"
15077 +
15078 +#ifdef CONFIG_PAX_REFCOUNT
15079 + "jno 0f\n"
15080 + LOCK_PREFIX "incq %0\n"
15081 + "int $4\n0:\n"
15082 + _ASM_EXTABLE(0b, 0b)
15083 +#endif
15084 +
15085 + "sete %1\n"
15086 : "=m" (v->counter), "=qm" (c)
15087 : "m" (v->counter) : "memory");
15088 return c != 0;
15089 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
15090 {
15091 unsigned char c;
15092
15093 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
15094 + asm volatile(LOCK_PREFIX "incq %0\n"
15095 +
15096 +#ifdef CONFIG_PAX_REFCOUNT
15097 + "jno 0f\n"
15098 + LOCK_PREFIX "decq %0\n"
15099 + "int $4\n0:\n"
15100 + _ASM_EXTABLE(0b, 0b)
15101 +#endif
15102 +
15103 + "sete %1\n"
15104 : "=m" (v->counter), "=qm" (c)
15105 : "m" (v->counter) : "memory");
15106 return c != 0;
15107 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
15108 {
15109 unsigned char c;
15110
15111 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
15112 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
15113 +
15114 +#ifdef CONFIG_PAX_REFCOUNT
15115 + "jno 0f\n"
15116 + LOCK_PREFIX "subq %2,%0\n"
15117 + "int $4\n0:\n"
15118 + _ASM_EXTABLE(0b, 0b)
15119 +#endif
15120 +
15121 + "sets %1\n"
15122 : "=m" (v->counter), "=qm" (c)
15123 : "er" (i), "m" (v->counter) : "memory");
15124 return c;
15125 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
15126 */
15127 static inline long atomic64_add_return(long i, atomic64_t *v)
15128 {
15129 + return i + xadd_check_overflow(&v->counter, i);
15130 +}
15131 +
15132 +/**
15133 + * atomic64_add_return_unchecked - add and return
15134 + * @i: integer value to add
15135 + * @v: pointer to type atomic64_unchecked_t
15136 + *
15137 + * Atomically adds @i to @v and returns @i + @v
15138 + */
15139 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
15140 +{
15141 return i + xadd(&v->counter, i);
15142 }
15143
15144 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
15145 }
15146
15147 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
15148 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
15149 +{
15150 + return atomic64_add_return_unchecked(1, v);
15151 +}
15152 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
15153
15154 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
15155 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
15156 return cmpxchg(&v->counter, old, new);
15157 }
15158
15159 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
15160 +{
15161 + return cmpxchg(&v->counter, old, new);
15162 +}
15163 +
15164 static inline long atomic64_xchg(atomic64_t *v, long new)
15165 {
15166 return xchg(&v->counter, new);
15167 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
15168 */
15169 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
15170 {
15171 - long c, old;
15172 + long c, old, new;
15173 c = atomic64_read(v);
15174 for (;;) {
15175 - if (unlikely(c == (u)))
15176 + if (unlikely(c == u))
15177 break;
15178 - old = atomic64_cmpxchg((v), c, c + (a));
15179 +
15180 + asm volatile("add %2,%0\n"
15181 +
15182 +#ifdef CONFIG_PAX_REFCOUNT
15183 + "jno 0f\n"
15184 + "sub %2,%0\n"
15185 + "int $4\n0:\n"
15186 + _ASM_EXTABLE(0b, 0b)
15187 +#endif
15188 +
15189 + : "=r" (new)
15190 + : "0" (c), "ir" (a));
15191 +
15192 + old = atomic64_cmpxchg(v, c, new);
15193 if (likely(old == c))
15194 break;
15195 c = old;
15196 }
15197 - return c != (u);
15198 + return c != u;
15199 }
15200
15201 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
15202 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
15203 index 41639ce..ebce552 100644
15204 --- a/arch/x86/include/asm/bitops.h
15205 +++ b/arch/x86/include/asm/bitops.h
15206 @@ -48,7 +48,7 @@
15207 * a mask operation on a byte.
15208 */
15209 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
15210 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
15211 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
15212 #define CONST_MASK(nr) (1 << ((nr) & 7))
15213
15214 /**
15215 @@ -361,7 +361,7 @@ static int test_bit(int nr, const volatile unsigned long *addr);
15216 *
15217 * Undefined if no bit exists, so code should check against 0 first.
15218 */
15219 -static inline unsigned long __ffs(unsigned long word)
15220 +static inline unsigned long __intentional_overflow(-1) __ffs(unsigned long word)
15221 {
15222 asm("rep; bsf %1,%0"
15223 : "=r" (word)
15224 @@ -375,7 +375,7 @@ static inline unsigned long __ffs(unsigned long word)
15225 *
15226 * Undefined if no zero exists, so code should check against ~0UL first.
15227 */
15228 -static inline unsigned long ffz(unsigned long word)
15229 +static inline unsigned long __intentional_overflow(-1) ffz(unsigned long word)
15230 {
15231 asm("rep; bsf %1,%0"
15232 : "=r" (word)
15233 @@ -389,7 +389,7 @@ static inline unsigned long ffz(unsigned long word)
15234 *
15235 * Undefined if no set bit exists, so code should check against 0 first.
15236 */
15237 -static inline unsigned long __fls(unsigned long word)
15238 +static inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
15239 {
15240 asm("bsr %1,%0"
15241 : "=r" (word)
15242 @@ -452,7 +452,7 @@ static inline int ffs(int x)
15243 * set bit if value is nonzero. The last (most significant) bit is
15244 * at position 32.
15245 */
15246 -static inline int fls(int x)
15247 +static inline int __intentional_overflow(-1) fls(int x)
15248 {
15249 int r;
15250
15251 @@ -494,7 +494,7 @@ static inline int fls(int x)
15252 * at position 64.
15253 */
15254 #ifdef CONFIG_X86_64
15255 -static __always_inline int fls64(__u64 x)
15256 +static __always_inline long fls64(__u64 x)
15257 {
15258 int bitpos = -1;
15259 /*
15260 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
15261 index 4fa687a..60f2d39 100644
15262 --- a/arch/x86/include/asm/boot.h
15263 +++ b/arch/x86/include/asm/boot.h
15264 @@ -6,10 +6,15 @@
15265 #include <uapi/asm/boot.h>
15266
15267 /* Physical address where kernel should be loaded. */
15268 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
15269 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
15270 + (CONFIG_PHYSICAL_ALIGN - 1)) \
15271 & ~(CONFIG_PHYSICAL_ALIGN - 1))
15272
15273 +#ifndef __ASSEMBLY__
15274 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
15275 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
15276 +#endif
15277 +
15278 /* Minimum kernel alignment, as a power of two */
15279 #ifdef CONFIG_X86_64
15280 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
15281 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
15282 index 48f99f1..d78ebf9 100644
15283 --- a/arch/x86/include/asm/cache.h
15284 +++ b/arch/x86/include/asm/cache.h
15285 @@ -5,12 +5,13 @@
15286
15287 /* L1 cache line size */
15288 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
15289 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
15290 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
15291
15292 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
15293 +#define __read_only __attribute__((__section__(".data..read_only")))
15294
15295 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
15296 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
15297 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
15298
15299 #ifdef CONFIG_X86_VSMP
15300 #ifdef CONFIG_SMP
15301 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
15302 index 9863ee3..4a1f8e1 100644
15303 --- a/arch/x86/include/asm/cacheflush.h
15304 +++ b/arch/x86/include/asm/cacheflush.h
15305 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
15306 unsigned long pg_flags = pg->flags & _PGMT_MASK;
15307
15308 if (pg_flags == _PGMT_DEFAULT)
15309 - return -1;
15310 + return ~0UL;
15311 else if (pg_flags == _PGMT_WC)
15312 return _PAGE_CACHE_WC;
15313 else if (pg_flags == _PGMT_UC_MINUS)
15314 diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
15315 index 0fa6750..cb7b2c3 100644
15316 --- a/arch/x86/include/asm/calling.h
15317 +++ b/arch/x86/include/asm/calling.h
15318 @@ -80,103 +80,113 @@ For 32-bit we have the following conventions - kernel is built with
15319 #define RSP 152
15320 #define SS 160
15321
15322 -#define ARGOFFSET R11
15323 -#define SWFRAME ORIG_RAX
15324 +#define ARGOFFSET R15
15325
15326 .macro SAVE_ARGS addskip=0, save_rcx=1, save_r891011=1
15327 - subq $9*8+\addskip, %rsp
15328 - CFI_ADJUST_CFA_OFFSET 9*8+\addskip
15329 - movq_cfi rdi, 8*8
15330 - movq_cfi rsi, 7*8
15331 - movq_cfi rdx, 6*8
15332 + subq $ORIG_RAX-ARGOFFSET+\addskip, %rsp
15333 + CFI_ADJUST_CFA_OFFSET ORIG_RAX-ARGOFFSET+\addskip
15334 + movq_cfi rdi, RDI
15335 + movq_cfi rsi, RSI
15336 + movq_cfi rdx, RDX
15337
15338 .if \save_rcx
15339 - movq_cfi rcx, 5*8
15340 + movq_cfi rcx, RCX
15341 .endif
15342
15343 - movq_cfi rax, 4*8
15344 + movq_cfi rax, RAX
15345
15346 .if \save_r891011
15347 - movq_cfi r8, 3*8
15348 - movq_cfi r9, 2*8
15349 - movq_cfi r10, 1*8
15350 - movq_cfi r11, 0*8
15351 + movq_cfi r8, R8
15352 + movq_cfi r9, R9
15353 + movq_cfi r10, R10
15354 + movq_cfi r11, R11
15355 .endif
15356
15357 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15358 + movq_cfi r12, R12
15359 +#endif
15360 +
15361 .endm
15362
15363 -#define ARG_SKIP (9*8)
15364 +#define ARG_SKIP ORIG_RAX
15365
15366 .macro RESTORE_ARGS rstor_rax=1, addskip=0, rstor_rcx=1, rstor_r11=1, \
15367 rstor_r8910=1, rstor_rdx=1
15368 +
15369 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15370 + movq_cfi_restore R12, r12
15371 +#endif
15372 +
15373 .if \rstor_r11
15374 - movq_cfi_restore 0*8, r11
15375 + movq_cfi_restore R11, r11
15376 .endif
15377
15378 .if \rstor_r8910
15379 - movq_cfi_restore 1*8, r10
15380 - movq_cfi_restore 2*8, r9
15381 - movq_cfi_restore 3*8, r8
15382 + movq_cfi_restore R10, r10
15383 + movq_cfi_restore R9, r9
15384 + movq_cfi_restore R8, r8
15385 .endif
15386
15387 .if \rstor_rax
15388 - movq_cfi_restore 4*8, rax
15389 + movq_cfi_restore RAX, rax
15390 .endif
15391
15392 .if \rstor_rcx
15393 - movq_cfi_restore 5*8, rcx
15394 + movq_cfi_restore RCX, rcx
15395 .endif
15396
15397 .if \rstor_rdx
15398 - movq_cfi_restore 6*8, rdx
15399 + movq_cfi_restore RDX, rdx
15400 .endif
15401
15402 - movq_cfi_restore 7*8, rsi
15403 - movq_cfi_restore 8*8, rdi
15404 + movq_cfi_restore RSI, rsi
15405 + movq_cfi_restore RDI, rdi
15406
15407 - .if ARG_SKIP+\addskip > 0
15408 - addq $ARG_SKIP+\addskip, %rsp
15409 - CFI_ADJUST_CFA_OFFSET -(ARG_SKIP+\addskip)
15410 + .if ORIG_RAX+\addskip > 0
15411 + addq $ORIG_RAX+\addskip, %rsp
15412 + CFI_ADJUST_CFA_OFFSET -(ORIG_RAX+\addskip)
15413 .endif
15414 .endm
15415
15416 - .macro LOAD_ARGS offset, skiprax=0
15417 - movq \offset(%rsp), %r11
15418 - movq \offset+8(%rsp), %r10
15419 - movq \offset+16(%rsp), %r9
15420 - movq \offset+24(%rsp), %r8
15421 - movq \offset+40(%rsp), %rcx
15422 - movq \offset+48(%rsp), %rdx
15423 - movq \offset+56(%rsp), %rsi
15424 - movq \offset+64(%rsp), %rdi
15425 + .macro LOAD_ARGS skiprax=0
15426 + movq R11(%rsp), %r11
15427 + movq R10(%rsp), %r10
15428 + movq R9(%rsp), %r9
15429 + movq R8(%rsp), %r8
15430 + movq RCX(%rsp), %rcx
15431 + movq RDX(%rsp), %rdx
15432 + movq RSI(%rsp), %rsi
15433 + movq RDI(%rsp), %rdi
15434 .if \skiprax
15435 .else
15436 - movq \offset+72(%rsp), %rax
15437 + movq RAX(%rsp), %rax
15438 .endif
15439 .endm
15440
15441 -#define REST_SKIP (6*8)
15442 -
15443 .macro SAVE_REST
15444 - subq $REST_SKIP, %rsp
15445 - CFI_ADJUST_CFA_OFFSET REST_SKIP
15446 - movq_cfi rbx, 5*8
15447 - movq_cfi rbp, 4*8
15448 - movq_cfi r12, 3*8
15449 - movq_cfi r13, 2*8
15450 - movq_cfi r14, 1*8
15451 - movq_cfi r15, 0*8
15452 + movq_cfi rbx, RBX
15453 + movq_cfi rbp, RBP
15454 +
15455 +#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15456 + movq_cfi r12, R12
15457 +#endif
15458 +
15459 + movq_cfi r13, R13
15460 + movq_cfi r14, R14
15461 + movq_cfi r15, R15
15462 .endm
15463
15464 .macro RESTORE_REST
15465 - movq_cfi_restore 0*8, r15
15466 - movq_cfi_restore 1*8, r14
15467 - movq_cfi_restore 2*8, r13
15468 - movq_cfi_restore 3*8, r12
15469 - movq_cfi_restore 4*8, rbp
15470 - movq_cfi_restore 5*8, rbx
15471 - addq $REST_SKIP, %rsp
15472 - CFI_ADJUST_CFA_OFFSET -(REST_SKIP)
15473 + movq_cfi_restore R15, r15
15474 + movq_cfi_restore R14, r14
15475 + movq_cfi_restore R13, r13
15476 +
15477 +#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15478 + movq_cfi_restore R12, r12
15479 +#endif
15480 +
15481 + movq_cfi_restore RBP, rbp
15482 + movq_cfi_restore RBX, rbx
15483 .endm
15484
15485 .macro SAVE_ALL
15486 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
15487 index f50de69..2b0a458 100644
15488 --- a/arch/x86/include/asm/checksum_32.h
15489 +++ b/arch/x86/include/asm/checksum_32.h
15490 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
15491 int len, __wsum sum,
15492 int *src_err_ptr, int *dst_err_ptr);
15493
15494 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
15495 + int len, __wsum sum,
15496 + int *src_err_ptr, int *dst_err_ptr);
15497 +
15498 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
15499 + int len, __wsum sum,
15500 + int *src_err_ptr, int *dst_err_ptr);
15501 +
15502 /*
15503 * Note: when you get a NULL pointer exception here this means someone
15504 * passed in an incorrect kernel address to one of these functions.
15505 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
15506
15507 might_sleep();
15508 stac();
15509 - ret = csum_partial_copy_generic((__force void *)src, dst,
15510 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
15511 len, sum, err_ptr, NULL);
15512 clac();
15513
15514 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
15515 might_sleep();
15516 if (access_ok(VERIFY_WRITE, dst, len)) {
15517 stac();
15518 - ret = csum_partial_copy_generic(src, (__force void *)dst,
15519 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
15520 len, sum, NULL, err_ptr);
15521 clac();
15522 return ret;
15523 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
15524 index d47786a..ce1b05d 100644
15525 --- a/arch/x86/include/asm/cmpxchg.h
15526 +++ b/arch/x86/include/asm/cmpxchg.h
15527 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
15528 __compiletime_error("Bad argument size for cmpxchg");
15529 extern void __xadd_wrong_size(void)
15530 __compiletime_error("Bad argument size for xadd");
15531 +extern void __xadd_check_overflow_wrong_size(void)
15532 + __compiletime_error("Bad argument size for xadd_check_overflow");
15533 extern void __add_wrong_size(void)
15534 __compiletime_error("Bad argument size for add");
15535 +extern void __add_check_overflow_wrong_size(void)
15536 + __compiletime_error("Bad argument size for add_check_overflow");
15537
15538 /*
15539 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
15540 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
15541 __ret; \
15542 })
15543
15544 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
15545 + ({ \
15546 + __typeof__ (*(ptr)) __ret = (arg); \
15547 + switch (sizeof(*(ptr))) { \
15548 + case __X86_CASE_L: \
15549 + asm volatile (lock #op "l %0, %1\n" \
15550 + "jno 0f\n" \
15551 + "mov %0,%1\n" \
15552 + "int $4\n0:\n" \
15553 + _ASM_EXTABLE(0b, 0b) \
15554 + : "+r" (__ret), "+m" (*(ptr)) \
15555 + : : "memory", "cc"); \
15556 + break; \
15557 + case __X86_CASE_Q: \
15558 + asm volatile (lock #op "q %q0, %1\n" \
15559 + "jno 0f\n" \
15560 + "mov %0,%1\n" \
15561 + "int $4\n0:\n" \
15562 + _ASM_EXTABLE(0b, 0b) \
15563 + : "+r" (__ret), "+m" (*(ptr)) \
15564 + : : "memory", "cc"); \
15565 + break; \
15566 + default: \
15567 + __ ## op ## _check_overflow_wrong_size(); \
15568 + } \
15569 + __ret; \
15570 + })
15571 +
15572 /*
15573 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
15574 * Since this is generally used to protect other memory information, we
15575 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
15576 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
15577 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
15578
15579 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
15580 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
15581 +
15582 #define __add(ptr, inc, lock) \
15583 ({ \
15584 __typeof__ (*(ptr)) __ret = (inc); \
15585 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
15586 index 59c6c40..5e0b22c 100644
15587 --- a/arch/x86/include/asm/compat.h
15588 +++ b/arch/x86/include/asm/compat.h
15589 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
15590 typedef u32 compat_uint_t;
15591 typedef u32 compat_ulong_t;
15592 typedef u64 __attribute__((aligned(4))) compat_u64;
15593 -typedef u32 compat_uptr_t;
15594 +typedef u32 __user compat_uptr_t;
15595
15596 struct compat_timespec {
15597 compat_time_t tv_sec;
15598 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
15599 index 89270b4..f0abf8e 100644
15600 --- a/arch/x86/include/asm/cpufeature.h
15601 +++ b/arch/x86/include/asm/cpufeature.h
15602 @@ -203,7 +203,7 @@
15603 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
15604 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
15605 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
15606 -
15607 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
15608
15609 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
15610 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
15611 @@ -211,7 +211,7 @@
15612 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
15613 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
15614 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
15615 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
15616 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
15617 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
15618 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
15619 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
15620 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
15621 #undef cpu_has_centaur_mcr
15622 #define cpu_has_centaur_mcr 0
15623
15624 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
15625 #endif /* CONFIG_X86_64 */
15626
15627 #if __GNUC__ >= 4
15628 @@ -405,7 +406,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
15629
15630 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
15631 t_warn:
15632 - warn_pre_alternatives();
15633 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
15634 + warn_pre_alternatives();
15635 return false;
15636 #endif
15637
15638 @@ -425,7 +427,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
15639 ".section .discard,\"aw\",@progbits\n"
15640 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
15641 ".previous\n"
15642 - ".section .altinstr_replacement,\"ax\"\n"
15643 + ".section .altinstr_replacement,\"a\"\n"
15644 "3: movb $1,%0\n"
15645 "4:\n"
15646 ".previous\n"
15647 @@ -462,7 +464,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
15648 " .byte 2b - 1b\n" /* src len */
15649 " .byte 4f - 3f\n" /* repl len */
15650 ".previous\n"
15651 - ".section .altinstr_replacement,\"ax\"\n"
15652 + ".section .altinstr_replacement,\"a\"\n"
15653 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
15654 "4:\n"
15655 ".previous\n"
15656 @@ -495,7 +497,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
15657 ".section .discard,\"aw\",@progbits\n"
15658 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
15659 ".previous\n"
15660 - ".section .altinstr_replacement,\"ax\"\n"
15661 + ".section .altinstr_replacement,\"a\"\n"
15662 "3: movb $0,%0\n"
15663 "4:\n"
15664 ".previous\n"
15665 @@ -509,7 +511,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
15666 ".section .discard,\"aw\",@progbits\n"
15667 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
15668 ".previous\n"
15669 - ".section .altinstr_replacement,\"ax\"\n"
15670 + ".section .altinstr_replacement,\"a\"\n"
15671 "5: movb $1,%0\n"
15672 "6:\n"
15673 ".previous\n"
15674 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
15675 index b90e5df..b462c91 100644
15676 --- a/arch/x86/include/asm/desc.h
15677 +++ b/arch/x86/include/asm/desc.h
15678 @@ -4,6 +4,7 @@
15679 #include <asm/desc_defs.h>
15680 #include <asm/ldt.h>
15681 #include <asm/mmu.h>
15682 +#include <asm/pgtable.h>
15683
15684 #include <linux/smp.h>
15685 #include <linux/percpu.h>
15686 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
15687
15688 desc->type = (info->read_exec_only ^ 1) << 1;
15689 desc->type |= info->contents << 2;
15690 + desc->type |= info->seg_not_present ^ 1;
15691
15692 desc->s = 1;
15693 desc->dpl = 0x3;
15694 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
15695 }
15696
15697 extern struct desc_ptr idt_descr;
15698 -extern gate_desc idt_table[];
15699 -extern struct desc_ptr debug_idt_descr;
15700 -extern gate_desc debug_idt_table[];
15701 -
15702 -struct gdt_page {
15703 - struct desc_struct gdt[GDT_ENTRIES];
15704 -} __attribute__((aligned(PAGE_SIZE)));
15705 -
15706 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
15707 +extern gate_desc idt_table[IDT_ENTRIES];
15708 +extern const struct desc_ptr debug_idt_descr;
15709 +extern gate_desc debug_idt_table[IDT_ENTRIES];
15710
15711 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
15712 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
15713 {
15714 - return per_cpu(gdt_page, cpu).gdt;
15715 + return cpu_gdt_table[cpu];
15716 }
15717
15718 #ifdef CONFIG_X86_64
15719 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
15720 unsigned long base, unsigned dpl, unsigned flags,
15721 unsigned short seg)
15722 {
15723 - gate->a = (seg << 16) | (base & 0xffff);
15724 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
15725 + gate->gate.offset_low = base;
15726 + gate->gate.seg = seg;
15727 + gate->gate.reserved = 0;
15728 + gate->gate.type = type;
15729 + gate->gate.s = 0;
15730 + gate->gate.dpl = dpl;
15731 + gate->gate.p = 1;
15732 + gate->gate.offset_high = base >> 16;
15733 }
15734
15735 #endif
15736 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
15737
15738 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
15739 {
15740 + pax_open_kernel();
15741 memcpy(&idt[entry], gate, sizeof(*gate));
15742 + pax_close_kernel();
15743 }
15744
15745 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15746 {
15747 + pax_open_kernel();
15748 memcpy(&ldt[entry], desc, 8);
15749 + pax_close_kernel();
15750 }
15751
15752 static inline void
15753 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15754 default: size = sizeof(*gdt); break;
15755 }
15756
15757 + pax_open_kernel();
15758 memcpy(&gdt[entry], desc, size);
15759 + pax_close_kernel();
15760 }
15761
15762 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15763 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15764
15765 static inline void native_load_tr_desc(void)
15766 {
15767 + pax_open_kernel();
15768 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15769 + pax_close_kernel();
15770 }
15771
15772 static inline void native_load_gdt(const struct desc_ptr *dtr)
15773 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15774 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15775 unsigned int i;
15776
15777 + pax_open_kernel();
15778 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15779 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15780 + pax_close_kernel();
15781 }
15782
15783 #define _LDT_empty(info) \
15784 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15785 preempt_enable();
15786 }
15787
15788 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15789 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15790 {
15791 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15792 }
15793 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15794 }
15795
15796 #ifdef CONFIG_X86_64
15797 -static inline void set_nmi_gate(int gate, void *addr)
15798 +static inline void set_nmi_gate(int gate, const void *addr)
15799 {
15800 gate_desc s;
15801
15802 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15803 #endif
15804
15805 #ifdef CONFIG_TRACING
15806 -extern struct desc_ptr trace_idt_descr;
15807 -extern gate_desc trace_idt_table[];
15808 +extern const struct desc_ptr trace_idt_descr;
15809 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15810 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15811 {
15812 write_idt_entry(trace_idt_table, entry, gate);
15813 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15814 }
15815 #endif
15816
15817 -static inline void _set_gate(int gate, unsigned type, void *addr,
15818 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15819 unsigned dpl, unsigned ist, unsigned seg)
15820 {
15821 gate_desc s;
15822 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15823 * Pentium F0 0F bugfix can have resulted in the mapped
15824 * IDT being write-protected.
15825 */
15826 -static inline void set_intr_gate(unsigned int n, void *addr)
15827 +static inline void set_intr_gate(unsigned int n, const void *addr)
15828 {
15829 BUG_ON((unsigned)n > 0xFF);
15830 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15831 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15832 /*
15833 * This routine sets up an interrupt gate at directory privilege level 3.
15834 */
15835 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15836 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15837 {
15838 BUG_ON((unsigned)n > 0xFF);
15839 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15840 }
15841
15842 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15843 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15844 {
15845 BUG_ON((unsigned)n > 0xFF);
15846 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15847 }
15848
15849 -static inline void set_trap_gate(unsigned int n, void *addr)
15850 +static inline void set_trap_gate(unsigned int n, const void *addr)
15851 {
15852 BUG_ON((unsigned)n > 0xFF);
15853 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15854 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15855 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15856 {
15857 BUG_ON((unsigned)n > 0xFF);
15858 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15859 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15860 }
15861
15862 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15863 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15864 {
15865 BUG_ON((unsigned)n > 0xFF);
15866 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15867 }
15868
15869 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15870 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15871 {
15872 BUG_ON((unsigned)n > 0xFF);
15873 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15874 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15875 else
15876 load_idt((const struct desc_ptr *)&idt_descr);
15877 }
15878 +
15879 +#ifdef CONFIG_X86_32
15880 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15881 +{
15882 + struct desc_struct d;
15883 +
15884 + if (likely(limit))
15885 + limit = (limit - 1UL) >> PAGE_SHIFT;
15886 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15887 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15888 +}
15889 +#endif
15890 +
15891 #endif /* _ASM_X86_DESC_H */
15892 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15893 index 278441f..b95a174 100644
15894 --- a/arch/x86/include/asm/desc_defs.h
15895 +++ b/arch/x86/include/asm/desc_defs.h
15896 @@ -31,6 +31,12 @@ struct desc_struct {
15897 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15898 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15899 };
15900 + struct {
15901 + u16 offset_low;
15902 + u16 seg;
15903 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15904 + unsigned offset_high: 16;
15905 + } gate;
15906 };
15907 } __attribute__((packed));
15908
15909 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15910 index ced283a..ffe04cc 100644
15911 --- a/arch/x86/include/asm/div64.h
15912 +++ b/arch/x86/include/asm/div64.h
15913 @@ -39,7 +39,7 @@
15914 __mod; \
15915 })
15916
15917 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15918 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15919 {
15920 union {
15921 u64 v64;
15922 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15923 index 9c999c1..3860cb8 100644
15924 --- a/arch/x86/include/asm/elf.h
15925 +++ b/arch/x86/include/asm/elf.h
15926 @@ -243,7 +243,25 @@ extern int force_personality32;
15927 the loader. We need to make sure that it is out of the way of the program
15928 that it will "exec", and that there is sufficient room for the brk. */
15929
15930 +#ifdef CONFIG_PAX_SEGMEXEC
15931 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15932 +#else
15933 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15934 +#endif
15935 +
15936 +#ifdef CONFIG_PAX_ASLR
15937 +#ifdef CONFIG_X86_32
15938 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15939 +
15940 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15941 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15942 +#else
15943 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15944 +
15945 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15946 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15947 +#endif
15948 +#endif
15949
15950 /* This yields a mask that user programs can use to figure out what
15951 instruction set this CPU supports. This could be done in user space,
15952 @@ -296,16 +314,12 @@ do { \
15953
15954 #define ARCH_DLINFO \
15955 do { \
15956 - if (vdso_enabled) \
15957 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15958 - (unsigned long)current->mm->context.vdso); \
15959 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15960 } while (0)
15961
15962 #define ARCH_DLINFO_X32 \
15963 do { \
15964 - if (vdso_enabled) \
15965 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15966 - (unsigned long)current->mm->context.vdso); \
15967 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15968 } while (0)
15969
15970 #define AT_SYSINFO 32
15971 @@ -320,7 +334,7 @@ else \
15972
15973 #endif /* !CONFIG_X86_32 */
15974
15975 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15976 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15977
15978 #define VDSO_ENTRY \
15979 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15980 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15981 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15982 #define compat_arch_setup_additional_pages syscall32_setup_pages
15983
15984 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15985 -#define arch_randomize_brk arch_randomize_brk
15986 -
15987 /*
15988 * True on X86_32 or when emulating IA32 on X86_64
15989 */
15990 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15991 index 77a99ac..39ff7f5 100644
15992 --- a/arch/x86/include/asm/emergency-restart.h
15993 +++ b/arch/x86/include/asm/emergency-restart.h
15994 @@ -1,6 +1,6 @@
15995 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15996 #define _ASM_X86_EMERGENCY_RESTART_H
15997
15998 -extern void machine_emergency_restart(void);
15999 +extern void machine_emergency_restart(void) __noreturn;
16000
16001 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
16002 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
16003 index 5be9f87..0320912 100644
16004 --- a/arch/x86/include/asm/fpu-internal.h
16005 +++ b/arch/x86/include/asm/fpu-internal.h
16006 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
16007 #define user_insn(insn, output, input...) \
16008 ({ \
16009 int err; \
16010 + pax_open_userland(); \
16011 asm volatile(ASM_STAC "\n" \
16012 - "1:" #insn "\n\t" \
16013 + "1:" \
16014 + __copyuser_seg \
16015 + #insn "\n\t" \
16016 "2: " ASM_CLAC "\n" \
16017 ".section .fixup,\"ax\"\n" \
16018 "3: movl $-1,%[err]\n" \
16019 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
16020 _ASM_EXTABLE(1b, 3b) \
16021 : [err] "=r" (err), output \
16022 : "0"(0), input); \
16023 + pax_close_userland(); \
16024 err; \
16025 })
16026
16027 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
16028 "fnclex\n\t"
16029 "emms\n\t"
16030 "fildl %P[addr]" /* set F?P to defined value */
16031 - : : [addr] "m" (tsk->thread.fpu.has_fpu));
16032 + : : [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
16033 }
16034
16035 return fpu_restore_checking(&tsk->thread.fpu);
16036 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
16037 index be27ba1..04a8801 100644
16038 --- a/arch/x86/include/asm/futex.h
16039 +++ b/arch/x86/include/asm/futex.h
16040 @@ -12,6 +12,7 @@
16041 #include <asm/smap.h>
16042
16043 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
16044 + typecheck(u32 __user *, uaddr); \
16045 asm volatile("\t" ASM_STAC "\n" \
16046 "1:\t" insn "\n" \
16047 "2:\t" ASM_CLAC "\n" \
16048 @@ -20,15 +21,16 @@
16049 "\tjmp\t2b\n" \
16050 "\t.previous\n" \
16051 _ASM_EXTABLE(1b, 3b) \
16052 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
16053 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
16054 : "i" (-EFAULT), "0" (oparg), "1" (0))
16055
16056 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
16057 + typecheck(u32 __user *, uaddr); \
16058 asm volatile("\t" ASM_STAC "\n" \
16059 "1:\tmovl %2, %0\n" \
16060 "\tmovl\t%0, %3\n" \
16061 "\t" insn "\n" \
16062 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
16063 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
16064 "\tjnz\t1b\n" \
16065 "3:\t" ASM_CLAC "\n" \
16066 "\t.section .fixup,\"ax\"\n" \
16067 @@ -38,7 +40,7 @@
16068 _ASM_EXTABLE(1b, 4b) \
16069 _ASM_EXTABLE(2b, 4b) \
16070 : "=&a" (oldval), "=&r" (ret), \
16071 - "+m" (*uaddr), "=&r" (tem) \
16072 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
16073 : "r" (oparg), "i" (-EFAULT), "1" (0))
16074
16075 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
16076 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
16077
16078 pagefault_disable();
16079
16080 + pax_open_userland();
16081 switch (op) {
16082 case FUTEX_OP_SET:
16083 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
16084 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
16085 break;
16086 case FUTEX_OP_ADD:
16087 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
16088 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
16089 uaddr, oparg);
16090 break;
16091 case FUTEX_OP_OR:
16092 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
16093 default:
16094 ret = -ENOSYS;
16095 }
16096 + pax_close_userland();
16097
16098 pagefault_enable();
16099
16100 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
16101 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
16102 return -EFAULT;
16103
16104 + pax_open_userland();
16105 asm volatile("\t" ASM_STAC "\n"
16106 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
16107 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
16108 "2:\t" ASM_CLAC "\n"
16109 "\t.section .fixup, \"ax\"\n"
16110 "3:\tmov %3, %0\n"
16111 "\tjmp 2b\n"
16112 "\t.previous\n"
16113 _ASM_EXTABLE(1b, 3b)
16114 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
16115 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
16116 : "i" (-EFAULT), "r" (newval), "1" (oldval)
16117 : "memory"
16118 );
16119 + pax_close_userland();
16120
16121 *uval = oldval;
16122 return ret;
16123 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
16124 index 92b3bae..3866449 100644
16125 --- a/arch/x86/include/asm/hw_irq.h
16126 +++ b/arch/x86/include/asm/hw_irq.h
16127 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
16128 extern void enable_IO_APIC(void);
16129
16130 /* Statistics */
16131 -extern atomic_t irq_err_count;
16132 -extern atomic_t irq_mis_count;
16133 +extern atomic_unchecked_t irq_err_count;
16134 +extern atomic_unchecked_t irq_mis_count;
16135
16136 /* EISA */
16137 extern void eisa_set_level_irq(unsigned int irq);
16138 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
16139 index a203659..9889f1c 100644
16140 --- a/arch/x86/include/asm/i8259.h
16141 +++ b/arch/x86/include/asm/i8259.h
16142 @@ -62,7 +62,7 @@ struct legacy_pic {
16143 void (*init)(int auto_eoi);
16144 int (*irq_pending)(unsigned int irq);
16145 void (*make_irq)(unsigned int irq);
16146 -};
16147 +} __do_const;
16148
16149 extern struct legacy_pic *legacy_pic;
16150 extern struct legacy_pic null_legacy_pic;
16151 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
16152 index 34f69cb..6d95446 100644
16153 --- a/arch/x86/include/asm/io.h
16154 +++ b/arch/x86/include/asm/io.h
16155 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
16156 "m" (*(volatile type __force *)addr) barrier); }
16157
16158 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
16159 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
16160 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
16161 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
16162 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
16163
16164 build_mmio_read(__readb, "b", unsigned char, "=q", )
16165 -build_mmio_read(__readw, "w", unsigned short, "=r", )
16166 -build_mmio_read(__readl, "l", unsigned int, "=r", )
16167 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
16168 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
16169
16170 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
16171 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
16172 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
16173 return ioremap_nocache(offset, size);
16174 }
16175
16176 -extern void iounmap(volatile void __iomem *addr);
16177 +extern void iounmap(const volatile void __iomem *addr);
16178
16179 extern void set_iounmap_nonlazy(void);
16180
16181 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
16182
16183 #include <linux/vmalloc.h>
16184
16185 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
16186 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
16187 +{
16188 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
16189 +}
16190 +
16191 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
16192 +{
16193 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
16194 +}
16195 +
16196 /*
16197 * Convert a virtual cached pointer to an uncached pointer
16198 */
16199 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
16200 index bba3cf8..06bc8da 100644
16201 --- a/arch/x86/include/asm/irqflags.h
16202 +++ b/arch/x86/include/asm/irqflags.h
16203 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
16204 sti; \
16205 sysexit
16206
16207 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
16208 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
16209 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
16210 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
16211 +
16212 #else
16213 #define INTERRUPT_RETURN iret
16214 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
16215 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
16216 index 9454c16..e4100e3 100644
16217 --- a/arch/x86/include/asm/kprobes.h
16218 +++ b/arch/x86/include/asm/kprobes.h
16219 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
16220 #define RELATIVEJUMP_SIZE 5
16221 #define RELATIVECALL_OPCODE 0xe8
16222 #define RELATIVE_ADDR_SIZE 4
16223 -#define MAX_STACK_SIZE 64
16224 -#define MIN_STACK_SIZE(ADDR) \
16225 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
16226 - THREAD_SIZE - (unsigned long)(ADDR))) \
16227 - ? (MAX_STACK_SIZE) \
16228 - : (((unsigned long)current_thread_info()) + \
16229 - THREAD_SIZE - (unsigned long)(ADDR)))
16230 +#define MAX_STACK_SIZE 64UL
16231 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
16232
16233 #define flush_insn_slot(p) do { } while (0)
16234
16235 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
16236 index 2d89e39..baee879 100644
16237 --- a/arch/x86/include/asm/local.h
16238 +++ b/arch/x86/include/asm/local.h
16239 @@ -10,33 +10,97 @@ typedef struct {
16240 atomic_long_t a;
16241 } local_t;
16242
16243 +typedef struct {
16244 + atomic_long_unchecked_t a;
16245 +} local_unchecked_t;
16246 +
16247 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
16248
16249 #define local_read(l) atomic_long_read(&(l)->a)
16250 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
16251 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
16252 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
16253
16254 static inline void local_inc(local_t *l)
16255 {
16256 - asm volatile(_ASM_INC "%0"
16257 + asm volatile(_ASM_INC "%0\n"
16258 +
16259 +#ifdef CONFIG_PAX_REFCOUNT
16260 + "jno 0f\n"
16261 + _ASM_DEC "%0\n"
16262 + "int $4\n0:\n"
16263 + _ASM_EXTABLE(0b, 0b)
16264 +#endif
16265 +
16266 + : "+m" (l->a.counter));
16267 +}
16268 +
16269 +static inline void local_inc_unchecked(local_unchecked_t *l)
16270 +{
16271 + asm volatile(_ASM_INC "%0\n"
16272 : "+m" (l->a.counter));
16273 }
16274
16275 static inline void local_dec(local_t *l)
16276 {
16277 - asm volatile(_ASM_DEC "%0"
16278 + asm volatile(_ASM_DEC "%0\n"
16279 +
16280 +#ifdef CONFIG_PAX_REFCOUNT
16281 + "jno 0f\n"
16282 + _ASM_INC "%0\n"
16283 + "int $4\n0:\n"
16284 + _ASM_EXTABLE(0b, 0b)
16285 +#endif
16286 +
16287 + : "+m" (l->a.counter));
16288 +}
16289 +
16290 +static inline void local_dec_unchecked(local_unchecked_t *l)
16291 +{
16292 + asm volatile(_ASM_DEC "%0\n"
16293 : "+m" (l->a.counter));
16294 }
16295
16296 static inline void local_add(long i, local_t *l)
16297 {
16298 - asm volatile(_ASM_ADD "%1,%0"
16299 + asm volatile(_ASM_ADD "%1,%0\n"
16300 +
16301 +#ifdef CONFIG_PAX_REFCOUNT
16302 + "jno 0f\n"
16303 + _ASM_SUB "%1,%0\n"
16304 + "int $4\n0:\n"
16305 + _ASM_EXTABLE(0b, 0b)
16306 +#endif
16307 +
16308 + : "+m" (l->a.counter)
16309 + : "ir" (i));
16310 +}
16311 +
16312 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
16313 +{
16314 + asm volatile(_ASM_ADD "%1,%0\n"
16315 : "+m" (l->a.counter)
16316 : "ir" (i));
16317 }
16318
16319 static inline void local_sub(long i, local_t *l)
16320 {
16321 - asm volatile(_ASM_SUB "%1,%0"
16322 + asm volatile(_ASM_SUB "%1,%0\n"
16323 +
16324 +#ifdef CONFIG_PAX_REFCOUNT
16325 + "jno 0f\n"
16326 + _ASM_ADD "%1,%0\n"
16327 + "int $4\n0:\n"
16328 + _ASM_EXTABLE(0b, 0b)
16329 +#endif
16330 +
16331 + : "+m" (l->a.counter)
16332 + : "ir" (i));
16333 +}
16334 +
16335 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
16336 +{
16337 + asm volatile(_ASM_SUB "%1,%0\n"
16338 : "+m" (l->a.counter)
16339 : "ir" (i));
16340 }
16341 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
16342 {
16343 unsigned char c;
16344
16345 - asm volatile(_ASM_SUB "%2,%0; sete %1"
16346 + asm volatile(_ASM_SUB "%2,%0\n"
16347 +
16348 +#ifdef CONFIG_PAX_REFCOUNT
16349 + "jno 0f\n"
16350 + _ASM_ADD "%2,%0\n"
16351 + "int $4\n0:\n"
16352 + _ASM_EXTABLE(0b, 0b)
16353 +#endif
16354 +
16355 + "sete %1\n"
16356 : "+m" (l->a.counter), "=qm" (c)
16357 : "ir" (i) : "memory");
16358 return c;
16359 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
16360 {
16361 unsigned char c;
16362
16363 - asm volatile(_ASM_DEC "%0; sete %1"
16364 + asm volatile(_ASM_DEC "%0\n"
16365 +
16366 +#ifdef CONFIG_PAX_REFCOUNT
16367 + "jno 0f\n"
16368 + _ASM_INC "%0\n"
16369 + "int $4\n0:\n"
16370 + _ASM_EXTABLE(0b, 0b)
16371 +#endif
16372 +
16373 + "sete %1\n"
16374 : "+m" (l->a.counter), "=qm" (c)
16375 : : "memory");
16376 return c != 0;
16377 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
16378 {
16379 unsigned char c;
16380
16381 - asm volatile(_ASM_INC "%0; sete %1"
16382 + asm volatile(_ASM_INC "%0\n"
16383 +
16384 +#ifdef CONFIG_PAX_REFCOUNT
16385 + "jno 0f\n"
16386 + _ASM_DEC "%0\n"
16387 + "int $4\n0:\n"
16388 + _ASM_EXTABLE(0b, 0b)
16389 +#endif
16390 +
16391 + "sete %1\n"
16392 : "+m" (l->a.counter), "=qm" (c)
16393 : : "memory");
16394 return c != 0;
16395 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
16396 {
16397 unsigned char c;
16398
16399 - asm volatile(_ASM_ADD "%2,%0; sets %1"
16400 + asm volatile(_ASM_ADD "%2,%0\n"
16401 +
16402 +#ifdef CONFIG_PAX_REFCOUNT
16403 + "jno 0f\n"
16404 + _ASM_SUB "%2,%0\n"
16405 + "int $4\n0:\n"
16406 + _ASM_EXTABLE(0b, 0b)
16407 +#endif
16408 +
16409 + "sets %1\n"
16410 : "+m" (l->a.counter), "=qm" (c)
16411 : "ir" (i) : "memory");
16412 return c;
16413 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
16414 static inline long local_add_return(long i, local_t *l)
16415 {
16416 long __i = i;
16417 + asm volatile(_ASM_XADD "%0, %1\n"
16418 +
16419 +#ifdef CONFIG_PAX_REFCOUNT
16420 + "jno 0f\n"
16421 + _ASM_MOV "%0,%1\n"
16422 + "int $4\n0:\n"
16423 + _ASM_EXTABLE(0b, 0b)
16424 +#endif
16425 +
16426 + : "+r" (i), "+m" (l->a.counter)
16427 + : : "memory");
16428 + return i + __i;
16429 +}
16430 +
16431 +/**
16432 + * local_add_return_unchecked - add and return
16433 + * @i: integer value to add
16434 + * @l: pointer to type local_unchecked_t
16435 + *
16436 + * Atomically adds @i to @l and returns @i + @l
16437 + */
16438 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
16439 +{
16440 + long __i = i;
16441 asm volatile(_ASM_XADD "%0, %1;"
16442 : "+r" (i), "+m" (l->a.counter)
16443 : : "memory");
16444 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
16445
16446 #define local_cmpxchg(l, o, n) \
16447 (cmpxchg_local(&((l)->a.counter), (o), (n)))
16448 +#define local_cmpxchg_unchecked(l, o, n) \
16449 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
16450 /* Always has a lock prefix */
16451 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
16452
16453 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
16454 new file mode 100644
16455 index 0000000..2bfd3ba
16456 --- /dev/null
16457 +++ b/arch/x86/include/asm/mman.h
16458 @@ -0,0 +1,15 @@
16459 +#ifndef _X86_MMAN_H
16460 +#define _X86_MMAN_H
16461 +
16462 +#include <uapi/asm/mman.h>
16463 +
16464 +#ifdef __KERNEL__
16465 +#ifndef __ASSEMBLY__
16466 +#ifdef CONFIG_X86_32
16467 +#define arch_mmap_check i386_mmap_check
16468 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
16469 +#endif
16470 +#endif
16471 +#endif
16472 +
16473 +#endif /* X86_MMAN_H */
16474 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
16475 index 5f55e69..e20bfb1 100644
16476 --- a/arch/x86/include/asm/mmu.h
16477 +++ b/arch/x86/include/asm/mmu.h
16478 @@ -9,7 +9,7 @@
16479 * we put the segment information here.
16480 */
16481 typedef struct {
16482 - void *ldt;
16483 + struct desc_struct *ldt;
16484 int size;
16485
16486 #ifdef CONFIG_X86_64
16487 @@ -18,7 +18,19 @@ typedef struct {
16488 #endif
16489
16490 struct mutex lock;
16491 - void *vdso;
16492 + unsigned long vdso;
16493 +
16494 +#ifdef CONFIG_X86_32
16495 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
16496 + unsigned long user_cs_base;
16497 + unsigned long user_cs_limit;
16498 +
16499 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
16500 + cpumask_t cpu_user_cs_mask;
16501 +#endif
16502 +
16503 +#endif
16504 +#endif
16505 } mm_context_t;
16506
16507 #ifdef CONFIG_SMP
16508 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
16509 index be12c53..4d24039 100644
16510 --- a/arch/x86/include/asm/mmu_context.h
16511 +++ b/arch/x86/include/asm/mmu_context.h
16512 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
16513
16514 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
16515 {
16516 +
16517 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16518 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
16519 + unsigned int i;
16520 + pgd_t *pgd;
16521 +
16522 + pax_open_kernel();
16523 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
16524 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
16525 + set_pgd_batched(pgd+i, native_make_pgd(0));
16526 + pax_close_kernel();
16527 + }
16528 +#endif
16529 +
16530 #ifdef CONFIG_SMP
16531 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
16532 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
16533 @@ -34,16 +48,59 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
16534 struct task_struct *tsk)
16535 {
16536 unsigned cpu = smp_processor_id();
16537 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16538 + int tlbstate = TLBSTATE_OK;
16539 +#endif
16540
16541 if (likely(prev != next)) {
16542 #ifdef CONFIG_SMP
16543 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16544 + tlbstate = this_cpu_read(cpu_tlbstate.state);
16545 +#endif
16546 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
16547 this_cpu_write(cpu_tlbstate.active_mm, next);
16548 #endif
16549 cpumask_set_cpu(cpu, mm_cpumask(next));
16550
16551 /* Re-load page tables */
16552 +#ifdef CONFIG_PAX_PER_CPU_PGD
16553 + pax_open_kernel();
16554 +
16555 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16556 + if (static_cpu_has(X86_FEATURE_PCID))
16557 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
16558 + else
16559 +#endif
16560 +
16561 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
16562 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
16563 + pax_close_kernel();
16564 + 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));
16565 +
16566 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16567 + if (static_cpu_has(X86_FEATURE_PCID)) {
16568 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
16569 + u64 descriptor[2];
16570 + descriptor[0] = PCID_USER;
16571 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16572 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
16573 + descriptor[0] = PCID_KERNEL;
16574 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16575 + }
16576 + } else {
16577 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
16578 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
16579 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
16580 + else
16581 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
16582 + }
16583 + } else
16584 +#endif
16585 +
16586 + load_cr3(get_cpu_pgd(cpu, kernel));
16587 +#else
16588 load_cr3(next->pgd);
16589 +#endif
16590
16591 /* Stop flush ipis for the previous mm */
16592 cpumask_clear_cpu(cpu, mm_cpumask(prev));
16593 @@ -51,9 +108,67 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
16594 /* Load the LDT, if the LDT is different: */
16595 if (unlikely(prev->context.ldt != next->context.ldt))
16596 load_LDT_nolock(&next->context);
16597 +
16598 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
16599 + if (!(__supported_pte_mask & _PAGE_NX)) {
16600 + smp_mb__before_clear_bit();
16601 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
16602 + smp_mb__after_clear_bit();
16603 + cpu_set(cpu, next->context.cpu_user_cs_mask);
16604 + }
16605 +#endif
16606 +
16607 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16608 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
16609 + prev->context.user_cs_limit != next->context.user_cs_limit))
16610 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16611 +#ifdef CONFIG_SMP
16612 + else if (unlikely(tlbstate != TLBSTATE_OK))
16613 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16614 +#endif
16615 +#endif
16616 +
16617 }
16618 + else {
16619 +
16620 +#ifdef CONFIG_PAX_PER_CPU_PGD
16621 + pax_open_kernel();
16622 +
16623 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16624 + if (static_cpu_has(X86_FEATURE_PCID))
16625 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
16626 + else
16627 +#endif
16628 +
16629 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
16630 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
16631 + pax_close_kernel();
16632 + 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));
16633 +
16634 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16635 + if (static_cpu_has(X86_FEATURE_PCID)) {
16636 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
16637 + u64 descriptor[2];
16638 + descriptor[0] = PCID_USER;
16639 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16640 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
16641 + descriptor[0] = PCID_KERNEL;
16642 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16643 + }
16644 + } else {
16645 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
16646 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
16647 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
16648 + else
16649 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
16650 + }
16651 + } else
16652 +#endif
16653 +
16654 + load_cr3(get_cpu_pgd(cpu, kernel));
16655 +#endif
16656 +
16657 #ifdef CONFIG_SMP
16658 - else {
16659 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
16660 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
16661
16662 @@ -70,11 +185,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
16663 * tlb flush IPI delivery. We must reload CR3
16664 * to make sure to use no freed page tables.
16665 */
16666 +
16667 +#ifndef CONFIG_PAX_PER_CPU_PGD
16668 load_cr3(next->pgd);
16669 +#endif
16670 +
16671 load_LDT_nolock(&next->context);
16672 +
16673 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
16674 + if (!(__supported_pte_mask & _PAGE_NX))
16675 + cpu_set(cpu, next->context.cpu_user_cs_mask);
16676 +#endif
16677 +
16678 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16679 +#ifdef CONFIG_PAX_PAGEEXEC
16680 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
16681 +#endif
16682 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16683 +#endif
16684 +
16685 }
16686 +#endif
16687 }
16688 -#endif
16689 }
16690
16691 #define activate_mm(prev, next) \
16692 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
16693 index e3b7819..b257c64 100644
16694 --- a/arch/x86/include/asm/module.h
16695 +++ b/arch/x86/include/asm/module.h
16696 @@ -5,6 +5,7 @@
16697
16698 #ifdef CONFIG_X86_64
16699 /* X86_64 does not define MODULE_PROC_FAMILY */
16700 +#define MODULE_PROC_FAMILY ""
16701 #elif defined CONFIG_M486
16702 #define MODULE_PROC_FAMILY "486 "
16703 #elif defined CONFIG_M586
16704 @@ -57,8 +58,20 @@
16705 #error unknown processor family
16706 #endif
16707
16708 -#ifdef CONFIG_X86_32
16709 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
16710 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
16711 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
16712 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
16713 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
16714 +#else
16715 +#define MODULE_PAX_KERNEXEC ""
16716 #endif
16717
16718 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16719 +#define MODULE_PAX_UDEREF "UDEREF "
16720 +#else
16721 +#define MODULE_PAX_UDEREF ""
16722 +#endif
16723 +
16724 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
16725 +
16726 #endif /* _ASM_X86_MODULE_H */
16727 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
16728 index 86f9301..b365cda 100644
16729 --- a/arch/x86/include/asm/nmi.h
16730 +++ b/arch/x86/include/asm/nmi.h
16731 @@ -40,11 +40,11 @@ struct nmiaction {
16732 nmi_handler_t handler;
16733 unsigned long flags;
16734 const char *name;
16735 -};
16736 +} __do_const;
16737
16738 #define register_nmi_handler(t, fn, fg, n, init...) \
16739 ({ \
16740 - static struct nmiaction init fn##_na = { \
16741 + static const struct nmiaction init fn##_na = { \
16742 .handler = (fn), \
16743 .name = (n), \
16744 .flags = (fg), \
16745 @@ -52,7 +52,7 @@ struct nmiaction {
16746 __register_nmi_handler((t), &fn##_na); \
16747 })
16748
16749 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16750 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16751
16752 void unregister_nmi_handler(unsigned int, const char *);
16753
16754 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16755 index c878924..21f4889 100644
16756 --- a/arch/x86/include/asm/page.h
16757 +++ b/arch/x86/include/asm/page.h
16758 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16759 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16760
16761 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16762 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16763
16764 #define __boot_va(x) __va(x)
16765 #define __boot_pa(x) __pa(x)
16766 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16767 index 0f1ddee..e2fc3d1 100644
16768 --- a/arch/x86/include/asm/page_64.h
16769 +++ b/arch/x86/include/asm/page_64.h
16770 @@ -7,9 +7,9 @@
16771
16772 /* duplicated to the one in bootmem.h */
16773 extern unsigned long max_pfn;
16774 -extern unsigned long phys_base;
16775 +extern const unsigned long phys_base;
16776
16777 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16778 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16779 {
16780 unsigned long y = x - __START_KERNEL_map;
16781
16782 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16783 index 401f350..dee5d13 100644
16784 --- a/arch/x86/include/asm/paravirt.h
16785 +++ b/arch/x86/include/asm/paravirt.h
16786 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16787 return (pmd_t) { ret };
16788 }
16789
16790 -static inline pmdval_t pmd_val(pmd_t pmd)
16791 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16792 {
16793 pmdval_t ret;
16794
16795 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16796 val);
16797 }
16798
16799 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16800 +{
16801 + pgdval_t val = native_pgd_val(pgd);
16802 +
16803 + if (sizeof(pgdval_t) > sizeof(long))
16804 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16805 + val, (u64)val >> 32);
16806 + else
16807 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16808 + val);
16809 +}
16810 +
16811 static inline void pgd_clear(pgd_t *pgdp)
16812 {
16813 set_pgd(pgdp, __pgd(0));
16814 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16815 pv_mmu_ops.set_fixmap(idx, phys, flags);
16816 }
16817
16818 +#ifdef CONFIG_PAX_KERNEXEC
16819 +static inline unsigned long pax_open_kernel(void)
16820 +{
16821 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16822 +}
16823 +
16824 +static inline unsigned long pax_close_kernel(void)
16825 +{
16826 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16827 +}
16828 +#else
16829 +static inline unsigned long pax_open_kernel(void) { return 0; }
16830 +static inline unsigned long pax_close_kernel(void) { return 0; }
16831 +#endif
16832 +
16833 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16834
16835 static __always_inline void __ticket_lock_spinning(struct arch_spinlock *lock,
16836 @@ -906,7 +933,7 @@ extern void default_banner(void);
16837
16838 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16839 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16840 -#define PARA_INDIRECT(addr) *%cs:addr
16841 +#define PARA_INDIRECT(addr) *%ss:addr
16842 #endif
16843
16844 #define INTERRUPT_RETURN \
16845 @@ -981,6 +1008,21 @@ extern void default_banner(void);
16846 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16847 CLBR_NONE, \
16848 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16849 +
16850 +#define GET_CR0_INTO_RDI \
16851 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16852 + mov %rax,%rdi
16853 +
16854 +#define SET_RDI_INTO_CR0 \
16855 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16856 +
16857 +#define GET_CR3_INTO_RDI \
16858 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16859 + mov %rax,%rdi
16860 +
16861 +#define SET_RDI_INTO_CR3 \
16862 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16863 +
16864 #endif /* CONFIG_X86_32 */
16865
16866 #endif /* __ASSEMBLY__ */
16867 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16868 index aab8f67..2531748 100644
16869 --- a/arch/x86/include/asm/paravirt_types.h
16870 +++ b/arch/x86/include/asm/paravirt_types.h
16871 @@ -84,7 +84,7 @@ struct pv_init_ops {
16872 */
16873 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16874 unsigned long addr, unsigned len);
16875 -};
16876 +} __no_const;
16877
16878
16879 struct pv_lazy_ops {
16880 @@ -98,7 +98,7 @@ struct pv_time_ops {
16881 unsigned long long (*sched_clock)(void);
16882 unsigned long long (*steal_clock)(int cpu);
16883 unsigned long (*get_tsc_khz)(void);
16884 -};
16885 +} __no_const;
16886
16887 struct pv_cpu_ops {
16888 /* hooks for various privileged instructions */
16889 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16890
16891 void (*start_context_switch)(struct task_struct *prev);
16892 void (*end_context_switch)(struct task_struct *next);
16893 -};
16894 +} __no_const;
16895
16896 struct pv_irq_ops {
16897 /*
16898 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16899 unsigned long start_eip,
16900 unsigned long start_esp);
16901 #endif
16902 -};
16903 +} __no_const;
16904
16905 struct pv_mmu_ops {
16906 unsigned long (*read_cr2)(void);
16907 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16908 struct paravirt_callee_save make_pud;
16909
16910 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16911 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16912 #endif /* PAGETABLE_LEVELS == 4 */
16913 #endif /* PAGETABLE_LEVELS >= 3 */
16914
16915 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16916 an mfn. We can tell which is which from the index. */
16917 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16918 phys_addr_t phys, pgprot_t flags);
16919 +
16920 +#ifdef CONFIG_PAX_KERNEXEC
16921 + unsigned long (*pax_open_kernel)(void);
16922 + unsigned long (*pax_close_kernel)(void);
16923 +#endif
16924 +
16925 };
16926
16927 struct arch_spinlock;
16928 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16929 index b4389a4..7024269 100644
16930 --- a/arch/x86/include/asm/pgalloc.h
16931 +++ b/arch/x86/include/asm/pgalloc.h
16932 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16933 pmd_t *pmd, pte_t *pte)
16934 {
16935 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16936 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16937 +}
16938 +
16939 +static inline void pmd_populate_user(struct mm_struct *mm,
16940 + pmd_t *pmd, pte_t *pte)
16941 +{
16942 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16943 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16944 }
16945
16946 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16947
16948 #ifdef CONFIG_X86_PAE
16949 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16950 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16951 +{
16952 + pud_populate(mm, pudp, pmd);
16953 +}
16954 #else /* !CONFIG_X86_PAE */
16955 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16956 {
16957 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16958 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16959 }
16960 +
16961 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16962 +{
16963 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16964 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16965 +}
16966 #endif /* CONFIG_X86_PAE */
16967
16968 #if PAGETABLE_LEVELS > 3
16969 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16970 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16971 }
16972
16973 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16974 +{
16975 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16976 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16977 +}
16978 +
16979 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16980 {
16981 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16982 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16983 index 3bf2dd0..23d2a9f 100644
16984 --- a/arch/x86/include/asm/pgtable-2level.h
16985 +++ b/arch/x86/include/asm/pgtable-2level.h
16986 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16987
16988 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16989 {
16990 + pax_open_kernel();
16991 *pmdp = pmd;
16992 + pax_close_kernel();
16993 }
16994
16995 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16996 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16997 index 81bb91b..9392125 100644
16998 --- a/arch/x86/include/asm/pgtable-3level.h
16999 +++ b/arch/x86/include/asm/pgtable-3level.h
17000 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
17001
17002 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
17003 {
17004 + pax_open_kernel();
17005 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
17006 + pax_close_kernel();
17007 }
17008
17009 static inline void native_set_pud(pud_t *pudp, pud_t pud)
17010 {
17011 + pax_open_kernel();
17012 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
17013 + pax_close_kernel();
17014 }
17015
17016 /*
17017 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
17018 index bbc8b12..f228861 100644
17019 --- a/arch/x86/include/asm/pgtable.h
17020 +++ b/arch/x86/include/asm/pgtable.h
17021 @@ -45,6 +45,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
17022
17023 #ifndef __PAGETABLE_PUD_FOLDED
17024 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
17025 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
17026 #define pgd_clear(pgd) native_pgd_clear(pgd)
17027 #endif
17028
17029 @@ -82,12 +83,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
17030
17031 #define arch_end_context_switch(prev) do {} while(0)
17032
17033 +#define pax_open_kernel() native_pax_open_kernel()
17034 +#define pax_close_kernel() native_pax_close_kernel()
17035 #endif /* CONFIG_PARAVIRT */
17036
17037 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
17038 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
17039 +
17040 +#ifdef CONFIG_PAX_KERNEXEC
17041 +static inline unsigned long native_pax_open_kernel(void)
17042 +{
17043 + unsigned long cr0;
17044 +
17045 + preempt_disable();
17046 + barrier();
17047 + cr0 = read_cr0() ^ X86_CR0_WP;
17048 + BUG_ON(cr0 & X86_CR0_WP);
17049 + write_cr0(cr0);
17050 + return cr0 ^ X86_CR0_WP;
17051 +}
17052 +
17053 +static inline unsigned long native_pax_close_kernel(void)
17054 +{
17055 + unsigned long cr0;
17056 +
17057 + cr0 = read_cr0() ^ X86_CR0_WP;
17058 + BUG_ON(!(cr0 & X86_CR0_WP));
17059 + write_cr0(cr0);
17060 + barrier();
17061 + preempt_enable_no_resched();
17062 + return cr0 ^ X86_CR0_WP;
17063 +}
17064 +#else
17065 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
17066 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
17067 +#endif
17068 +
17069 /*
17070 * The following only work if pte_present() is true.
17071 * Undefined behaviour if not..
17072 */
17073 +static inline int pte_user(pte_t pte)
17074 +{
17075 + return pte_val(pte) & _PAGE_USER;
17076 +}
17077 +
17078 static inline int pte_dirty(pte_t pte)
17079 {
17080 return pte_flags(pte) & _PAGE_DIRTY;
17081 @@ -148,6 +188,11 @@ static inline unsigned long pud_pfn(pud_t pud)
17082 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
17083 }
17084
17085 +static inline unsigned long pgd_pfn(pgd_t pgd)
17086 +{
17087 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
17088 +}
17089 +
17090 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
17091
17092 static inline int pmd_large(pmd_t pte)
17093 @@ -201,9 +246,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
17094 return pte_clear_flags(pte, _PAGE_RW);
17095 }
17096
17097 +static inline pte_t pte_mkread(pte_t pte)
17098 +{
17099 + return __pte(pte_val(pte) | _PAGE_USER);
17100 +}
17101 +
17102 static inline pte_t pte_mkexec(pte_t pte)
17103 {
17104 - return pte_clear_flags(pte, _PAGE_NX);
17105 +#ifdef CONFIG_X86_PAE
17106 + if (__supported_pte_mask & _PAGE_NX)
17107 + return pte_clear_flags(pte, _PAGE_NX);
17108 + else
17109 +#endif
17110 + return pte_set_flags(pte, _PAGE_USER);
17111 +}
17112 +
17113 +static inline pte_t pte_exprotect(pte_t pte)
17114 +{
17115 +#ifdef CONFIG_X86_PAE
17116 + if (__supported_pte_mask & _PAGE_NX)
17117 + return pte_set_flags(pte, _PAGE_NX);
17118 + else
17119 +#endif
17120 + return pte_clear_flags(pte, _PAGE_USER);
17121 }
17122
17123 static inline pte_t pte_mkdirty(pte_t pte)
17124 @@ -430,6 +495,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
17125 #endif
17126
17127 #ifndef __ASSEMBLY__
17128 +
17129 +#ifdef CONFIG_PAX_PER_CPU_PGD
17130 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
17131 +enum cpu_pgd_type {kernel = 0, user = 1};
17132 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
17133 +{
17134 + return cpu_pgd[cpu][type];
17135 +}
17136 +#endif
17137 +
17138 #include <linux/mm_types.h>
17139 #include <linux/mmdebug.h>
17140 #include <linux/log2.h>
17141 @@ -570,7 +645,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
17142 * Currently stuck as a macro due to indirect forward reference to
17143 * linux/mmzone.h's __section_mem_map_addr() definition:
17144 */
17145 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
17146 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
17147
17148 /* Find an entry in the second-level page table.. */
17149 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
17150 @@ -610,7 +685,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
17151 * Currently stuck as a macro due to indirect forward reference to
17152 * linux/mmzone.h's __section_mem_map_addr() definition:
17153 */
17154 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
17155 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
17156
17157 /* to find an entry in a page-table-directory. */
17158 static inline unsigned long pud_index(unsigned long address)
17159 @@ -625,7 +700,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
17160
17161 static inline int pgd_bad(pgd_t pgd)
17162 {
17163 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
17164 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
17165 }
17166
17167 static inline int pgd_none(pgd_t pgd)
17168 @@ -648,7 +723,12 @@ static inline int pgd_none(pgd_t pgd)
17169 * pgd_offset() returns a (pgd_t *)
17170 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
17171 */
17172 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
17173 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
17174 +
17175 +#ifdef CONFIG_PAX_PER_CPU_PGD
17176 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
17177 +#endif
17178 +
17179 /*
17180 * a shortcut which implies the use of the kernel's pgd, instead
17181 * of a process's
17182 @@ -659,6 +739,23 @@ static inline int pgd_none(pgd_t pgd)
17183 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
17184 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
17185
17186 +#ifdef CONFIG_X86_32
17187 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
17188 +#else
17189 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
17190 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
17191 +
17192 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17193 +#ifdef __ASSEMBLY__
17194 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
17195 +#else
17196 +extern unsigned long pax_user_shadow_base;
17197 +extern pgdval_t clone_pgd_mask;
17198 +#endif
17199 +#endif
17200 +
17201 +#endif
17202 +
17203 #ifndef __ASSEMBLY__
17204
17205 extern int direct_gbpages;
17206 @@ -825,11 +922,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
17207 * dst and src can be on the same page, but the range must not overlap,
17208 * and must not cross a page boundary.
17209 */
17210 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
17211 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
17212 {
17213 - memcpy(dst, src, count * sizeof(pgd_t));
17214 + pax_open_kernel();
17215 + while (count--)
17216 + *dst++ = *src++;
17217 + pax_close_kernel();
17218 }
17219
17220 +#ifdef CONFIG_PAX_PER_CPU_PGD
17221 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
17222 +#endif
17223 +
17224 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17225 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
17226 +#else
17227 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
17228 +#endif
17229 +
17230 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
17231 static inline int page_level_shift(enum pg_level level)
17232 {
17233 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
17234 index 9ee3221..b979c6b 100644
17235 --- a/arch/x86/include/asm/pgtable_32.h
17236 +++ b/arch/x86/include/asm/pgtable_32.h
17237 @@ -25,9 +25,6 @@
17238 struct mm_struct;
17239 struct vm_area_struct;
17240
17241 -extern pgd_t swapper_pg_dir[1024];
17242 -extern pgd_t initial_page_table[1024];
17243 -
17244 static inline void pgtable_cache_init(void) { }
17245 static inline void check_pgt_cache(void) { }
17246 void paging_init(void);
17247 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
17248 # include <asm/pgtable-2level.h>
17249 #endif
17250
17251 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
17252 +extern pgd_t initial_page_table[PTRS_PER_PGD];
17253 +#ifdef CONFIG_X86_PAE
17254 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
17255 +#endif
17256 +
17257 #if defined(CONFIG_HIGHPTE)
17258 #define pte_offset_map(dir, address) \
17259 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
17260 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
17261 /* Clear a kernel PTE and flush it from the TLB */
17262 #define kpte_clear_flush(ptep, vaddr) \
17263 do { \
17264 + pax_open_kernel(); \
17265 pte_clear(&init_mm, (vaddr), (ptep)); \
17266 + pax_close_kernel(); \
17267 __flush_tlb_one((vaddr)); \
17268 } while (0)
17269
17270 #endif /* !__ASSEMBLY__ */
17271
17272 +#define HAVE_ARCH_UNMAPPED_AREA
17273 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
17274 +
17275 /*
17276 * kern_addr_valid() is (1) for FLATMEM and (0) for
17277 * SPARSEMEM and DISCONTIGMEM
17278 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
17279 index ed5903b..c7fe163 100644
17280 --- a/arch/x86/include/asm/pgtable_32_types.h
17281 +++ b/arch/x86/include/asm/pgtable_32_types.h
17282 @@ -8,7 +8,7 @@
17283 */
17284 #ifdef CONFIG_X86_PAE
17285 # include <asm/pgtable-3level_types.h>
17286 -# define PMD_SIZE (1UL << PMD_SHIFT)
17287 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
17288 # define PMD_MASK (~(PMD_SIZE - 1))
17289 #else
17290 # include <asm/pgtable-2level_types.h>
17291 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
17292 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
17293 #endif
17294
17295 +#ifdef CONFIG_PAX_KERNEXEC
17296 +#ifndef __ASSEMBLY__
17297 +extern unsigned char MODULES_EXEC_VADDR[];
17298 +extern unsigned char MODULES_EXEC_END[];
17299 +#endif
17300 +#include <asm/boot.h>
17301 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
17302 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
17303 +#else
17304 +#define ktla_ktva(addr) (addr)
17305 +#define ktva_ktla(addr) (addr)
17306 +#endif
17307 +
17308 #define MODULES_VADDR VMALLOC_START
17309 #define MODULES_END VMALLOC_END
17310 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
17311 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
17312 index e22c1db..23a625a 100644
17313 --- a/arch/x86/include/asm/pgtable_64.h
17314 +++ b/arch/x86/include/asm/pgtable_64.h
17315 @@ -16,10 +16,14 @@
17316
17317 extern pud_t level3_kernel_pgt[512];
17318 extern pud_t level3_ident_pgt[512];
17319 +extern pud_t level3_vmalloc_start_pgt[512];
17320 +extern pud_t level3_vmalloc_end_pgt[512];
17321 +extern pud_t level3_vmemmap_pgt[512];
17322 +extern pud_t level2_vmemmap_pgt[512];
17323 extern pmd_t level2_kernel_pgt[512];
17324 extern pmd_t level2_fixmap_pgt[512];
17325 -extern pmd_t level2_ident_pgt[512];
17326 -extern pgd_t init_level4_pgt[];
17327 +extern pmd_t level2_ident_pgt[512*2];
17328 +extern pgd_t init_level4_pgt[512];
17329
17330 #define swapper_pg_dir init_level4_pgt
17331
17332 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
17333
17334 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
17335 {
17336 + pax_open_kernel();
17337 *pmdp = pmd;
17338 + pax_close_kernel();
17339 }
17340
17341 static inline void native_pmd_clear(pmd_t *pmd)
17342 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
17343
17344 static inline void native_set_pud(pud_t *pudp, pud_t pud)
17345 {
17346 + pax_open_kernel();
17347 *pudp = pud;
17348 + pax_close_kernel();
17349 }
17350
17351 static inline void native_pud_clear(pud_t *pud)
17352 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
17353
17354 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
17355 {
17356 + pax_open_kernel();
17357 + *pgdp = pgd;
17358 + pax_close_kernel();
17359 +}
17360 +
17361 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
17362 +{
17363 *pgdp = pgd;
17364 }
17365
17366 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
17367 index 2d88344..4679fc3 100644
17368 --- a/arch/x86/include/asm/pgtable_64_types.h
17369 +++ b/arch/x86/include/asm/pgtable_64_types.h
17370 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
17371 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
17372 #define MODULES_END _AC(0xffffffffff000000, UL)
17373 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
17374 +#define MODULES_EXEC_VADDR MODULES_VADDR
17375 +#define MODULES_EXEC_END MODULES_END
17376 +
17377 +#define ktla_ktva(addr) (addr)
17378 +#define ktva_ktla(addr) (addr)
17379
17380 #define EARLY_DYNAMIC_PAGE_TABLES 64
17381
17382 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
17383 index 0ecac25..306c276 100644
17384 --- a/arch/x86/include/asm/pgtable_types.h
17385 +++ b/arch/x86/include/asm/pgtable_types.h
17386 @@ -16,13 +16,12 @@
17387 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
17388 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
17389 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
17390 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
17391 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
17392 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
17393 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
17394 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
17395 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
17396 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
17397 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
17398 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
17399 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
17400 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
17401
17402 /* If _PAGE_BIT_PRESENT is clear, we use these: */
17403 @@ -40,7 +39,6 @@
17404 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
17405 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
17406 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
17407 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
17408 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
17409 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
17410 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
17411 @@ -87,8 +85,10 @@
17412
17413 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
17414 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
17415 -#else
17416 +#elif defined(CONFIG_KMEMCHECK)
17417 #define _PAGE_NX (_AT(pteval_t, 0))
17418 +#else
17419 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
17420 #endif
17421
17422 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
17423 @@ -146,6 +146,9 @@
17424 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
17425 _PAGE_ACCESSED)
17426
17427 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
17428 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
17429 +
17430 #define __PAGE_KERNEL_EXEC \
17431 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
17432 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
17433 @@ -156,7 +159,7 @@
17434 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
17435 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
17436 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
17437 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
17438 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
17439 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
17440 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
17441 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
17442 @@ -218,8 +221,8 @@
17443 * bits are combined, this will alow user to access the high address mapped
17444 * VDSO in the presence of CONFIG_COMPAT_VDSO
17445 */
17446 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
17447 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
17448 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
17449 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
17450 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
17451 #endif
17452
17453 @@ -257,7 +260,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
17454 {
17455 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
17456 }
17457 +#endif
17458
17459 +#if PAGETABLE_LEVELS == 3
17460 +#include <asm-generic/pgtable-nopud.h>
17461 +#endif
17462 +
17463 +#if PAGETABLE_LEVELS == 2
17464 +#include <asm-generic/pgtable-nopmd.h>
17465 +#endif
17466 +
17467 +#ifndef __ASSEMBLY__
17468 #if PAGETABLE_LEVELS > 3
17469 typedef struct { pudval_t pud; } pud_t;
17470
17471 @@ -271,8 +284,6 @@ static inline pudval_t native_pud_val(pud_t pud)
17472 return pud.pud;
17473 }
17474 #else
17475 -#include <asm-generic/pgtable-nopud.h>
17476 -
17477 static inline pudval_t native_pud_val(pud_t pud)
17478 {
17479 return native_pgd_val(pud.pgd);
17480 @@ -292,8 +303,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
17481 return pmd.pmd;
17482 }
17483 #else
17484 -#include <asm-generic/pgtable-nopmd.h>
17485 -
17486 static inline pmdval_t native_pmd_val(pmd_t pmd)
17487 {
17488 return native_pgd_val(pmd.pud.pgd);
17489 @@ -333,7 +342,6 @@ typedef struct page *pgtable_t;
17490
17491 extern pteval_t __supported_pte_mask;
17492 extern void set_nx(void);
17493 -extern int nx_enabled;
17494
17495 #define pgprot_writecombine pgprot_writecombine
17496 extern pgprot_t pgprot_writecombine(pgprot_t prot);
17497 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
17498 index 987c75e..2723054 100644
17499 --- a/arch/x86/include/asm/processor.h
17500 +++ b/arch/x86/include/asm/processor.h
17501 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
17502 : "memory");
17503 }
17504
17505 +/* invpcid (%rdx),%rax */
17506 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
17507 +
17508 +#define INVPCID_SINGLE_ADDRESS 0UL
17509 +#define INVPCID_SINGLE_CONTEXT 1UL
17510 +#define INVPCID_ALL_GLOBAL 2UL
17511 +#define INVPCID_ALL_MONGLOBAL 3UL
17512 +
17513 +#define PCID_KERNEL 0UL
17514 +#define PCID_USER 1UL
17515 +#define PCID_NOFLUSH (1UL << 63)
17516 +
17517 static inline void load_cr3(pgd_t *pgdir)
17518 {
17519 - write_cr3(__pa(pgdir));
17520 + write_cr3(__pa(pgdir) | PCID_KERNEL);
17521 }
17522
17523 #ifdef CONFIG_X86_32
17524 @@ -283,7 +295,7 @@ struct tss_struct {
17525
17526 } ____cacheline_aligned;
17527
17528 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
17529 +extern struct tss_struct init_tss[NR_CPUS];
17530
17531 /*
17532 * Save the original ist values for checking stack pointers during debugging
17533 @@ -453,6 +465,7 @@ struct thread_struct {
17534 unsigned short ds;
17535 unsigned short fsindex;
17536 unsigned short gsindex;
17537 + unsigned short ss;
17538 #endif
17539 #ifdef CONFIG_X86_32
17540 unsigned long ip;
17541 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
17542 extern unsigned long mmu_cr4_features;
17543 extern u32 *trampoline_cr4_features;
17544
17545 -static inline void set_in_cr4(unsigned long mask)
17546 -{
17547 - unsigned long cr4;
17548 -
17549 - mmu_cr4_features |= mask;
17550 - if (trampoline_cr4_features)
17551 - *trampoline_cr4_features = mmu_cr4_features;
17552 - cr4 = read_cr4();
17553 - cr4 |= mask;
17554 - write_cr4(cr4);
17555 -}
17556 -
17557 -static inline void clear_in_cr4(unsigned long mask)
17558 -{
17559 - unsigned long cr4;
17560 -
17561 - mmu_cr4_features &= ~mask;
17562 - if (trampoline_cr4_features)
17563 - *trampoline_cr4_features = mmu_cr4_features;
17564 - cr4 = read_cr4();
17565 - cr4 &= ~mask;
17566 - write_cr4(cr4);
17567 -}
17568 +extern void set_in_cr4(unsigned long mask);
17569 +extern void clear_in_cr4(unsigned long mask);
17570
17571 typedef struct {
17572 unsigned long seg;
17573 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
17574 */
17575 #define TASK_SIZE PAGE_OFFSET
17576 #define TASK_SIZE_MAX TASK_SIZE
17577 +
17578 +#ifdef CONFIG_PAX_SEGMEXEC
17579 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
17580 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
17581 +#else
17582 #define STACK_TOP TASK_SIZE
17583 -#define STACK_TOP_MAX STACK_TOP
17584 +#endif
17585 +
17586 +#define STACK_TOP_MAX TASK_SIZE
17587
17588 #define INIT_THREAD { \
17589 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
17590 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
17591 .vm86_info = NULL, \
17592 .sysenter_cs = __KERNEL_CS, \
17593 .io_bitmap_ptr = NULL, \
17594 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
17595 */
17596 #define INIT_TSS { \
17597 .x86_tss = { \
17598 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
17599 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
17600 .ss0 = __KERNEL_DS, \
17601 .ss1 = __KERNEL_CS, \
17602 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
17603 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
17604 extern unsigned long thread_saved_pc(struct task_struct *tsk);
17605
17606 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
17607 -#define KSTK_TOP(info) \
17608 -({ \
17609 - unsigned long *__ptr = (unsigned long *)(info); \
17610 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
17611 -})
17612 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
17613
17614 /*
17615 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
17616 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17617 #define task_pt_regs(task) \
17618 ({ \
17619 struct pt_regs *__regs__; \
17620 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
17621 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
17622 __regs__ - 1; \
17623 })
17624
17625 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17626 /*
17627 * User space process size. 47bits minus one guard page.
17628 */
17629 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
17630 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
17631
17632 /* This decides where the kernel will search for a free chunk of vm
17633 * space during mmap's.
17634 */
17635 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
17636 - 0xc0000000 : 0xFFFFe000)
17637 + 0xc0000000 : 0xFFFFf000)
17638
17639 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
17640 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
17641 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17642 #define STACK_TOP_MAX TASK_SIZE_MAX
17643
17644 #define INIT_THREAD { \
17645 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
17646 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
17647 }
17648
17649 #define INIT_TSS { \
17650 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
17651 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
17652 }
17653
17654 /*
17655 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
17656 */
17657 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
17658
17659 +#ifdef CONFIG_PAX_SEGMEXEC
17660 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
17661 +#endif
17662 +
17663 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
17664
17665 /* Get/set a process' ability to use the timestamp counter instruction */
17666 @@ -957,7 +956,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
17667 return 0;
17668 }
17669
17670 -extern unsigned long arch_align_stack(unsigned long sp);
17671 +#define arch_align_stack(x) ((x) & ~0xfUL)
17672 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
17673
17674 void default_idle(void);
17675 @@ -967,6 +966,6 @@ bool xen_set_default_idle(void);
17676 #define xen_set_default_idle 0
17677 #endif
17678
17679 -void stop_this_cpu(void *dummy);
17680 +void stop_this_cpu(void *dummy) __noreturn;
17681 void df_debug(struct pt_regs *regs, long error_code);
17682 #endif /* _ASM_X86_PROCESSOR_H */
17683 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
17684 index 942a086..6c26446 100644
17685 --- a/arch/x86/include/asm/ptrace.h
17686 +++ b/arch/x86/include/asm/ptrace.h
17687 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
17688 }
17689
17690 /*
17691 - * user_mode_vm(regs) determines whether a register set came from user mode.
17692 + * user_mode(regs) determines whether a register set came from user mode.
17693 * This is true if V8086 mode was enabled OR if the register set was from
17694 * protected mode with RPL-3 CS value. This tricky test checks that with
17695 * one comparison. Many places in the kernel can bypass this full check
17696 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
17697 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
17698 + * be used.
17699 */
17700 -static inline int user_mode(struct pt_regs *regs)
17701 +static inline int user_mode_novm(struct pt_regs *regs)
17702 {
17703 #ifdef CONFIG_X86_32
17704 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
17705 #else
17706 - return !!(regs->cs & 3);
17707 + return !!(regs->cs & SEGMENT_RPL_MASK);
17708 #endif
17709 }
17710
17711 -static inline int user_mode_vm(struct pt_regs *regs)
17712 +static inline int user_mode(struct pt_regs *regs)
17713 {
17714 #ifdef CONFIG_X86_32
17715 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
17716 USER_RPL;
17717 #else
17718 - return user_mode(regs);
17719 + return user_mode_novm(regs);
17720 #endif
17721 }
17722
17723 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17724 #ifdef CONFIG_X86_64
17725 static inline bool user_64bit_mode(struct pt_regs *regs)
17726 {
17727 + unsigned long cs = regs->cs & 0xffff;
17728 #ifndef CONFIG_PARAVIRT
17729 /*
17730 * On non-paravirt systems, this is the only long mode CPL 3
17731 * selector. We do not allow long mode selectors in the LDT.
17732 */
17733 - return regs->cs == __USER_CS;
17734 + return cs == __USER_CS;
17735 #else
17736 /* Headers are too twisted for this to go in paravirt.h. */
17737 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17738 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17739 #endif
17740 }
17741
17742 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17743 * Traps from the kernel do not save sp and ss.
17744 * Use the helper function to retrieve sp.
17745 */
17746 - if (offset == offsetof(struct pt_regs, sp) &&
17747 - regs->cs == __KERNEL_CS)
17748 - return kernel_stack_pointer(regs);
17749 + if (offset == offsetof(struct pt_regs, sp)) {
17750 + unsigned long cs = regs->cs & 0xffff;
17751 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17752 + return kernel_stack_pointer(regs);
17753 + }
17754 #endif
17755 return *(unsigned long *)((unsigned long)regs + offset);
17756 }
17757 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17758 index 9c6b890..5305f53 100644
17759 --- a/arch/x86/include/asm/realmode.h
17760 +++ b/arch/x86/include/asm/realmode.h
17761 @@ -22,16 +22,14 @@ struct real_mode_header {
17762 #endif
17763 /* APM/BIOS reboot */
17764 u32 machine_real_restart_asm;
17765 -#ifdef CONFIG_X86_64
17766 u32 machine_real_restart_seg;
17767 -#endif
17768 };
17769
17770 /* This must match data at trampoline_32/64.S */
17771 struct trampoline_header {
17772 #ifdef CONFIG_X86_32
17773 u32 start;
17774 - u16 gdt_pad;
17775 + u16 boot_cs;
17776 u16 gdt_limit;
17777 u32 gdt_base;
17778 #else
17779 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17780 index a82c4f1..ac45053 100644
17781 --- a/arch/x86/include/asm/reboot.h
17782 +++ b/arch/x86/include/asm/reboot.h
17783 @@ -6,13 +6,13 @@
17784 struct pt_regs;
17785
17786 struct machine_ops {
17787 - void (*restart)(char *cmd);
17788 - void (*halt)(void);
17789 - void (*power_off)(void);
17790 + void (* __noreturn restart)(char *cmd);
17791 + void (* __noreturn halt)(void);
17792 + void (* __noreturn power_off)(void);
17793 void (*shutdown)(void);
17794 void (*crash_shutdown)(struct pt_regs *);
17795 - void (*emergency_restart)(void);
17796 -};
17797 + void (* __noreturn emergency_restart)(void);
17798 +} __no_const;
17799
17800 extern struct machine_ops machine_ops;
17801
17802 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17803 index cad82c9..2e5c5c1 100644
17804 --- a/arch/x86/include/asm/rwsem.h
17805 +++ b/arch/x86/include/asm/rwsem.h
17806 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17807 {
17808 asm volatile("# beginning down_read\n\t"
17809 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17810 +
17811 +#ifdef CONFIG_PAX_REFCOUNT
17812 + "jno 0f\n"
17813 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17814 + "int $4\n0:\n"
17815 + _ASM_EXTABLE(0b, 0b)
17816 +#endif
17817 +
17818 /* adds 0x00000001 */
17819 " jns 1f\n"
17820 " call call_rwsem_down_read_failed\n"
17821 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17822 "1:\n\t"
17823 " mov %1,%2\n\t"
17824 " add %3,%2\n\t"
17825 +
17826 +#ifdef CONFIG_PAX_REFCOUNT
17827 + "jno 0f\n"
17828 + "sub %3,%2\n"
17829 + "int $4\n0:\n"
17830 + _ASM_EXTABLE(0b, 0b)
17831 +#endif
17832 +
17833 " jle 2f\n\t"
17834 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17835 " jnz 1b\n\t"
17836 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17837 long tmp;
17838 asm volatile("# beginning down_write\n\t"
17839 LOCK_PREFIX " xadd %1,(%2)\n\t"
17840 +
17841 +#ifdef CONFIG_PAX_REFCOUNT
17842 + "jno 0f\n"
17843 + "mov %1,(%2)\n"
17844 + "int $4\n0:\n"
17845 + _ASM_EXTABLE(0b, 0b)
17846 +#endif
17847 +
17848 /* adds 0xffff0001, returns the old value */
17849 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17850 /* was the active mask 0 before? */
17851 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17852 long tmp;
17853 asm volatile("# beginning __up_read\n\t"
17854 LOCK_PREFIX " xadd %1,(%2)\n\t"
17855 +
17856 +#ifdef CONFIG_PAX_REFCOUNT
17857 + "jno 0f\n"
17858 + "mov %1,(%2)\n"
17859 + "int $4\n0:\n"
17860 + _ASM_EXTABLE(0b, 0b)
17861 +#endif
17862 +
17863 /* subtracts 1, returns the old value */
17864 " jns 1f\n\t"
17865 " call call_rwsem_wake\n" /* expects old value in %edx */
17866 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17867 long tmp;
17868 asm volatile("# beginning __up_write\n\t"
17869 LOCK_PREFIX " xadd %1,(%2)\n\t"
17870 +
17871 +#ifdef CONFIG_PAX_REFCOUNT
17872 + "jno 0f\n"
17873 + "mov %1,(%2)\n"
17874 + "int $4\n0:\n"
17875 + _ASM_EXTABLE(0b, 0b)
17876 +#endif
17877 +
17878 /* subtracts 0xffff0001, returns the old value */
17879 " jns 1f\n\t"
17880 " call call_rwsem_wake\n" /* expects old value in %edx */
17881 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17882 {
17883 asm volatile("# beginning __downgrade_write\n\t"
17884 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17885 +
17886 +#ifdef CONFIG_PAX_REFCOUNT
17887 + "jno 0f\n"
17888 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17889 + "int $4\n0:\n"
17890 + _ASM_EXTABLE(0b, 0b)
17891 +#endif
17892 +
17893 /*
17894 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17895 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17896 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17897 */
17898 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17899 {
17900 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17901 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17902 +
17903 +#ifdef CONFIG_PAX_REFCOUNT
17904 + "jno 0f\n"
17905 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17906 + "int $4\n0:\n"
17907 + _ASM_EXTABLE(0b, 0b)
17908 +#endif
17909 +
17910 : "+m" (sem->count)
17911 : "er" (delta));
17912 }
17913 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17914 */
17915 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17916 {
17917 - return delta + xadd(&sem->count, delta);
17918 + return delta + xadd_check_overflow(&sem->count, delta);
17919 }
17920
17921 #endif /* __KERNEL__ */
17922 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17923 index c48a950..bc40804 100644
17924 --- a/arch/x86/include/asm/segment.h
17925 +++ b/arch/x86/include/asm/segment.h
17926 @@ -64,10 +64,15 @@
17927 * 26 - ESPFIX small SS
17928 * 27 - per-cpu [ offset to per-cpu data area ]
17929 * 28 - stack_canary-20 [ for stack protector ]
17930 - * 29 - unused
17931 - * 30 - unused
17932 + * 29 - PCI BIOS CS
17933 + * 30 - PCI BIOS DS
17934 * 31 - TSS for double fault handler
17935 */
17936 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17937 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17938 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17939 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17940 +
17941 #define GDT_ENTRY_TLS_MIN 6
17942 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17943
17944 @@ -79,6 +84,8 @@
17945
17946 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17947
17948 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17949 +
17950 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17951
17952 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17953 @@ -104,6 +111,12 @@
17954 #define __KERNEL_STACK_CANARY 0
17955 #endif
17956
17957 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17958 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17959 +
17960 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17961 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17962 +
17963 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17964
17965 /*
17966 @@ -141,7 +154,7 @@
17967 */
17968
17969 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17970 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17971 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17972
17973
17974 #else
17975 @@ -165,6 +178,8 @@
17976 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17977 #define __USER32_DS __USER_DS
17978
17979 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17980 +
17981 #define GDT_ENTRY_TSS 8 /* needs two entries */
17982 #define GDT_ENTRY_LDT 10 /* needs two entries */
17983 #define GDT_ENTRY_TLS_MIN 12
17984 @@ -173,6 +188,8 @@
17985 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17986 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17987
17988 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17989 +
17990 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17991 #define FS_TLS 0
17992 #define GS_TLS 1
17993 @@ -180,12 +197,14 @@
17994 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17995 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17996
17997 -#define GDT_ENTRIES 16
17998 +#define GDT_ENTRIES 17
17999
18000 #endif
18001
18002 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
18003 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
18004 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
18005 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
18006 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
18007 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
18008 #ifndef CONFIG_PARAVIRT
18009 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
18010 {
18011 unsigned long __limit;
18012 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
18013 - return __limit + 1;
18014 + return __limit;
18015 }
18016
18017 #endif /* !__ASSEMBLY__ */
18018 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
18019 index 8d3120f..352b440 100644
18020 --- a/arch/x86/include/asm/smap.h
18021 +++ b/arch/x86/include/asm/smap.h
18022 @@ -25,11 +25,40 @@
18023
18024 #include <asm/alternative-asm.h>
18025
18026 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18027 +#define ASM_PAX_OPEN_USERLAND \
18028 + 661: jmp 663f; \
18029 + .pushsection .altinstr_replacement, "a" ; \
18030 + 662: pushq %rax; nop; \
18031 + .popsection ; \
18032 + .pushsection .altinstructions, "a" ; \
18033 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
18034 + .popsection ; \
18035 + call __pax_open_userland; \
18036 + popq %rax; \
18037 + 663:
18038 +
18039 +#define ASM_PAX_CLOSE_USERLAND \
18040 + 661: jmp 663f; \
18041 + .pushsection .altinstr_replacement, "a" ; \
18042 + 662: pushq %rax; nop; \
18043 + .popsection; \
18044 + .pushsection .altinstructions, "a" ; \
18045 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
18046 + .popsection; \
18047 + call __pax_close_userland; \
18048 + popq %rax; \
18049 + 663:
18050 +#else
18051 +#define ASM_PAX_OPEN_USERLAND
18052 +#define ASM_PAX_CLOSE_USERLAND
18053 +#endif
18054 +
18055 #ifdef CONFIG_X86_SMAP
18056
18057 #define ASM_CLAC \
18058 661: ASM_NOP3 ; \
18059 - .pushsection .altinstr_replacement, "ax" ; \
18060 + .pushsection .altinstr_replacement, "a" ; \
18061 662: __ASM_CLAC ; \
18062 .popsection ; \
18063 .pushsection .altinstructions, "a" ; \
18064 @@ -38,7 +67,7 @@
18065
18066 #define ASM_STAC \
18067 661: ASM_NOP3 ; \
18068 - .pushsection .altinstr_replacement, "ax" ; \
18069 + .pushsection .altinstr_replacement, "a" ; \
18070 662: __ASM_STAC ; \
18071 .popsection ; \
18072 .pushsection .altinstructions, "a" ; \
18073 @@ -56,6 +85,37 @@
18074
18075 #include <asm/alternative.h>
18076
18077 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
18078 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
18079 +
18080 +extern void __pax_open_userland(void);
18081 +static __always_inline unsigned long pax_open_userland(void)
18082 +{
18083 +
18084 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18085 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
18086 + :
18087 + : [open] "i" (__pax_open_userland)
18088 + : "memory", "rax");
18089 +#endif
18090 +
18091 + return 0;
18092 +}
18093 +
18094 +extern void __pax_close_userland(void);
18095 +static __always_inline unsigned long pax_close_userland(void)
18096 +{
18097 +
18098 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18099 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
18100 + :
18101 + : [close] "i" (__pax_close_userland)
18102 + : "memory", "rax");
18103 +#endif
18104 +
18105 + return 0;
18106 +}
18107 +
18108 #ifdef CONFIG_X86_SMAP
18109
18110 static __always_inline void clac(void)
18111 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
18112 index 4137890..03fa172 100644
18113 --- a/arch/x86/include/asm/smp.h
18114 +++ b/arch/x86/include/asm/smp.h
18115 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
18116 /* cpus sharing the last level cache: */
18117 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
18118 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
18119 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
18120 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
18121
18122 static inline struct cpumask *cpu_sibling_mask(int cpu)
18123 {
18124 @@ -79,7 +79,7 @@ struct smp_ops {
18125
18126 void (*send_call_func_ipi)(const struct cpumask *mask);
18127 void (*send_call_func_single_ipi)(int cpu);
18128 -};
18129 +} __no_const;
18130
18131 /* Globals due to paravirt */
18132 extern void set_cpu_sibling_map(int cpu);
18133 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
18134 extern int safe_smp_processor_id(void);
18135
18136 #elif defined(CONFIG_X86_64_SMP)
18137 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
18138 -
18139 -#define stack_smp_processor_id() \
18140 -({ \
18141 - struct thread_info *ti; \
18142 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
18143 - ti->cpu; \
18144 -})
18145 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
18146 +#define stack_smp_processor_id() raw_smp_processor_id()
18147 #define safe_smp_processor_id() smp_processor_id()
18148
18149 #endif
18150 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
18151 index bf156de..1a782ab 100644
18152 --- a/arch/x86/include/asm/spinlock.h
18153 +++ b/arch/x86/include/asm/spinlock.h
18154 @@ -223,6 +223,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
18155 static inline void arch_read_lock(arch_rwlock_t *rw)
18156 {
18157 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
18158 +
18159 +#ifdef CONFIG_PAX_REFCOUNT
18160 + "jno 0f\n"
18161 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
18162 + "int $4\n0:\n"
18163 + _ASM_EXTABLE(0b, 0b)
18164 +#endif
18165 +
18166 "jns 1f\n"
18167 "call __read_lock_failed\n\t"
18168 "1:\n"
18169 @@ -232,6 +240,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
18170 static inline void arch_write_lock(arch_rwlock_t *rw)
18171 {
18172 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
18173 +
18174 +#ifdef CONFIG_PAX_REFCOUNT
18175 + "jno 0f\n"
18176 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
18177 + "int $4\n0:\n"
18178 + _ASM_EXTABLE(0b, 0b)
18179 +#endif
18180 +
18181 "jz 1f\n"
18182 "call __write_lock_failed\n\t"
18183 "1:\n"
18184 @@ -261,13 +277,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
18185
18186 static inline void arch_read_unlock(arch_rwlock_t *rw)
18187 {
18188 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
18189 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
18190 +
18191 +#ifdef CONFIG_PAX_REFCOUNT
18192 + "jno 0f\n"
18193 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
18194 + "int $4\n0:\n"
18195 + _ASM_EXTABLE(0b, 0b)
18196 +#endif
18197 +
18198 :"+m" (rw->lock) : : "memory");
18199 }
18200
18201 static inline void arch_write_unlock(arch_rwlock_t *rw)
18202 {
18203 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
18204 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
18205 +
18206 +#ifdef CONFIG_PAX_REFCOUNT
18207 + "jno 0f\n"
18208 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
18209 + "int $4\n0:\n"
18210 + _ASM_EXTABLE(0b, 0b)
18211 +#endif
18212 +
18213 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
18214 }
18215
18216 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
18217 index 6a99859..03cb807 100644
18218 --- a/arch/x86/include/asm/stackprotector.h
18219 +++ b/arch/x86/include/asm/stackprotector.h
18220 @@ -47,7 +47,7 @@
18221 * head_32 for boot CPU and setup_per_cpu_areas() for others.
18222 */
18223 #define GDT_STACK_CANARY_INIT \
18224 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
18225 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
18226
18227 /*
18228 * Initialize the stackprotector canary value.
18229 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
18230
18231 static inline void load_stack_canary_segment(void)
18232 {
18233 -#ifdef CONFIG_X86_32
18234 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
18235 asm volatile ("mov %0, %%gs" : : "r" (0));
18236 #endif
18237 }
18238 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
18239 index 70bbe39..4ae2bd4 100644
18240 --- a/arch/x86/include/asm/stacktrace.h
18241 +++ b/arch/x86/include/asm/stacktrace.h
18242 @@ -11,28 +11,20 @@
18243
18244 extern int kstack_depth_to_print;
18245
18246 -struct thread_info;
18247 +struct task_struct;
18248 struct stacktrace_ops;
18249
18250 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
18251 - unsigned long *stack,
18252 - unsigned long bp,
18253 - const struct stacktrace_ops *ops,
18254 - void *data,
18255 - unsigned long *end,
18256 - int *graph);
18257 +typedef unsigned long walk_stack_t(struct task_struct *task,
18258 + void *stack_start,
18259 + unsigned long *stack,
18260 + unsigned long bp,
18261 + const struct stacktrace_ops *ops,
18262 + void *data,
18263 + unsigned long *end,
18264 + int *graph);
18265
18266 -extern unsigned long
18267 -print_context_stack(struct thread_info *tinfo,
18268 - unsigned long *stack, unsigned long bp,
18269 - const struct stacktrace_ops *ops, void *data,
18270 - unsigned long *end, int *graph);
18271 -
18272 -extern unsigned long
18273 -print_context_stack_bp(struct thread_info *tinfo,
18274 - unsigned long *stack, unsigned long bp,
18275 - const struct stacktrace_ops *ops, void *data,
18276 - unsigned long *end, int *graph);
18277 +extern walk_stack_t print_context_stack;
18278 +extern walk_stack_t print_context_stack_bp;
18279
18280 /* Generic stack tracer with callbacks */
18281
18282 @@ -40,7 +32,7 @@ struct stacktrace_ops {
18283 void (*address)(void *data, unsigned long address, int reliable);
18284 /* On negative return stop dumping */
18285 int (*stack)(void *data, char *name);
18286 - walk_stack_t walk_stack;
18287 + walk_stack_t *walk_stack;
18288 };
18289
18290 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
18291 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
18292 index d7f3b3b..3cc39f1 100644
18293 --- a/arch/x86/include/asm/switch_to.h
18294 +++ b/arch/x86/include/asm/switch_to.h
18295 @@ -108,7 +108,7 @@ do { \
18296 "call __switch_to\n\t" \
18297 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
18298 __switch_canary \
18299 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
18300 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
18301 "movq %%rax,%%rdi\n\t" \
18302 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
18303 "jnz ret_from_fork\n\t" \
18304 @@ -119,7 +119,7 @@ do { \
18305 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
18306 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
18307 [_tif_fork] "i" (_TIF_FORK), \
18308 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
18309 + [thread_info] "m" (current_tinfo), \
18310 [current_task] "m" (current_task) \
18311 __switch_canary_iparam \
18312 : "memory", "cc" __EXTRA_CLOBBER)
18313 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
18314 index 2781119..618b59b 100644
18315 --- a/arch/x86/include/asm/thread_info.h
18316 +++ b/arch/x86/include/asm/thread_info.h
18317 @@ -10,6 +10,7 @@
18318 #include <linux/compiler.h>
18319 #include <asm/page.h>
18320 #include <asm/types.h>
18321 +#include <asm/percpu.h>
18322
18323 /*
18324 * low level task data that entry.S needs immediate access to
18325 @@ -23,7 +24,6 @@ struct exec_domain;
18326 #include <linux/atomic.h>
18327
18328 struct thread_info {
18329 - struct task_struct *task; /* main task structure */
18330 struct exec_domain *exec_domain; /* execution domain */
18331 __u32 flags; /* low level flags */
18332 __u32 status; /* thread synchronous flags */
18333 @@ -33,19 +33,13 @@ struct thread_info {
18334 mm_segment_t addr_limit;
18335 struct restart_block restart_block;
18336 void __user *sysenter_return;
18337 -#ifdef CONFIG_X86_32
18338 - unsigned long previous_esp; /* ESP of the previous stack in
18339 - case of nested (IRQ) stacks
18340 - */
18341 - __u8 supervisor_stack[0];
18342 -#endif
18343 + unsigned long lowest_stack;
18344 unsigned int sig_on_uaccess_error:1;
18345 unsigned int uaccess_err:1; /* uaccess failed */
18346 };
18347
18348 -#define INIT_THREAD_INFO(tsk) \
18349 +#define INIT_THREAD_INFO \
18350 { \
18351 - .task = &tsk, \
18352 .exec_domain = &default_exec_domain, \
18353 .flags = 0, \
18354 .cpu = 0, \
18355 @@ -56,7 +50,7 @@ struct thread_info {
18356 }, \
18357 }
18358
18359 -#define init_thread_info (init_thread_union.thread_info)
18360 +#define init_thread_info (init_thread_union.stack)
18361 #define init_stack (init_thread_union.stack)
18362
18363 #else /* !__ASSEMBLY__ */
18364 @@ -96,6 +90,7 @@ struct thread_info {
18365 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
18366 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
18367 #define TIF_X32 30 /* 32-bit native x86-64 binary */
18368 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
18369
18370 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
18371 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
18372 @@ -119,17 +114,18 @@ struct thread_info {
18373 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
18374 #define _TIF_ADDR32 (1 << TIF_ADDR32)
18375 #define _TIF_X32 (1 << TIF_X32)
18376 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
18377
18378 /* work to do in syscall_trace_enter() */
18379 #define _TIF_WORK_SYSCALL_ENTRY \
18380 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
18381 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
18382 - _TIF_NOHZ)
18383 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
18384
18385 /* work to do in syscall_trace_leave() */
18386 #define _TIF_WORK_SYSCALL_EXIT \
18387 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
18388 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
18389 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
18390
18391 /* work to do on interrupt/exception return */
18392 #define _TIF_WORK_MASK \
18393 @@ -140,7 +136,7 @@ struct thread_info {
18394 /* work to do on any return to user space */
18395 #define _TIF_ALLWORK_MASK \
18396 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
18397 - _TIF_NOHZ)
18398 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
18399
18400 /* Only used for 64 bit */
18401 #define _TIF_DO_NOTIFY_MASK \
18402 @@ -156,45 +152,40 @@ struct thread_info {
18403
18404 #define PREEMPT_ACTIVE 0x10000000
18405
18406 -#ifdef CONFIG_X86_32
18407 -
18408 -#define STACK_WARN (THREAD_SIZE/8)
18409 -/*
18410 - * macros/functions for gaining access to the thread information structure
18411 - *
18412 - * preempt_count needs to be 1 initially, until the scheduler is functional.
18413 - */
18414 -#ifndef __ASSEMBLY__
18415 -
18416 -
18417 -/* how to get the current stack pointer from C */
18418 -register unsigned long current_stack_pointer asm("esp") __used;
18419 -
18420 -/* how to get the thread information struct from C */
18421 -static inline struct thread_info *current_thread_info(void)
18422 -{
18423 - return (struct thread_info *)
18424 - (current_stack_pointer & ~(THREAD_SIZE - 1));
18425 -}
18426 -
18427 -#else /* !__ASSEMBLY__ */
18428 -
18429 +#ifdef __ASSEMBLY__
18430 /* how to get the thread information struct from ASM */
18431 #define GET_THREAD_INFO(reg) \
18432 - movl $-THREAD_SIZE, reg; \
18433 - andl %esp, reg
18434 + mov PER_CPU_VAR(current_tinfo), reg
18435
18436 /* use this one if reg already contains %esp */
18437 -#define GET_THREAD_INFO_WITH_ESP(reg) \
18438 - andl $-THREAD_SIZE, reg
18439 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
18440 +#else
18441 +/* how to get the thread information struct from C */
18442 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
18443 +
18444 +static __always_inline struct thread_info *current_thread_info(void)
18445 +{
18446 + return this_cpu_read_stable(current_tinfo);
18447 +}
18448 +#endif
18449 +
18450 +#ifdef CONFIG_X86_32
18451 +
18452 +#define STACK_WARN (THREAD_SIZE/8)
18453 +/*
18454 + * macros/functions for gaining access to the thread information structure
18455 + *
18456 + * preempt_count needs to be 1 initially, until the scheduler is functional.
18457 + */
18458 +#ifndef __ASSEMBLY__
18459 +
18460 +/* how to get the current stack pointer from C */
18461 +register unsigned long current_stack_pointer asm("esp") __used;
18462
18463 #endif
18464
18465 #else /* X86_32 */
18466
18467 -#include <asm/percpu.h>
18468 -#define KERNEL_STACK_OFFSET (5*8)
18469 -
18470 /*
18471 * macros/functions for gaining access to the thread information structure
18472 * preempt_count needs to be 1 initially, until the scheduler is functional.
18473 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
18474 #ifndef __ASSEMBLY__
18475 DECLARE_PER_CPU(unsigned long, kernel_stack);
18476
18477 -static inline struct thread_info *current_thread_info(void)
18478 -{
18479 - struct thread_info *ti;
18480 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
18481 - KERNEL_STACK_OFFSET - THREAD_SIZE);
18482 - return ti;
18483 -}
18484 -
18485 -#else /* !__ASSEMBLY__ */
18486 -
18487 -/* how to get the thread information struct from ASM */
18488 -#define GET_THREAD_INFO(reg) \
18489 - movq PER_CPU_VAR(kernel_stack),reg ; \
18490 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
18491 -
18492 -/*
18493 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
18494 - * a certain register (to be used in assembler memory operands).
18495 - */
18496 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
18497 -
18498 +/* how to get the current stack pointer from C */
18499 +register unsigned long current_stack_pointer asm("rsp") __used;
18500 #endif
18501
18502 #endif /* !X86_32 */
18503 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
18504 extern void arch_task_cache_init(void);
18505 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
18506 extern void arch_release_task_struct(struct task_struct *tsk);
18507 +
18508 +#define __HAVE_THREAD_FUNCTIONS
18509 +#define task_thread_info(task) (&(task)->tinfo)
18510 +#define task_stack_page(task) ((task)->stack)
18511 +#define setup_thread_stack(p, org) do {} while (0)
18512 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
18513 +
18514 #endif
18515 #endif /* _ASM_X86_THREAD_INFO_H */
18516 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
18517 index e6d90ba..0897f44 100644
18518 --- a/arch/x86/include/asm/tlbflush.h
18519 +++ b/arch/x86/include/asm/tlbflush.h
18520 @@ -17,18 +17,44 @@
18521
18522 static inline void __native_flush_tlb(void)
18523 {
18524 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
18525 + u64 descriptor[2];
18526 +
18527 + descriptor[0] = PCID_KERNEL;
18528 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
18529 + return;
18530 + }
18531 +
18532 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18533 + if (static_cpu_has(X86_FEATURE_PCID)) {
18534 + unsigned int cpu = raw_get_cpu();
18535 +
18536 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
18537 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
18538 + raw_put_cpu_no_resched();
18539 + return;
18540 + }
18541 +#endif
18542 +
18543 native_write_cr3(native_read_cr3());
18544 }
18545
18546 static inline void __native_flush_tlb_global_irq_disabled(void)
18547 {
18548 - unsigned long cr4;
18549 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
18550 + u64 descriptor[2];
18551
18552 - cr4 = native_read_cr4();
18553 - /* clear PGE */
18554 - native_write_cr4(cr4 & ~X86_CR4_PGE);
18555 - /* write old PGE again and flush TLBs */
18556 - native_write_cr4(cr4);
18557 + descriptor[0] = PCID_KERNEL;
18558 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
18559 + } else {
18560 + unsigned long cr4;
18561 +
18562 + cr4 = native_read_cr4();
18563 + /* clear PGE */
18564 + native_write_cr4(cr4 & ~X86_CR4_PGE);
18565 + /* write old PGE again and flush TLBs */
18566 + native_write_cr4(cr4);
18567 + }
18568 }
18569
18570 static inline void __native_flush_tlb_global(void)
18571 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
18572
18573 static inline void __native_flush_tlb_single(unsigned long addr)
18574 {
18575 +
18576 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
18577 + u64 descriptor[2];
18578 +
18579 + descriptor[0] = PCID_KERNEL;
18580 + descriptor[1] = addr;
18581 +
18582 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18583 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
18584 + if (addr < TASK_SIZE_MAX)
18585 + descriptor[1] += pax_user_shadow_base;
18586 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
18587 + }
18588 +
18589 + descriptor[0] = PCID_USER;
18590 + descriptor[1] = addr;
18591 +#endif
18592 +
18593 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
18594 + return;
18595 + }
18596 +
18597 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18598 + if (static_cpu_has(X86_FEATURE_PCID)) {
18599 + unsigned int cpu = raw_get_cpu();
18600 +
18601 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
18602 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
18603 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
18604 + raw_put_cpu_no_resched();
18605 +
18606 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
18607 + addr += pax_user_shadow_base;
18608 + }
18609 +#endif
18610 +
18611 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
18612 }
18613
18614 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
18615 index 5838fa9..f7ae572 100644
18616 --- a/arch/x86/include/asm/uaccess.h
18617 +++ b/arch/x86/include/asm/uaccess.h
18618 @@ -7,6 +7,7 @@
18619 #include <linux/compiler.h>
18620 #include <linux/thread_info.h>
18621 #include <linux/string.h>
18622 +#include <linux/sched.h>
18623 #include <asm/asm.h>
18624 #include <asm/page.h>
18625 #include <asm/smap.h>
18626 @@ -29,7 +30,12 @@
18627
18628 #define get_ds() (KERNEL_DS)
18629 #define get_fs() (current_thread_info()->addr_limit)
18630 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
18631 +void __set_fs(mm_segment_t x);
18632 +void set_fs(mm_segment_t x);
18633 +#else
18634 #define set_fs(x) (current_thread_info()->addr_limit = (x))
18635 +#endif
18636
18637 #define segment_eq(a, b) ((a).seg == (b).seg)
18638
18639 @@ -77,8 +83,33 @@
18640 * checks that the pointer is in the user space range - after calling
18641 * this function, memory access functions may still return -EFAULT.
18642 */
18643 -#define access_ok(type, addr, size) \
18644 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
18645 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
18646 +#define access_ok(type, addr, size) \
18647 +({ \
18648 + long __size = size; \
18649 + unsigned long __addr = (unsigned long)addr; \
18650 + unsigned long __addr_ao = __addr & PAGE_MASK; \
18651 + unsigned long __end_ao = __addr + __size - 1; \
18652 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
18653 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
18654 + while(__addr_ao <= __end_ao) { \
18655 + char __c_ao; \
18656 + __addr_ao += PAGE_SIZE; \
18657 + if (__size > PAGE_SIZE) \
18658 + cond_resched(); \
18659 + if (__get_user(__c_ao, (char __user *)__addr)) \
18660 + break; \
18661 + if (type != VERIFY_WRITE) { \
18662 + __addr = __addr_ao; \
18663 + continue; \
18664 + } \
18665 + if (__put_user(__c_ao, (char __user *)__addr)) \
18666 + break; \
18667 + __addr = __addr_ao; \
18668 + } \
18669 + } \
18670 + __ret_ao; \
18671 +})
18672
18673 /*
18674 * The exception table consists of pairs of addresses relative to the
18675 @@ -168,10 +199,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18676 register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX); \
18677 __chk_user_ptr(ptr); \
18678 might_fault(); \
18679 + pax_open_userland(); \
18680 asm volatile("call __get_user_%P3" \
18681 : "=a" (__ret_gu), "=r" (__val_gu) \
18682 : "0" (ptr), "i" (sizeof(*(ptr)))); \
18683 (x) = (__typeof__(*(ptr))) __val_gu; \
18684 + pax_close_userland(); \
18685 __ret_gu; \
18686 })
18687
18688 @@ -179,13 +212,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18689 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
18690 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
18691
18692 -
18693 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
18694 +#define __copyuser_seg "gs;"
18695 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
18696 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
18697 +#else
18698 +#define __copyuser_seg
18699 +#define __COPYUSER_SET_ES
18700 +#define __COPYUSER_RESTORE_ES
18701 +#endif
18702
18703 #ifdef CONFIG_X86_32
18704 #define __put_user_asm_u64(x, addr, err, errret) \
18705 asm volatile(ASM_STAC "\n" \
18706 - "1: movl %%eax,0(%2)\n" \
18707 - "2: movl %%edx,4(%2)\n" \
18708 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
18709 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
18710 "3: " ASM_CLAC "\n" \
18711 ".section .fixup,\"ax\"\n" \
18712 "4: movl %3,%0\n" \
18713 @@ -198,8 +239,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18714
18715 #define __put_user_asm_ex_u64(x, addr) \
18716 asm volatile(ASM_STAC "\n" \
18717 - "1: movl %%eax,0(%1)\n" \
18718 - "2: movl %%edx,4(%1)\n" \
18719 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
18720 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18721 "3: " ASM_CLAC "\n" \
18722 _ASM_EXTABLE_EX(1b, 2b) \
18723 _ASM_EXTABLE_EX(2b, 3b) \
18724 @@ -249,7 +290,8 @@ extern void __put_user_8(void);
18725 __typeof__(*(ptr)) __pu_val; \
18726 __chk_user_ptr(ptr); \
18727 might_fault(); \
18728 - __pu_val = x; \
18729 + __pu_val = (x); \
18730 + pax_open_userland(); \
18731 switch (sizeof(*(ptr))) { \
18732 case 1: \
18733 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18734 @@ -267,6 +309,7 @@ extern void __put_user_8(void);
18735 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18736 break; \
18737 } \
18738 + pax_close_userland(); \
18739 __ret_pu; \
18740 })
18741
18742 @@ -347,8 +390,10 @@ do { \
18743 } while (0)
18744
18745 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18746 +do { \
18747 + pax_open_userland(); \
18748 asm volatile(ASM_STAC "\n" \
18749 - "1: mov"itype" %2,%"rtype"1\n" \
18750 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18751 "2: " ASM_CLAC "\n" \
18752 ".section .fixup,\"ax\"\n" \
18753 "3: mov %3,%0\n" \
18754 @@ -356,8 +401,10 @@ do { \
18755 " jmp 2b\n" \
18756 ".previous\n" \
18757 _ASM_EXTABLE(1b, 3b) \
18758 - : "=r" (err), ltype(x) \
18759 - : "m" (__m(addr)), "i" (errret), "0" (err))
18760 + : "=r" (err), ltype (x) \
18761 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18762 + pax_close_userland(); \
18763 +} while (0)
18764
18765 #define __get_user_size_ex(x, ptr, size) \
18766 do { \
18767 @@ -381,7 +428,7 @@ do { \
18768 } while (0)
18769
18770 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18771 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18772 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18773 "2:\n" \
18774 _ASM_EXTABLE_EX(1b, 2b) \
18775 : ltype(x) : "m" (__m(addr)))
18776 @@ -398,13 +445,24 @@ do { \
18777 int __gu_err; \
18778 unsigned long __gu_val; \
18779 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18780 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18781 + (x) = (__typeof__(*(ptr)))__gu_val; \
18782 __gu_err; \
18783 })
18784
18785 /* FIXME: this hack is definitely wrong -AK */
18786 struct __large_struct { unsigned long buf[100]; };
18787 -#define __m(x) (*(struct __large_struct __user *)(x))
18788 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18789 +#define ____m(x) \
18790 +({ \
18791 + unsigned long ____x = (unsigned long)(x); \
18792 + if (____x < pax_user_shadow_base) \
18793 + ____x += pax_user_shadow_base; \
18794 + (typeof(x))____x; \
18795 +})
18796 +#else
18797 +#define ____m(x) (x)
18798 +#endif
18799 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18800
18801 /*
18802 * Tell gcc we read from memory instead of writing: this is because
18803 @@ -412,8 +470,10 @@ struct __large_struct { unsigned long buf[100]; };
18804 * aliasing issues.
18805 */
18806 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18807 +do { \
18808 + pax_open_userland(); \
18809 asm volatile(ASM_STAC "\n" \
18810 - "1: mov"itype" %"rtype"1,%2\n" \
18811 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18812 "2: " ASM_CLAC "\n" \
18813 ".section .fixup,\"ax\"\n" \
18814 "3: mov %3,%0\n" \
18815 @@ -421,10 +481,12 @@ struct __large_struct { unsigned long buf[100]; };
18816 ".previous\n" \
18817 _ASM_EXTABLE(1b, 3b) \
18818 : "=r"(err) \
18819 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18820 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18821 + pax_close_userland(); \
18822 +} while (0)
18823
18824 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18825 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18826 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18827 "2:\n" \
18828 _ASM_EXTABLE_EX(1b, 2b) \
18829 : : ltype(x), "m" (__m(addr)))
18830 @@ -434,11 +496,13 @@ struct __large_struct { unsigned long buf[100]; };
18831 */
18832 #define uaccess_try do { \
18833 current_thread_info()->uaccess_err = 0; \
18834 + pax_open_userland(); \
18835 stac(); \
18836 barrier();
18837
18838 #define uaccess_catch(err) \
18839 clac(); \
18840 + pax_close_userland(); \
18841 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18842 } while (0)
18843
18844 @@ -463,8 +527,12 @@ struct __large_struct { unsigned long buf[100]; };
18845 * On error, the variable @x is set to zero.
18846 */
18847
18848 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18849 +#define __get_user(x, ptr) get_user((x), (ptr))
18850 +#else
18851 #define __get_user(x, ptr) \
18852 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18853 +#endif
18854
18855 /**
18856 * __put_user: - Write a simple value into user space, with less checking.
18857 @@ -486,8 +554,12 @@ struct __large_struct { unsigned long buf[100]; };
18858 * Returns zero on success, or -EFAULT on error.
18859 */
18860
18861 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18862 +#define __put_user(x, ptr) put_user((x), (ptr))
18863 +#else
18864 #define __put_user(x, ptr) \
18865 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18866 +#endif
18867
18868 #define __get_user_unaligned __get_user
18869 #define __put_user_unaligned __put_user
18870 @@ -505,7 +577,7 @@ struct __large_struct { unsigned long buf[100]; };
18871 #define get_user_ex(x, ptr) do { \
18872 unsigned long __gue_val; \
18873 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18874 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18875 + (x) = (__typeof__(*(ptr)))__gue_val; \
18876 } while (0)
18877
18878 #define put_user_try uaccess_try
18879 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18880 index 7f760a9..b596b9a 100644
18881 --- a/arch/x86/include/asm/uaccess_32.h
18882 +++ b/arch/x86/include/asm/uaccess_32.h
18883 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18884 static __always_inline unsigned long __must_check
18885 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18886 {
18887 + if ((long)n < 0)
18888 + return n;
18889 +
18890 + check_object_size(from, n, true);
18891 +
18892 if (__builtin_constant_p(n)) {
18893 unsigned long ret;
18894
18895 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18896 __copy_to_user(void __user *to, const void *from, unsigned long n)
18897 {
18898 might_fault();
18899 +
18900 return __copy_to_user_inatomic(to, from, n);
18901 }
18902
18903 static __always_inline unsigned long
18904 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18905 {
18906 + if ((long)n < 0)
18907 + return n;
18908 +
18909 /* Avoid zeroing the tail if the copy fails..
18910 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18911 * but as the zeroing behaviour is only significant when n is not
18912 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18913 __copy_from_user(void *to, const void __user *from, unsigned long n)
18914 {
18915 might_fault();
18916 +
18917 + if ((long)n < 0)
18918 + return n;
18919 +
18920 + check_object_size(to, n, false);
18921 +
18922 if (__builtin_constant_p(n)) {
18923 unsigned long ret;
18924
18925 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18926 const void __user *from, unsigned long n)
18927 {
18928 might_fault();
18929 +
18930 + if ((long)n < 0)
18931 + return n;
18932 +
18933 if (__builtin_constant_p(n)) {
18934 unsigned long ret;
18935
18936 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18937 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18938 unsigned long n)
18939 {
18940 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18941 + if ((long)n < 0)
18942 + return n;
18943 +
18944 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18945 }
18946
18947 -unsigned long __must_check copy_to_user(void __user *to,
18948 - const void *from, unsigned long n);
18949 -unsigned long __must_check _copy_from_user(void *to,
18950 - const void __user *from,
18951 - unsigned long n);
18952 -
18953 +extern void copy_to_user_overflow(void)
18954 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18955 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18956 +#else
18957 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18958 +#endif
18959 +;
18960
18961 extern void copy_from_user_overflow(void)
18962 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18963 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18964 #endif
18965 ;
18966
18967 -static inline unsigned long __must_check copy_from_user(void *to,
18968 - const void __user *from,
18969 - unsigned long n)
18970 +/**
18971 + * copy_to_user: - Copy a block of data into user space.
18972 + * @to: Destination address, in user space.
18973 + * @from: Source address, in kernel space.
18974 + * @n: Number of bytes to copy.
18975 + *
18976 + * Context: User context only. This function may sleep.
18977 + *
18978 + * Copy data from kernel space to user space.
18979 + *
18980 + * Returns number of bytes that could not be copied.
18981 + * On success, this will be zero.
18982 + */
18983 +static inline unsigned long __must_check
18984 +copy_to_user(void __user *to, const void *from, unsigned long n)
18985 {
18986 - int sz = __compiletime_object_size(to);
18987 + size_t sz = __compiletime_object_size(from);
18988
18989 - if (likely(sz == -1 || sz >= n))
18990 - n = _copy_from_user(to, from, n);
18991 - else
18992 + if (unlikely(sz != (size_t)-1 && sz < n))
18993 + copy_to_user_overflow();
18994 + else if (access_ok(VERIFY_WRITE, to, n))
18995 + n = __copy_to_user(to, from, n);
18996 + return n;
18997 +}
18998 +
18999 +/**
19000 + * copy_from_user: - Copy a block of data from user space.
19001 + * @to: Destination address, in kernel space.
19002 + * @from: Source address, in user space.
19003 + * @n: Number of bytes to copy.
19004 + *
19005 + * Context: User context only. This function may sleep.
19006 + *
19007 + * Copy data from user space to kernel space.
19008 + *
19009 + * Returns number of bytes that could not be copied.
19010 + * On success, this will be zero.
19011 + *
19012 + * If some data could not be copied, this function will pad the copied
19013 + * data to the requested size using zero bytes.
19014 + */
19015 +static inline unsigned long __must_check
19016 +copy_from_user(void *to, const void __user *from, unsigned long n)
19017 +{
19018 + size_t sz = __compiletime_object_size(to);
19019 +
19020 + check_object_size(to, n, false);
19021 +
19022 + if (unlikely(sz != (size_t)-1 && sz < n))
19023 copy_from_user_overflow();
19024 -
19025 + else if (access_ok(VERIFY_READ, from, n))
19026 + n = __copy_from_user(to, from, n);
19027 + else if ((long)n > 0)
19028 + memset(to, 0, n);
19029 return n;
19030 }
19031
19032 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
19033 index 4f7923d..201b58d 100644
19034 --- a/arch/x86/include/asm/uaccess_64.h
19035 +++ b/arch/x86/include/asm/uaccess_64.h
19036 @@ -10,6 +10,9 @@
19037 #include <asm/alternative.h>
19038 #include <asm/cpufeature.h>
19039 #include <asm/page.h>
19040 +#include <asm/pgtable.h>
19041 +
19042 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
19043
19044 /*
19045 * Copy To/From Userspace
19046 @@ -17,14 +20,14 @@
19047
19048 /* Handles exceptions in both to and from, but doesn't do access_ok */
19049 __must_check unsigned long
19050 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
19051 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
19052 __must_check unsigned long
19053 -copy_user_generic_string(void *to, const void *from, unsigned len);
19054 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
19055 __must_check unsigned long
19056 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
19057 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
19058
19059 -static __always_inline __must_check unsigned long
19060 -copy_user_generic(void *to, const void *from, unsigned len)
19061 +static __always_inline __must_check unsigned long
19062 +copy_user_generic(void *to, const void *from, unsigned long len)
19063 {
19064 unsigned ret;
19065
19066 @@ -45,138 +48,200 @@ copy_user_generic(void *to, const void *from, unsigned len)
19067 return ret;
19068 }
19069
19070 +static __always_inline __must_check unsigned long
19071 +__copy_to_user(void __user *to, const void *from, unsigned long len);
19072 +static __always_inline __must_check unsigned long
19073 +__copy_from_user(void *to, const void __user *from, unsigned long len);
19074 __must_check unsigned long
19075 -_copy_to_user(void __user *to, const void *from, unsigned len);
19076 -__must_check unsigned long
19077 -_copy_from_user(void *to, const void __user *from, unsigned len);
19078 -__must_check unsigned long
19079 -copy_in_user(void __user *to, const void __user *from, unsigned len);
19080 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
19081 +
19082 +extern void copy_to_user_overflow(void)
19083 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
19084 + __compiletime_error("copy_to_user() buffer size is not provably correct")
19085 +#else
19086 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
19087 +#endif
19088 +;
19089 +
19090 +extern void copy_from_user_overflow(void)
19091 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
19092 + __compiletime_error("copy_from_user() buffer size is not provably correct")
19093 +#else
19094 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
19095 +#endif
19096 +;
19097
19098 static inline unsigned long __must_check copy_from_user(void *to,
19099 const void __user *from,
19100 unsigned long n)
19101 {
19102 - int sz = __compiletime_object_size(to);
19103 -
19104 might_fault();
19105 - if (likely(sz == -1 || sz >= n))
19106 - n = _copy_from_user(to, from, n);
19107 -#ifdef CONFIG_DEBUG_VM
19108 - else
19109 - WARN(1, "Buffer overflow detected!\n");
19110 -#endif
19111 +
19112 + check_object_size(to, n, false);
19113 +
19114 + if (access_ok(VERIFY_READ, from, n))
19115 + n = __copy_from_user(to, from, n);
19116 + else if (n < INT_MAX)
19117 + memset(to, 0, n);
19118 return n;
19119 }
19120
19121 static __always_inline __must_check
19122 -int copy_to_user(void __user *dst, const void *src, unsigned size)
19123 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
19124 {
19125 might_fault();
19126
19127 - return _copy_to_user(dst, src, size);
19128 + if (access_ok(VERIFY_WRITE, dst, size))
19129 + size = __copy_to_user(dst, src, size);
19130 + return size;
19131 }
19132
19133 static __always_inline __must_check
19134 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
19135 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
19136 {
19137 - int ret = 0;
19138 + size_t sz = __compiletime_object_size(dst);
19139 + unsigned ret = 0;
19140
19141 might_fault();
19142 +
19143 + if (size > INT_MAX)
19144 + return size;
19145 +
19146 + check_object_size(dst, size, false);
19147 +
19148 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19149 + if (!__access_ok(VERIFY_READ, src, size))
19150 + return size;
19151 +#endif
19152 +
19153 + if (unlikely(sz != (size_t)-1 && sz < size)) {
19154 + copy_from_user_overflow();
19155 + return size;
19156 + }
19157 +
19158 if (!__builtin_constant_p(size))
19159 - return copy_user_generic(dst, (__force void *)src, size);
19160 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
19161 switch (size) {
19162 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
19163 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
19164 ret, "b", "b", "=q", 1);
19165 return ret;
19166 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
19167 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
19168 ret, "w", "w", "=r", 2);
19169 return ret;
19170 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
19171 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
19172 ret, "l", "k", "=r", 4);
19173 return ret;
19174 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
19175 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
19176 ret, "q", "", "=r", 8);
19177 return ret;
19178 case 10:
19179 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
19180 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
19181 ret, "q", "", "=r", 10);
19182 if (unlikely(ret))
19183 return ret;
19184 __get_user_asm(*(u16 *)(8 + (char *)dst),
19185 - (u16 __user *)(8 + (char __user *)src),
19186 + (const u16 __user *)(8 + (const char __user *)src),
19187 ret, "w", "w", "=r", 2);
19188 return ret;
19189 case 16:
19190 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
19191 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
19192 ret, "q", "", "=r", 16);
19193 if (unlikely(ret))
19194 return ret;
19195 __get_user_asm(*(u64 *)(8 + (char *)dst),
19196 - (u64 __user *)(8 + (char __user *)src),
19197 + (const u64 __user *)(8 + (const char __user *)src),
19198 ret, "q", "", "=r", 8);
19199 return ret;
19200 default:
19201 - return copy_user_generic(dst, (__force void *)src, size);
19202 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
19203 }
19204 }
19205
19206 static __always_inline __must_check
19207 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
19208 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
19209 {
19210 - int ret = 0;
19211 + size_t sz = __compiletime_object_size(src);
19212 + unsigned ret = 0;
19213
19214 might_fault();
19215 +
19216 + if (size > INT_MAX)
19217 + return size;
19218 +
19219 + check_object_size(src, size, true);
19220 +
19221 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19222 + if (!__access_ok(VERIFY_WRITE, dst, size))
19223 + return size;
19224 +#endif
19225 +
19226 + if (unlikely(sz != (size_t)-1 && sz < size)) {
19227 + copy_to_user_overflow();
19228 + return size;
19229 + }
19230 +
19231 if (!__builtin_constant_p(size))
19232 - return copy_user_generic((__force void *)dst, src, size);
19233 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
19234 switch (size) {
19235 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
19236 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
19237 ret, "b", "b", "iq", 1);
19238 return ret;
19239 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
19240 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
19241 ret, "w", "w", "ir", 2);
19242 return ret;
19243 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
19244 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
19245 ret, "l", "k", "ir", 4);
19246 return ret;
19247 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
19248 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
19249 ret, "q", "", "er", 8);
19250 return ret;
19251 case 10:
19252 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
19253 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
19254 ret, "q", "", "er", 10);
19255 if (unlikely(ret))
19256 return ret;
19257 asm("":::"memory");
19258 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
19259 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
19260 ret, "w", "w", "ir", 2);
19261 return ret;
19262 case 16:
19263 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
19264 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
19265 ret, "q", "", "er", 16);
19266 if (unlikely(ret))
19267 return ret;
19268 asm("":::"memory");
19269 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
19270 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
19271 ret, "q", "", "er", 8);
19272 return ret;
19273 default:
19274 - return copy_user_generic((__force void *)dst, src, size);
19275 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
19276 }
19277 }
19278
19279 static __always_inline __must_check
19280 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19281 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
19282 {
19283 - int ret = 0;
19284 + unsigned ret = 0;
19285
19286 might_fault();
19287 +
19288 + if (size > INT_MAX)
19289 + return size;
19290 +
19291 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19292 + if (!__access_ok(VERIFY_READ, src, size))
19293 + return size;
19294 + if (!__access_ok(VERIFY_WRITE, dst, size))
19295 + return size;
19296 +#endif
19297 +
19298 if (!__builtin_constant_p(size))
19299 - return copy_user_generic((__force void *)dst,
19300 - (__force void *)src, size);
19301 + return copy_user_generic((__force_kernel void *)____m(dst),
19302 + (__force_kernel const void *)____m(src), size);
19303 switch (size) {
19304 case 1: {
19305 u8 tmp;
19306 - __get_user_asm(tmp, (u8 __user *)src,
19307 + __get_user_asm(tmp, (const u8 __user *)src,
19308 ret, "b", "b", "=q", 1);
19309 if (likely(!ret))
19310 __put_user_asm(tmp, (u8 __user *)dst,
19311 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19312 }
19313 case 2: {
19314 u16 tmp;
19315 - __get_user_asm(tmp, (u16 __user *)src,
19316 + __get_user_asm(tmp, (const u16 __user *)src,
19317 ret, "w", "w", "=r", 2);
19318 if (likely(!ret))
19319 __put_user_asm(tmp, (u16 __user *)dst,
19320 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19321
19322 case 4: {
19323 u32 tmp;
19324 - __get_user_asm(tmp, (u32 __user *)src,
19325 + __get_user_asm(tmp, (const u32 __user *)src,
19326 ret, "l", "k", "=r", 4);
19327 if (likely(!ret))
19328 __put_user_asm(tmp, (u32 __user *)dst,
19329 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19330 }
19331 case 8: {
19332 u64 tmp;
19333 - __get_user_asm(tmp, (u64 __user *)src,
19334 + __get_user_asm(tmp, (const u64 __user *)src,
19335 ret, "q", "", "=r", 8);
19336 if (likely(!ret))
19337 __put_user_asm(tmp, (u64 __user *)dst,
19338 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19339 return ret;
19340 }
19341 default:
19342 - return copy_user_generic((__force void *)dst,
19343 - (__force void *)src, size);
19344 + return copy_user_generic((__force_kernel void *)____m(dst),
19345 + (__force_kernel const void *)____m(src), size);
19346 }
19347 }
19348
19349 -static __must_check __always_inline int
19350 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
19351 +static __must_check __always_inline unsigned long
19352 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
19353 {
19354 - return copy_user_generic(dst, (__force const void *)src, size);
19355 + if (size > INT_MAX)
19356 + return size;
19357 +
19358 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19359 + if (!__access_ok(VERIFY_READ, src, size))
19360 + return size;
19361 +#endif
19362 +
19363 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
19364 }
19365
19366 -static __must_check __always_inline int
19367 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
19368 +static __must_check __always_inline unsigned long
19369 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
19370 {
19371 - return copy_user_generic((__force void *)dst, src, size);
19372 + if (size > INT_MAX)
19373 + return size;
19374 +
19375 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19376 + if (!__access_ok(VERIFY_WRITE, dst, size))
19377 + return size;
19378 +#endif
19379 +
19380 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
19381 }
19382
19383 -extern long __copy_user_nocache(void *dst, const void __user *src,
19384 - unsigned size, int zerorest);
19385 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
19386 + unsigned long size, int zerorest);
19387
19388 -static inline int
19389 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
19390 +static inline unsigned long
19391 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
19392 {
19393 might_fault();
19394 +
19395 + if (size > INT_MAX)
19396 + return size;
19397 +
19398 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19399 + if (!__access_ok(VERIFY_READ, src, size))
19400 + return size;
19401 +#endif
19402 +
19403 return __copy_user_nocache(dst, src, size, 1);
19404 }
19405
19406 -static inline int
19407 +static inline unsigned long
19408 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
19409 - unsigned size)
19410 + unsigned long size)
19411 {
19412 + if (size > INT_MAX)
19413 + return size;
19414 +
19415 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19416 + if (!__access_ok(VERIFY_READ, src, size))
19417 + return size;
19418 +#endif
19419 +
19420 return __copy_user_nocache(dst, src, size, 0);
19421 }
19422
19423 unsigned long
19424 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
19425 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
19426
19427 #endif /* _ASM_X86_UACCESS_64_H */
19428 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
19429 index 5b238981..77fdd78 100644
19430 --- a/arch/x86/include/asm/word-at-a-time.h
19431 +++ b/arch/x86/include/asm/word-at-a-time.h
19432 @@ -11,7 +11,7 @@
19433 * and shift, for example.
19434 */
19435 struct word_at_a_time {
19436 - const unsigned long one_bits, high_bits;
19437 + unsigned long one_bits, high_bits;
19438 };
19439
19440 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
19441 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
19442 index 828a156..650e625 100644
19443 --- a/arch/x86/include/asm/x86_init.h
19444 +++ b/arch/x86/include/asm/x86_init.h
19445 @@ -129,7 +129,7 @@ struct x86_init_ops {
19446 struct x86_init_timers timers;
19447 struct x86_init_iommu iommu;
19448 struct x86_init_pci pci;
19449 -};
19450 +} __no_const;
19451
19452 /**
19453 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
19454 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
19455 void (*setup_percpu_clockev)(void);
19456 void (*early_percpu_clock_init)(void);
19457 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
19458 -};
19459 +} __no_const;
19460
19461 struct timespec;
19462
19463 @@ -168,7 +168,7 @@ struct x86_platform_ops {
19464 void (*save_sched_clock_state)(void);
19465 void (*restore_sched_clock_state)(void);
19466 void (*apic_post_init)(void);
19467 -};
19468 +} __no_const;
19469
19470 struct pci_dev;
19471 struct msi_msg;
19472 @@ -182,7 +182,7 @@ struct x86_msi_ops {
19473 void (*teardown_msi_irqs)(struct pci_dev *dev);
19474 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
19475 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
19476 -};
19477 +} __no_const;
19478
19479 struct IO_APIC_route_entry;
19480 struct io_apic_irq_attr;
19481 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
19482 unsigned int destination, int vector,
19483 struct io_apic_irq_attr *attr);
19484 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
19485 -};
19486 +} __no_const;
19487
19488 extern struct x86_init_ops x86_init;
19489 extern struct x86_cpuinit_ops x86_cpuinit;
19490 diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
19491 index b913915..4f5a581 100644
19492 --- a/arch/x86/include/asm/xen/page.h
19493 +++ b/arch/x86/include/asm/xen/page.h
19494 @@ -56,7 +56,7 @@ extern int m2p_remove_override(struct page *page,
19495 extern struct page *m2p_find_override(unsigned long mfn);
19496 extern unsigned long m2p_find_override_pfn(unsigned long mfn, unsigned long pfn);
19497
19498 -static inline unsigned long pfn_to_mfn(unsigned long pfn)
19499 +static inline unsigned long __intentional_overflow(-1) pfn_to_mfn(unsigned long pfn)
19500 {
19501 unsigned long mfn;
19502
19503 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
19504 index 0415cda..3b22adc 100644
19505 --- a/arch/x86/include/asm/xsave.h
19506 +++ b/arch/x86/include/asm/xsave.h
19507 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
19508 if (unlikely(err))
19509 return -EFAULT;
19510
19511 + pax_open_userland();
19512 __asm__ __volatile__(ASM_STAC "\n"
19513 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
19514 + "1:"
19515 + __copyuser_seg
19516 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
19517 "2: " ASM_CLAC "\n"
19518 ".section .fixup,\"ax\"\n"
19519 "3: movl $-1,%[err]\n"
19520 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
19521 : [err] "=r" (err)
19522 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
19523 : "memory");
19524 + pax_close_userland();
19525 return err;
19526 }
19527
19528 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
19529 {
19530 int err;
19531 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
19532 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
19533 u32 lmask = mask;
19534 u32 hmask = mask >> 32;
19535
19536 + pax_open_userland();
19537 __asm__ __volatile__(ASM_STAC "\n"
19538 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
19539 + "1:"
19540 + __copyuser_seg
19541 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
19542 "2: " ASM_CLAC "\n"
19543 ".section .fixup,\"ax\"\n"
19544 "3: movl $-1,%[err]\n"
19545 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
19546 : [err] "=r" (err)
19547 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
19548 : "memory"); /* memory required? */
19549 + pax_close_userland();
19550 return err;
19551 }
19552
19553 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
19554 index bbae024..e1528f9 100644
19555 --- a/arch/x86/include/uapi/asm/e820.h
19556 +++ b/arch/x86/include/uapi/asm/e820.h
19557 @@ -63,7 +63,7 @@ struct e820map {
19558 #define ISA_START_ADDRESS 0xa0000
19559 #define ISA_END_ADDRESS 0x100000
19560
19561 -#define BIOS_BEGIN 0x000a0000
19562 +#define BIOS_BEGIN 0x000c0000
19563 #define BIOS_END 0x00100000
19564
19565 #define BIOS_ROM_BASE 0xffe00000
19566 diff --git a/arch/x86/include/uapi/asm/ptrace-abi.h b/arch/x86/include/uapi/asm/ptrace-abi.h
19567 index 7b0a55a..ad115bf 100644
19568 --- a/arch/x86/include/uapi/asm/ptrace-abi.h
19569 +++ b/arch/x86/include/uapi/asm/ptrace-abi.h
19570 @@ -49,7 +49,6 @@
19571 #define EFLAGS 144
19572 #define RSP 152
19573 #define SS 160
19574 -#define ARGOFFSET R11
19575 #endif /* __ASSEMBLY__ */
19576
19577 /* top of stack page */
19578 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
19579 index a5408b9..5133813 100644
19580 --- a/arch/x86/kernel/Makefile
19581 +++ b/arch/x86/kernel/Makefile
19582 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
19583 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
19584 obj-$(CONFIG_IRQ_WORK) += irq_work.o
19585 obj-y += probe_roms.o
19586 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
19587 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
19588 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
19589 obj-y += syscall_$(BITS).o
19590 obj-$(CONFIG_X86_64) += vsyscall_64.o
19591 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
19592 index 40c7660..f709f4b 100644
19593 --- a/arch/x86/kernel/acpi/boot.c
19594 +++ b/arch/x86/kernel/acpi/boot.c
19595 @@ -1365,7 +1365,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
19596 * If your system is blacklisted here, but you find that acpi=force
19597 * works for you, please contact linux-acpi@vger.kernel.org
19598 */
19599 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
19600 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
19601 /*
19602 * Boxes that need ACPI disabled
19603 */
19604 @@ -1440,7 +1440,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
19605 };
19606
19607 /* second table for DMI checks that should run after early-quirks */
19608 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
19609 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
19610 /*
19611 * HP laptops which use a DSDT reporting as HP/SB400/10000,
19612 * which includes some code which overrides all temperature
19613 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
19614 index 3312010..a65ca7b 100644
19615 --- a/arch/x86/kernel/acpi/sleep.c
19616 +++ b/arch/x86/kernel/acpi/sleep.c
19617 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
19618 #else /* CONFIG_64BIT */
19619 #ifdef CONFIG_SMP
19620 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
19621 +
19622 + pax_open_kernel();
19623 early_gdt_descr.address =
19624 (unsigned long)get_cpu_gdt_table(smp_processor_id());
19625 + pax_close_kernel();
19626 +
19627 initial_gs = per_cpu_offset(smp_processor_id());
19628 #endif
19629 initial_code = (unsigned long)wakeup_long64;
19630 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
19631 index d1daa66..59fecba 100644
19632 --- a/arch/x86/kernel/acpi/wakeup_32.S
19633 +++ b/arch/x86/kernel/acpi/wakeup_32.S
19634 @@ -29,13 +29,11 @@ wakeup_pmode_return:
19635 # and restore the stack ... but you need gdt for this to work
19636 movl saved_context_esp, %esp
19637
19638 - movl %cs:saved_magic, %eax
19639 - cmpl $0x12345678, %eax
19640 + cmpl $0x12345678, saved_magic
19641 jne bogus_magic
19642
19643 # jump to place where we left off
19644 - movl saved_eip, %eax
19645 - jmp *%eax
19646 + jmp *(saved_eip)
19647
19648 bogus_magic:
19649 jmp bogus_magic
19650 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
19651 index 15e8563..323cbe1 100644
19652 --- a/arch/x86/kernel/alternative.c
19653 +++ b/arch/x86/kernel/alternative.c
19654 @@ -269,6 +269,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
19655 */
19656 for (a = start; a < end; a++) {
19657 instr = (u8 *)&a->instr_offset + a->instr_offset;
19658 +
19659 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19660 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19661 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
19662 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19663 +#endif
19664 +
19665 replacement = (u8 *)&a->repl_offset + a->repl_offset;
19666 BUG_ON(a->replacementlen > a->instrlen);
19667 BUG_ON(a->instrlen > sizeof(insnbuf));
19668 @@ -300,10 +307,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
19669 for (poff = start; poff < end; poff++) {
19670 u8 *ptr = (u8 *)poff + *poff;
19671
19672 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19673 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19674 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
19675 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19676 +#endif
19677 +
19678 if (!*poff || ptr < text || ptr >= text_end)
19679 continue;
19680 /* turn DS segment override prefix into lock prefix */
19681 - if (*ptr == 0x3e)
19682 + if (*ktla_ktva(ptr) == 0x3e)
19683 text_poke(ptr, ((unsigned char []){0xf0}), 1);
19684 }
19685 mutex_unlock(&text_mutex);
19686 @@ -318,10 +331,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
19687 for (poff = start; poff < end; poff++) {
19688 u8 *ptr = (u8 *)poff + *poff;
19689
19690 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19691 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19692 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
19693 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19694 +#endif
19695 +
19696 if (!*poff || ptr < text || ptr >= text_end)
19697 continue;
19698 /* turn lock prefix into DS segment override prefix */
19699 - if (*ptr == 0xf0)
19700 + if (*ktla_ktva(ptr) == 0xf0)
19701 text_poke(ptr, ((unsigned char []){0x3E}), 1);
19702 }
19703 mutex_unlock(&text_mutex);
19704 @@ -469,7 +488,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
19705
19706 BUG_ON(p->len > MAX_PATCH_LEN);
19707 /* prep the buffer with the original instructions */
19708 - memcpy(insnbuf, p->instr, p->len);
19709 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
19710 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
19711 (unsigned long)p->instr, p->len);
19712
19713 @@ -516,7 +535,7 @@ void __init alternative_instructions(void)
19714 if (!uniproc_patched || num_possible_cpus() == 1)
19715 free_init_pages("SMP alternatives",
19716 (unsigned long)__smp_locks,
19717 - (unsigned long)__smp_locks_end);
19718 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19719 #endif
19720
19721 apply_paravirt(__parainstructions, __parainstructions_end);
19722 @@ -536,13 +555,17 @@ void __init alternative_instructions(void)
19723 * instructions. And on the local CPU you need to be protected again NMI or MCE
19724 * handlers seeing an inconsistent instruction while you patch.
19725 */
19726 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19727 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19728 size_t len)
19729 {
19730 unsigned long flags;
19731 local_irq_save(flags);
19732 - memcpy(addr, opcode, len);
19733 +
19734 + pax_open_kernel();
19735 + memcpy(ktla_ktva(addr), opcode, len);
19736 sync_core();
19737 + pax_close_kernel();
19738 +
19739 local_irq_restore(flags);
19740 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19741 that causes hangs on some VIA CPUs. */
19742 @@ -564,36 +587,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19743 */
19744 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19745 {
19746 - unsigned long flags;
19747 - char *vaddr;
19748 + unsigned char *vaddr = ktla_ktva(addr);
19749 struct page *pages[2];
19750 - int i;
19751 + size_t i;
19752
19753 if (!core_kernel_text((unsigned long)addr)) {
19754 - pages[0] = vmalloc_to_page(addr);
19755 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19756 + pages[0] = vmalloc_to_page(vaddr);
19757 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19758 } else {
19759 - pages[0] = virt_to_page(addr);
19760 + pages[0] = virt_to_page(vaddr);
19761 WARN_ON(!PageReserved(pages[0]));
19762 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19763 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19764 }
19765 BUG_ON(!pages[0]);
19766 - local_irq_save(flags);
19767 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19768 - if (pages[1])
19769 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19770 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19771 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19772 - clear_fixmap(FIX_TEXT_POKE0);
19773 - if (pages[1])
19774 - clear_fixmap(FIX_TEXT_POKE1);
19775 - local_flush_tlb();
19776 - sync_core();
19777 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19778 - that causes hangs on some VIA CPUs. */
19779 + text_poke_early(addr, opcode, len);
19780 for (i = 0; i < len; i++)
19781 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19782 - local_irq_restore(flags);
19783 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19784 return addr;
19785 }
19786
19787 @@ -613,7 +622,7 @@ int poke_int3_handler(struct pt_regs *regs)
19788 if (likely(!bp_patching_in_progress))
19789 return 0;
19790
19791 - if (user_mode_vm(regs) || regs->ip != (unsigned long)bp_int3_addr)
19792 + if (user_mode(regs) || regs->ip != (unsigned long)bp_int3_addr)
19793 return 0;
19794
19795 /* set up the specified breakpoint handler */
19796 @@ -647,7 +656,7 @@ int poke_int3_handler(struct pt_regs *regs)
19797 */
19798 void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
19799 {
19800 - unsigned char int3 = 0xcc;
19801 + const unsigned char int3 = 0xcc;
19802
19803 bp_int3_handler = handler;
19804 bp_int3_addr = (u8 *)addr + sizeof(int3);
19805 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19806 index a7eb82d..f6e52d4 100644
19807 --- a/arch/x86/kernel/apic/apic.c
19808 +++ b/arch/x86/kernel/apic/apic.c
19809 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19810 /*
19811 * Debug level, exported for io_apic.c
19812 */
19813 -unsigned int apic_verbosity;
19814 +int apic_verbosity;
19815
19816 int pic_mode;
19817
19818 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19819 apic_write(APIC_ESR, 0);
19820 v1 = apic_read(APIC_ESR);
19821 ack_APIC_irq();
19822 - atomic_inc(&irq_err_count);
19823 + atomic_inc_unchecked(&irq_err_count);
19824
19825 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19826 smp_processor_id(), v0 , v1);
19827 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19828 index 00c77cf..2dc6a2d 100644
19829 --- a/arch/x86/kernel/apic/apic_flat_64.c
19830 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19831 @@ -157,7 +157,7 @@ static int flat_probe(void)
19832 return 1;
19833 }
19834
19835 -static struct apic apic_flat = {
19836 +static struct apic apic_flat __read_only = {
19837 .name = "flat",
19838 .probe = flat_probe,
19839 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19840 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19841 return 0;
19842 }
19843
19844 -static struct apic apic_physflat = {
19845 +static struct apic apic_physflat __read_only = {
19846
19847 .name = "physical flat",
19848 .probe = physflat_probe,
19849 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19850 index e145f28..2752888 100644
19851 --- a/arch/x86/kernel/apic/apic_noop.c
19852 +++ b/arch/x86/kernel/apic/apic_noop.c
19853 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19854 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19855 }
19856
19857 -struct apic apic_noop = {
19858 +struct apic apic_noop __read_only = {
19859 .name = "noop",
19860 .probe = noop_probe,
19861 .acpi_madt_oem_check = NULL,
19862 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19863 index d50e364..543bee3 100644
19864 --- a/arch/x86/kernel/apic/bigsmp_32.c
19865 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19866 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19867 return dmi_bigsmp;
19868 }
19869
19870 -static struct apic apic_bigsmp = {
19871 +static struct apic apic_bigsmp __read_only = {
19872
19873 .name = "bigsmp",
19874 .probe = probe_bigsmp,
19875 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19876 index c552247..587a316 100644
19877 --- a/arch/x86/kernel/apic/es7000_32.c
19878 +++ b/arch/x86/kernel/apic/es7000_32.c
19879 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19880 return ret && es7000_apic_is_cluster();
19881 }
19882
19883 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19884 -static struct apic __refdata apic_es7000_cluster = {
19885 +static struct apic apic_es7000_cluster __read_only = {
19886
19887 .name = "es7000",
19888 .probe = probe_es7000,
19889 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19890 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19891 };
19892
19893 -static struct apic __refdata apic_es7000 = {
19894 +static struct apic apic_es7000 __read_only = {
19895
19896 .name = "es7000",
19897 .probe = probe_es7000,
19898 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19899 index e63a5bd..c0babf8 100644
19900 --- a/arch/x86/kernel/apic/io_apic.c
19901 +++ b/arch/x86/kernel/apic/io_apic.c
19902 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19903 }
19904 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19905
19906 -void lock_vector_lock(void)
19907 +void lock_vector_lock(void) __acquires(vector_lock)
19908 {
19909 /* Used to the online set of cpus does not change
19910 * during assign_irq_vector.
19911 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19912 raw_spin_lock(&vector_lock);
19913 }
19914
19915 -void unlock_vector_lock(void)
19916 +void unlock_vector_lock(void) __releases(vector_lock)
19917 {
19918 raw_spin_unlock(&vector_lock);
19919 }
19920 @@ -2367,7 +2367,7 @@ static void ack_apic_edge(struct irq_data *data)
19921 ack_APIC_irq();
19922 }
19923
19924 -atomic_t irq_mis_count;
19925 +atomic_unchecked_t irq_mis_count;
19926
19927 #ifdef CONFIG_GENERIC_PENDING_IRQ
19928 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19929 @@ -2508,7 +2508,7 @@ static void ack_apic_level(struct irq_data *data)
19930 * at the cpu.
19931 */
19932 if (!(v & (1 << (i & 0x1f)))) {
19933 - atomic_inc(&irq_mis_count);
19934 + atomic_inc_unchecked(&irq_mis_count);
19935
19936 eoi_ioapic_irq(irq, cfg);
19937 }
19938 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19939 index 1e42e8f..daacf44 100644
19940 --- a/arch/x86/kernel/apic/numaq_32.c
19941 +++ b/arch/x86/kernel/apic/numaq_32.c
19942 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19943 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19944 }
19945
19946 -/* Use __refdata to keep false positive warning calm. */
19947 -static struct apic __refdata apic_numaq = {
19948 +static struct apic apic_numaq __read_only = {
19949
19950 .name = "NUMAQ",
19951 .probe = probe_numaq,
19952 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19953 index eb35ef9..f184a21 100644
19954 --- a/arch/x86/kernel/apic/probe_32.c
19955 +++ b/arch/x86/kernel/apic/probe_32.c
19956 @@ -72,7 +72,7 @@ static int probe_default(void)
19957 return 1;
19958 }
19959
19960 -static struct apic apic_default = {
19961 +static struct apic apic_default __read_only = {
19962
19963 .name = "default",
19964 .probe = probe_default,
19965 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19966 index 77c95c0..434f8a4 100644
19967 --- a/arch/x86/kernel/apic/summit_32.c
19968 +++ b/arch/x86/kernel/apic/summit_32.c
19969 @@ -486,7 +486,7 @@ void setup_summit(void)
19970 }
19971 #endif
19972
19973 -static struct apic apic_summit = {
19974 +static struct apic apic_summit __read_only = {
19975
19976 .name = "summit",
19977 .probe = probe_summit,
19978 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19979 index 140e29d..d88bc95 100644
19980 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19981 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19982 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19983 return notifier_from_errno(err);
19984 }
19985
19986 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19987 +static struct notifier_block x2apic_cpu_notifier = {
19988 .notifier_call = update_clusterinfo,
19989 };
19990
19991 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19992 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19993 }
19994
19995 -static struct apic apic_x2apic_cluster = {
19996 +static struct apic apic_x2apic_cluster __read_only = {
19997
19998 .name = "cluster x2apic",
19999 .probe = x2apic_cluster_probe,
20000 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
20001 index 562a76d..a003c0f 100644
20002 --- a/arch/x86/kernel/apic/x2apic_phys.c
20003 +++ b/arch/x86/kernel/apic/x2apic_phys.c
20004 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
20005 return apic == &apic_x2apic_phys;
20006 }
20007
20008 -static struct apic apic_x2apic_phys = {
20009 +static struct apic apic_x2apic_phys __read_only = {
20010
20011 .name = "physical x2apic",
20012 .probe = x2apic_phys_probe,
20013 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
20014 index a419814..1dd34a0 100644
20015 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
20016 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
20017 @@ -357,7 +357,7 @@ static int uv_probe(void)
20018 return apic == &apic_x2apic_uv_x;
20019 }
20020
20021 -static struct apic __refdata apic_x2apic_uv_x = {
20022 +static struct apic apic_x2apic_uv_x __read_only = {
20023
20024 .name = "UV large system",
20025 .probe = uv_probe,
20026 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
20027 index 3ab0343..814c4787 100644
20028 --- a/arch/x86/kernel/apm_32.c
20029 +++ b/arch/x86/kernel/apm_32.c
20030 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
20031 * This is for buggy BIOS's that refer to (real mode) segment 0x40
20032 * even though they are called in protected mode.
20033 */
20034 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
20035 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
20036 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
20037
20038 static const char driver_version[] = "1.16ac"; /* no spaces */
20039 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
20040 BUG_ON(cpu != 0);
20041 gdt = get_cpu_gdt_table(cpu);
20042 save_desc_40 = gdt[0x40 / 8];
20043 +
20044 + pax_open_kernel();
20045 gdt[0x40 / 8] = bad_bios_desc;
20046 + pax_close_kernel();
20047
20048 apm_irq_save(flags);
20049 APM_DO_SAVE_SEGS;
20050 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
20051 &call->esi);
20052 APM_DO_RESTORE_SEGS;
20053 apm_irq_restore(flags);
20054 +
20055 + pax_open_kernel();
20056 gdt[0x40 / 8] = save_desc_40;
20057 + pax_close_kernel();
20058 +
20059 put_cpu();
20060
20061 return call->eax & 0xff;
20062 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
20063 BUG_ON(cpu != 0);
20064 gdt = get_cpu_gdt_table(cpu);
20065 save_desc_40 = gdt[0x40 / 8];
20066 +
20067 + pax_open_kernel();
20068 gdt[0x40 / 8] = bad_bios_desc;
20069 + pax_close_kernel();
20070
20071 apm_irq_save(flags);
20072 APM_DO_SAVE_SEGS;
20073 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
20074 &call->eax);
20075 APM_DO_RESTORE_SEGS;
20076 apm_irq_restore(flags);
20077 +
20078 + pax_open_kernel();
20079 gdt[0x40 / 8] = save_desc_40;
20080 + pax_close_kernel();
20081 +
20082 put_cpu();
20083 return error;
20084 }
20085 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
20086 * code to that CPU.
20087 */
20088 gdt = get_cpu_gdt_table(0);
20089 +
20090 + pax_open_kernel();
20091 set_desc_base(&gdt[APM_CS >> 3],
20092 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
20093 set_desc_base(&gdt[APM_CS_16 >> 3],
20094 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
20095 set_desc_base(&gdt[APM_DS >> 3],
20096 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
20097 + pax_close_kernel();
20098
20099 proc_create("apm", 0, NULL, &apm_file_ops);
20100
20101 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
20102 index 2861082..6d4718e 100644
20103 --- a/arch/x86/kernel/asm-offsets.c
20104 +++ b/arch/x86/kernel/asm-offsets.c
20105 @@ -33,6 +33,8 @@ void common(void) {
20106 OFFSET(TI_status, thread_info, status);
20107 OFFSET(TI_addr_limit, thread_info, addr_limit);
20108 OFFSET(TI_preempt_count, thread_info, preempt_count);
20109 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
20110 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
20111
20112 BLANK();
20113 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
20114 @@ -53,8 +55,26 @@ void common(void) {
20115 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
20116 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
20117 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
20118 +
20119 +#ifdef CONFIG_PAX_KERNEXEC
20120 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
20121 #endif
20122
20123 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20124 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
20125 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
20126 +#ifdef CONFIG_X86_64
20127 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
20128 +#endif
20129 +#endif
20130 +
20131 +#endif
20132 +
20133 + BLANK();
20134 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
20135 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
20136 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
20137 +
20138 #ifdef CONFIG_XEN
20139 BLANK();
20140 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
20141 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
20142 index e7c798b..2b2019b 100644
20143 --- a/arch/x86/kernel/asm-offsets_64.c
20144 +++ b/arch/x86/kernel/asm-offsets_64.c
20145 @@ -77,6 +77,7 @@ int main(void)
20146 BLANK();
20147 #undef ENTRY
20148
20149 + DEFINE(TSS_size, sizeof(struct tss_struct));
20150 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
20151 BLANK();
20152
20153 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
20154 index 47b56a7..efc2bc6 100644
20155 --- a/arch/x86/kernel/cpu/Makefile
20156 +++ b/arch/x86/kernel/cpu/Makefile
20157 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
20158 CFLAGS_REMOVE_perf_event.o = -pg
20159 endif
20160
20161 -# Make sure load_percpu_segment has no stackprotector
20162 -nostackp := $(call cc-option, -fno-stack-protector)
20163 -CFLAGS_common.o := $(nostackp)
20164 -
20165 obj-y := intel_cacheinfo.o scattered.o topology.o
20166 obj-y += proc.o capflags.o powerflags.o common.o
20167 obj-y += rdrand.o
20168 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
20169 index 903a264..fc955f3 100644
20170 --- a/arch/x86/kernel/cpu/amd.c
20171 +++ b/arch/x86/kernel/cpu/amd.c
20172 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
20173 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
20174 {
20175 /* AMD errata T13 (order #21922) */
20176 - if ((c->x86 == 6)) {
20177 + if (c->x86 == 6) {
20178 /* Duron Rev A0 */
20179 if (c->x86_model == 3 && c->x86_mask == 0)
20180 size = 64;
20181 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
20182 index 2793d1f..b4f313a 100644
20183 --- a/arch/x86/kernel/cpu/common.c
20184 +++ b/arch/x86/kernel/cpu/common.c
20185 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
20186
20187 static const struct cpu_dev *this_cpu = &default_cpu;
20188
20189 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
20190 -#ifdef CONFIG_X86_64
20191 - /*
20192 - * We need valid kernel segments for data and code in long mode too
20193 - * IRET will check the segment types kkeil 2000/10/28
20194 - * Also sysret mandates a special GDT layout
20195 - *
20196 - * TLS descriptors are currently at a different place compared to i386.
20197 - * Hopefully nobody expects them at a fixed place (Wine?)
20198 - */
20199 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
20200 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
20201 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
20202 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
20203 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
20204 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
20205 -#else
20206 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
20207 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
20208 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
20209 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
20210 - /*
20211 - * Segments used for calling PnP BIOS have byte granularity.
20212 - * They code segments and data segments have fixed 64k limits,
20213 - * the transfer segment sizes are set at run time.
20214 - */
20215 - /* 32-bit code */
20216 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
20217 - /* 16-bit code */
20218 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
20219 - /* 16-bit data */
20220 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
20221 - /* 16-bit data */
20222 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
20223 - /* 16-bit data */
20224 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
20225 - /*
20226 - * The APM segments have byte granularity and their bases
20227 - * are set at run time. All have 64k limits.
20228 - */
20229 - /* 32-bit code */
20230 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
20231 - /* 16-bit code */
20232 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
20233 - /* data */
20234 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
20235 -
20236 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
20237 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
20238 - GDT_STACK_CANARY_INIT
20239 -#endif
20240 -} };
20241 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
20242 -
20243 static int __init x86_xsave_setup(char *s)
20244 {
20245 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
20246 @@ -288,6 +234,59 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
20247 set_in_cr4(X86_CR4_SMAP);
20248 }
20249
20250 +#ifdef CONFIG_X86_64
20251 +static __init int setup_disable_pcid(char *arg)
20252 +{
20253 + setup_clear_cpu_cap(X86_FEATURE_PCID);
20254 + setup_clear_cpu_cap(X86_FEATURE_INVPCID);
20255 +
20256 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20257 + if (clone_pgd_mask != ~(pgdval_t)0UL)
20258 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
20259 +#endif
20260 +
20261 + return 1;
20262 +}
20263 +__setup("nopcid", setup_disable_pcid);
20264 +
20265 +static void setup_pcid(struct cpuinfo_x86 *c)
20266 +{
20267 + if (!cpu_has(c, X86_FEATURE_PCID)) {
20268 + clear_cpu_cap(c, X86_FEATURE_INVPCID);
20269 +
20270 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20271 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
20272 + pax_open_kernel();
20273 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
20274 + pax_close_kernel();
20275 + printk("PAX: slow and weak UDEREF enabled\n");
20276 + } else
20277 + printk("PAX: UDEREF disabled\n");
20278 +#endif
20279 +
20280 + return;
20281 + }
20282 +
20283 + printk("PAX: PCID detected\n");
20284 + set_in_cr4(X86_CR4_PCIDE);
20285 +
20286 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20287 + pax_open_kernel();
20288 + clone_pgd_mask = ~(pgdval_t)0UL;
20289 + pax_close_kernel();
20290 + if (pax_user_shadow_base)
20291 + printk("PAX: weak UDEREF enabled\n");
20292 + else {
20293 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
20294 + printk("PAX: strong UDEREF enabled\n");
20295 + }
20296 +#endif
20297 +
20298 + if (cpu_has(c, X86_FEATURE_INVPCID))
20299 + printk("PAX: INVPCID detected\n");
20300 +}
20301 +#endif
20302 +
20303 /*
20304 * Some CPU features depend on higher CPUID levels, which may not always
20305 * be available due to CPUID level capping or broken virtualization
20306 @@ -386,7 +385,7 @@ void switch_to_new_gdt(int cpu)
20307 {
20308 struct desc_ptr gdt_descr;
20309
20310 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
20311 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
20312 gdt_descr.size = GDT_SIZE - 1;
20313 load_gdt(&gdt_descr);
20314 /* Reload the per-cpu base */
20315 @@ -875,6 +874,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
20316 setup_smep(c);
20317 setup_smap(c);
20318
20319 +#ifdef CONFIG_X86_64
20320 + setup_pcid(c);
20321 +#endif
20322 +
20323 /*
20324 * The vendor-specific functions might have changed features.
20325 * Now we do "generic changes."
20326 @@ -883,6 +886,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
20327 /* Filter out anything that depends on CPUID levels we don't have */
20328 filter_cpuid_features(c, true);
20329
20330 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
20331 + setup_clear_cpu_cap(X86_FEATURE_SEP);
20332 +#endif
20333 +
20334 /* If the model name is still unset, do table lookup. */
20335 if (!c->x86_model_id[0]) {
20336 const char *p;
20337 @@ -1070,10 +1077,12 @@ static __init int setup_disablecpuid(char *arg)
20338 }
20339 __setup("clearcpuid=", setup_disablecpuid);
20340
20341 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
20342 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
20343 +
20344 #ifdef CONFIG_X86_64
20345 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
20346 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
20347 - (unsigned long) debug_idt_table };
20348 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
20349 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
20350
20351 DEFINE_PER_CPU_FIRST(union irq_stack_union,
20352 irq_stack_union) __aligned(PAGE_SIZE) __visible;
20353 @@ -1087,7 +1096,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
20354 EXPORT_PER_CPU_SYMBOL(current_task);
20355
20356 DEFINE_PER_CPU(unsigned long, kernel_stack) =
20357 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
20358 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
20359 EXPORT_PER_CPU_SYMBOL(kernel_stack);
20360
20361 DEFINE_PER_CPU(char *, irq_stack_ptr) =
20362 @@ -1232,7 +1241,7 @@ void cpu_init(void)
20363 load_ucode_ap();
20364
20365 cpu = stack_smp_processor_id();
20366 - t = &per_cpu(init_tss, cpu);
20367 + t = init_tss + cpu;
20368 oist = &per_cpu(orig_ist, cpu);
20369
20370 #ifdef CONFIG_NUMA
20371 @@ -1267,7 +1276,6 @@ void cpu_init(void)
20372 wrmsrl(MSR_KERNEL_GS_BASE, 0);
20373 barrier();
20374
20375 - x86_configure_nx();
20376 enable_x2apic();
20377
20378 /*
20379 @@ -1319,7 +1327,7 @@ void cpu_init(void)
20380 {
20381 int cpu = smp_processor_id();
20382 struct task_struct *curr = current;
20383 - struct tss_struct *t = &per_cpu(init_tss, cpu);
20384 + struct tss_struct *t = init_tss + cpu;
20385 struct thread_struct *thread = &curr->thread;
20386
20387 show_ucode_info_early();
20388 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
20389 index 1414c90..1159406 100644
20390 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
20391 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
20392 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
20393 };
20394
20395 #ifdef CONFIG_AMD_NB
20396 +static struct attribute *default_attrs_amd_nb[] = {
20397 + &type.attr,
20398 + &level.attr,
20399 + &coherency_line_size.attr,
20400 + &physical_line_partition.attr,
20401 + &ways_of_associativity.attr,
20402 + &number_of_sets.attr,
20403 + &size.attr,
20404 + &shared_cpu_map.attr,
20405 + &shared_cpu_list.attr,
20406 + NULL,
20407 + NULL,
20408 + NULL,
20409 + NULL
20410 +};
20411 +
20412 static struct attribute **amd_l3_attrs(void)
20413 {
20414 static struct attribute **attrs;
20415 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
20416
20417 n = ARRAY_SIZE(default_attrs);
20418
20419 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
20420 - n += 2;
20421 -
20422 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
20423 - n += 1;
20424 -
20425 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
20426 - if (attrs == NULL)
20427 - return attrs = default_attrs;
20428 -
20429 - for (n = 0; default_attrs[n]; n++)
20430 - attrs[n] = default_attrs[n];
20431 + attrs = default_attrs_amd_nb;
20432
20433 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
20434 attrs[n++] = &cache_disable_0.attr;
20435 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
20436 .default_attrs = default_attrs,
20437 };
20438
20439 +#ifdef CONFIG_AMD_NB
20440 +static struct kobj_type ktype_cache_amd_nb = {
20441 + .sysfs_ops = &sysfs_ops,
20442 + .default_attrs = default_attrs_amd_nb,
20443 +};
20444 +#endif
20445 +
20446 static struct kobj_type ktype_percpu_entry = {
20447 .sysfs_ops = &sysfs_ops,
20448 };
20449 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
20450 return retval;
20451 }
20452
20453 +#ifdef CONFIG_AMD_NB
20454 + amd_l3_attrs();
20455 +#endif
20456 +
20457 for (i = 0; i < num_cache_leaves; i++) {
20458 + struct kobj_type *ktype;
20459 +
20460 this_object = INDEX_KOBJECT_PTR(cpu, i);
20461 this_object->cpu = cpu;
20462 this_object->index = i;
20463
20464 this_leaf = CPUID4_INFO_IDX(cpu, i);
20465
20466 - ktype_cache.default_attrs = default_attrs;
20467 + ktype = &ktype_cache;
20468 #ifdef CONFIG_AMD_NB
20469 if (this_leaf->base.nb)
20470 - ktype_cache.default_attrs = amd_l3_attrs();
20471 + ktype = &ktype_cache_amd_nb;
20472 #endif
20473 retval = kobject_init_and_add(&(this_object->kobj),
20474 - &ktype_cache,
20475 + ktype,
20476 per_cpu(ici_cache_kobject, cpu),
20477 "index%1lu", i);
20478 if (unlikely(retval)) {
20479 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
20480 index b3218cd..99a75de 100644
20481 --- a/arch/x86/kernel/cpu/mcheck/mce.c
20482 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
20483 @@ -45,6 +45,7 @@
20484 #include <asm/processor.h>
20485 #include <asm/mce.h>
20486 #include <asm/msr.h>
20487 +#include <asm/local.h>
20488
20489 #include "mce-internal.h"
20490
20491 @@ -258,7 +259,7 @@ static void print_mce(struct mce *m)
20492 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
20493 m->cs, m->ip);
20494
20495 - if (m->cs == __KERNEL_CS)
20496 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
20497 print_symbol("{%s}", m->ip);
20498 pr_cont("\n");
20499 }
20500 @@ -291,10 +292,10 @@ static void print_mce(struct mce *m)
20501
20502 #define PANIC_TIMEOUT 5 /* 5 seconds */
20503
20504 -static atomic_t mce_paniced;
20505 +static atomic_unchecked_t mce_paniced;
20506
20507 static int fake_panic;
20508 -static atomic_t mce_fake_paniced;
20509 +static atomic_unchecked_t mce_fake_paniced;
20510
20511 /* Panic in progress. Enable interrupts and wait for final IPI */
20512 static void wait_for_panic(void)
20513 @@ -318,7 +319,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
20514 /*
20515 * Make sure only one CPU runs in machine check panic
20516 */
20517 - if (atomic_inc_return(&mce_paniced) > 1)
20518 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
20519 wait_for_panic();
20520 barrier();
20521
20522 @@ -326,7 +327,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
20523 console_verbose();
20524 } else {
20525 /* Don't log too much for fake panic */
20526 - if (atomic_inc_return(&mce_fake_paniced) > 1)
20527 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
20528 return;
20529 }
20530 /* First print corrected ones that are still unlogged */
20531 @@ -365,7 +366,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
20532 if (!fake_panic) {
20533 if (panic_timeout == 0)
20534 panic_timeout = mca_cfg.panic_timeout;
20535 - panic(msg);
20536 + panic("%s", msg);
20537 } else
20538 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
20539 }
20540 @@ -695,7 +696,7 @@ static int mce_timed_out(u64 *t)
20541 * might have been modified by someone else.
20542 */
20543 rmb();
20544 - if (atomic_read(&mce_paniced))
20545 + if (atomic_read_unchecked(&mce_paniced))
20546 wait_for_panic();
20547 if (!mca_cfg.monarch_timeout)
20548 goto out;
20549 @@ -1666,7 +1667,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
20550 }
20551
20552 /* Call the installed machine check handler for this CPU setup. */
20553 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
20554 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
20555 unexpected_machine_check;
20556
20557 /*
20558 @@ -1689,7 +1690,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
20559 return;
20560 }
20561
20562 + pax_open_kernel();
20563 machine_check_vector = do_machine_check;
20564 + pax_close_kernel();
20565
20566 __mcheck_cpu_init_generic();
20567 __mcheck_cpu_init_vendor(c);
20568 @@ -1703,7 +1706,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
20569 */
20570
20571 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
20572 -static int mce_chrdev_open_count; /* #times opened */
20573 +static local_t mce_chrdev_open_count; /* #times opened */
20574 static int mce_chrdev_open_exclu; /* already open exclusive? */
20575
20576 static int mce_chrdev_open(struct inode *inode, struct file *file)
20577 @@ -1711,7 +1714,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
20578 spin_lock(&mce_chrdev_state_lock);
20579
20580 if (mce_chrdev_open_exclu ||
20581 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
20582 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
20583 spin_unlock(&mce_chrdev_state_lock);
20584
20585 return -EBUSY;
20586 @@ -1719,7 +1722,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
20587
20588 if (file->f_flags & O_EXCL)
20589 mce_chrdev_open_exclu = 1;
20590 - mce_chrdev_open_count++;
20591 + local_inc(&mce_chrdev_open_count);
20592
20593 spin_unlock(&mce_chrdev_state_lock);
20594
20595 @@ -1730,7 +1733,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
20596 {
20597 spin_lock(&mce_chrdev_state_lock);
20598
20599 - mce_chrdev_open_count--;
20600 + local_dec(&mce_chrdev_open_count);
20601 mce_chrdev_open_exclu = 0;
20602
20603 spin_unlock(&mce_chrdev_state_lock);
20604 @@ -2404,7 +2407,7 @@ static __init void mce_init_banks(void)
20605
20606 for (i = 0; i < mca_cfg.banks; i++) {
20607 struct mce_bank *b = &mce_banks[i];
20608 - struct device_attribute *a = &b->attr;
20609 + device_attribute_no_const *a = &b->attr;
20610
20611 sysfs_attr_init(&a->attr);
20612 a->attr.name = b->attrname;
20613 @@ -2472,7 +2475,7 @@ struct dentry *mce_get_debugfs_dir(void)
20614 static void mce_reset(void)
20615 {
20616 cpu_missing = 0;
20617 - atomic_set(&mce_fake_paniced, 0);
20618 + atomic_set_unchecked(&mce_fake_paniced, 0);
20619 atomic_set(&mce_executing, 0);
20620 atomic_set(&mce_callin, 0);
20621 atomic_set(&global_nwo, 0);
20622 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
20623 index 1c044b1..37a2a43 100644
20624 --- a/arch/x86/kernel/cpu/mcheck/p5.c
20625 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
20626 @@ -11,6 +11,7 @@
20627 #include <asm/processor.h>
20628 #include <asm/mce.h>
20629 #include <asm/msr.h>
20630 +#include <asm/pgtable.h>
20631
20632 /* By default disabled */
20633 int mce_p5_enabled __read_mostly;
20634 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
20635 if (!cpu_has(c, X86_FEATURE_MCE))
20636 return;
20637
20638 + pax_open_kernel();
20639 machine_check_vector = pentium_machine_check;
20640 + pax_close_kernel();
20641 /* Make sure the vector pointer is visible before we enable MCEs: */
20642 wmb();
20643
20644 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
20645 index e9a701a..35317d6 100644
20646 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
20647 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
20648 @@ -10,6 +10,7 @@
20649 #include <asm/processor.h>
20650 #include <asm/mce.h>
20651 #include <asm/msr.h>
20652 +#include <asm/pgtable.h>
20653
20654 /* Machine check handler for WinChip C6: */
20655 static void winchip_machine_check(struct pt_regs *regs, long error_code)
20656 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
20657 {
20658 u32 lo, hi;
20659
20660 + pax_open_kernel();
20661 machine_check_vector = winchip_machine_check;
20662 + pax_close_kernel();
20663 /* Make sure the vector pointer is visible before we enable MCEs: */
20664 wmb();
20665
20666 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
20667 index f961de9..8a9d332 100644
20668 --- a/arch/x86/kernel/cpu/mtrr/main.c
20669 +++ b/arch/x86/kernel/cpu/mtrr/main.c
20670 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
20671 u64 size_or_mask, size_and_mask;
20672 static bool mtrr_aps_delayed_init;
20673
20674 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
20675 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
20676
20677 const struct mtrr_ops *mtrr_if;
20678
20679 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
20680 index df5e41f..816c719 100644
20681 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
20682 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
20683 @@ -25,7 +25,7 @@ struct mtrr_ops {
20684 int (*validate_add_page)(unsigned long base, unsigned long size,
20685 unsigned int type);
20686 int (*have_wrcomb)(void);
20687 -};
20688 +} __do_const;
20689
20690 extern int generic_get_free_region(unsigned long base, unsigned long size,
20691 int replace_reg);
20692 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
20693 index 8a87a32..682a22a 100644
20694 --- a/arch/x86/kernel/cpu/perf_event.c
20695 +++ b/arch/x86/kernel/cpu/perf_event.c
20696 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
20697 pr_info("no hardware sampling interrupt available.\n");
20698 }
20699
20700 -static struct attribute_group x86_pmu_format_group = {
20701 +static attribute_group_no_const x86_pmu_format_group = {
20702 .name = "format",
20703 .attrs = NULL,
20704 };
20705 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
20706 NULL,
20707 };
20708
20709 -static struct attribute_group x86_pmu_events_group = {
20710 +static attribute_group_no_const x86_pmu_events_group = {
20711 .name = "events",
20712 .attrs = events_attr,
20713 };
20714 @@ -1958,7 +1958,7 @@ static unsigned long get_segment_base(unsigned int segment)
20715 if (idx > GDT_ENTRIES)
20716 return 0;
20717
20718 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
20719 + desc = get_cpu_gdt_table(smp_processor_id());
20720 }
20721
20722 return get_desc_base(desc + idx);
20723 @@ -2048,7 +2048,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
20724 break;
20725
20726 perf_callchain_store(entry, frame.return_address);
20727 - fp = frame.next_frame;
20728 + fp = (const void __force_user *)frame.next_frame;
20729 }
20730 }
20731
20732 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20733 index 639d128..e92d7e5 100644
20734 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20735 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20736 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
20737 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
20738 {
20739 struct attribute **attrs;
20740 - struct attribute_group *attr_group;
20741 + attribute_group_no_const *attr_group;
20742 int i = 0, j;
20743
20744 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20745 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20746 index f31a165..7b46cd8 100644
20747 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20748 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20749 @@ -2247,10 +2247,10 @@ __init int intel_pmu_init(void)
20750 * v2 and above have a perf capabilities MSR
20751 */
20752 if (version > 1) {
20753 - u64 capabilities;
20754 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20755
20756 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20757 - x86_pmu.intel_cap.capabilities = capabilities;
20758 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20759 + x86_pmu.intel_cap.capabilities = capabilities;
20760 }
20761
20762 intel_ds_init();
20763 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20764 index 4118f9f..f91d0ab 100644
20765 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20766 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20767 @@ -3204,7 +3204,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20768 static int __init uncore_type_init(struct intel_uncore_type *type)
20769 {
20770 struct intel_uncore_pmu *pmus;
20771 - struct attribute_group *attr_group;
20772 + attribute_group_no_const *attr_group;
20773 struct attribute **attrs;
20774 int i, j;
20775
20776 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20777 index a80ab71..4089da5 100644
20778 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20779 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20780 @@ -498,7 +498,7 @@ struct intel_uncore_box {
20781 struct uncore_event_desc {
20782 struct kobj_attribute attr;
20783 const char *config;
20784 -};
20785 +} __do_const;
20786
20787 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20788 { \
20789 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20790 index 7d9481c..99c7e4b 100644
20791 --- a/arch/x86/kernel/cpuid.c
20792 +++ b/arch/x86/kernel/cpuid.c
20793 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20794 return notifier_from_errno(err);
20795 }
20796
20797 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20798 +static struct notifier_block cpuid_class_cpu_notifier =
20799 {
20800 .notifier_call = cpuid_class_cpu_callback,
20801 };
20802 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20803 index 18677a9..f67c45b 100644
20804 --- a/arch/x86/kernel/crash.c
20805 +++ b/arch/x86/kernel/crash.c
20806 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20807 {
20808 #ifdef CONFIG_X86_32
20809 struct pt_regs fixed_regs;
20810 -#endif
20811
20812 -#ifdef CONFIG_X86_32
20813 - if (!user_mode_vm(regs)) {
20814 + if (!user_mode(regs)) {
20815 crash_fixup_ss_esp(&fixed_regs, regs);
20816 regs = &fixed_regs;
20817 }
20818 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20819 index afa64ad..dce67dd 100644
20820 --- a/arch/x86/kernel/crash_dump_64.c
20821 +++ b/arch/x86/kernel/crash_dump_64.c
20822 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20823 return -ENOMEM;
20824
20825 if (userbuf) {
20826 - if (copy_to_user(buf, vaddr + offset, csize)) {
20827 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20828 iounmap(vaddr);
20829 return -EFAULT;
20830 }
20831 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20832 index 5d3fe8d..02e1429 100644
20833 --- a/arch/x86/kernel/doublefault.c
20834 +++ b/arch/x86/kernel/doublefault.c
20835 @@ -13,7 +13,7 @@
20836
20837 #define DOUBLEFAULT_STACKSIZE (1024)
20838 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20839 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20840 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20841
20842 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20843
20844 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20845 unsigned long gdt, tss;
20846
20847 native_store_gdt(&gdt_desc);
20848 - gdt = gdt_desc.address;
20849 + gdt = (unsigned long)gdt_desc.address;
20850
20851 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20852
20853 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20854 /* 0x2 bit is always set */
20855 .flags = X86_EFLAGS_SF | 0x2,
20856 .sp = STACK_START,
20857 - .es = __USER_DS,
20858 + .es = __KERNEL_DS,
20859 .cs = __KERNEL_CS,
20860 .ss = __KERNEL_DS,
20861 - .ds = __USER_DS,
20862 + .ds = __KERNEL_DS,
20863 .fs = __KERNEL_PERCPU,
20864
20865 .__cr3 = __pa_nodebug(swapper_pg_dir),
20866 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20867 index deb6421..76bbc12 100644
20868 --- a/arch/x86/kernel/dumpstack.c
20869 +++ b/arch/x86/kernel/dumpstack.c
20870 @@ -2,6 +2,9 @@
20871 * Copyright (C) 1991, 1992 Linus Torvalds
20872 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20873 */
20874 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20875 +#define __INCLUDED_BY_HIDESYM 1
20876 +#endif
20877 #include <linux/kallsyms.h>
20878 #include <linux/kprobes.h>
20879 #include <linux/uaccess.h>
20880 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20881 static void
20882 print_ftrace_graph_addr(unsigned long addr, void *data,
20883 const struct stacktrace_ops *ops,
20884 - struct thread_info *tinfo, int *graph)
20885 + struct task_struct *task, int *graph)
20886 {
20887 - struct task_struct *task;
20888 unsigned long ret_addr;
20889 int index;
20890
20891 if (addr != (unsigned long)return_to_handler)
20892 return;
20893
20894 - task = tinfo->task;
20895 index = task->curr_ret_stack;
20896
20897 if (!task->ret_stack || index < *graph)
20898 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20899 static inline void
20900 print_ftrace_graph_addr(unsigned long addr, void *data,
20901 const struct stacktrace_ops *ops,
20902 - struct thread_info *tinfo, int *graph)
20903 + struct task_struct *task, int *graph)
20904 { }
20905 #endif
20906
20907 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20908 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20909 */
20910
20911 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20912 - void *p, unsigned int size, void *end)
20913 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20914 {
20915 - void *t = tinfo;
20916 if (end) {
20917 if (p < end && p >= (end-THREAD_SIZE))
20918 return 1;
20919 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20920 }
20921
20922 unsigned long
20923 -print_context_stack(struct thread_info *tinfo,
20924 +print_context_stack(struct task_struct *task, void *stack_start,
20925 unsigned long *stack, unsigned long bp,
20926 const struct stacktrace_ops *ops, void *data,
20927 unsigned long *end, int *graph)
20928 {
20929 struct stack_frame *frame = (struct stack_frame *)bp;
20930
20931 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20932 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20933 unsigned long addr;
20934
20935 addr = *stack;
20936 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20937 } else {
20938 ops->address(data, addr, 0);
20939 }
20940 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20941 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20942 }
20943 stack++;
20944 }
20945 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20946 EXPORT_SYMBOL_GPL(print_context_stack);
20947
20948 unsigned long
20949 -print_context_stack_bp(struct thread_info *tinfo,
20950 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20951 unsigned long *stack, unsigned long bp,
20952 const struct stacktrace_ops *ops, void *data,
20953 unsigned long *end, int *graph)
20954 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20955 struct stack_frame *frame = (struct stack_frame *)bp;
20956 unsigned long *ret_addr = &frame->return_address;
20957
20958 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20959 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20960 unsigned long addr = *ret_addr;
20961
20962 if (!__kernel_text_address(addr))
20963 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20964 ops->address(data, addr, 1);
20965 frame = frame->next_frame;
20966 ret_addr = &frame->return_address;
20967 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20968 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20969 }
20970
20971 return (unsigned long)frame;
20972 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20973 static void print_trace_address(void *data, unsigned long addr, int reliable)
20974 {
20975 touch_nmi_watchdog();
20976 - printk(data);
20977 + printk("%s", (char *)data);
20978 printk_address(addr, reliable);
20979 }
20980
20981 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20982 }
20983 EXPORT_SYMBOL_GPL(oops_begin);
20984
20985 +extern void gr_handle_kernel_exploit(void);
20986 +
20987 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20988 {
20989 if (regs && kexec_should_crash(current))
20990 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20991 panic("Fatal exception in interrupt");
20992 if (panic_on_oops)
20993 panic("Fatal exception");
20994 - do_exit(signr);
20995 +
20996 + gr_handle_kernel_exploit();
20997 +
20998 + do_group_exit(signr);
20999 }
21000
21001 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
21002 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
21003 print_modules();
21004 show_regs(regs);
21005 #ifdef CONFIG_X86_32
21006 - if (user_mode_vm(regs)) {
21007 + if (user_mode(regs)) {
21008 sp = regs->sp;
21009 ss = regs->ss & 0xffff;
21010 } else {
21011 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
21012 unsigned long flags = oops_begin();
21013 int sig = SIGSEGV;
21014
21015 - if (!user_mode_vm(regs))
21016 + if (!user_mode(regs))
21017 report_bug(regs->ip, regs);
21018
21019 if (__die(str, regs, err))
21020 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
21021 index f2a1770..540657f 100644
21022 --- a/arch/x86/kernel/dumpstack_32.c
21023 +++ b/arch/x86/kernel/dumpstack_32.c
21024 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21025 bp = stack_frame(task, regs);
21026
21027 for (;;) {
21028 - struct thread_info *context;
21029 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
21030
21031 - context = (struct thread_info *)
21032 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
21033 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
21034 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
21035
21036 - stack = (unsigned long *)context->previous_esp;
21037 - if (!stack)
21038 + if (stack_start == task_stack_page(task))
21039 break;
21040 + stack = *(unsigned long **)stack_start;
21041 if (ops->stack(data, "IRQ") < 0)
21042 break;
21043 touch_nmi_watchdog();
21044 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
21045 int i;
21046
21047 show_regs_print_info(KERN_EMERG);
21048 - __show_regs(regs, !user_mode_vm(regs));
21049 + __show_regs(regs, !user_mode(regs));
21050
21051 /*
21052 * When in-kernel, we also print out the stack and code at the
21053 * time of the fault..
21054 */
21055 - if (!user_mode_vm(regs)) {
21056 + if (!user_mode(regs)) {
21057 unsigned int code_prologue = code_bytes * 43 / 64;
21058 unsigned int code_len = code_bytes;
21059 unsigned char c;
21060 u8 *ip;
21061 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
21062
21063 pr_emerg("Stack:\n");
21064 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
21065
21066 pr_emerg("Code:");
21067
21068 - ip = (u8 *)regs->ip - code_prologue;
21069 + ip = (u8 *)regs->ip - code_prologue + cs_base;
21070 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
21071 /* try starting at IP */
21072 - ip = (u8 *)regs->ip;
21073 + ip = (u8 *)regs->ip + cs_base;
21074 code_len = code_len - code_prologue + 1;
21075 }
21076 for (i = 0; i < code_len; i++, ip++) {
21077 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
21078 pr_cont(" Bad EIP value.");
21079 break;
21080 }
21081 - if (ip == (u8 *)regs->ip)
21082 + if (ip == (u8 *)regs->ip + cs_base)
21083 pr_cont(" <%02x>", c);
21084 else
21085 pr_cont(" %02x", c);
21086 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
21087 {
21088 unsigned short ud2;
21089
21090 + ip = ktla_ktva(ip);
21091 if (ip < PAGE_OFFSET)
21092 return 0;
21093 if (probe_kernel_address((unsigned short *)ip, ud2))
21094 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
21095
21096 return ud2 == 0x0b0f;
21097 }
21098 +
21099 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21100 +void pax_check_alloca(unsigned long size)
21101 +{
21102 + unsigned long sp = (unsigned long)&sp, stack_left;
21103 +
21104 + /* all kernel stacks are of the same size */
21105 + stack_left = sp & (THREAD_SIZE - 1);
21106 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21107 +}
21108 +EXPORT_SYMBOL(pax_check_alloca);
21109 +#endif
21110 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
21111 index addb207..99635fa 100644
21112 --- a/arch/x86/kernel/dumpstack_64.c
21113 +++ b/arch/x86/kernel/dumpstack_64.c
21114 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21115 unsigned long *irq_stack_end =
21116 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
21117 unsigned used = 0;
21118 - struct thread_info *tinfo;
21119 int graph = 0;
21120 unsigned long dummy;
21121 + void *stack_start;
21122
21123 if (!task)
21124 task = current;
21125 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21126 * current stack address. If the stacks consist of nested
21127 * exceptions
21128 */
21129 - tinfo = task_thread_info(task);
21130 for (;;) {
21131 char *id;
21132 unsigned long *estack_end;
21133 +
21134 estack_end = in_exception_stack(cpu, (unsigned long)stack,
21135 &used, &id);
21136
21137 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21138 if (ops->stack(data, id) < 0)
21139 break;
21140
21141 - bp = ops->walk_stack(tinfo, stack, bp, ops,
21142 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
21143 data, estack_end, &graph);
21144 ops->stack(data, "<EOE>");
21145 /*
21146 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21147 * second-to-last pointer (index -2 to end) in the
21148 * exception stack:
21149 */
21150 + if ((u16)estack_end[-1] != __KERNEL_DS)
21151 + goto out;
21152 stack = (unsigned long *) estack_end[-2];
21153 continue;
21154 }
21155 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21156 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
21157 if (ops->stack(data, "IRQ") < 0)
21158 break;
21159 - bp = ops->walk_stack(tinfo, stack, bp,
21160 + bp = ops->walk_stack(task, irq_stack, stack, bp,
21161 ops, data, irq_stack_end, &graph);
21162 /*
21163 * We link to the next stack (which would be
21164 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21165 /*
21166 * This handles the process stack:
21167 */
21168 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
21169 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
21170 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
21171 +out:
21172 put_cpu();
21173 }
21174 EXPORT_SYMBOL(dump_trace);
21175 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
21176
21177 return ud2 == 0x0b0f;
21178 }
21179 +
21180 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21181 +void pax_check_alloca(unsigned long size)
21182 +{
21183 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
21184 + unsigned cpu, used;
21185 + char *id;
21186 +
21187 + /* check the process stack first */
21188 + stack_start = (unsigned long)task_stack_page(current);
21189 + stack_end = stack_start + THREAD_SIZE;
21190 + if (likely(stack_start <= sp && sp < stack_end)) {
21191 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
21192 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21193 + return;
21194 + }
21195 +
21196 + cpu = get_cpu();
21197 +
21198 + /* check the irq stacks */
21199 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
21200 + stack_start = stack_end - IRQ_STACK_SIZE;
21201 + if (stack_start <= sp && sp < stack_end) {
21202 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
21203 + put_cpu();
21204 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21205 + return;
21206 + }
21207 +
21208 + /* check the exception stacks */
21209 + used = 0;
21210 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
21211 + stack_start = stack_end - EXCEPTION_STKSZ;
21212 + if (stack_end && stack_start <= sp && sp < stack_end) {
21213 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
21214 + put_cpu();
21215 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21216 + return;
21217 + }
21218 +
21219 + put_cpu();
21220 +
21221 + /* unknown stack */
21222 + BUG();
21223 +}
21224 +EXPORT_SYMBOL(pax_check_alloca);
21225 +#endif
21226 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
21227 index 174da5f..5e55606 100644
21228 --- a/arch/x86/kernel/e820.c
21229 +++ b/arch/x86/kernel/e820.c
21230 @@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
21231
21232 static void early_panic(char *msg)
21233 {
21234 - early_printk(msg);
21235 - panic(msg);
21236 + early_printk("%s", msg);
21237 + panic("%s", msg);
21238 }
21239
21240 static int userdef __initdata;
21241 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
21242 index d15f575..d692043 100644
21243 --- a/arch/x86/kernel/early_printk.c
21244 +++ b/arch/x86/kernel/early_printk.c
21245 @@ -7,6 +7,7 @@
21246 #include <linux/pci_regs.h>
21247 #include <linux/pci_ids.h>
21248 #include <linux/errno.h>
21249 +#include <linux/sched.h>
21250 #include <asm/io.h>
21251 #include <asm/processor.h>
21252 #include <asm/fcntl.h>
21253 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
21254 index f0dcb0c..9f39b80 100644
21255 --- a/arch/x86/kernel/entry_32.S
21256 +++ b/arch/x86/kernel/entry_32.S
21257 @@ -177,13 +177,153 @@
21258 /*CFI_REL_OFFSET gs, PT_GS*/
21259 .endm
21260 .macro SET_KERNEL_GS reg
21261 +
21262 +#ifdef CONFIG_CC_STACKPROTECTOR
21263 movl $(__KERNEL_STACK_CANARY), \reg
21264 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
21265 + movl $(__USER_DS), \reg
21266 +#else
21267 + xorl \reg, \reg
21268 +#endif
21269 +
21270 movl \reg, %gs
21271 .endm
21272
21273 #endif /* CONFIG_X86_32_LAZY_GS */
21274
21275 -.macro SAVE_ALL
21276 +.macro pax_enter_kernel
21277 +#ifdef CONFIG_PAX_KERNEXEC
21278 + call pax_enter_kernel
21279 +#endif
21280 +.endm
21281 +
21282 +.macro pax_exit_kernel
21283 +#ifdef CONFIG_PAX_KERNEXEC
21284 + call pax_exit_kernel
21285 +#endif
21286 +.endm
21287 +
21288 +#ifdef CONFIG_PAX_KERNEXEC
21289 +ENTRY(pax_enter_kernel)
21290 +#ifdef CONFIG_PARAVIRT
21291 + pushl %eax
21292 + pushl %ecx
21293 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
21294 + mov %eax, %esi
21295 +#else
21296 + mov %cr0, %esi
21297 +#endif
21298 + bts $16, %esi
21299 + jnc 1f
21300 + mov %cs, %esi
21301 + cmp $__KERNEL_CS, %esi
21302 + jz 3f
21303 + ljmp $__KERNEL_CS, $3f
21304 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
21305 +2:
21306 +#ifdef CONFIG_PARAVIRT
21307 + mov %esi, %eax
21308 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
21309 +#else
21310 + mov %esi, %cr0
21311 +#endif
21312 +3:
21313 +#ifdef CONFIG_PARAVIRT
21314 + popl %ecx
21315 + popl %eax
21316 +#endif
21317 + ret
21318 +ENDPROC(pax_enter_kernel)
21319 +
21320 +ENTRY(pax_exit_kernel)
21321 +#ifdef CONFIG_PARAVIRT
21322 + pushl %eax
21323 + pushl %ecx
21324 +#endif
21325 + mov %cs, %esi
21326 + cmp $__KERNEXEC_KERNEL_CS, %esi
21327 + jnz 2f
21328 +#ifdef CONFIG_PARAVIRT
21329 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
21330 + mov %eax, %esi
21331 +#else
21332 + mov %cr0, %esi
21333 +#endif
21334 + btr $16, %esi
21335 + ljmp $__KERNEL_CS, $1f
21336 +1:
21337 +#ifdef CONFIG_PARAVIRT
21338 + mov %esi, %eax
21339 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
21340 +#else
21341 + mov %esi, %cr0
21342 +#endif
21343 +2:
21344 +#ifdef CONFIG_PARAVIRT
21345 + popl %ecx
21346 + popl %eax
21347 +#endif
21348 + ret
21349 +ENDPROC(pax_exit_kernel)
21350 +#endif
21351 +
21352 + .macro pax_erase_kstack
21353 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21354 + call pax_erase_kstack
21355 +#endif
21356 + .endm
21357 +
21358 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21359 +/*
21360 + * ebp: thread_info
21361 + */
21362 +ENTRY(pax_erase_kstack)
21363 + pushl %edi
21364 + pushl %ecx
21365 + pushl %eax
21366 +
21367 + mov TI_lowest_stack(%ebp), %edi
21368 + mov $-0xBEEF, %eax
21369 + std
21370 +
21371 +1: mov %edi, %ecx
21372 + and $THREAD_SIZE_asm - 1, %ecx
21373 + shr $2, %ecx
21374 + repne scasl
21375 + jecxz 2f
21376 +
21377 + cmp $2*16, %ecx
21378 + jc 2f
21379 +
21380 + mov $2*16, %ecx
21381 + repe scasl
21382 + jecxz 2f
21383 + jne 1b
21384 +
21385 +2: cld
21386 + mov %esp, %ecx
21387 + sub %edi, %ecx
21388 +
21389 + cmp $THREAD_SIZE_asm, %ecx
21390 + jb 3f
21391 + ud2
21392 +3:
21393 +
21394 + shr $2, %ecx
21395 + rep stosl
21396 +
21397 + mov TI_task_thread_sp0(%ebp), %edi
21398 + sub $128, %edi
21399 + mov %edi, TI_lowest_stack(%ebp)
21400 +
21401 + popl %eax
21402 + popl %ecx
21403 + popl %edi
21404 + ret
21405 +ENDPROC(pax_erase_kstack)
21406 +#endif
21407 +
21408 +.macro __SAVE_ALL _DS
21409 cld
21410 PUSH_GS
21411 pushl_cfi %fs
21412 @@ -206,7 +346,7 @@
21413 CFI_REL_OFFSET ecx, 0
21414 pushl_cfi %ebx
21415 CFI_REL_OFFSET ebx, 0
21416 - movl $(__USER_DS), %edx
21417 + movl $\_DS, %edx
21418 movl %edx, %ds
21419 movl %edx, %es
21420 movl $(__KERNEL_PERCPU), %edx
21421 @@ -214,6 +354,15 @@
21422 SET_KERNEL_GS %edx
21423 .endm
21424
21425 +.macro SAVE_ALL
21426 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21427 + __SAVE_ALL __KERNEL_DS
21428 + pax_enter_kernel
21429 +#else
21430 + __SAVE_ALL __USER_DS
21431 +#endif
21432 +.endm
21433 +
21434 .macro RESTORE_INT_REGS
21435 popl_cfi %ebx
21436 CFI_RESTORE ebx
21437 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
21438 popfl_cfi
21439 jmp syscall_exit
21440 CFI_ENDPROC
21441 -END(ret_from_fork)
21442 +ENDPROC(ret_from_fork)
21443
21444 ENTRY(ret_from_kernel_thread)
21445 CFI_STARTPROC
21446 @@ -344,7 +493,15 @@ ret_from_intr:
21447 andl $SEGMENT_RPL_MASK, %eax
21448 #endif
21449 cmpl $USER_RPL, %eax
21450 +
21451 +#ifdef CONFIG_PAX_KERNEXEC
21452 + jae resume_userspace
21453 +
21454 + pax_exit_kernel
21455 + jmp resume_kernel
21456 +#else
21457 jb resume_kernel # not returning to v8086 or userspace
21458 +#endif
21459
21460 ENTRY(resume_userspace)
21461 LOCKDEP_SYS_EXIT
21462 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
21463 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
21464 # int/exception return?
21465 jne work_pending
21466 - jmp restore_all
21467 -END(ret_from_exception)
21468 + jmp restore_all_pax
21469 +ENDPROC(ret_from_exception)
21470
21471 #ifdef CONFIG_PREEMPT
21472 ENTRY(resume_kernel)
21473 @@ -372,7 +529,7 @@ need_resched:
21474 jz restore_all
21475 call preempt_schedule_irq
21476 jmp need_resched
21477 -END(resume_kernel)
21478 +ENDPROC(resume_kernel)
21479 #endif
21480 CFI_ENDPROC
21481 /*
21482 @@ -406,30 +563,45 @@ sysenter_past_esp:
21483 /*CFI_REL_OFFSET cs, 0*/
21484 /*
21485 * Push current_thread_info()->sysenter_return to the stack.
21486 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
21487 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
21488 */
21489 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
21490 + pushl_cfi $0
21491 CFI_REL_OFFSET eip, 0
21492
21493 pushl_cfi %eax
21494 SAVE_ALL
21495 + GET_THREAD_INFO(%ebp)
21496 + movl TI_sysenter_return(%ebp),%ebp
21497 + movl %ebp,PT_EIP(%esp)
21498 ENABLE_INTERRUPTS(CLBR_NONE)
21499
21500 /*
21501 * Load the potential sixth argument from user stack.
21502 * Careful about security.
21503 */
21504 + movl PT_OLDESP(%esp),%ebp
21505 +
21506 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21507 + mov PT_OLDSS(%esp),%ds
21508 +1: movl %ds:(%ebp),%ebp
21509 + push %ss
21510 + pop %ds
21511 +#else
21512 cmpl $__PAGE_OFFSET-3,%ebp
21513 jae syscall_fault
21514 ASM_STAC
21515 1: movl (%ebp),%ebp
21516 ASM_CLAC
21517 +#endif
21518 +
21519 movl %ebp,PT_EBP(%esp)
21520 _ASM_EXTABLE(1b,syscall_fault)
21521
21522 GET_THREAD_INFO(%ebp)
21523
21524 +#ifdef CONFIG_PAX_RANDKSTACK
21525 + pax_erase_kstack
21526 +#endif
21527 +
21528 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
21529 jnz sysenter_audit
21530 sysenter_do_call:
21531 @@ -444,12 +616,24 @@ sysenter_do_call:
21532 testl $_TIF_ALLWORK_MASK, %ecx
21533 jne sysexit_audit
21534 sysenter_exit:
21535 +
21536 +#ifdef CONFIG_PAX_RANDKSTACK
21537 + pushl_cfi %eax
21538 + movl %esp, %eax
21539 + call pax_randomize_kstack
21540 + popl_cfi %eax
21541 +#endif
21542 +
21543 + pax_erase_kstack
21544 +
21545 /* if something modifies registers it must also disable sysexit */
21546 movl PT_EIP(%esp), %edx
21547 movl PT_OLDESP(%esp), %ecx
21548 xorl %ebp,%ebp
21549 TRACE_IRQS_ON
21550 1: mov PT_FS(%esp), %fs
21551 +2: mov PT_DS(%esp), %ds
21552 +3: mov PT_ES(%esp), %es
21553 PTGS_TO_GS
21554 ENABLE_INTERRUPTS_SYSEXIT
21555
21556 @@ -466,6 +650,9 @@ sysenter_audit:
21557 movl %eax,%edx /* 2nd arg: syscall number */
21558 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
21559 call __audit_syscall_entry
21560 +
21561 + pax_erase_kstack
21562 +
21563 pushl_cfi %ebx
21564 movl PT_EAX(%esp),%eax /* reload syscall number */
21565 jmp sysenter_do_call
21566 @@ -491,10 +678,16 @@ sysexit_audit:
21567
21568 CFI_ENDPROC
21569 .pushsection .fixup,"ax"
21570 -2: movl $0,PT_FS(%esp)
21571 +4: movl $0,PT_FS(%esp)
21572 + jmp 1b
21573 +5: movl $0,PT_DS(%esp)
21574 + jmp 1b
21575 +6: movl $0,PT_ES(%esp)
21576 jmp 1b
21577 .popsection
21578 - _ASM_EXTABLE(1b,2b)
21579 + _ASM_EXTABLE(1b,4b)
21580 + _ASM_EXTABLE(2b,5b)
21581 + _ASM_EXTABLE(3b,6b)
21582 PTGS_TO_GS_EX
21583 ENDPROC(ia32_sysenter_target)
21584
21585 @@ -509,6 +702,11 @@ ENTRY(system_call)
21586 pushl_cfi %eax # save orig_eax
21587 SAVE_ALL
21588 GET_THREAD_INFO(%ebp)
21589 +
21590 +#ifdef CONFIG_PAX_RANDKSTACK
21591 + pax_erase_kstack
21592 +#endif
21593 +
21594 # system call tracing in operation / emulation
21595 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
21596 jnz syscall_trace_entry
21597 @@ -527,6 +725,15 @@ syscall_exit:
21598 testl $_TIF_ALLWORK_MASK, %ecx # current->work
21599 jne syscall_exit_work
21600
21601 +restore_all_pax:
21602 +
21603 +#ifdef CONFIG_PAX_RANDKSTACK
21604 + movl %esp, %eax
21605 + call pax_randomize_kstack
21606 +#endif
21607 +
21608 + pax_erase_kstack
21609 +
21610 restore_all:
21611 TRACE_IRQS_IRET
21612 restore_all_notrace:
21613 @@ -583,14 +790,34 @@ ldt_ss:
21614 * compensating for the offset by changing to the ESPFIX segment with
21615 * a base address that matches for the difference.
21616 */
21617 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
21618 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
21619 mov %esp, %edx /* load kernel esp */
21620 mov PT_OLDESP(%esp), %eax /* load userspace esp */
21621 mov %dx, %ax /* eax: new kernel esp */
21622 sub %eax, %edx /* offset (low word is 0) */
21623 +#ifdef CONFIG_SMP
21624 + movl PER_CPU_VAR(cpu_number), %ebx
21625 + shll $PAGE_SHIFT_asm, %ebx
21626 + addl $cpu_gdt_table, %ebx
21627 +#else
21628 + movl $cpu_gdt_table, %ebx
21629 +#endif
21630 shr $16, %edx
21631 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
21632 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
21633 +
21634 +#ifdef CONFIG_PAX_KERNEXEC
21635 + mov %cr0, %esi
21636 + btr $16, %esi
21637 + mov %esi, %cr0
21638 +#endif
21639 +
21640 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
21641 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
21642 +
21643 +#ifdef CONFIG_PAX_KERNEXEC
21644 + bts $16, %esi
21645 + mov %esi, %cr0
21646 +#endif
21647 +
21648 pushl_cfi $__ESPFIX_SS
21649 pushl_cfi %eax /* new kernel esp */
21650 /* Disable interrupts, but do not irqtrace this section: we
21651 @@ -619,20 +846,18 @@ work_resched:
21652 movl TI_flags(%ebp), %ecx
21653 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
21654 # than syscall tracing?
21655 - jz restore_all
21656 + jz restore_all_pax
21657 testb $_TIF_NEED_RESCHED, %cl
21658 jnz work_resched
21659
21660 work_notifysig: # deal with pending signals and
21661 # notify-resume requests
21662 + movl %esp, %eax
21663 #ifdef CONFIG_VM86
21664 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
21665 - movl %esp, %eax
21666 jne work_notifysig_v86 # returning to kernel-space or
21667 # vm86-space
21668 1:
21669 -#else
21670 - movl %esp, %eax
21671 #endif
21672 TRACE_IRQS_ON
21673 ENABLE_INTERRUPTS(CLBR_NONE)
21674 @@ -653,7 +878,7 @@ work_notifysig_v86:
21675 movl %eax, %esp
21676 jmp 1b
21677 #endif
21678 -END(work_pending)
21679 +ENDPROC(work_pending)
21680
21681 # perform syscall exit tracing
21682 ALIGN
21683 @@ -661,11 +886,14 @@ syscall_trace_entry:
21684 movl $-ENOSYS,PT_EAX(%esp)
21685 movl %esp, %eax
21686 call syscall_trace_enter
21687 +
21688 + pax_erase_kstack
21689 +
21690 /* What it returned is what we'll actually use. */
21691 cmpl $(NR_syscalls), %eax
21692 jnae syscall_call
21693 jmp syscall_exit
21694 -END(syscall_trace_entry)
21695 +ENDPROC(syscall_trace_entry)
21696
21697 # perform syscall exit tracing
21698 ALIGN
21699 @@ -678,21 +906,25 @@ syscall_exit_work:
21700 movl %esp, %eax
21701 call syscall_trace_leave
21702 jmp resume_userspace
21703 -END(syscall_exit_work)
21704 +ENDPROC(syscall_exit_work)
21705 CFI_ENDPROC
21706
21707 RING0_INT_FRAME # can't unwind into user space anyway
21708 syscall_fault:
21709 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21710 + push %ss
21711 + pop %ds
21712 +#endif
21713 ASM_CLAC
21714 GET_THREAD_INFO(%ebp)
21715 movl $-EFAULT,PT_EAX(%esp)
21716 jmp resume_userspace
21717 -END(syscall_fault)
21718 +ENDPROC(syscall_fault)
21719
21720 syscall_badsys:
21721 movl $-ENOSYS,PT_EAX(%esp)
21722 jmp resume_userspace
21723 -END(syscall_badsys)
21724 +ENDPROC(syscall_badsys)
21725 CFI_ENDPROC
21726 /*
21727 * End of kprobes section
21728 @@ -708,8 +940,15 @@ END(syscall_badsys)
21729 * normal stack and adjusts ESP with the matching offset.
21730 */
21731 /* fixup the stack */
21732 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
21733 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21734 +#ifdef CONFIG_SMP
21735 + movl PER_CPU_VAR(cpu_number), %ebx
21736 + shll $PAGE_SHIFT_asm, %ebx
21737 + addl $cpu_gdt_table, %ebx
21738 +#else
21739 + movl $cpu_gdt_table, %ebx
21740 +#endif
21741 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21742 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21743 shl $16, %eax
21744 addl %esp, %eax /* the adjusted stack pointer */
21745 pushl_cfi $__KERNEL_DS
21746 @@ -762,7 +1001,7 @@ vector=vector+1
21747 .endr
21748 2: jmp common_interrupt
21749 .endr
21750 -END(irq_entries_start)
21751 +ENDPROC(irq_entries_start)
21752
21753 .previous
21754 END(interrupt)
21755 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21756 pushl_cfi $do_coprocessor_error
21757 jmp error_code
21758 CFI_ENDPROC
21759 -END(coprocessor_error)
21760 +ENDPROC(coprocessor_error)
21761
21762 ENTRY(simd_coprocessor_error)
21763 RING0_INT_FRAME
21764 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21765 .section .altinstructions,"a"
21766 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21767 .previous
21768 -.section .altinstr_replacement,"ax"
21769 +.section .altinstr_replacement,"a"
21770 663: pushl $do_simd_coprocessor_error
21771 664:
21772 .previous
21773 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21774 #endif
21775 jmp error_code
21776 CFI_ENDPROC
21777 -END(simd_coprocessor_error)
21778 +ENDPROC(simd_coprocessor_error)
21779
21780 ENTRY(device_not_available)
21781 RING0_INT_FRAME
21782 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21783 pushl_cfi $do_device_not_available
21784 jmp error_code
21785 CFI_ENDPROC
21786 -END(device_not_available)
21787 +ENDPROC(device_not_available)
21788
21789 #ifdef CONFIG_PARAVIRT
21790 ENTRY(native_iret)
21791 iret
21792 _ASM_EXTABLE(native_iret, iret_exc)
21793 -END(native_iret)
21794 +ENDPROC(native_iret)
21795
21796 ENTRY(native_irq_enable_sysexit)
21797 sti
21798 sysexit
21799 -END(native_irq_enable_sysexit)
21800 +ENDPROC(native_irq_enable_sysexit)
21801 #endif
21802
21803 ENTRY(overflow)
21804 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21805 pushl_cfi $do_overflow
21806 jmp error_code
21807 CFI_ENDPROC
21808 -END(overflow)
21809 +ENDPROC(overflow)
21810
21811 ENTRY(bounds)
21812 RING0_INT_FRAME
21813 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21814 pushl_cfi $do_bounds
21815 jmp error_code
21816 CFI_ENDPROC
21817 -END(bounds)
21818 +ENDPROC(bounds)
21819
21820 ENTRY(invalid_op)
21821 RING0_INT_FRAME
21822 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21823 pushl_cfi $do_invalid_op
21824 jmp error_code
21825 CFI_ENDPROC
21826 -END(invalid_op)
21827 +ENDPROC(invalid_op)
21828
21829 ENTRY(coprocessor_segment_overrun)
21830 RING0_INT_FRAME
21831 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21832 pushl_cfi $do_coprocessor_segment_overrun
21833 jmp error_code
21834 CFI_ENDPROC
21835 -END(coprocessor_segment_overrun)
21836 +ENDPROC(coprocessor_segment_overrun)
21837
21838 ENTRY(invalid_TSS)
21839 RING0_EC_FRAME
21840 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21841 pushl_cfi $do_invalid_TSS
21842 jmp error_code
21843 CFI_ENDPROC
21844 -END(invalid_TSS)
21845 +ENDPROC(invalid_TSS)
21846
21847 ENTRY(segment_not_present)
21848 RING0_EC_FRAME
21849 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21850 pushl_cfi $do_segment_not_present
21851 jmp error_code
21852 CFI_ENDPROC
21853 -END(segment_not_present)
21854 +ENDPROC(segment_not_present)
21855
21856 ENTRY(stack_segment)
21857 RING0_EC_FRAME
21858 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21859 pushl_cfi $do_stack_segment
21860 jmp error_code
21861 CFI_ENDPROC
21862 -END(stack_segment)
21863 +ENDPROC(stack_segment)
21864
21865 ENTRY(alignment_check)
21866 RING0_EC_FRAME
21867 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21868 pushl_cfi $do_alignment_check
21869 jmp error_code
21870 CFI_ENDPROC
21871 -END(alignment_check)
21872 +ENDPROC(alignment_check)
21873
21874 ENTRY(divide_error)
21875 RING0_INT_FRAME
21876 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21877 pushl_cfi $do_divide_error
21878 jmp error_code
21879 CFI_ENDPROC
21880 -END(divide_error)
21881 +ENDPROC(divide_error)
21882
21883 #ifdef CONFIG_X86_MCE
21884 ENTRY(machine_check)
21885 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21886 pushl_cfi machine_check_vector
21887 jmp error_code
21888 CFI_ENDPROC
21889 -END(machine_check)
21890 +ENDPROC(machine_check)
21891 #endif
21892
21893 ENTRY(spurious_interrupt_bug)
21894 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21895 pushl_cfi $do_spurious_interrupt_bug
21896 jmp error_code
21897 CFI_ENDPROC
21898 -END(spurious_interrupt_bug)
21899 +ENDPROC(spurious_interrupt_bug)
21900 /*
21901 * End of kprobes section
21902 */
21903 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21904
21905 ENTRY(mcount)
21906 ret
21907 -END(mcount)
21908 +ENDPROC(mcount)
21909
21910 ENTRY(ftrace_caller)
21911 cmpl $0, function_trace_stop
21912 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21913 .globl ftrace_stub
21914 ftrace_stub:
21915 ret
21916 -END(ftrace_caller)
21917 +ENDPROC(ftrace_caller)
21918
21919 ENTRY(ftrace_regs_caller)
21920 pushf /* push flags before compare (in cs location) */
21921 @@ -1210,7 +1449,7 @@ trace:
21922 popl %ecx
21923 popl %eax
21924 jmp ftrace_stub
21925 -END(mcount)
21926 +ENDPROC(mcount)
21927 #endif /* CONFIG_DYNAMIC_FTRACE */
21928 #endif /* CONFIG_FUNCTION_TRACER */
21929
21930 @@ -1228,7 +1467,7 @@ ENTRY(ftrace_graph_caller)
21931 popl %ecx
21932 popl %eax
21933 ret
21934 -END(ftrace_graph_caller)
21935 +ENDPROC(ftrace_graph_caller)
21936
21937 .globl return_to_handler
21938 return_to_handler:
21939 @@ -1284,15 +1523,18 @@ error_code:
21940 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21941 REG_TO_PTGS %ecx
21942 SET_KERNEL_GS %ecx
21943 - movl $(__USER_DS), %ecx
21944 + movl $(__KERNEL_DS), %ecx
21945 movl %ecx, %ds
21946 movl %ecx, %es
21947 +
21948 + pax_enter_kernel
21949 +
21950 TRACE_IRQS_OFF
21951 movl %esp,%eax # pt_regs pointer
21952 call *%edi
21953 jmp ret_from_exception
21954 CFI_ENDPROC
21955 -END(page_fault)
21956 +ENDPROC(page_fault)
21957
21958 /*
21959 * Debug traps and NMI can happen at the one SYSENTER instruction
21960 @@ -1335,7 +1577,7 @@ debug_stack_correct:
21961 call do_debug
21962 jmp ret_from_exception
21963 CFI_ENDPROC
21964 -END(debug)
21965 +ENDPROC(debug)
21966
21967 /*
21968 * NMI is doubly nasty. It can happen _while_ we're handling
21969 @@ -1373,6 +1615,9 @@ nmi_stack_correct:
21970 xorl %edx,%edx # zero error code
21971 movl %esp,%eax # pt_regs pointer
21972 call do_nmi
21973 +
21974 + pax_exit_kernel
21975 +
21976 jmp restore_all_notrace
21977 CFI_ENDPROC
21978
21979 @@ -1409,12 +1654,15 @@ nmi_espfix_stack:
21980 FIXUP_ESPFIX_STACK # %eax == %esp
21981 xorl %edx,%edx # zero error code
21982 call do_nmi
21983 +
21984 + pax_exit_kernel
21985 +
21986 RESTORE_REGS
21987 lss 12+4(%esp), %esp # back to espfix stack
21988 CFI_ADJUST_CFA_OFFSET -24
21989 jmp irq_return
21990 CFI_ENDPROC
21991 -END(nmi)
21992 +ENDPROC(nmi)
21993
21994 ENTRY(int3)
21995 RING0_INT_FRAME
21996 @@ -1427,14 +1675,14 @@ ENTRY(int3)
21997 call do_int3
21998 jmp ret_from_exception
21999 CFI_ENDPROC
22000 -END(int3)
22001 +ENDPROC(int3)
22002
22003 ENTRY(general_protection)
22004 RING0_EC_FRAME
22005 pushl_cfi $do_general_protection
22006 jmp error_code
22007 CFI_ENDPROC
22008 -END(general_protection)
22009 +ENDPROC(general_protection)
22010
22011 #ifdef CONFIG_KVM_GUEST
22012 ENTRY(async_page_fault)
22013 @@ -1443,7 +1691,7 @@ ENTRY(async_page_fault)
22014 pushl_cfi $do_async_page_fault
22015 jmp error_code
22016 CFI_ENDPROC
22017 -END(async_page_fault)
22018 +ENDPROC(async_page_fault)
22019 #endif
22020
22021 /*
22022 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
22023 index b077f4c..8e0df9f 100644
22024 --- a/arch/x86/kernel/entry_64.S
22025 +++ b/arch/x86/kernel/entry_64.S
22026 @@ -59,6 +59,8 @@
22027 #include <asm/context_tracking.h>
22028 #include <asm/smap.h>
22029 #include <linux/err.h>
22030 +#include <asm/pgtable.h>
22031 +#include <asm/alternative-asm.h>
22032
22033 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
22034 #include <linux/elf-em.h>
22035 @@ -80,8 +82,9 @@
22036 #ifdef CONFIG_DYNAMIC_FTRACE
22037
22038 ENTRY(function_hook)
22039 + pax_force_retaddr
22040 retq
22041 -END(function_hook)
22042 +ENDPROC(function_hook)
22043
22044 /* skip is set if stack has been adjusted */
22045 .macro ftrace_caller_setup skip=0
22046 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
22047 #endif
22048
22049 GLOBAL(ftrace_stub)
22050 + pax_force_retaddr
22051 retq
22052 -END(ftrace_caller)
22053 +ENDPROC(ftrace_caller)
22054
22055 ENTRY(ftrace_regs_caller)
22056 /* Save the current flags before compare (in SS location)*/
22057 @@ -191,7 +195,7 @@ ftrace_restore_flags:
22058 popfq
22059 jmp ftrace_stub
22060
22061 -END(ftrace_regs_caller)
22062 +ENDPROC(ftrace_regs_caller)
22063
22064
22065 #else /* ! CONFIG_DYNAMIC_FTRACE */
22066 @@ -212,6 +216,7 @@ ENTRY(function_hook)
22067 #endif
22068
22069 GLOBAL(ftrace_stub)
22070 + pax_force_retaddr
22071 retq
22072
22073 trace:
22074 @@ -225,12 +230,13 @@ trace:
22075 #endif
22076 subq $MCOUNT_INSN_SIZE, %rdi
22077
22078 + pax_force_fptr ftrace_trace_function
22079 call *ftrace_trace_function
22080
22081 MCOUNT_RESTORE_FRAME
22082
22083 jmp ftrace_stub
22084 -END(function_hook)
22085 +ENDPROC(function_hook)
22086 #endif /* CONFIG_DYNAMIC_FTRACE */
22087 #endif /* CONFIG_FUNCTION_TRACER */
22088
22089 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
22090
22091 MCOUNT_RESTORE_FRAME
22092
22093 + pax_force_retaddr
22094 retq
22095 -END(ftrace_graph_caller)
22096 +ENDPROC(ftrace_graph_caller)
22097
22098 GLOBAL(return_to_handler)
22099 subq $24, %rsp
22100 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
22101 movq 8(%rsp), %rdx
22102 movq (%rsp), %rax
22103 addq $24, %rsp
22104 + pax_force_fptr %rdi
22105 jmp *%rdi
22106 +ENDPROC(return_to_handler)
22107 #endif
22108
22109
22110 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
22111 ENDPROC(native_usergs_sysret64)
22112 #endif /* CONFIG_PARAVIRT */
22113
22114 + .macro ljmpq sel, off
22115 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
22116 + .byte 0x48; ljmp *1234f(%rip)
22117 + .pushsection .rodata
22118 + .align 16
22119 + 1234: .quad \off; .word \sel
22120 + .popsection
22121 +#else
22122 + pushq $\sel
22123 + pushq $\off
22124 + lretq
22125 +#endif
22126 + .endm
22127 +
22128 + .macro pax_enter_kernel
22129 + pax_set_fptr_mask
22130 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22131 + call pax_enter_kernel
22132 +#endif
22133 + .endm
22134 +
22135 + .macro pax_exit_kernel
22136 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22137 + call pax_exit_kernel
22138 +#endif
22139 +
22140 + .endm
22141 +
22142 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22143 +ENTRY(pax_enter_kernel)
22144 + pushq %rdi
22145 +
22146 +#ifdef CONFIG_PARAVIRT
22147 + PV_SAVE_REGS(CLBR_RDI)
22148 +#endif
22149 +
22150 +#ifdef CONFIG_PAX_KERNEXEC
22151 + GET_CR0_INTO_RDI
22152 + bts $16,%rdi
22153 + jnc 3f
22154 + mov %cs,%edi
22155 + cmp $__KERNEL_CS,%edi
22156 + jnz 2f
22157 +1:
22158 +#endif
22159 +
22160 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22161 + 661: jmp 111f
22162 + .pushsection .altinstr_replacement, "a"
22163 + 662: ASM_NOP2
22164 + .popsection
22165 + .pushsection .altinstructions, "a"
22166 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22167 + .popsection
22168 + GET_CR3_INTO_RDI
22169 + cmp $0,%dil
22170 + jnz 112f
22171 + mov $__KERNEL_DS,%edi
22172 + mov %edi,%ss
22173 + jmp 111f
22174 +112: cmp $1,%dil
22175 + jz 113f
22176 + ud2
22177 +113: sub $4097,%rdi
22178 + bts $63,%rdi
22179 + SET_RDI_INTO_CR3
22180 + mov $__UDEREF_KERNEL_DS,%edi
22181 + mov %edi,%ss
22182 +111:
22183 +#endif
22184 +
22185 +#ifdef CONFIG_PARAVIRT
22186 + PV_RESTORE_REGS(CLBR_RDI)
22187 +#endif
22188 +
22189 + popq %rdi
22190 + pax_force_retaddr
22191 + retq
22192 +
22193 +#ifdef CONFIG_PAX_KERNEXEC
22194 +2: ljmpq __KERNEL_CS,1b
22195 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
22196 +4: SET_RDI_INTO_CR0
22197 + jmp 1b
22198 +#endif
22199 +ENDPROC(pax_enter_kernel)
22200 +
22201 +ENTRY(pax_exit_kernel)
22202 + pushq %rdi
22203 +
22204 +#ifdef CONFIG_PARAVIRT
22205 + PV_SAVE_REGS(CLBR_RDI)
22206 +#endif
22207 +
22208 +#ifdef CONFIG_PAX_KERNEXEC
22209 + mov %cs,%rdi
22210 + cmp $__KERNEXEC_KERNEL_CS,%edi
22211 + jz 2f
22212 + GET_CR0_INTO_RDI
22213 + bts $16,%rdi
22214 + jnc 4f
22215 +1:
22216 +#endif
22217 +
22218 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22219 + 661: jmp 111f
22220 + .pushsection .altinstr_replacement, "a"
22221 + 662: ASM_NOP2
22222 + .popsection
22223 + .pushsection .altinstructions, "a"
22224 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22225 + .popsection
22226 + mov %ss,%edi
22227 + cmp $__UDEREF_KERNEL_DS,%edi
22228 + jnz 111f
22229 + GET_CR3_INTO_RDI
22230 + cmp $0,%dil
22231 + jz 112f
22232 + ud2
22233 +112: add $4097,%rdi
22234 + bts $63,%rdi
22235 + SET_RDI_INTO_CR3
22236 + mov $__KERNEL_DS,%edi
22237 + mov %edi,%ss
22238 +111:
22239 +#endif
22240 +
22241 +#ifdef CONFIG_PARAVIRT
22242 + PV_RESTORE_REGS(CLBR_RDI);
22243 +#endif
22244 +
22245 + popq %rdi
22246 + pax_force_retaddr
22247 + retq
22248 +
22249 +#ifdef CONFIG_PAX_KERNEXEC
22250 +2: GET_CR0_INTO_RDI
22251 + btr $16,%rdi
22252 + jnc 4f
22253 + ljmpq __KERNEL_CS,3f
22254 +3: SET_RDI_INTO_CR0
22255 + jmp 1b
22256 +4: ud2
22257 + jmp 4b
22258 +#endif
22259 +ENDPROC(pax_exit_kernel)
22260 +#endif
22261 +
22262 + .macro pax_enter_kernel_user
22263 + pax_set_fptr_mask
22264 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22265 + call pax_enter_kernel_user
22266 +#endif
22267 + .endm
22268 +
22269 + .macro pax_exit_kernel_user
22270 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22271 + call pax_exit_kernel_user
22272 +#endif
22273 +#ifdef CONFIG_PAX_RANDKSTACK
22274 + pushq %rax
22275 + pushq %r11
22276 + call pax_randomize_kstack
22277 + popq %r11
22278 + popq %rax
22279 +#endif
22280 + .endm
22281 +
22282 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22283 +ENTRY(pax_enter_kernel_user)
22284 + pushq %rdi
22285 + pushq %rbx
22286 +
22287 +#ifdef CONFIG_PARAVIRT
22288 + PV_SAVE_REGS(CLBR_RDI)
22289 +#endif
22290 +
22291 + 661: jmp 111f
22292 + .pushsection .altinstr_replacement, "a"
22293 + 662: ASM_NOP2
22294 + .popsection
22295 + .pushsection .altinstructions, "a"
22296 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22297 + .popsection
22298 + GET_CR3_INTO_RDI
22299 + cmp $1,%dil
22300 + jnz 4f
22301 + sub $4097,%rdi
22302 + bts $63,%rdi
22303 + SET_RDI_INTO_CR3
22304 + jmp 3f
22305 +111:
22306 +
22307 + GET_CR3_INTO_RDI
22308 + mov %rdi,%rbx
22309 + add $__START_KERNEL_map,%rbx
22310 + sub phys_base(%rip),%rbx
22311 +
22312 +#ifdef CONFIG_PARAVIRT
22313 + cmpl $0, pv_info+PARAVIRT_enabled
22314 + jz 1f
22315 + pushq %rdi
22316 + i = 0
22317 + .rept USER_PGD_PTRS
22318 + mov i*8(%rbx),%rsi
22319 + mov $0,%sil
22320 + lea i*8(%rbx),%rdi
22321 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
22322 + i = i + 1
22323 + .endr
22324 + popq %rdi
22325 + jmp 2f
22326 +1:
22327 +#endif
22328 +
22329 + i = 0
22330 + .rept USER_PGD_PTRS
22331 + movb $0,i*8(%rbx)
22332 + i = i + 1
22333 + .endr
22334 +
22335 +2: SET_RDI_INTO_CR3
22336 +
22337 +#ifdef CONFIG_PAX_KERNEXEC
22338 + GET_CR0_INTO_RDI
22339 + bts $16,%rdi
22340 + SET_RDI_INTO_CR0
22341 +#endif
22342 +
22343 +3:
22344 +
22345 +#ifdef CONFIG_PARAVIRT
22346 + PV_RESTORE_REGS(CLBR_RDI)
22347 +#endif
22348 +
22349 + popq %rbx
22350 + popq %rdi
22351 + pax_force_retaddr
22352 + retq
22353 +4: ud2
22354 +ENDPROC(pax_enter_kernel_user)
22355 +
22356 +ENTRY(pax_exit_kernel_user)
22357 + pushq %rdi
22358 + pushq %rbx
22359 +
22360 +#ifdef CONFIG_PARAVIRT
22361 + PV_SAVE_REGS(CLBR_RDI)
22362 +#endif
22363 +
22364 + GET_CR3_INTO_RDI
22365 + 661: jmp 1f
22366 + .pushsection .altinstr_replacement, "a"
22367 + 662: ASM_NOP2
22368 + .popsection
22369 + .pushsection .altinstructions, "a"
22370 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22371 + .popsection
22372 + cmp $0,%dil
22373 + jnz 3f
22374 + add $4097,%rdi
22375 + bts $63,%rdi
22376 + SET_RDI_INTO_CR3
22377 + jmp 2f
22378 +1:
22379 +
22380 + mov %rdi,%rbx
22381 +
22382 +#ifdef CONFIG_PAX_KERNEXEC
22383 + GET_CR0_INTO_RDI
22384 + btr $16,%rdi
22385 + jnc 3f
22386 + SET_RDI_INTO_CR0
22387 +#endif
22388 +
22389 + add $__START_KERNEL_map,%rbx
22390 + sub phys_base(%rip),%rbx
22391 +
22392 +#ifdef CONFIG_PARAVIRT
22393 + cmpl $0, pv_info+PARAVIRT_enabled
22394 + jz 1f
22395 + i = 0
22396 + .rept USER_PGD_PTRS
22397 + mov i*8(%rbx),%rsi
22398 + mov $0x67,%sil
22399 + lea i*8(%rbx),%rdi
22400 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
22401 + i = i + 1
22402 + .endr
22403 + jmp 2f
22404 +1:
22405 +#endif
22406 +
22407 + i = 0
22408 + .rept USER_PGD_PTRS
22409 + movb $0x67,i*8(%rbx)
22410 + i = i + 1
22411 + .endr
22412 +2:
22413 +
22414 +#ifdef CONFIG_PARAVIRT
22415 + PV_RESTORE_REGS(CLBR_RDI)
22416 +#endif
22417 +
22418 + popq %rbx
22419 + popq %rdi
22420 + pax_force_retaddr
22421 + retq
22422 +3: ud2
22423 +ENDPROC(pax_exit_kernel_user)
22424 +#endif
22425 +
22426 + .macro pax_enter_kernel_nmi
22427 + pax_set_fptr_mask
22428 +
22429 +#ifdef CONFIG_PAX_KERNEXEC
22430 + GET_CR0_INTO_RDI
22431 + bts $16,%rdi
22432 + jc 110f
22433 + SET_RDI_INTO_CR0
22434 + or $2,%ebx
22435 +110:
22436 +#endif
22437 +
22438 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22439 + 661: jmp 111f
22440 + .pushsection .altinstr_replacement, "a"
22441 + 662: ASM_NOP2
22442 + .popsection
22443 + .pushsection .altinstructions, "a"
22444 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22445 + .popsection
22446 + GET_CR3_INTO_RDI
22447 + cmp $0,%dil
22448 + jz 111f
22449 + sub $4097,%rdi
22450 + or $4,%ebx
22451 + bts $63,%rdi
22452 + SET_RDI_INTO_CR3
22453 + mov $__UDEREF_KERNEL_DS,%edi
22454 + mov %edi,%ss
22455 +111:
22456 +#endif
22457 + .endm
22458 +
22459 + .macro pax_exit_kernel_nmi
22460 +#ifdef CONFIG_PAX_KERNEXEC
22461 + btr $1,%ebx
22462 + jnc 110f
22463 + GET_CR0_INTO_RDI
22464 + btr $16,%rdi
22465 + SET_RDI_INTO_CR0
22466 +110:
22467 +#endif
22468 +
22469 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22470 + btr $2,%ebx
22471 + jnc 111f
22472 + GET_CR3_INTO_RDI
22473 + add $4097,%rdi
22474 + bts $63,%rdi
22475 + SET_RDI_INTO_CR3
22476 + mov $__KERNEL_DS,%edi
22477 + mov %edi,%ss
22478 +111:
22479 +#endif
22480 + .endm
22481 +
22482 + .macro pax_erase_kstack
22483 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
22484 + call pax_erase_kstack
22485 +#endif
22486 + .endm
22487 +
22488 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
22489 +ENTRY(pax_erase_kstack)
22490 + pushq %rdi
22491 + pushq %rcx
22492 + pushq %rax
22493 + pushq %r11
22494 +
22495 + GET_THREAD_INFO(%r11)
22496 + mov TI_lowest_stack(%r11), %rdi
22497 + mov $-0xBEEF, %rax
22498 + std
22499 +
22500 +1: mov %edi, %ecx
22501 + and $THREAD_SIZE_asm - 1, %ecx
22502 + shr $3, %ecx
22503 + repne scasq
22504 + jecxz 2f
22505 +
22506 + cmp $2*8, %ecx
22507 + jc 2f
22508 +
22509 + mov $2*8, %ecx
22510 + repe scasq
22511 + jecxz 2f
22512 + jne 1b
22513 +
22514 +2: cld
22515 + mov %esp, %ecx
22516 + sub %edi, %ecx
22517 +
22518 + cmp $THREAD_SIZE_asm, %rcx
22519 + jb 3f
22520 + ud2
22521 +3:
22522 +
22523 + shr $3, %ecx
22524 + rep stosq
22525 +
22526 + mov TI_task_thread_sp0(%r11), %rdi
22527 + sub $256, %rdi
22528 + mov %rdi, TI_lowest_stack(%r11)
22529 +
22530 + popq %r11
22531 + popq %rax
22532 + popq %rcx
22533 + popq %rdi
22534 + pax_force_retaddr
22535 + ret
22536 +ENDPROC(pax_erase_kstack)
22537 +#endif
22538
22539 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
22540 #ifdef CONFIG_TRACE_IRQFLAGS
22541 @@ -320,7 +753,7 @@ ENDPROC(native_usergs_sysret64)
22542 .endm
22543
22544 .macro TRACE_IRQS_IRETQ_DEBUG offset=ARGOFFSET
22545 - bt $9,EFLAGS-\offset(%rsp) /* interrupts off? */
22546 + bt $X86_EFLAGS_IF_BIT,EFLAGS-\offset(%rsp) /* interrupts off? */
22547 jnc 1f
22548 TRACE_IRQS_ON_DEBUG
22549 1:
22550 @@ -358,27 +791,6 @@ ENDPROC(native_usergs_sysret64)
22551 movq \tmp,R11+\offset(%rsp)
22552 .endm
22553
22554 - .macro FAKE_STACK_FRAME child_rip
22555 - /* push in order ss, rsp, eflags, cs, rip */
22556 - xorl %eax, %eax
22557 - pushq_cfi $__KERNEL_DS /* ss */
22558 - /*CFI_REL_OFFSET ss,0*/
22559 - pushq_cfi %rax /* rsp */
22560 - CFI_REL_OFFSET rsp,0
22561 - pushq_cfi $(X86_EFLAGS_IF|X86_EFLAGS_FIXED) /* eflags - interrupts on */
22562 - /*CFI_REL_OFFSET rflags,0*/
22563 - pushq_cfi $__KERNEL_CS /* cs */
22564 - /*CFI_REL_OFFSET cs,0*/
22565 - pushq_cfi \child_rip /* rip */
22566 - CFI_REL_OFFSET rip,0
22567 - pushq_cfi %rax /* orig rax */
22568 - .endm
22569 -
22570 - .macro UNFAKE_STACK_FRAME
22571 - addq $8*6, %rsp
22572 - CFI_ADJUST_CFA_OFFSET -(6*8)
22573 - .endm
22574 -
22575 /*
22576 * initial frame state for interrupts (and exceptions without error code)
22577 */
22578 @@ -445,25 +857,26 @@ ENDPROC(native_usergs_sysret64)
22579 /* save partial stack frame */
22580 .macro SAVE_ARGS_IRQ
22581 cld
22582 - /* start from rbp in pt_regs and jump over */
22583 - movq_cfi rdi, (RDI-RBP)
22584 - movq_cfi rsi, (RSI-RBP)
22585 - movq_cfi rdx, (RDX-RBP)
22586 - movq_cfi rcx, (RCX-RBP)
22587 - movq_cfi rax, (RAX-RBP)
22588 - movq_cfi r8, (R8-RBP)
22589 - movq_cfi r9, (R9-RBP)
22590 - movq_cfi r10, (R10-RBP)
22591 - movq_cfi r11, (R11-RBP)
22592 + /* start from r15 in pt_regs and jump over */
22593 + movq_cfi rdi, RDI
22594 + movq_cfi rsi, RSI
22595 + movq_cfi rdx, RDX
22596 + movq_cfi rcx, RCX
22597 + movq_cfi rax, RAX
22598 + movq_cfi r8, R8
22599 + movq_cfi r9, R9
22600 + movq_cfi r10, R10
22601 + movq_cfi r11, R11
22602 + movq_cfi r12, R12
22603
22604 /* Save rbp so that we can unwind from get_irq_regs() */
22605 - movq_cfi rbp, 0
22606 + movq_cfi rbp, RBP
22607
22608 /* Save previous stack value */
22609 movq %rsp, %rsi
22610
22611 - leaq -RBP(%rsp),%rdi /* arg1 for handler */
22612 - testl $3, CS-RBP(%rsi)
22613 + movq %rsp,%rdi /* arg1 for handler */
22614 + testb $3, CS(%rsi)
22615 je 1f
22616 SWAPGS
22617 /*
22618 @@ -514,9 +927,10 @@ ENTRY(save_paranoid)
22619 js 1f /* negative -> in kernel */
22620 SWAPGS
22621 xorl %ebx,%ebx
22622 -1: ret
22623 +1: pax_force_retaddr_bts
22624 + ret
22625 CFI_ENDPROC
22626 -END(save_paranoid)
22627 +ENDPROC(save_paranoid)
22628 .popsection
22629
22630 /*
22631 @@ -538,7 +952,7 @@ ENTRY(ret_from_fork)
22632
22633 RESTORE_REST
22634
22635 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
22636 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
22637 jz 1f
22638
22639 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
22640 @@ -548,15 +962,13 @@ ENTRY(ret_from_fork)
22641 jmp ret_from_sys_call # go to the SYSRET fastpath
22642
22643 1:
22644 - subq $REST_SKIP, %rsp # leave space for volatiles
22645 - CFI_ADJUST_CFA_OFFSET REST_SKIP
22646 movq %rbp, %rdi
22647 call *%rbx
22648 movl $0, RAX(%rsp)
22649 RESTORE_REST
22650 jmp int_ret_from_sys_call
22651 CFI_ENDPROC
22652 -END(ret_from_fork)
22653 +ENDPROC(ret_from_fork)
22654
22655 /*
22656 * System call entry. Up to 6 arguments in registers are supported.
22657 @@ -593,7 +1005,7 @@ END(ret_from_fork)
22658 ENTRY(system_call)
22659 CFI_STARTPROC simple
22660 CFI_SIGNAL_FRAME
22661 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
22662 + CFI_DEF_CFA rsp,0
22663 CFI_REGISTER rip,rcx
22664 /*CFI_REGISTER rflags,r11*/
22665 SWAPGS_UNSAFE_STACK
22666 @@ -606,16 +1018,23 @@ GLOBAL(system_call_after_swapgs)
22667
22668 movq %rsp,PER_CPU_VAR(old_rsp)
22669 movq PER_CPU_VAR(kernel_stack),%rsp
22670 + SAVE_ARGS 8*6,0
22671 + pax_enter_kernel_user
22672 +
22673 +#ifdef CONFIG_PAX_RANDKSTACK
22674 + pax_erase_kstack
22675 +#endif
22676 +
22677 /*
22678 * No need to follow this irqs off/on section - it's straight
22679 * and short:
22680 */
22681 ENABLE_INTERRUPTS(CLBR_NONE)
22682 - SAVE_ARGS 8,0
22683 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
22684 movq %rcx,RIP-ARGOFFSET(%rsp)
22685 CFI_REL_OFFSET rip,RIP-ARGOFFSET
22686 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
22687 + GET_THREAD_INFO(%rcx)
22688 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
22689 jnz tracesys
22690 system_call_fastpath:
22691 #if __SYSCALL_MASK == ~0
22692 @@ -639,10 +1058,13 @@ sysret_check:
22693 LOCKDEP_SYS_EXIT
22694 DISABLE_INTERRUPTS(CLBR_NONE)
22695 TRACE_IRQS_OFF
22696 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
22697 + GET_THREAD_INFO(%rcx)
22698 + movl TI_flags(%rcx),%edx
22699 andl %edi,%edx
22700 jnz sysret_careful
22701 CFI_REMEMBER_STATE
22702 + pax_exit_kernel_user
22703 + pax_erase_kstack
22704 /*
22705 * sysretq will re-enable interrupts:
22706 */
22707 @@ -701,6 +1123,9 @@ auditsys:
22708 movq %rax,%rsi /* 2nd arg: syscall number */
22709 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
22710 call __audit_syscall_entry
22711 +
22712 + pax_erase_kstack
22713 +
22714 LOAD_ARGS 0 /* reload call-clobbered registers */
22715 jmp system_call_fastpath
22716
22717 @@ -722,7 +1147,7 @@ sysret_audit:
22718 /* Do syscall tracing */
22719 tracesys:
22720 #ifdef CONFIG_AUDITSYSCALL
22721 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
22722 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
22723 jz auditsys
22724 #endif
22725 SAVE_REST
22726 @@ -730,12 +1155,15 @@ tracesys:
22727 FIXUP_TOP_OF_STACK %rdi
22728 movq %rsp,%rdi
22729 call syscall_trace_enter
22730 +
22731 + pax_erase_kstack
22732 +
22733 /*
22734 * Reload arg registers from stack in case ptrace changed them.
22735 * We don't reload %rax because syscall_trace_enter() returned
22736 * the value it wants us to use in the table lookup.
22737 */
22738 - LOAD_ARGS ARGOFFSET, 1
22739 + LOAD_ARGS 1
22740 RESTORE_REST
22741 #if __SYSCALL_MASK == ~0
22742 cmpq $__NR_syscall_max,%rax
22743 @@ -765,7 +1193,9 @@ GLOBAL(int_with_check)
22744 andl %edi,%edx
22745 jnz int_careful
22746 andl $~TS_COMPAT,TI_status(%rcx)
22747 - jmp retint_swapgs
22748 + pax_exit_kernel_user
22749 + pax_erase_kstack
22750 + jmp retint_swapgs_pax
22751
22752 /* Either reschedule or signal or syscall exit tracking needed. */
22753 /* First do a reschedule test. */
22754 @@ -811,7 +1241,7 @@ int_restore_rest:
22755 TRACE_IRQS_OFF
22756 jmp int_with_check
22757 CFI_ENDPROC
22758 -END(system_call)
22759 +ENDPROC(system_call)
22760
22761 .macro FORK_LIKE func
22762 ENTRY(stub_\func)
22763 @@ -824,9 +1254,10 @@ ENTRY(stub_\func)
22764 DEFAULT_FRAME 0 8 /* offset 8: return address */
22765 call sys_\func
22766 RESTORE_TOP_OF_STACK %r11, 8
22767 - ret $REST_SKIP /* pop extended registers */
22768 + pax_force_retaddr
22769 + ret
22770 CFI_ENDPROC
22771 -END(stub_\func)
22772 +ENDPROC(stub_\func)
22773 .endm
22774
22775 .macro FIXED_FRAME label,func
22776 @@ -836,9 +1267,10 @@ ENTRY(\label)
22777 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22778 call \func
22779 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22780 + pax_force_retaddr
22781 ret
22782 CFI_ENDPROC
22783 -END(\label)
22784 +ENDPROC(\label)
22785 .endm
22786
22787 FORK_LIKE clone
22788 @@ -846,19 +1278,6 @@ END(\label)
22789 FORK_LIKE vfork
22790 FIXED_FRAME stub_iopl, sys_iopl
22791
22792 -ENTRY(ptregscall_common)
22793 - DEFAULT_FRAME 1 8 /* offset 8: return address */
22794 - RESTORE_TOP_OF_STACK %r11, 8
22795 - movq_cfi_restore R15+8, r15
22796 - movq_cfi_restore R14+8, r14
22797 - movq_cfi_restore R13+8, r13
22798 - movq_cfi_restore R12+8, r12
22799 - movq_cfi_restore RBP+8, rbp
22800 - movq_cfi_restore RBX+8, rbx
22801 - ret $REST_SKIP /* pop extended registers */
22802 - CFI_ENDPROC
22803 -END(ptregscall_common)
22804 -
22805 ENTRY(stub_execve)
22806 CFI_STARTPROC
22807 addq $8, %rsp
22808 @@ -870,7 +1289,7 @@ ENTRY(stub_execve)
22809 RESTORE_REST
22810 jmp int_ret_from_sys_call
22811 CFI_ENDPROC
22812 -END(stub_execve)
22813 +ENDPROC(stub_execve)
22814
22815 /*
22816 * sigreturn is special because it needs to restore all registers on return.
22817 @@ -887,7 +1306,7 @@ ENTRY(stub_rt_sigreturn)
22818 RESTORE_REST
22819 jmp int_ret_from_sys_call
22820 CFI_ENDPROC
22821 -END(stub_rt_sigreturn)
22822 +ENDPROC(stub_rt_sigreturn)
22823
22824 #ifdef CONFIG_X86_X32_ABI
22825 ENTRY(stub_x32_rt_sigreturn)
22826 @@ -901,7 +1320,7 @@ ENTRY(stub_x32_rt_sigreturn)
22827 RESTORE_REST
22828 jmp int_ret_from_sys_call
22829 CFI_ENDPROC
22830 -END(stub_x32_rt_sigreturn)
22831 +ENDPROC(stub_x32_rt_sigreturn)
22832
22833 ENTRY(stub_x32_execve)
22834 CFI_STARTPROC
22835 @@ -915,7 +1334,7 @@ ENTRY(stub_x32_execve)
22836 RESTORE_REST
22837 jmp int_ret_from_sys_call
22838 CFI_ENDPROC
22839 -END(stub_x32_execve)
22840 +ENDPROC(stub_x32_execve)
22841
22842 #endif
22843
22844 @@ -952,7 +1371,7 @@ vector=vector+1
22845 2: jmp common_interrupt
22846 .endr
22847 CFI_ENDPROC
22848 -END(irq_entries_start)
22849 +ENDPROC(irq_entries_start)
22850
22851 .previous
22852 END(interrupt)
22853 @@ -969,9 +1388,19 @@ END(interrupt)
22854 /* 0(%rsp): ~(interrupt number) */
22855 .macro interrupt func
22856 /* reserve pt_regs for scratch regs and rbp */
22857 - subq $ORIG_RAX-RBP, %rsp
22858 - CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22859 + subq $ORIG_RAX, %rsp
22860 + CFI_ADJUST_CFA_OFFSET ORIG_RAX
22861 SAVE_ARGS_IRQ
22862 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22863 + testb $3, CS(%rdi)
22864 + jnz 1f
22865 + pax_enter_kernel
22866 + jmp 2f
22867 +1: pax_enter_kernel_user
22868 +2:
22869 +#else
22870 + pax_enter_kernel
22871 +#endif
22872 call \func
22873 .endm
22874
22875 @@ -997,14 +1426,14 @@ ret_from_intr:
22876
22877 /* Restore saved previous stack */
22878 popq %rsi
22879 - CFI_DEF_CFA rsi,SS+8-RBP /* reg/off reset after def_cfa_expr */
22880 - leaq ARGOFFSET-RBP(%rsi), %rsp
22881 + CFI_DEF_CFA rsi,SS+8 /* reg/off reset after def_cfa_expr */
22882 + movq %rsi, %rsp
22883 CFI_DEF_CFA_REGISTER rsp
22884 - CFI_ADJUST_CFA_OFFSET RBP-ARGOFFSET
22885 + CFI_ADJUST_CFA_OFFSET -ARGOFFSET
22886
22887 exit_intr:
22888 GET_THREAD_INFO(%rcx)
22889 - testl $3,CS-ARGOFFSET(%rsp)
22890 + testb $3,CS-ARGOFFSET(%rsp)
22891 je retint_kernel
22892
22893 /* Interrupt came from user space */
22894 @@ -1026,12 +1455,16 @@ retint_swapgs: /* return to user-space */
22895 * The iretq could re-enable interrupts:
22896 */
22897 DISABLE_INTERRUPTS(CLBR_ANY)
22898 + pax_exit_kernel_user
22899 +retint_swapgs_pax:
22900 TRACE_IRQS_IRETQ
22901 SWAPGS
22902 jmp restore_args
22903
22904 retint_restore_args: /* return to kernel space */
22905 DISABLE_INTERRUPTS(CLBR_ANY)
22906 + pax_exit_kernel
22907 + pax_force_retaddr (RIP-ARGOFFSET)
22908 /*
22909 * The iretq could re-enable interrupts:
22910 */
22911 @@ -1114,7 +1547,7 @@ ENTRY(retint_kernel)
22912 #endif
22913
22914 CFI_ENDPROC
22915 -END(common_interrupt)
22916 +ENDPROC(common_interrupt)
22917 /*
22918 * End of kprobes section
22919 */
22920 @@ -1132,7 +1565,7 @@ ENTRY(\sym)
22921 interrupt \do_sym
22922 jmp ret_from_intr
22923 CFI_ENDPROC
22924 -END(\sym)
22925 +ENDPROC(\sym)
22926 .endm
22927
22928 #ifdef CONFIG_TRACING
22929 @@ -1215,12 +1648,22 @@ ENTRY(\sym)
22930 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22931 call error_entry
22932 DEFAULT_FRAME 0
22933 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22934 + testb $3, CS(%rsp)
22935 + jnz 1f
22936 + pax_enter_kernel
22937 + jmp 2f
22938 +1: pax_enter_kernel_user
22939 +2:
22940 +#else
22941 + pax_enter_kernel
22942 +#endif
22943 movq %rsp,%rdi /* pt_regs pointer */
22944 xorl %esi,%esi /* no error code */
22945 call \do_sym
22946 jmp error_exit /* %ebx: no swapgs flag */
22947 CFI_ENDPROC
22948 -END(\sym)
22949 +ENDPROC(\sym)
22950 .endm
22951
22952 .macro paranoidzeroentry sym do_sym
22953 @@ -1233,15 +1676,25 @@ ENTRY(\sym)
22954 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22955 call save_paranoid
22956 TRACE_IRQS_OFF
22957 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22958 + testb $3, CS(%rsp)
22959 + jnz 1f
22960 + pax_enter_kernel
22961 + jmp 2f
22962 +1: pax_enter_kernel_user
22963 +2:
22964 +#else
22965 + pax_enter_kernel
22966 +#endif
22967 movq %rsp,%rdi /* pt_regs pointer */
22968 xorl %esi,%esi /* no error code */
22969 call \do_sym
22970 jmp paranoid_exit /* %ebx: no swapgs flag */
22971 CFI_ENDPROC
22972 -END(\sym)
22973 +ENDPROC(\sym)
22974 .endm
22975
22976 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22977 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r13)
22978 .macro paranoidzeroentry_ist sym do_sym ist
22979 ENTRY(\sym)
22980 INTR_FRAME
22981 @@ -1252,14 +1705,30 @@ ENTRY(\sym)
22982 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22983 call save_paranoid
22984 TRACE_IRQS_OFF_DEBUG
22985 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22986 + testb $3, CS(%rsp)
22987 + jnz 1f
22988 + pax_enter_kernel
22989 + jmp 2f
22990 +1: pax_enter_kernel_user
22991 +2:
22992 +#else
22993 + pax_enter_kernel
22994 +#endif
22995 movq %rsp,%rdi /* pt_regs pointer */
22996 xorl %esi,%esi /* no error code */
22997 +#ifdef CONFIG_SMP
22998 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r13d
22999 + lea init_tss(%r13), %r13
23000 +#else
23001 + lea init_tss(%rip), %r13
23002 +#endif
23003 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
23004 call \do_sym
23005 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
23006 jmp paranoid_exit /* %ebx: no swapgs flag */
23007 CFI_ENDPROC
23008 -END(\sym)
23009 +ENDPROC(\sym)
23010 .endm
23011
23012 .macro errorentry sym do_sym
23013 @@ -1271,13 +1740,23 @@ ENTRY(\sym)
23014 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
23015 call error_entry
23016 DEFAULT_FRAME 0
23017 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23018 + testb $3, CS(%rsp)
23019 + jnz 1f
23020 + pax_enter_kernel
23021 + jmp 2f
23022 +1: pax_enter_kernel_user
23023 +2:
23024 +#else
23025 + pax_enter_kernel
23026 +#endif
23027 movq %rsp,%rdi /* pt_regs pointer */
23028 movq ORIG_RAX(%rsp),%rsi /* get error code */
23029 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
23030 call \do_sym
23031 jmp error_exit /* %ebx: no swapgs flag */
23032 CFI_ENDPROC
23033 -END(\sym)
23034 +ENDPROC(\sym)
23035 .endm
23036
23037 /* error code is on the stack already */
23038 @@ -1291,13 +1770,23 @@ ENTRY(\sym)
23039 call save_paranoid
23040 DEFAULT_FRAME 0
23041 TRACE_IRQS_OFF
23042 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23043 + testb $3, CS(%rsp)
23044 + jnz 1f
23045 + pax_enter_kernel
23046 + jmp 2f
23047 +1: pax_enter_kernel_user
23048 +2:
23049 +#else
23050 + pax_enter_kernel
23051 +#endif
23052 movq %rsp,%rdi /* pt_regs pointer */
23053 movq ORIG_RAX(%rsp),%rsi /* get error code */
23054 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
23055 call \do_sym
23056 jmp paranoid_exit /* %ebx: no swapgs flag */
23057 CFI_ENDPROC
23058 -END(\sym)
23059 +ENDPROC(\sym)
23060 .endm
23061
23062 zeroentry divide_error do_divide_error
23063 @@ -1327,9 +1816,10 @@ gs_change:
23064 2: mfence /* workaround */
23065 SWAPGS
23066 popfq_cfi
23067 + pax_force_retaddr
23068 ret
23069 CFI_ENDPROC
23070 -END(native_load_gs_index)
23071 +ENDPROC(native_load_gs_index)
23072
23073 _ASM_EXTABLE(gs_change,bad_gs)
23074 .section .fixup,"ax"
23075 @@ -1357,9 +1847,10 @@ ENTRY(call_softirq)
23076 CFI_DEF_CFA_REGISTER rsp
23077 CFI_ADJUST_CFA_OFFSET -8
23078 decl PER_CPU_VAR(irq_count)
23079 + pax_force_retaddr
23080 ret
23081 CFI_ENDPROC
23082 -END(call_softirq)
23083 +ENDPROC(call_softirq)
23084
23085 #ifdef CONFIG_XEN
23086 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
23087 @@ -1397,7 +1888,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
23088 decl PER_CPU_VAR(irq_count)
23089 jmp error_exit
23090 CFI_ENDPROC
23091 -END(xen_do_hypervisor_callback)
23092 +ENDPROC(xen_do_hypervisor_callback)
23093
23094 /*
23095 * Hypervisor uses this for application faults while it executes.
23096 @@ -1456,7 +1947,7 @@ ENTRY(xen_failsafe_callback)
23097 SAVE_ALL
23098 jmp error_exit
23099 CFI_ENDPROC
23100 -END(xen_failsafe_callback)
23101 +ENDPROC(xen_failsafe_callback)
23102
23103 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
23104 xen_hvm_callback_vector xen_evtchn_do_upcall
23105 @@ -1508,18 +1999,33 @@ ENTRY(paranoid_exit)
23106 DEFAULT_FRAME
23107 DISABLE_INTERRUPTS(CLBR_NONE)
23108 TRACE_IRQS_OFF_DEBUG
23109 - testl %ebx,%ebx /* swapgs needed? */
23110 + testl $1,%ebx /* swapgs needed? */
23111 jnz paranoid_restore
23112 - testl $3,CS(%rsp)
23113 + testb $3,CS(%rsp)
23114 jnz paranoid_userspace
23115 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23116 + pax_exit_kernel
23117 + TRACE_IRQS_IRETQ 0
23118 + SWAPGS_UNSAFE_STACK
23119 + RESTORE_ALL 8
23120 + pax_force_retaddr_bts
23121 + jmp irq_return
23122 +#endif
23123 paranoid_swapgs:
23124 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23125 + pax_exit_kernel_user
23126 +#else
23127 + pax_exit_kernel
23128 +#endif
23129 TRACE_IRQS_IRETQ 0
23130 SWAPGS_UNSAFE_STACK
23131 RESTORE_ALL 8
23132 jmp irq_return
23133 paranoid_restore:
23134 + pax_exit_kernel
23135 TRACE_IRQS_IRETQ_DEBUG 0
23136 RESTORE_ALL 8
23137 + pax_force_retaddr_bts
23138 jmp irq_return
23139 paranoid_userspace:
23140 GET_THREAD_INFO(%rcx)
23141 @@ -1548,7 +2054,7 @@ paranoid_schedule:
23142 TRACE_IRQS_OFF
23143 jmp paranoid_userspace
23144 CFI_ENDPROC
23145 -END(paranoid_exit)
23146 +ENDPROC(paranoid_exit)
23147
23148 /*
23149 * Exception entry point. This expects an error code/orig_rax on the stack.
23150 @@ -1575,12 +2081,13 @@ ENTRY(error_entry)
23151 movq_cfi r14, R14+8
23152 movq_cfi r15, R15+8
23153 xorl %ebx,%ebx
23154 - testl $3,CS+8(%rsp)
23155 + testb $3,CS+8(%rsp)
23156 je error_kernelspace
23157 error_swapgs:
23158 SWAPGS
23159 error_sti:
23160 TRACE_IRQS_OFF
23161 + pax_force_retaddr_bts
23162 ret
23163
23164 /*
23165 @@ -1607,7 +2114,7 @@ bstep_iret:
23166 movq %rcx,RIP+8(%rsp)
23167 jmp error_swapgs
23168 CFI_ENDPROC
23169 -END(error_entry)
23170 +ENDPROC(error_entry)
23171
23172
23173 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
23174 @@ -1618,7 +2125,7 @@ ENTRY(error_exit)
23175 DISABLE_INTERRUPTS(CLBR_NONE)
23176 TRACE_IRQS_OFF
23177 GET_THREAD_INFO(%rcx)
23178 - testl %eax,%eax
23179 + testl $1,%eax
23180 jne retint_kernel
23181 LOCKDEP_SYS_EXIT_IRQ
23182 movl TI_flags(%rcx),%edx
23183 @@ -1627,7 +2134,7 @@ ENTRY(error_exit)
23184 jnz retint_careful
23185 jmp retint_swapgs
23186 CFI_ENDPROC
23187 -END(error_exit)
23188 +ENDPROC(error_exit)
23189
23190 /*
23191 * Test if a given stack is an NMI stack or not.
23192 @@ -1685,9 +2192,11 @@ ENTRY(nmi)
23193 * If %cs was not the kernel segment, then the NMI triggered in user
23194 * space, which means it is definitely not nested.
23195 */
23196 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
23197 + je 1f
23198 cmpl $__KERNEL_CS, 16(%rsp)
23199 jne first_nmi
23200 -
23201 +1:
23202 /*
23203 * Check the special variable on the stack to see if NMIs are
23204 * executing.
23205 @@ -1721,8 +2230,7 @@ nested_nmi:
23206
23207 1:
23208 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
23209 - leaq -1*8(%rsp), %rdx
23210 - movq %rdx, %rsp
23211 + subq $8, %rsp
23212 CFI_ADJUST_CFA_OFFSET 1*8
23213 leaq -10*8(%rsp), %rdx
23214 pushq_cfi $__KERNEL_DS
23215 @@ -1740,6 +2248,7 @@ nested_nmi_out:
23216 CFI_RESTORE rdx
23217
23218 /* No need to check faults here */
23219 +# pax_force_retaddr_bts
23220 INTERRUPT_RETURN
23221
23222 CFI_RESTORE_STATE
23223 @@ -1852,9 +2361,11 @@ end_repeat_nmi:
23224 * NMI itself takes a page fault, the page fault that was preempted
23225 * will read the information from the NMI page fault and not the
23226 * origin fault. Save it off and restore it if it changes.
23227 - * Use the r12 callee-saved register.
23228 + * Use the r13 callee-saved register.
23229 */
23230 - movq %cr2, %r12
23231 + movq %cr2, %r13
23232 +
23233 + pax_enter_kernel_nmi
23234
23235 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
23236 movq %rsp,%rdi
23237 @@ -1863,31 +2374,36 @@ end_repeat_nmi:
23238
23239 /* Did the NMI take a page fault? Restore cr2 if it did */
23240 movq %cr2, %rcx
23241 - cmpq %rcx, %r12
23242 + cmpq %rcx, %r13
23243 je 1f
23244 - movq %r12, %cr2
23245 + movq %r13, %cr2
23246 1:
23247
23248 - testl %ebx,%ebx /* swapgs needed? */
23249 + testl $1,%ebx /* swapgs needed? */
23250 jnz nmi_restore
23251 nmi_swapgs:
23252 SWAPGS_UNSAFE_STACK
23253 nmi_restore:
23254 + pax_exit_kernel_nmi
23255 /* Pop the extra iret frame at once */
23256 RESTORE_ALL 6*8
23257 + testb $3, 8(%rsp)
23258 + jnz 1f
23259 + pax_force_retaddr_bts
23260 +1:
23261
23262 /* Clear the NMI executing stack variable */
23263 movq $0, 5*8(%rsp)
23264 jmp irq_return
23265 CFI_ENDPROC
23266 -END(nmi)
23267 +ENDPROC(nmi)
23268
23269 ENTRY(ignore_sysret)
23270 CFI_STARTPROC
23271 mov $-ENOSYS,%eax
23272 sysret
23273 CFI_ENDPROC
23274 -END(ignore_sysret)
23275 +ENDPROC(ignore_sysret)
23276
23277 /*
23278 * End of kprobes section
23279 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
23280 index d4bdd25..912664c 100644
23281 --- a/arch/x86/kernel/ftrace.c
23282 +++ b/arch/x86/kernel/ftrace.c
23283 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
23284 {
23285 unsigned char replaced[MCOUNT_INSN_SIZE];
23286
23287 + ip = ktla_ktva(ip);
23288 +
23289 /*
23290 * Note: Due to modules and __init, code can
23291 * disappear and change, we need to protect against faulting
23292 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
23293 unsigned char old[MCOUNT_INSN_SIZE], *new;
23294 int ret;
23295
23296 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
23297 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
23298 new = ftrace_call_replace(ip, (unsigned long)func);
23299
23300 /* See comment above by declaration of modifying_ftrace_code */
23301 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
23302 /* Also update the regs callback function */
23303 if (!ret) {
23304 ip = (unsigned long)(&ftrace_regs_call);
23305 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
23306 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
23307 new = ftrace_call_replace(ip, (unsigned long)func);
23308 ret = ftrace_modify_code(ip, old, new);
23309 }
23310 @@ -291,7 +293,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
23311 * kernel identity mapping to modify code.
23312 */
23313 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
23314 - ip = (unsigned long)__va(__pa_symbol(ip));
23315 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
23316
23317 return probe_kernel_write((void *)ip, val, size);
23318 }
23319 @@ -301,7 +303,7 @@ static int add_break(unsigned long ip, const char *old)
23320 unsigned char replaced[MCOUNT_INSN_SIZE];
23321 unsigned char brk = BREAKPOINT_INSTRUCTION;
23322
23323 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
23324 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
23325 return -EFAULT;
23326
23327 /* Make sure it is what we expect it to be */
23328 @@ -649,7 +651,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
23329 return ret;
23330
23331 fail_update:
23332 - probe_kernel_write((void *)ip, &old_code[0], 1);
23333 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
23334 goto out;
23335 }
23336
23337 @@ -682,6 +684,8 @@ static int ftrace_mod_jmp(unsigned long ip,
23338 {
23339 unsigned char code[MCOUNT_INSN_SIZE];
23340
23341 + ip = ktla_ktva(ip);
23342 +
23343 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
23344 return -EFAULT;
23345
23346 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
23347 index 1be8e43..d9b9ef6 100644
23348 --- a/arch/x86/kernel/head64.c
23349 +++ b/arch/x86/kernel/head64.c
23350 @@ -67,12 +67,12 @@ again:
23351 pgd = *pgd_p;
23352
23353 /*
23354 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
23355 - * critical -- __PAGE_OFFSET would point us back into the dynamic
23356 + * The use of __early_va rather than __va here is critical:
23357 + * __va would point us back into the dynamic
23358 * range and we might end up looping forever...
23359 */
23360 if (pgd)
23361 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
23362 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
23363 else {
23364 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
23365 reset_early_page_tables();
23366 @@ -82,13 +82,13 @@ again:
23367 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
23368 for (i = 0; i < PTRS_PER_PUD; i++)
23369 pud_p[i] = 0;
23370 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
23371 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
23372 }
23373 pud_p += pud_index(address);
23374 pud = *pud_p;
23375
23376 if (pud)
23377 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
23378 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
23379 else {
23380 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
23381 reset_early_page_tables();
23382 @@ -98,7 +98,7 @@ again:
23383 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
23384 for (i = 0; i < PTRS_PER_PMD; i++)
23385 pmd_p[i] = 0;
23386 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
23387 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
23388 }
23389 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
23390 pmd_p[pmd_index(address)] = pmd;
23391 @@ -175,7 +175,6 @@ asmlinkage void __init x86_64_start_kernel(char * real_mode_data)
23392 if (console_loglevel == 10)
23393 early_printk("Kernel alive\n");
23394
23395 - clear_page(init_level4_pgt);
23396 /* set init_level4_pgt kernel high mapping*/
23397 init_level4_pgt[511] = early_level4_pgt[511];
23398
23399 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
23400 index 81ba276..30c5411 100644
23401 --- a/arch/x86/kernel/head_32.S
23402 +++ b/arch/x86/kernel/head_32.S
23403 @@ -26,6 +26,12 @@
23404 /* Physical address */
23405 #define pa(X) ((X) - __PAGE_OFFSET)
23406
23407 +#ifdef CONFIG_PAX_KERNEXEC
23408 +#define ta(X) (X)
23409 +#else
23410 +#define ta(X) ((X) - __PAGE_OFFSET)
23411 +#endif
23412 +
23413 /*
23414 * References to members of the new_cpu_data structure.
23415 */
23416 @@ -55,11 +61,7 @@
23417 * and small than max_low_pfn, otherwise will waste some page table entries
23418 */
23419
23420 -#if PTRS_PER_PMD > 1
23421 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
23422 -#else
23423 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
23424 -#endif
23425 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
23426
23427 /* Number of possible pages in the lowmem region */
23428 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
23429 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
23430 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
23431
23432 /*
23433 + * Real beginning of normal "text" segment
23434 + */
23435 +ENTRY(stext)
23436 +ENTRY(_stext)
23437 +
23438 +/*
23439 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
23440 * %esi points to the real-mode code as a 32-bit pointer.
23441 * CS and DS must be 4 GB flat segments, but we don't depend on
23442 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
23443 * can.
23444 */
23445 __HEAD
23446 +
23447 +#ifdef CONFIG_PAX_KERNEXEC
23448 + jmp startup_32
23449 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
23450 +.fill PAGE_SIZE-5,1,0xcc
23451 +#endif
23452 +
23453 ENTRY(startup_32)
23454 movl pa(stack_start),%ecx
23455
23456 @@ -106,6 +121,59 @@ ENTRY(startup_32)
23457 2:
23458 leal -__PAGE_OFFSET(%ecx),%esp
23459
23460 +#ifdef CONFIG_SMP
23461 + movl $pa(cpu_gdt_table),%edi
23462 + movl $__per_cpu_load,%eax
23463 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
23464 + rorl $16,%eax
23465 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
23466 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
23467 + movl $__per_cpu_end - 1,%eax
23468 + subl $__per_cpu_start,%eax
23469 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
23470 +#endif
23471 +
23472 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23473 + movl $NR_CPUS,%ecx
23474 + movl $pa(cpu_gdt_table),%edi
23475 +1:
23476 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
23477 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
23478 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
23479 + addl $PAGE_SIZE_asm,%edi
23480 + loop 1b
23481 +#endif
23482 +
23483 +#ifdef CONFIG_PAX_KERNEXEC
23484 + movl $pa(boot_gdt),%edi
23485 + movl $__LOAD_PHYSICAL_ADDR,%eax
23486 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
23487 + rorl $16,%eax
23488 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
23489 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
23490 + rorl $16,%eax
23491 +
23492 + ljmp $(__BOOT_CS),$1f
23493 +1:
23494 +
23495 + movl $NR_CPUS,%ecx
23496 + movl $pa(cpu_gdt_table),%edi
23497 + addl $__PAGE_OFFSET,%eax
23498 +1:
23499 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
23500 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
23501 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
23502 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
23503 + rorl $16,%eax
23504 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
23505 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
23506 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
23507 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
23508 + rorl $16,%eax
23509 + addl $PAGE_SIZE_asm,%edi
23510 + loop 1b
23511 +#endif
23512 +
23513 /*
23514 * Clear BSS first so that there are no surprises...
23515 */
23516 @@ -201,8 +269,11 @@ ENTRY(startup_32)
23517 movl %eax, pa(max_pfn_mapped)
23518
23519 /* Do early initialization of the fixmap area */
23520 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
23521 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
23522 +#ifdef CONFIG_COMPAT_VDSO
23523 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
23524 +#else
23525 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
23526 +#endif
23527 #else /* Not PAE */
23528
23529 page_pde_offset = (__PAGE_OFFSET >> 20);
23530 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
23531 movl %eax, pa(max_pfn_mapped)
23532
23533 /* Do early initialization of the fixmap area */
23534 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
23535 - movl %eax,pa(initial_page_table+0xffc)
23536 +#ifdef CONFIG_COMPAT_VDSO
23537 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
23538 +#else
23539 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
23540 +#endif
23541 #endif
23542
23543 #ifdef CONFIG_PARAVIRT
23544 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
23545 cmpl $num_subarch_entries, %eax
23546 jae bad_subarch
23547
23548 - movl pa(subarch_entries)(,%eax,4), %eax
23549 - subl $__PAGE_OFFSET, %eax
23550 - jmp *%eax
23551 + jmp *pa(subarch_entries)(,%eax,4)
23552
23553 bad_subarch:
23554 WEAK(lguest_entry)
23555 @@ -261,10 +333,10 @@ WEAK(xen_entry)
23556 __INITDATA
23557
23558 subarch_entries:
23559 - .long default_entry /* normal x86/PC */
23560 - .long lguest_entry /* lguest hypervisor */
23561 - .long xen_entry /* Xen hypervisor */
23562 - .long default_entry /* Moorestown MID */
23563 + .long ta(default_entry) /* normal x86/PC */
23564 + .long ta(lguest_entry) /* lguest hypervisor */
23565 + .long ta(xen_entry) /* Xen hypervisor */
23566 + .long ta(default_entry) /* Moorestown MID */
23567 num_subarch_entries = (. - subarch_entries) / 4
23568 .previous
23569 #else
23570 @@ -354,6 +426,7 @@ default_entry:
23571 movl pa(mmu_cr4_features),%eax
23572 movl %eax,%cr4
23573
23574 +#ifdef CONFIG_X86_PAE
23575 testb $X86_CR4_PAE, %al # check if PAE is enabled
23576 jz enable_paging
23577
23578 @@ -382,6 +455,9 @@ default_entry:
23579 /* Make changes effective */
23580 wrmsr
23581
23582 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
23583 +#endif
23584 +
23585 enable_paging:
23586
23587 /*
23588 @@ -449,14 +525,20 @@ is486:
23589 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
23590 movl %eax,%ss # after changing gdt.
23591
23592 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
23593 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
23594 movl %eax,%ds
23595 movl %eax,%es
23596
23597 movl $(__KERNEL_PERCPU), %eax
23598 movl %eax,%fs # set this cpu's percpu
23599
23600 +#ifdef CONFIG_CC_STACKPROTECTOR
23601 movl $(__KERNEL_STACK_CANARY),%eax
23602 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
23603 + movl $(__USER_DS),%eax
23604 +#else
23605 + xorl %eax,%eax
23606 +#endif
23607 movl %eax,%gs
23608
23609 xorl %eax,%eax # Clear LDT
23610 @@ -512,8 +594,11 @@ setup_once:
23611 * relocation. Manually set base address in stack canary
23612 * segment descriptor.
23613 */
23614 - movl $gdt_page,%eax
23615 + movl $cpu_gdt_table,%eax
23616 movl $stack_canary,%ecx
23617 +#ifdef CONFIG_SMP
23618 + addl $__per_cpu_load,%ecx
23619 +#endif
23620 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
23621 shrl $16, %ecx
23622 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
23623 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
23624 /* This is global to keep gas from relaxing the jumps */
23625 ENTRY(early_idt_handler)
23626 cld
23627 - cmpl $2,%ss:early_recursion_flag
23628 + cmpl $1,%ss:early_recursion_flag
23629 je hlt_loop
23630 incl %ss:early_recursion_flag
23631
23632 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
23633 pushl (20+6*4)(%esp) /* trapno */
23634 pushl $fault_msg
23635 call printk
23636 -#endif
23637 call dump_stack
23638 +#endif
23639 hlt_loop:
23640 hlt
23641 jmp hlt_loop
23642 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
23643 /* This is the default interrupt "handler" :-) */
23644 ALIGN
23645 ignore_int:
23646 - cld
23647 #ifdef CONFIG_PRINTK
23648 + cmpl $2,%ss:early_recursion_flag
23649 + je hlt_loop
23650 + incl %ss:early_recursion_flag
23651 + cld
23652 pushl %eax
23653 pushl %ecx
23654 pushl %edx
23655 @@ -612,9 +700,6 @@ ignore_int:
23656 movl $(__KERNEL_DS),%eax
23657 movl %eax,%ds
23658 movl %eax,%es
23659 - cmpl $2,early_recursion_flag
23660 - je hlt_loop
23661 - incl early_recursion_flag
23662 pushl 16(%esp)
23663 pushl 24(%esp)
23664 pushl 32(%esp)
23665 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
23666 /*
23667 * BSS section
23668 */
23669 -__PAGE_ALIGNED_BSS
23670 - .align PAGE_SIZE
23671 #ifdef CONFIG_X86_PAE
23672 +.section .initial_pg_pmd,"a",@progbits
23673 initial_pg_pmd:
23674 .fill 1024*KPMDS,4,0
23675 #else
23676 +.section .initial_page_table,"a",@progbits
23677 ENTRY(initial_page_table)
23678 .fill 1024,4,0
23679 #endif
23680 +.section .initial_pg_fixmap,"a",@progbits
23681 initial_pg_fixmap:
23682 .fill 1024,4,0
23683 +.section .empty_zero_page,"a",@progbits
23684 ENTRY(empty_zero_page)
23685 .fill 4096,1,0
23686 +.section .swapper_pg_dir,"a",@progbits
23687 ENTRY(swapper_pg_dir)
23688 +#ifdef CONFIG_X86_PAE
23689 + .fill 4,8,0
23690 +#else
23691 .fill 1024,4,0
23692 +#endif
23693
23694 /*
23695 * This starts the data section.
23696 */
23697 #ifdef CONFIG_X86_PAE
23698 -__PAGE_ALIGNED_DATA
23699 - /* Page-aligned for the benefit of paravirt? */
23700 - .align PAGE_SIZE
23701 +.section .initial_page_table,"a",@progbits
23702 ENTRY(initial_page_table)
23703 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
23704 # if KPMDS == 3
23705 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
23706 # error "Kernel PMDs should be 1, 2 or 3"
23707 # endif
23708 .align PAGE_SIZE /* needs to be page-sized too */
23709 +
23710 +#ifdef CONFIG_PAX_PER_CPU_PGD
23711 +ENTRY(cpu_pgd)
23712 + .rept 2*NR_CPUS
23713 + .fill 4,8,0
23714 + .endr
23715 +#endif
23716 +
23717 #endif
23718
23719 .data
23720 .balign 4
23721 ENTRY(stack_start)
23722 - .long init_thread_union+THREAD_SIZE
23723 + .long init_thread_union+THREAD_SIZE-8
23724
23725 __INITRODATA
23726 int_msg:
23727 @@ -722,7 +820,7 @@ fault_msg:
23728 * segment size, and 32-bit linear address value:
23729 */
23730
23731 - .data
23732 +.section .rodata,"a",@progbits
23733 .globl boot_gdt_descr
23734 .globl idt_descr
23735
23736 @@ -731,7 +829,7 @@ fault_msg:
23737 .word 0 # 32 bit align gdt_desc.address
23738 boot_gdt_descr:
23739 .word __BOOT_DS+7
23740 - .long boot_gdt - __PAGE_OFFSET
23741 + .long pa(boot_gdt)
23742
23743 .word 0 # 32-bit align idt_desc.address
23744 idt_descr:
23745 @@ -742,7 +840,7 @@ idt_descr:
23746 .word 0 # 32 bit align gdt_desc.address
23747 ENTRY(early_gdt_descr)
23748 .word GDT_ENTRIES*8-1
23749 - .long gdt_page /* Overwritten for secondary CPUs */
23750 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
23751
23752 /*
23753 * The boot_gdt must mirror the equivalent in setup.S and is
23754 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
23755 .align L1_CACHE_BYTES
23756 ENTRY(boot_gdt)
23757 .fill GDT_ENTRY_BOOT_CS,8,0
23758 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
23759 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
23760 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
23761 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
23762 +
23763 + .align PAGE_SIZE_asm
23764 +ENTRY(cpu_gdt_table)
23765 + .rept NR_CPUS
23766 + .quad 0x0000000000000000 /* NULL descriptor */
23767 + .quad 0x0000000000000000 /* 0x0b reserved */
23768 + .quad 0x0000000000000000 /* 0x13 reserved */
23769 + .quad 0x0000000000000000 /* 0x1b reserved */
23770 +
23771 +#ifdef CONFIG_PAX_KERNEXEC
23772 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
23773 +#else
23774 + .quad 0x0000000000000000 /* 0x20 unused */
23775 +#endif
23776 +
23777 + .quad 0x0000000000000000 /* 0x28 unused */
23778 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
23779 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
23780 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
23781 + .quad 0x0000000000000000 /* 0x4b reserved */
23782 + .quad 0x0000000000000000 /* 0x53 reserved */
23783 + .quad 0x0000000000000000 /* 0x5b reserved */
23784 +
23785 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
23786 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
23787 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
23788 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
23789 +
23790 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
23791 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
23792 +
23793 + /*
23794 + * Segments used for calling PnP BIOS have byte granularity.
23795 + * The code segments and data segments have fixed 64k limits,
23796 + * the transfer segment sizes are set at run time.
23797 + */
23798 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23799 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23800 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23801 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23802 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23803 +
23804 + /*
23805 + * The APM segments have byte granularity and their bases
23806 + * are set at run time. All have 64k limits.
23807 + */
23808 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23809 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23810 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23811 +
23812 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23813 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23814 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23815 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23816 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23817 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23818 +
23819 + /* Be sure this is zeroed to avoid false validations in Xen */
23820 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23821 + .endr
23822 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23823 index e1aabdb..fee4fee 100644
23824 --- a/arch/x86/kernel/head_64.S
23825 +++ b/arch/x86/kernel/head_64.S
23826 @@ -20,6 +20,8 @@
23827 #include <asm/processor-flags.h>
23828 #include <asm/percpu.h>
23829 #include <asm/nops.h>
23830 +#include <asm/cpufeature.h>
23831 +#include <asm/alternative-asm.h>
23832
23833 #ifdef CONFIG_PARAVIRT
23834 #include <asm/asm-offsets.h>
23835 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23836 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23837 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23838 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23839 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23840 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23841 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23842 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23843 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23844 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23845
23846 .text
23847 __HEAD
23848 @@ -89,11 +97,24 @@ startup_64:
23849 * Fixup the physical addresses in the page table
23850 */
23851 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23852 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23853 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23854 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23855 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23856 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23857
23858 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23859 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23860 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23861 +#ifndef CONFIG_XEN
23862 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23863 +#endif
23864 +
23865 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23866 +
23867 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23868 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23869
23870 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23871 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23872
23873 /*
23874 * Set up the identity mapping for the switchover. These
23875 @@ -177,8 +198,8 @@ ENTRY(secondary_startup_64)
23876 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23877 1:
23878
23879 - /* Enable PAE mode and PGE */
23880 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23881 + /* Enable PAE mode and PSE/PGE */
23882 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23883 movq %rcx, %cr4
23884
23885 /* Setup early boot stage 4 level pagetables. */
23886 @@ -199,10 +220,19 @@ ENTRY(secondary_startup_64)
23887 movl $MSR_EFER, %ecx
23888 rdmsr
23889 btsl $_EFER_SCE, %eax /* Enable System Call */
23890 - btl $20,%edi /* No Execute supported? */
23891 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23892 jnc 1f
23893 btsl $_EFER_NX, %eax
23894 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23895 +#ifndef CONFIG_EFI
23896 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_PAGE_OFFSET(%rip)
23897 +#endif
23898 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_START(%rip)
23899 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_END(%rip)
23900 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMEMMAP_START(%rip)
23901 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*506(%rip)
23902 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*507(%rip)
23903 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23904 1: wrmsr /* Make changes effective */
23905
23906 /* Setup cr0 */
23907 @@ -282,6 +312,7 @@ ENTRY(secondary_startup_64)
23908 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23909 * address given in m16:64.
23910 */
23911 + pax_set_fptr_mask
23912 movq initial_code(%rip),%rax
23913 pushq $0 # fake return address to stop unwinder
23914 pushq $__KERNEL_CS # set correct cs
23915 @@ -388,7 +419,7 @@ ENTRY(early_idt_handler)
23916 call dump_stack
23917 #ifdef CONFIG_KALLSYMS
23918 leaq early_idt_ripmsg(%rip),%rdi
23919 - movq 40(%rsp),%rsi # %rip again
23920 + movq 88(%rsp),%rsi # %rip again
23921 call __print_symbol
23922 #endif
23923 #endif /* EARLY_PRINTK */
23924 @@ -416,6 +447,7 @@ ENDPROC(early_idt_handler)
23925 early_recursion_flag:
23926 .long 0
23927
23928 + .section .rodata,"a",@progbits
23929 #ifdef CONFIG_EARLY_PRINTK
23930 early_idt_msg:
23931 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23932 @@ -443,29 +475,52 @@ NEXT_PAGE(early_level4_pgt)
23933 NEXT_PAGE(early_dynamic_pgts)
23934 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23935
23936 - .data
23937 + .section .rodata,"a",@progbits
23938
23939 -#ifndef CONFIG_XEN
23940 NEXT_PAGE(init_level4_pgt)
23941 - .fill 512,8,0
23942 -#else
23943 -NEXT_PAGE(init_level4_pgt)
23944 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23945 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23946 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23947 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23948 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23949 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23950 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23951 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23952 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23953 .org init_level4_pgt + L4_START_KERNEL*8, 0
23954 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23955 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23956
23957 +#ifdef CONFIG_PAX_PER_CPU_PGD
23958 +NEXT_PAGE(cpu_pgd)
23959 + .rept 2*NR_CPUS
23960 + .fill 512,8,0
23961 + .endr
23962 +#endif
23963 +
23964 NEXT_PAGE(level3_ident_pgt)
23965 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23966 +#ifdef CONFIG_XEN
23967 .fill 511, 8, 0
23968 +#else
23969 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23970 + .fill 510,8,0
23971 +#endif
23972 +
23973 +NEXT_PAGE(level3_vmalloc_start_pgt)
23974 + .fill 512,8,0
23975 +
23976 +NEXT_PAGE(level3_vmalloc_end_pgt)
23977 + .fill 512,8,0
23978 +
23979 +NEXT_PAGE(level3_vmemmap_pgt)
23980 + .fill L3_VMEMMAP_START,8,0
23981 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23982 +
23983 NEXT_PAGE(level2_ident_pgt)
23984 - /* Since I easily can, map the first 1G.
23985 + /* Since I easily can, map the first 2G.
23986 * Don't set NX because code runs from these pages.
23987 */
23988 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23989 -#endif
23990 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23991
23992 NEXT_PAGE(level3_kernel_pgt)
23993 .fill L3_START_KERNEL,8,0
23994 @@ -473,6 +528,9 @@ NEXT_PAGE(level3_kernel_pgt)
23995 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23996 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23997
23998 +NEXT_PAGE(level2_vmemmap_pgt)
23999 + .fill 512,8,0
24000 +
24001 NEXT_PAGE(level2_kernel_pgt)
24002 /*
24003 * 512 MB kernel mapping. We spend a full page on this pagetable
24004 @@ -490,28 +548,64 @@ NEXT_PAGE(level2_kernel_pgt)
24005 NEXT_PAGE(level2_fixmap_pgt)
24006 .fill 506,8,0
24007 .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
24008 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
24009 - .fill 5,8,0
24010 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
24011 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
24012 + .fill 4,8,0
24013
24014 NEXT_PAGE(level1_fixmap_pgt)
24015 .fill 512,8,0
24016
24017 +NEXT_PAGE(level1_vsyscall_pgt)
24018 + .fill 512,8,0
24019 +
24020 #undef PMDS
24021
24022 - .data
24023 + .align PAGE_SIZE
24024 +ENTRY(cpu_gdt_table)
24025 + .rept NR_CPUS
24026 + .quad 0x0000000000000000 /* NULL descriptor */
24027 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
24028 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
24029 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
24030 + .quad 0x00cffb000000ffff /* __USER32_CS */
24031 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
24032 + .quad 0x00affb000000ffff /* __USER_CS */
24033 +
24034 +#ifdef CONFIG_PAX_KERNEXEC
24035 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
24036 +#else
24037 + .quad 0x0 /* unused */
24038 +#endif
24039 +
24040 + .quad 0,0 /* TSS */
24041 + .quad 0,0 /* LDT */
24042 + .quad 0,0,0 /* three TLS descriptors */
24043 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
24044 + /* asm/segment.h:GDT_ENTRIES must match this */
24045 +
24046 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24047 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
24048 +#else
24049 + .quad 0x0 /* unused */
24050 +#endif
24051 +
24052 + /* zero the remaining page */
24053 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
24054 + .endr
24055 +
24056 .align 16
24057 .globl early_gdt_descr
24058 early_gdt_descr:
24059 .word GDT_ENTRIES*8-1
24060 early_gdt_descr_base:
24061 - .quad INIT_PER_CPU_VAR(gdt_page)
24062 + .quad cpu_gdt_table
24063
24064 ENTRY(phys_base)
24065 /* This must match the first entry in level2_kernel_pgt */
24066 .quad 0x0000000000000000
24067
24068 #include "../../x86/xen/xen-head.S"
24069 -
24070 - __PAGE_ALIGNED_BSS
24071 +
24072 + .section .rodata,"a",@progbits
24073 NEXT_PAGE(empty_zero_page)
24074 .skip PAGE_SIZE
24075 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
24076 index 0fa6912..b37438b 100644
24077 --- a/arch/x86/kernel/i386_ksyms_32.c
24078 +++ b/arch/x86/kernel/i386_ksyms_32.c
24079 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
24080 EXPORT_SYMBOL(cmpxchg8b_emu);
24081 #endif
24082
24083 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
24084 +
24085 /* Networking helper routines. */
24086 EXPORT_SYMBOL(csum_partial_copy_generic);
24087 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
24088 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
24089
24090 EXPORT_SYMBOL(__get_user_1);
24091 EXPORT_SYMBOL(__get_user_2);
24092 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
24093
24094 EXPORT_SYMBOL(csum_partial);
24095 EXPORT_SYMBOL(empty_zero_page);
24096 +
24097 +#ifdef CONFIG_PAX_KERNEXEC
24098 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
24099 +#endif
24100 +
24101 +#ifdef CONFIG_PAX_PER_CPU_PGD
24102 +EXPORT_SYMBOL(cpu_pgd);
24103 +#endif
24104 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
24105 index 5d576ab..1403a03 100644
24106 --- a/arch/x86/kernel/i387.c
24107 +++ b/arch/x86/kernel/i387.c
24108 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
24109 static inline bool interrupted_user_mode(void)
24110 {
24111 struct pt_regs *regs = get_irq_regs();
24112 - return regs && user_mode_vm(regs);
24113 + return regs && user_mode(regs);
24114 }
24115
24116 /*
24117 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
24118 index 9a5c460..84868423 100644
24119 --- a/arch/x86/kernel/i8259.c
24120 +++ b/arch/x86/kernel/i8259.c
24121 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
24122 static void make_8259A_irq(unsigned int irq)
24123 {
24124 disable_irq_nosync(irq);
24125 - io_apic_irqs &= ~(1<<irq);
24126 + io_apic_irqs &= ~(1UL<<irq);
24127 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
24128 i8259A_chip.name);
24129 enable_irq(irq);
24130 @@ -209,7 +209,7 @@ spurious_8259A_irq:
24131 "spurious 8259A interrupt: IRQ%d.\n", irq);
24132 spurious_irq_mask |= irqmask;
24133 }
24134 - atomic_inc(&irq_err_count);
24135 + atomic_inc_unchecked(&irq_err_count);
24136 /*
24137 * Theoretically we do not have to handle this IRQ,
24138 * but in Linux this does not cause problems and is
24139 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
24140 /* (slave's support for AEOI in flat mode is to be investigated) */
24141 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
24142
24143 + pax_open_kernel();
24144 if (auto_eoi)
24145 /*
24146 * In AEOI mode we just have to mask the interrupt
24147 * when acking.
24148 */
24149 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
24150 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
24151 else
24152 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
24153 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
24154 + pax_close_kernel();
24155
24156 udelay(100); /* wait for 8259A to initialize */
24157
24158 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
24159 index a979b5b..1d6db75 100644
24160 --- a/arch/x86/kernel/io_delay.c
24161 +++ b/arch/x86/kernel/io_delay.c
24162 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
24163 * Quirk table for systems that misbehave (lock up, etc.) if port
24164 * 0x80 is used:
24165 */
24166 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
24167 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
24168 {
24169 .callback = dmi_io_delay_0xed_port,
24170 .ident = "Compaq Presario V6000",
24171 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
24172 index 4ddaf66..49d5c18 100644
24173 --- a/arch/x86/kernel/ioport.c
24174 +++ b/arch/x86/kernel/ioport.c
24175 @@ -6,6 +6,7 @@
24176 #include <linux/sched.h>
24177 #include <linux/kernel.h>
24178 #include <linux/capability.h>
24179 +#include <linux/security.h>
24180 #include <linux/errno.h>
24181 #include <linux/types.h>
24182 #include <linux/ioport.h>
24183 @@ -30,6 +31,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
24184 return -EINVAL;
24185 if (turn_on && !capable(CAP_SYS_RAWIO))
24186 return -EPERM;
24187 +#ifdef CONFIG_GRKERNSEC_IO
24188 + if (turn_on && grsec_disable_privio) {
24189 + gr_handle_ioperm();
24190 + return -ENODEV;
24191 + }
24192 +#endif
24193
24194 /*
24195 * If it's the first ioperm() call in this thread's lifetime, set the
24196 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
24197 * because the ->io_bitmap_max value must match the bitmap
24198 * contents:
24199 */
24200 - tss = &per_cpu(init_tss, get_cpu());
24201 + tss = init_tss + get_cpu();
24202
24203 if (turn_on)
24204 bitmap_clear(t->io_bitmap_ptr, from, num);
24205 @@ -105,6 +112,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
24206 if (level > old) {
24207 if (!capable(CAP_SYS_RAWIO))
24208 return -EPERM;
24209 +#ifdef CONFIG_GRKERNSEC_IO
24210 + if (grsec_disable_privio) {
24211 + gr_handle_iopl();
24212 + return -ENODEV;
24213 + }
24214 +#endif
24215 }
24216 regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12);
24217 t->iopl = level << 12;
24218 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
24219 index 22d0687..e07b2a5 100644
24220 --- a/arch/x86/kernel/irq.c
24221 +++ b/arch/x86/kernel/irq.c
24222 @@ -21,7 +21,7 @@
24223 #define CREATE_TRACE_POINTS
24224 #include <asm/trace/irq_vectors.h>
24225
24226 -atomic_t irq_err_count;
24227 +atomic_unchecked_t irq_err_count;
24228
24229 /* Function pointer for generic interrupt vector handling */
24230 void (*x86_platform_ipi_callback)(void) = NULL;
24231 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
24232 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
24233 seq_printf(p, " Machine check polls\n");
24234 #endif
24235 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
24236 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
24237 #if defined(CONFIG_X86_IO_APIC)
24238 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
24239 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
24240 #endif
24241 return 0;
24242 }
24243 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
24244
24245 u64 arch_irq_stat(void)
24246 {
24247 - u64 sum = atomic_read(&irq_err_count);
24248 + u64 sum = atomic_read_unchecked(&irq_err_count);
24249 return sum;
24250 }
24251
24252 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
24253 index 4186755..18d6a9e 100644
24254 --- a/arch/x86/kernel/irq_32.c
24255 +++ b/arch/x86/kernel/irq_32.c
24256 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
24257 __asm__ __volatile__("andl %%esp,%0" :
24258 "=r" (sp) : "0" (THREAD_SIZE - 1));
24259
24260 - return sp < (sizeof(struct thread_info) + STACK_WARN);
24261 + return sp < STACK_WARN;
24262 }
24263
24264 static void print_stack_overflow(void)
24265 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
24266 * per-CPU IRQ handling contexts (thread information and stack)
24267 */
24268 union irq_ctx {
24269 - struct thread_info tinfo;
24270 - u32 stack[THREAD_SIZE/sizeof(u32)];
24271 + unsigned long previous_esp;
24272 + u32 stack[THREAD_SIZE/sizeof(u32)];
24273 } __attribute__((aligned(THREAD_SIZE)));
24274
24275 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
24276 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
24277 static inline int
24278 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
24279 {
24280 - union irq_ctx *curctx, *irqctx;
24281 + union irq_ctx *irqctx;
24282 u32 *isp, arg1, arg2;
24283
24284 - curctx = (union irq_ctx *) current_thread_info();
24285 irqctx = __this_cpu_read(hardirq_ctx);
24286
24287 /*
24288 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
24289 * handler) we can't do that and just have to keep using the
24290 * current stack (which is the irq stack already after all)
24291 */
24292 - if (unlikely(curctx == irqctx))
24293 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
24294 return 0;
24295
24296 /* build the stack frame on the IRQ stack */
24297 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
24298 - irqctx->tinfo.task = curctx->tinfo.task;
24299 - irqctx->tinfo.previous_esp = current_stack_pointer;
24300 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
24301 + irqctx->previous_esp = current_stack_pointer;
24302
24303 - /* Copy the preempt_count so that the [soft]irq checks work. */
24304 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
24305 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24306 + __set_fs(MAKE_MM_SEG(0));
24307 +#endif
24308
24309 if (unlikely(overflow))
24310 call_on_stack(print_stack_overflow, isp);
24311 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
24312 : "0" (irq), "1" (desc), "2" (isp),
24313 "D" (desc->handle_irq)
24314 : "memory", "cc", "ecx");
24315 +
24316 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24317 + __set_fs(current_thread_info()->addr_limit);
24318 +#endif
24319 +
24320 return 1;
24321 }
24322
24323 @@ -121,29 +125,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
24324 */
24325 void irq_ctx_init(int cpu)
24326 {
24327 - union irq_ctx *irqctx;
24328 -
24329 if (per_cpu(hardirq_ctx, cpu))
24330 return;
24331
24332 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
24333 - THREADINFO_GFP,
24334 - THREAD_SIZE_ORDER));
24335 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
24336 - irqctx->tinfo.cpu = cpu;
24337 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
24338 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
24339 -
24340 - per_cpu(hardirq_ctx, cpu) = irqctx;
24341 -
24342 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
24343 - THREADINFO_GFP,
24344 - THREAD_SIZE_ORDER));
24345 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
24346 - irqctx->tinfo.cpu = cpu;
24347 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
24348 -
24349 - per_cpu(softirq_ctx, cpu) = irqctx;
24350 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
24351 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
24352
24353 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
24354 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
24355 @@ -152,7 +138,6 @@ void irq_ctx_init(int cpu)
24356 asmlinkage void do_softirq(void)
24357 {
24358 unsigned long flags;
24359 - struct thread_info *curctx;
24360 union irq_ctx *irqctx;
24361 u32 *isp;
24362
24363 @@ -162,15 +147,22 @@ asmlinkage void do_softirq(void)
24364 local_irq_save(flags);
24365
24366 if (local_softirq_pending()) {
24367 - curctx = current_thread_info();
24368 irqctx = __this_cpu_read(softirq_ctx);
24369 - irqctx->tinfo.task = curctx->task;
24370 - irqctx->tinfo.previous_esp = current_stack_pointer;
24371 + irqctx->previous_esp = current_stack_pointer;
24372
24373 /* build the stack frame on the softirq stack */
24374 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
24375 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
24376 +
24377 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24378 + __set_fs(MAKE_MM_SEG(0));
24379 +#endif
24380
24381 call_on_stack(__do_softirq, isp);
24382 +
24383 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24384 + __set_fs(current_thread_info()->addr_limit);
24385 +#endif
24386 +
24387 /*
24388 * Shouldn't happen, we returned above if in_interrupt():
24389 */
24390 @@ -191,7 +183,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
24391 if (unlikely(!desc))
24392 return false;
24393
24394 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
24395 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
24396 if (unlikely(overflow))
24397 print_stack_overflow();
24398 desc->handle_irq(irq, desc);
24399 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
24400 index d04d3ec..ea4b374 100644
24401 --- a/arch/x86/kernel/irq_64.c
24402 +++ b/arch/x86/kernel/irq_64.c
24403 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
24404 u64 estack_top, estack_bottom;
24405 u64 curbase = (u64)task_stack_page(current);
24406
24407 - if (user_mode_vm(regs))
24408 + if (user_mode(regs))
24409 return;
24410
24411 if (regs->sp >= curbase + sizeof(struct thread_info) +
24412 diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
24413 index ee11b7d..4df4d0c 100644
24414 --- a/arch/x86/kernel/jump_label.c
24415 +++ b/arch/x86/kernel/jump_label.c
24416 @@ -49,7 +49,7 @@ static void __jump_label_transform(struct jump_entry *entry,
24417 * We are enabling this jump label. If it is not a nop
24418 * then something must have gone wrong.
24419 */
24420 - if (unlikely(memcmp((void *)entry->code, ideal_nop, 5) != 0))
24421 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), ideal_nop, 5) != 0))
24422 bug_at((void *)entry->code, __LINE__);
24423
24424 code.jump = 0xe9;
24425 @@ -64,13 +64,13 @@ static void __jump_label_transform(struct jump_entry *entry,
24426 */
24427 if (init) {
24428 const unsigned char default_nop[] = { STATIC_KEY_INIT_NOP };
24429 - if (unlikely(memcmp((void *)entry->code, default_nop, 5) != 0))
24430 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5) != 0))
24431 bug_at((void *)entry->code, __LINE__);
24432 } else {
24433 code.jump = 0xe9;
24434 code.offset = entry->target -
24435 (entry->code + JUMP_LABEL_NOP_SIZE);
24436 - if (unlikely(memcmp((void *)entry->code, &code, 5) != 0))
24437 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), &code, 5) != 0))
24438 bug_at((void *)entry->code, __LINE__);
24439 }
24440 memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
24441 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
24442 index 836f832..a8bda67 100644
24443 --- a/arch/x86/kernel/kgdb.c
24444 +++ b/arch/x86/kernel/kgdb.c
24445 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
24446 #ifdef CONFIG_X86_32
24447 switch (regno) {
24448 case GDB_SS:
24449 - if (!user_mode_vm(regs))
24450 + if (!user_mode(regs))
24451 *(unsigned long *)mem = __KERNEL_DS;
24452 break;
24453 case GDB_SP:
24454 - if (!user_mode_vm(regs))
24455 + if (!user_mode(regs))
24456 *(unsigned long *)mem = kernel_stack_pointer(regs);
24457 break;
24458 case GDB_GS:
24459 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
24460 bp->attr.bp_addr = breakinfo[breakno].addr;
24461 bp->attr.bp_len = breakinfo[breakno].len;
24462 bp->attr.bp_type = breakinfo[breakno].type;
24463 - info->address = breakinfo[breakno].addr;
24464 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
24465 + info->address = ktla_ktva(breakinfo[breakno].addr);
24466 + else
24467 + info->address = breakinfo[breakno].addr;
24468 info->len = breakinfo[breakno].len;
24469 info->type = breakinfo[breakno].type;
24470 val = arch_install_hw_breakpoint(bp);
24471 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
24472 case 'k':
24473 /* clear the trace bit */
24474 linux_regs->flags &= ~X86_EFLAGS_TF;
24475 - atomic_set(&kgdb_cpu_doing_single_step, -1);
24476 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
24477
24478 /* set the trace bit if we're stepping */
24479 if (remcomInBuffer[0] == 's') {
24480 linux_regs->flags |= X86_EFLAGS_TF;
24481 - atomic_set(&kgdb_cpu_doing_single_step,
24482 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
24483 raw_smp_processor_id());
24484 }
24485
24486 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
24487
24488 switch (cmd) {
24489 case DIE_DEBUG:
24490 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
24491 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
24492 if (user_mode(regs))
24493 return single_step_cont(regs, args);
24494 break;
24495 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
24496 #endif /* CONFIG_DEBUG_RODATA */
24497
24498 bpt->type = BP_BREAKPOINT;
24499 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
24500 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
24501 BREAK_INSTR_SIZE);
24502 if (err)
24503 return err;
24504 - err = probe_kernel_write((char *)bpt->bpt_addr,
24505 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
24506 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
24507 #ifdef CONFIG_DEBUG_RODATA
24508 if (!err)
24509 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
24510 return -EBUSY;
24511 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
24512 BREAK_INSTR_SIZE);
24513 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
24514 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
24515 if (err)
24516 return err;
24517 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
24518 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
24519 if (mutex_is_locked(&text_mutex))
24520 goto knl_write;
24521 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
24522 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
24523 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
24524 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
24525 goto knl_write;
24526 return err;
24527 knl_write:
24528 #endif /* CONFIG_DEBUG_RODATA */
24529 - return probe_kernel_write((char *)bpt->bpt_addr,
24530 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
24531 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
24532 }
24533
24534 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
24535 index 79a3f96..6ba030a 100644
24536 --- a/arch/x86/kernel/kprobes/core.c
24537 +++ b/arch/x86/kernel/kprobes/core.c
24538 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
24539 s32 raddr;
24540 } __packed *insn;
24541
24542 - insn = (struct __arch_relative_insn *)from;
24543 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
24544 +
24545 + pax_open_kernel();
24546 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
24547 insn->op = op;
24548 + pax_close_kernel();
24549 }
24550
24551 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
24552 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
24553 kprobe_opcode_t opcode;
24554 kprobe_opcode_t *orig_opcodes = opcodes;
24555
24556 - if (search_exception_tables((unsigned long)opcodes))
24557 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
24558 return 0; /* Page fault may occur on this address. */
24559
24560 retry:
24561 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
24562 * for the first byte, we can recover the original instruction
24563 * from it and kp->opcode.
24564 */
24565 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
24566 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
24567 buf[0] = kp->opcode;
24568 - return (unsigned long)buf;
24569 + return ktva_ktla((unsigned long)buf);
24570 }
24571
24572 /*
24573 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
24574 /* Another subsystem puts a breakpoint, failed to recover */
24575 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
24576 return 0;
24577 + pax_open_kernel();
24578 memcpy(dest, insn.kaddr, insn.length);
24579 + pax_close_kernel();
24580
24581 #ifdef CONFIG_X86_64
24582 if (insn_rip_relative(&insn)) {
24583 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
24584 return 0;
24585 }
24586 disp = (u8 *) dest + insn_offset_displacement(&insn);
24587 + pax_open_kernel();
24588 *(s32 *) disp = (s32) newdisp;
24589 + pax_close_kernel();
24590 }
24591 #endif
24592 return insn.length;
24593 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
24594 * nor set current_kprobe, because it doesn't use single
24595 * stepping.
24596 */
24597 - regs->ip = (unsigned long)p->ainsn.insn;
24598 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
24599 preempt_enable_no_resched();
24600 return;
24601 }
24602 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
24603 regs->flags &= ~X86_EFLAGS_IF;
24604 /* single step inline if the instruction is an int3 */
24605 if (p->opcode == BREAKPOINT_INSTRUCTION)
24606 - regs->ip = (unsigned long)p->addr;
24607 + regs->ip = ktla_ktva((unsigned long)p->addr);
24608 else
24609 - regs->ip = (unsigned long)p->ainsn.insn;
24610 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
24611 }
24612
24613 /*
24614 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
24615 setup_singlestep(p, regs, kcb, 0);
24616 return 1;
24617 }
24618 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
24619 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
24620 /*
24621 * The breakpoint instruction was removed right
24622 * after we hit it. Another cpu has removed
24623 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
24624 " movq %rax, 152(%rsp)\n"
24625 RESTORE_REGS_STRING
24626 " popfq\n"
24627 +#ifdef KERNEXEC_PLUGIN
24628 + " btsq $63,(%rsp)\n"
24629 +#endif
24630 #else
24631 " pushf\n"
24632 SAVE_REGS_STRING
24633 @@ -779,7 +789,7 @@ static void __kprobes
24634 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
24635 {
24636 unsigned long *tos = stack_addr(regs);
24637 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
24638 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
24639 unsigned long orig_ip = (unsigned long)p->addr;
24640 kprobe_opcode_t *insn = p->ainsn.insn;
24641
24642 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
24643 struct die_args *args = data;
24644 int ret = NOTIFY_DONE;
24645
24646 - if (args->regs && user_mode_vm(args->regs))
24647 + if (args->regs && user_mode(args->regs))
24648 return ret;
24649
24650 switch (val) {
24651 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
24652 index 898160b..758cde8 100644
24653 --- a/arch/x86/kernel/kprobes/opt.c
24654 +++ b/arch/x86/kernel/kprobes/opt.c
24655 @@ -79,6 +79,7 @@ found:
24656 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
24657 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
24658 {
24659 + pax_open_kernel();
24660 #ifdef CONFIG_X86_64
24661 *addr++ = 0x48;
24662 *addr++ = 0xbf;
24663 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
24664 *addr++ = 0xb8;
24665 #endif
24666 *(unsigned long *)addr = val;
24667 + pax_close_kernel();
24668 }
24669
24670 asm (
24671 @@ -335,7 +337,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
24672 * Verify if the address gap is in 2GB range, because this uses
24673 * a relative jump.
24674 */
24675 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
24676 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
24677 if (abs(rel) > 0x7fffffff)
24678 return -ERANGE;
24679
24680 @@ -350,16 +352,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
24681 op->optinsn.size = ret;
24682
24683 /* Copy arch-dep-instance from template */
24684 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
24685 + pax_open_kernel();
24686 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
24687 + pax_close_kernel();
24688
24689 /* Set probe information */
24690 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
24691
24692 /* Set probe function call */
24693 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
24694 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
24695
24696 /* Set returning jmp instruction at the tail of out-of-line buffer */
24697 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
24698 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
24699 (u8 *)op->kp.addr + op->optinsn.size);
24700
24701 flush_icache_range((unsigned long) buf,
24702 @@ -384,7 +388,7 @@ void __kprobes arch_optimize_kprobes(struct list_head *oplist)
24703 WARN_ON(kprobe_disabled(&op->kp));
24704
24705 /* Backup instructions which will be replaced by jump address */
24706 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
24707 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
24708 RELATIVE_ADDR_SIZE);
24709
24710 insn_buf[0] = RELATIVEJUMP_OPCODE;
24711 @@ -433,7 +437,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
24712 /* This kprobe is really able to run optimized path. */
24713 op = container_of(p, struct optimized_kprobe, kp);
24714 /* Detour through copied instructions */
24715 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
24716 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
24717 if (!reenter)
24718 reset_current_kprobe();
24719 preempt_enable_no_resched();
24720 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
24721 index ebc9873..1b9724b 100644
24722 --- a/arch/x86/kernel/ldt.c
24723 +++ b/arch/x86/kernel/ldt.c
24724 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
24725 if (reload) {
24726 #ifdef CONFIG_SMP
24727 preempt_disable();
24728 - load_LDT(pc);
24729 + load_LDT_nolock(pc);
24730 if (!cpumask_equal(mm_cpumask(current->mm),
24731 cpumask_of(smp_processor_id())))
24732 smp_call_function(flush_ldt, current->mm, 1);
24733 preempt_enable();
24734 #else
24735 - load_LDT(pc);
24736 + load_LDT_nolock(pc);
24737 #endif
24738 }
24739 if (oldsize) {
24740 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
24741 return err;
24742
24743 for (i = 0; i < old->size; i++)
24744 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
24745 + write_ldt_entry(new->ldt, i, old->ldt + i);
24746 return 0;
24747 }
24748
24749 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
24750 retval = copy_ldt(&mm->context, &old_mm->context);
24751 mutex_unlock(&old_mm->context.lock);
24752 }
24753 +
24754 + if (tsk == current) {
24755 + mm->context.vdso = 0;
24756 +
24757 +#ifdef CONFIG_X86_32
24758 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
24759 + mm->context.user_cs_base = 0UL;
24760 + mm->context.user_cs_limit = ~0UL;
24761 +
24762 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
24763 + cpus_clear(mm->context.cpu_user_cs_mask);
24764 +#endif
24765 +
24766 +#endif
24767 +#endif
24768 +
24769 + }
24770 +
24771 return retval;
24772 }
24773
24774 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
24775 }
24776 }
24777
24778 +#ifdef CONFIG_PAX_SEGMEXEC
24779 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
24780 + error = -EINVAL;
24781 + goto out_unlock;
24782 + }
24783 +#endif
24784 +
24785 fill_ldt(&ldt, &ldt_info);
24786 if (oldmode)
24787 ldt.avl = 0;
24788 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
24789 index 5b19e4d..6476a76 100644
24790 --- a/arch/x86/kernel/machine_kexec_32.c
24791 +++ b/arch/x86/kernel/machine_kexec_32.c
24792 @@ -26,7 +26,7 @@
24793 #include <asm/cacheflush.h>
24794 #include <asm/debugreg.h>
24795
24796 -static void set_idt(void *newidt, __u16 limit)
24797 +static void set_idt(struct desc_struct *newidt, __u16 limit)
24798 {
24799 struct desc_ptr curidt;
24800
24801 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
24802 }
24803
24804
24805 -static void set_gdt(void *newgdt, __u16 limit)
24806 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
24807 {
24808 struct desc_ptr curgdt;
24809
24810 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24811 }
24812
24813 control_page = page_address(image->control_code_page);
24814 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24815 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24816
24817 relocate_kernel_ptr = control_page;
24818 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24819 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24820 index 15c9876..0a43909 100644
24821 --- a/arch/x86/kernel/microcode_core.c
24822 +++ b/arch/x86/kernel/microcode_core.c
24823 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24824 return NOTIFY_OK;
24825 }
24826
24827 -static struct notifier_block __refdata mc_cpu_notifier = {
24828 +static struct notifier_block mc_cpu_notifier = {
24829 .notifier_call = mc_cpu_callback,
24830 };
24831
24832 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24833 index 5fb2ceb..3ae90bb 100644
24834 --- a/arch/x86/kernel/microcode_intel.c
24835 +++ b/arch/x86/kernel/microcode_intel.c
24836 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24837
24838 static int get_ucode_user(void *to, const void *from, size_t n)
24839 {
24840 - return copy_from_user(to, from, n);
24841 + return copy_from_user(to, (const void __force_user *)from, n);
24842 }
24843
24844 static enum ucode_state
24845 request_microcode_user(int cpu, const void __user *buf, size_t size)
24846 {
24847 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24848 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24849 }
24850
24851 static void microcode_fini_cpu(int cpu)
24852 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24853 index 216a4d7..228255a 100644
24854 --- a/arch/x86/kernel/module.c
24855 +++ b/arch/x86/kernel/module.c
24856 @@ -43,15 +43,60 @@ do { \
24857 } while (0)
24858 #endif
24859
24860 -void *module_alloc(unsigned long size)
24861 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24862 {
24863 - if (PAGE_ALIGN(size) > MODULES_LEN)
24864 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24865 return NULL;
24866 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24867 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24868 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24869 -1, __builtin_return_address(0));
24870 }
24871
24872 +void *module_alloc(unsigned long size)
24873 +{
24874 +
24875 +#ifdef CONFIG_PAX_KERNEXEC
24876 + return __module_alloc(size, PAGE_KERNEL);
24877 +#else
24878 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24879 +#endif
24880 +
24881 +}
24882 +
24883 +#ifdef CONFIG_PAX_KERNEXEC
24884 +#ifdef CONFIG_X86_32
24885 +void *module_alloc_exec(unsigned long size)
24886 +{
24887 + struct vm_struct *area;
24888 +
24889 + if (size == 0)
24890 + return NULL;
24891 +
24892 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24893 + return area ? area->addr : NULL;
24894 +}
24895 +EXPORT_SYMBOL(module_alloc_exec);
24896 +
24897 +void module_free_exec(struct module *mod, void *module_region)
24898 +{
24899 + vunmap(module_region);
24900 +}
24901 +EXPORT_SYMBOL(module_free_exec);
24902 +#else
24903 +void module_free_exec(struct module *mod, void *module_region)
24904 +{
24905 + module_free(mod, module_region);
24906 +}
24907 +EXPORT_SYMBOL(module_free_exec);
24908 +
24909 +void *module_alloc_exec(unsigned long size)
24910 +{
24911 + return __module_alloc(size, PAGE_KERNEL_RX);
24912 +}
24913 +EXPORT_SYMBOL(module_alloc_exec);
24914 +#endif
24915 +#endif
24916 +
24917 #ifdef CONFIG_X86_32
24918 int apply_relocate(Elf32_Shdr *sechdrs,
24919 const char *strtab,
24920 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24921 unsigned int i;
24922 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24923 Elf32_Sym *sym;
24924 - uint32_t *location;
24925 + uint32_t *plocation, location;
24926
24927 DEBUGP("Applying relocate section %u to %u\n",
24928 relsec, sechdrs[relsec].sh_info);
24929 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24930 /* This is where to make the change */
24931 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24932 - + rel[i].r_offset;
24933 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24934 + location = (uint32_t)plocation;
24935 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24936 + plocation = ktla_ktva((void *)plocation);
24937 /* This is the symbol it is referring to. Note that all
24938 undefined symbols have been resolved. */
24939 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24940 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24941 switch (ELF32_R_TYPE(rel[i].r_info)) {
24942 case R_386_32:
24943 /* We add the value into the location given */
24944 - *location += sym->st_value;
24945 + pax_open_kernel();
24946 + *plocation += sym->st_value;
24947 + pax_close_kernel();
24948 break;
24949 case R_386_PC32:
24950 /* Add the value, subtract its position */
24951 - *location += sym->st_value - (uint32_t)location;
24952 + pax_open_kernel();
24953 + *plocation += sym->st_value - location;
24954 + pax_close_kernel();
24955 break;
24956 default:
24957 pr_err("%s: Unknown relocation: %u\n",
24958 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24959 case R_X86_64_NONE:
24960 break;
24961 case R_X86_64_64:
24962 + pax_open_kernel();
24963 *(u64 *)loc = val;
24964 + pax_close_kernel();
24965 break;
24966 case R_X86_64_32:
24967 + pax_open_kernel();
24968 *(u32 *)loc = val;
24969 + pax_close_kernel();
24970 if (val != *(u32 *)loc)
24971 goto overflow;
24972 break;
24973 case R_X86_64_32S:
24974 + pax_open_kernel();
24975 *(s32 *)loc = val;
24976 + pax_close_kernel();
24977 if ((s64)val != *(s32 *)loc)
24978 goto overflow;
24979 break;
24980 case R_X86_64_PC32:
24981 val -= (u64)loc;
24982 + pax_open_kernel();
24983 *(u32 *)loc = val;
24984 + pax_close_kernel();
24985 +
24986 #if 0
24987 if ((s64)val != *(s32 *)loc)
24988 goto overflow;
24989 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24990 index 88458fa..349f7a4 100644
24991 --- a/arch/x86/kernel/msr.c
24992 +++ b/arch/x86/kernel/msr.c
24993 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24994 return notifier_from_errno(err);
24995 }
24996
24997 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24998 +static struct notifier_block msr_class_cpu_notifier = {
24999 .notifier_call = msr_class_cpu_callback,
25000 };
25001
25002 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
25003 index 6fcb49c..5b3f4ff 100644
25004 --- a/arch/x86/kernel/nmi.c
25005 +++ b/arch/x86/kernel/nmi.c
25006 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
25007 return handled;
25008 }
25009
25010 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
25011 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
25012 {
25013 struct nmi_desc *desc = nmi_to_desc(type);
25014 unsigned long flags;
25015 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
25016 * event confuses some handlers (kdump uses this flag)
25017 */
25018 if (action->flags & NMI_FLAG_FIRST)
25019 - list_add_rcu(&action->list, &desc->head);
25020 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
25021 else
25022 - list_add_tail_rcu(&action->list, &desc->head);
25023 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
25024
25025 spin_unlock_irqrestore(&desc->lock, flags);
25026 return 0;
25027 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
25028 if (!strcmp(n->name, name)) {
25029 WARN(in_nmi(),
25030 "Trying to free NMI (%s) from NMI context!\n", n->name);
25031 - list_del_rcu(&n->list);
25032 + pax_list_del_rcu((struct list_head *)&n->list);
25033 break;
25034 }
25035 }
25036 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
25037 dotraplinkage notrace __kprobes void
25038 do_nmi(struct pt_regs *regs, long error_code)
25039 {
25040 +
25041 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25042 + if (!user_mode(regs)) {
25043 + unsigned long cs = regs->cs & 0xFFFF;
25044 + unsigned long ip = ktva_ktla(regs->ip);
25045 +
25046 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
25047 + regs->ip = ip;
25048 + }
25049 +#endif
25050 +
25051 nmi_nesting_preprocess(regs);
25052
25053 nmi_enter();
25054 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
25055 index 6d9582e..f746287 100644
25056 --- a/arch/x86/kernel/nmi_selftest.c
25057 +++ b/arch/x86/kernel/nmi_selftest.c
25058 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
25059 {
25060 /* trap all the unknown NMIs we may generate */
25061 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
25062 - __initdata);
25063 + __initconst);
25064 }
25065
25066 static void __init cleanup_nmi_testsuite(void)
25067 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
25068 unsigned long timeout;
25069
25070 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
25071 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
25072 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
25073 nmi_fail = FAILURE;
25074 return;
25075 }
25076 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
25077 index bbb6c73..24a58ef 100644
25078 --- a/arch/x86/kernel/paravirt-spinlocks.c
25079 +++ b/arch/x86/kernel/paravirt-spinlocks.c
25080 @@ -8,7 +8,7 @@
25081
25082 #include <asm/paravirt.h>
25083
25084 -struct pv_lock_ops pv_lock_ops = {
25085 +struct pv_lock_ops pv_lock_ops __read_only = {
25086 #ifdef CONFIG_SMP
25087 .lock_spinning = __PV_IS_CALLEE_SAVE(paravirt_nop),
25088 .unlock_kick = paravirt_nop,
25089 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
25090 index 1b10af8..0b58cbc 100644
25091 --- a/arch/x86/kernel/paravirt.c
25092 +++ b/arch/x86/kernel/paravirt.c
25093 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
25094 {
25095 return x;
25096 }
25097 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
25098 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
25099 +#endif
25100
25101 void __init default_banner(void)
25102 {
25103 @@ -142,15 +145,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
25104 if (opfunc == NULL)
25105 /* If there's no function, patch it with a ud2a (BUG) */
25106 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
25107 - else if (opfunc == _paravirt_nop)
25108 + else if (opfunc == (void *)_paravirt_nop)
25109 /* If the operation is a nop, then nop the callsite */
25110 ret = paravirt_patch_nop();
25111
25112 /* identity functions just return their single argument */
25113 - else if (opfunc == _paravirt_ident_32)
25114 + else if (opfunc == (void *)_paravirt_ident_32)
25115 ret = paravirt_patch_ident_32(insnbuf, len);
25116 - else if (opfunc == _paravirt_ident_64)
25117 + else if (opfunc == (void *)_paravirt_ident_64)
25118 ret = paravirt_patch_ident_64(insnbuf, len);
25119 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
25120 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
25121 + ret = paravirt_patch_ident_64(insnbuf, len);
25122 +#endif
25123
25124 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
25125 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
25126 @@ -175,7 +182,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
25127 if (insn_len > len || start == NULL)
25128 insn_len = len;
25129 else
25130 - memcpy(insnbuf, start, insn_len);
25131 + memcpy(insnbuf, ktla_ktva(start), insn_len);
25132
25133 return insn_len;
25134 }
25135 @@ -299,7 +306,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
25136 return this_cpu_read(paravirt_lazy_mode);
25137 }
25138
25139 -struct pv_info pv_info = {
25140 +struct pv_info pv_info __read_only = {
25141 .name = "bare hardware",
25142 .paravirt_enabled = 0,
25143 .kernel_rpl = 0,
25144 @@ -310,16 +317,16 @@ struct pv_info pv_info = {
25145 #endif
25146 };
25147
25148 -struct pv_init_ops pv_init_ops = {
25149 +struct pv_init_ops pv_init_ops __read_only = {
25150 .patch = native_patch,
25151 };
25152
25153 -struct pv_time_ops pv_time_ops = {
25154 +struct pv_time_ops pv_time_ops __read_only = {
25155 .sched_clock = native_sched_clock,
25156 .steal_clock = native_steal_clock,
25157 };
25158
25159 -__visible struct pv_irq_ops pv_irq_ops = {
25160 +__visible struct pv_irq_ops pv_irq_ops __read_only = {
25161 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
25162 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
25163 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
25164 @@ -331,7 +338,7 @@ __visible struct pv_irq_ops pv_irq_ops = {
25165 #endif
25166 };
25167
25168 -__visible struct pv_cpu_ops pv_cpu_ops = {
25169 +__visible struct pv_cpu_ops pv_cpu_ops __read_only = {
25170 .cpuid = native_cpuid,
25171 .get_debugreg = native_get_debugreg,
25172 .set_debugreg = native_set_debugreg,
25173 @@ -389,21 +396,26 @@ __visible struct pv_cpu_ops pv_cpu_ops = {
25174 .end_context_switch = paravirt_nop,
25175 };
25176
25177 -struct pv_apic_ops pv_apic_ops = {
25178 +struct pv_apic_ops pv_apic_ops __read_only= {
25179 #ifdef CONFIG_X86_LOCAL_APIC
25180 .startup_ipi_hook = paravirt_nop,
25181 #endif
25182 };
25183
25184 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
25185 +#ifdef CONFIG_X86_32
25186 +#ifdef CONFIG_X86_PAE
25187 +/* 64-bit pagetable entries */
25188 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
25189 +#else
25190 /* 32-bit pagetable entries */
25191 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
25192 +#endif
25193 #else
25194 /* 64-bit pagetable entries */
25195 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
25196 #endif
25197
25198 -struct pv_mmu_ops pv_mmu_ops = {
25199 +struct pv_mmu_ops pv_mmu_ops __read_only = {
25200
25201 .read_cr2 = native_read_cr2,
25202 .write_cr2 = native_write_cr2,
25203 @@ -453,6 +465,7 @@ struct pv_mmu_ops pv_mmu_ops = {
25204 .make_pud = PTE_IDENT,
25205
25206 .set_pgd = native_set_pgd,
25207 + .set_pgd_batched = native_set_pgd_batched,
25208 #endif
25209 #endif /* PAGETABLE_LEVELS >= 3 */
25210
25211 @@ -473,6 +486,12 @@ struct pv_mmu_ops pv_mmu_ops = {
25212 },
25213
25214 .set_fixmap = native_set_fixmap,
25215 +
25216 +#ifdef CONFIG_PAX_KERNEXEC
25217 + .pax_open_kernel = native_pax_open_kernel,
25218 + .pax_close_kernel = native_pax_close_kernel,
25219 +#endif
25220 +
25221 };
25222
25223 EXPORT_SYMBOL_GPL(pv_time_ops);
25224 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
25225 index 299d493..2ccb0ee 100644
25226 --- a/arch/x86/kernel/pci-calgary_64.c
25227 +++ b/arch/x86/kernel/pci-calgary_64.c
25228 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
25229 tce_space = be64_to_cpu(readq(target));
25230 tce_space = tce_space & TAR_SW_BITS;
25231
25232 - tce_space = tce_space & (~specified_table_size);
25233 + tce_space = tce_space & (~(unsigned long)specified_table_size);
25234 info->tce_space = (u64 *)__va(tce_space);
25235 }
25236 }
25237 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
25238 index 35ccf75..7a15747 100644
25239 --- a/arch/x86/kernel/pci-iommu_table.c
25240 +++ b/arch/x86/kernel/pci-iommu_table.c
25241 @@ -2,7 +2,7 @@
25242 #include <asm/iommu_table.h>
25243 #include <linux/string.h>
25244 #include <linux/kallsyms.h>
25245 -
25246 +#include <linux/sched.h>
25247
25248 #define DEBUG 1
25249
25250 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
25251 index 6c483ba..d10ce2f 100644
25252 --- a/arch/x86/kernel/pci-swiotlb.c
25253 +++ b/arch/x86/kernel/pci-swiotlb.c
25254 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
25255 void *vaddr, dma_addr_t dma_addr,
25256 struct dma_attrs *attrs)
25257 {
25258 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
25259 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
25260 }
25261
25262 static struct dma_map_ops swiotlb_dma_ops = {
25263 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
25264 index 3fb8d95..254dc51 100644
25265 --- a/arch/x86/kernel/process.c
25266 +++ b/arch/x86/kernel/process.c
25267 @@ -36,7 +36,8 @@
25268 * section. Since TSS's are completely CPU-local, we want them
25269 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
25270 */
25271 -__visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
25272 +struct tss_struct init_tss[NR_CPUS] __visible ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
25273 +EXPORT_SYMBOL(init_tss);
25274
25275 #ifdef CONFIG_X86_64
25276 static DEFINE_PER_CPU(unsigned char, is_idle);
25277 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
25278 task_xstate_cachep =
25279 kmem_cache_create("task_xstate", xstate_size,
25280 __alignof__(union thread_xstate),
25281 - SLAB_PANIC | SLAB_NOTRACK, NULL);
25282 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
25283 }
25284
25285 /*
25286 @@ -105,7 +106,7 @@ void exit_thread(void)
25287 unsigned long *bp = t->io_bitmap_ptr;
25288
25289 if (bp) {
25290 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
25291 + struct tss_struct *tss = init_tss + get_cpu();
25292
25293 t->io_bitmap_ptr = NULL;
25294 clear_thread_flag(TIF_IO_BITMAP);
25295 @@ -125,6 +126,9 @@ void flush_thread(void)
25296 {
25297 struct task_struct *tsk = current;
25298
25299 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
25300 + loadsegment(gs, 0);
25301 +#endif
25302 flush_ptrace_hw_breakpoint(tsk);
25303 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
25304 drop_init_fpu(tsk);
25305 @@ -271,7 +275,7 @@ static void __exit_idle(void)
25306 void exit_idle(void)
25307 {
25308 /* idle loop has pid 0 */
25309 - if (current->pid)
25310 + if (task_pid_nr(current))
25311 return;
25312 __exit_idle();
25313 }
25314 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
25315 return ret;
25316 }
25317 #endif
25318 -void stop_this_cpu(void *dummy)
25319 +__noreturn void stop_this_cpu(void *dummy)
25320 {
25321 local_irq_disable();
25322 /*
25323 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
25324 }
25325 early_param("idle", idle_setup);
25326
25327 -unsigned long arch_align_stack(unsigned long sp)
25328 +#ifdef CONFIG_PAX_RANDKSTACK
25329 +void pax_randomize_kstack(struct pt_regs *regs)
25330 {
25331 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
25332 - sp -= get_random_int() % 8192;
25333 - return sp & ~0xf;
25334 -}
25335 + struct thread_struct *thread = &current->thread;
25336 + unsigned long time;
25337
25338 -unsigned long arch_randomize_brk(struct mm_struct *mm)
25339 -{
25340 - unsigned long range_end = mm->brk + 0x02000000;
25341 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
25342 -}
25343 + if (!randomize_va_space)
25344 + return;
25345 +
25346 + if (v8086_mode(regs))
25347 + return;
25348
25349 + rdtscl(time);
25350 +
25351 + /* P4 seems to return a 0 LSB, ignore it */
25352 +#ifdef CONFIG_MPENTIUM4
25353 + time &= 0x3EUL;
25354 + time <<= 2;
25355 +#elif defined(CONFIG_X86_64)
25356 + time &= 0xFUL;
25357 + time <<= 4;
25358 +#else
25359 + time &= 0x1FUL;
25360 + time <<= 3;
25361 +#endif
25362 +
25363 + thread->sp0 ^= time;
25364 + load_sp0(init_tss + smp_processor_id(), thread);
25365 +
25366 +#ifdef CONFIG_X86_64
25367 + this_cpu_write(kernel_stack, thread->sp0);
25368 +#endif
25369 +}
25370 +#endif
25371 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
25372 index 884f98f..ec23e04 100644
25373 --- a/arch/x86/kernel/process_32.c
25374 +++ b/arch/x86/kernel/process_32.c
25375 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
25376 unsigned long thread_saved_pc(struct task_struct *tsk)
25377 {
25378 return ((unsigned long *)tsk->thread.sp)[3];
25379 +//XXX return tsk->thread.eip;
25380 }
25381
25382 void __show_regs(struct pt_regs *regs, int all)
25383 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
25384 unsigned long sp;
25385 unsigned short ss, gs;
25386
25387 - if (user_mode_vm(regs)) {
25388 + if (user_mode(regs)) {
25389 sp = regs->sp;
25390 ss = regs->ss & 0xffff;
25391 - gs = get_user_gs(regs);
25392 } else {
25393 sp = kernel_stack_pointer(regs);
25394 savesegment(ss, ss);
25395 - savesegment(gs, gs);
25396 }
25397 + gs = get_user_gs(regs);
25398
25399 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
25400 (u16)regs->cs, regs->ip, regs->flags,
25401 - smp_processor_id());
25402 + raw_smp_processor_id());
25403 print_symbol("EIP is at %s\n", regs->ip);
25404
25405 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
25406 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
25407 int copy_thread(unsigned long clone_flags, unsigned long sp,
25408 unsigned long arg, struct task_struct *p)
25409 {
25410 - struct pt_regs *childregs = task_pt_regs(p);
25411 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
25412 struct task_struct *tsk;
25413 int err;
25414
25415 p->thread.sp = (unsigned long) childregs;
25416 p->thread.sp0 = (unsigned long) (childregs+1);
25417 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
25418
25419 if (unlikely(p->flags & PF_KTHREAD)) {
25420 /* kernel thread */
25421 memset(childregs, 0, sizeof(struct pt_regs));
25422 p->thread.ip = (unsigned long) ret_from_kernel_thread;
25423 - task_user_gs(p) = __KERNEL_STACK_CANARY;
25424 - childregs->ds = __USER_DS;
25425 - childregs->es = __USER_DS;
25426 + savesegment(gs, childregs->gs);
25427 + childregs->ds = __KERNEL_DS;
25428 + childregs->es = __KERNEL_DS;
25429 childregs->fs = __KERNEL_PERCPU;
25430 childregs->bx = sp; /* function */
25431 childregs->bp = arg;
25432 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25433 struct thread_struct *prev = &prev_p->thread,
25434 *next = &next_p->thread;
25435 int cpu = smp_processor_id();
25436 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
25437 + struct tss_struct *tss = init_tss + cpu;
25438 fpu_switch_t fpu;
25439
25440 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
25441 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25442 */
25443 lazy_save_gs(prev->gs);
25444
25445 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25446 + __set_fs(task_thread_info(next_p)->addr_limit);
25447 +#endif
25448 +
25449 /*
25450 * Load the per-thread Thread-Local Storage descriptor.
25451 */
25452 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25453 */
25454 arch_end_context_switch(next_p);
25455
25456 + this_cpu_write(current_task, next_p);
25457 + this_cpu_write(current_tinfo, &next_p->tinfo);
25458 +
25459 /*
25460 * Restore %gs if needed (which is common)
25461 */
25462 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25463
25464 switch_fpu_finish(next_p, fpu);
25465
25466 - this_cpu_write(current_task, next_p);
25467 -
25468 return prev_p;
25469 }
25470
25471 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
25472 } while (count++ < 16);
25473 return 0;
25474 }
25475 -
25476 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
25477 index bb1dc51..08dda7f 100644
25478 --- a/arch/x86/kernel/process_64.c
25479 +++ b/arch/x86/kernel/process_64.c
25480 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
25481 struct pt_regs *childregs;
25482 struct task_struct *me = current;
25483
25484 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
25485 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
25486 childregs = task_pt_regs(p);
25487 p->thread.sp = (unsigned long) childregs;
25488 p->thread.usersp = me->thread.usersp;
25489 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
25490 set_tsk_thread_flag(p, TIF_FORK);
25491 p->fpu_counter = 0;
25492 p->thread.io_bitmap_ptr = NULL;
25493 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
25494 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
25495 savesegment(es, p->thread.es);
25496 savesegment(ds, p->thread.ds);
25497 + savesegment(ss, p->thread.ss);
25498 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
25499 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
25500
25501 if (unlikely(p->flags & PF_KTHREAD)) {
25502 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25503 struct thread_struct *prev = &prev_p->thread;
25504 struct thread_struct *next = &next_p->thread;
25505 int cpu = smp_processor_id();
25506 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
25507 + struct tss_struct *tss = init_tss + cpu;
25508 unsigned fsindex, gsindex;
25509 fpu_switch_t fpu;
25510
25511 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25512 if (unlikely(next->ds | prev->ds))
25513 loadsegment(ds, next->ds);
25514
25515 + savesegment(ss, prev->ss);
25516 + if (unlikely(next->ss != prev->ss))
25517 + loadsegment(ss, next->ss);
25518
25519 /* We must save %fs and %gs before load_TLS() because
25520 * %fs and %gs may be cleared by load_TLS().
25521 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25522 prev->usersp = this_cpu_read(old_rsp);
25523 this_cpu_write(old_rsp, next->usersp);
25524 this_cpu_write(current_task, next_p);
25525 + this_cpu_write(current_tinfo, &next_p->tinfo);
25526
25527 - this_cpu_write(kernel_stack,
25528 - (unsigned long)task_stack_page(next_p) +
25529 - THREAD_SIZE - KERNEL_STACK_OFFSET);
25530 + this_cpu_write(kernel_stack, next->sp0);
25531
25532 /*
25533 * Now maybe reload the debug registers and handle I/O bitmaps
25534 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
25535 if (!p || p == current || p->state == TASK_RUNNING)
25536 return 0;
25537 stack = (unsigned long)task_stack_page(p);
25538 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
25539 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
25540 return 0;
25541 fp = *(u64 *)(p->thread.sp);
25542 do {
25543 - if (fp < (unsigned long)stack ||
25544 - fp >= (unsigned long)stack+THREAD_SIZE)
25545 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
25546 return 0;
25547 ip = *(u64 *)(fp+8);
25548 if (!in_sched_functions(ip))
25549 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
25550 index 7461f50..1334029 100644
25551 --- a/arch/x86/kernel/ptrace.c
25552 +++ b/arch/x86/kernel/ptrace.c
25553 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
25554 {
25555 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
25556 unsigned long sp = (unsigned long)&regs->sp;
25557 - struct thread_info *tinfo;
25558
25559 - if (context == (sp & ~(THREAD_SIZE - 1)))
25560 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
25561 return sp;
25562
25563 - tinfo = (struct thread_info *)context;
25564 - if (tinfo->previous_esp)
25565 - return tinfo->previous_esp;
25566 + sp = *(unsigned long *)context;
25567 + if (sp)
25568 + return sp;
25569
25570 return (unsigned long)regs;
25571 }
25572 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
25573 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
25574 {
25575 int i;
25576 - int dr7 = 0;
25577 + unsigned long dr7 = 0;
25578 struct arch_hw_breakpoint *info;
25579
25580 for (i = 0; i < HBP_NUM; i++) {
25581 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
25582 unsigned long addr, unsigned long data)
25583 {
25584 int ret;
25585 - unsigned long __user *datap = (unsigned long __user *)data;
25586 + unsigned long __user *datap = (__force unsigned long __user *)data;
25587
25588 switch (request) {
25589 /* read the word at location addr in the USER area. */
25590 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
25591 if ((int) addr < 0)
25592 return -EIO;
25593 ret = do_get_thread_area(child, addr,
25594 - (struct user_desc __user *)data);
25595 + (__force struct user_desc __user *) data);
25596 break;
25597
25598 case PTRACE_SET_THREAD_AREA:
25599 if ((int) addr < 0)
25600 return -EIO;
25601 ret = do_set_thread_area(child, addr,
25602 - (struct user_desc __user *)data, 0);
25603 + (__force struct user_desc __user *) data, 0);
25604 break;
25605 #endif
25606
25607 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
25608
25609 #ifdef CONFIG_X86_64
25610
25611 -static struct user_regset x86_64_regsets[] __read_mostly = {
25612 +static user_regset_no_const x86_64_regsets[] __read_only = {
25613 [REGSET_GENERAL] = {
25614 .core_note_type = NT_PRSTATUS,
25615 .n = sizeof(struct user_regs_struct) / sizeof(long),
25616 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
25617 #endif /* CONFIG_X86_64 */
25618
25619 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
25620 -static struct user_regset x86_32_regsets[] __read_mostly = {
25621 +static user_regset_no_const x86_32_regsets[] __read_only = {
25622 [REGSET_GENERAL] = {
25623 .core_note_type = NT_PRSTATUS,
25624 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
25625 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
25626 */
25627 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
25628
25629 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
25630 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
25631 {
25632 #ifdef CONFIG_X86_64
25633 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
25634 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
25635 memset(info, 0, sizeof(*info));
25636 info->si_signo = SIGTRAP;
25637 info->si_code = si_code;
25638 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
25639 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
25640 }
25641
25642 void user_single_step_siginfo(struct task_struct *tsk,
25643 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
25644 # define IS_IA32 0
25645 #endif
25646
25647 +#ifdef CONFIG_GRKERNSEC_SETXID
25648 +extern void gr_delayed_cred_worker(void);
25649 +#endif
25650 +
25651 /*
25652 * We must return the syscall number to actually look up in the table.
25653 * This can be -1L to skip running any syscall at all.
25654 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
25655
25656 user_exit();
25657
25658 +#ifdef CONFIG_GRKERNSEC_SETXID
25659 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
25660 + gr_delayed_cred_worker();
25661 +#endif
25662 +
25663 /*
25664 * If we stepped into a sysenter/syscall insn, it trapped in
25665 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
25666 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
25667 */
25668 user_exit();
25669
25670 +#ifdef CONFIG_GRKERNSEC_SETXID
25671 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
25672 + gr_delayed_cred_worker();
25673 +#endif
25674 +
25675 audit_syscall_exit(regs);
25676
25677 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
25678 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
25679 index a16bae3..1f65f25 100644
25680 --- a/arch/x86/kernel/pvclock.c
25681 +++ b/arch/x86/kernel/pvclock.c
25682 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
25683 return pv_tsc_khz;
25684 }
25685
25686 -static atomic64_t last_value = ATOMIC64_INIT(0);
25687 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
25688
25689 void pvclock_resume(void)
25690 {
25691 - atomic64_set(&last_value, 0);
25692 + atomic64_set_unchecked(&last_value, 0);
25693 }
25694
25695 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
25696 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
25697 * updating at the same time, and one of them could be slightly behind,
25698 * making the assumption that last_value always go forward fail to hold.
25699 */
25700 - last = atomic64_read(&last_value);
25701 + last = atomic64_read_unchecked(&last_value);
25702 do {
25703 if (ret < last)
25704 return last;
25705 - last = atomic64_cmpxchg(&last_value, last, ret);
25706 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
25707 } while (unlikely(last != ret));
25708
25709 return ret;
25710 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
25711 index 618ce26..ec7e21c 100644
25712 --- a/arch/x86/kernel/reboot.c
25713 +++ b/arch/x86/kernel/reboot.c
25714 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
25715
25716 void __noreturn machine_real_restart(unsigned int type)
25717 {
25718 +
25719 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
25720 + struct desc_struct *gdt;
25721 +#endif
25722 +
25723 local_irq_disable();
25724
25725 /*
25726 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
25727
25728 /* Jump to the identity-mapped low memory code */
25729 #ifdef CONFIG_X86_32
25730 - asm volatile("jmpl *%0" : :
25731 +
25732 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
25733 + gdt = get_cpu_gdt_table(smp_processor_id());
25734 + pax_open_kernel();
25735 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25736 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
25737 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
25738 + loadsegment(ds, __KERNEL_DS);
25739 + loadsegment(es, __KERNEL_DS);
25740 + loadsegment(ss, __KERNEL_DS);
25741 +#endif
25742 +#ifdef CONFIG_PAX_KERNEXEC
25743 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
25744 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
25745 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
25746 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
25747 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
25748 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
25749 +#endif
25750 + pax_close_kernel();
25751 +#endif
25752 +
25753 + asm volatile("ljmpl *%0" : :
25754 "rm" (real_mode_header->machine_real_restart_asm),
25755 "a" (type));
25756 #else
25757 @@ -466,7 +493,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
25758 * try to force a triple fault and then cycle between hitting the keyboard
25759 * controller and doing that
25760 */
25761 -static void native_machine_emergency_restart(void)
25762 +static void __noreturn native_machine_emergency_restart(void)
25763 {
25764 int i;
25765 int attempt = 0;
25766 @@ -575,13 +602,13 @@ void native_machine_shutdown(void)
25767 #endif
25768 }
25769
25770 -static void __machine_emergency_restart(int emergency)
25771 +static void __noreturn __machine_emergency_restart(int emergency)
25772 {
25773 reboot_emergency = emergency;
25774 machine_ops.emergency_restart();
25775 }
25776
25777 -static void native_machine_restart(char *__unused)
25778 +static void __noreturn native_machine_restart(char *__unused)
25779 {
25780 pr_notice("machine restart\n");
25781
25782 @@ -590,7 +617,7 @@ static void native_machine_restart(char *__unused)
25783 __machine_emergency_restart(0);
25784 }
25785
25786 -static void native_machine_halt(void)
25787 +static void __noreturn native_machine_halt(void)
25788 {
25789 /* Stop other cpus and apics */
25790 machine_shutdown();
25791 @@ -600,7 +627,7 @@ static void native_machine_halt(void)
25792 stop_this_cpu(NULL);
25793 }
25794
25795 -static void native_machine_power_off(void)
25796 +static void __noreturn native_machine_power_off(void)
25797 {
25798 if (pm_power_off) {
25799 if (!reboot_force)
25800 @@ -609,9 +636,10 @@ static void native_machine_power_off(void)
25801 }
25802 /* A fallback in case there is no PM info available */
25803 tboot_shutdown(TB_SHUTDOWN_HALT);
25804 + unreachable();
25805 }
25806
25807 -struct machine_ops machine_ops = {
25808 +struct machine_ops machine_ops __read_only = {
25809 .power_off = native_machine_power_off,
25810 .shutdown = native_machine_shutdown,
25811 .emergency_restart = native_machine_emergency_restart,
25812 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25813 index c8e41e9..64049ef 100644
25814 --- a/arch/x86/kernel/reboot_fixups_32.c
25815 +++ b/arch/x86/kernel/reboot_fixups_32.c
25816 @@ -57,7 +57,7 @@ struct device_fixup {
25817 unsigned int vendor;
25818 unsigned int device;
25819 void (*reboot_fixup)(struct pci_dev *);
25820 -};
25821 +} __do_const;
25822
25823 /*
25824 * PCI ids solely used for fixups_table go here
25825 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25826 index 3fd2c69..16ef367 100644
25827 --- a/arch/x86/kernel/relocate_kernel_64.S
25828 +++ b/arch/x86/kernel/relocate_kernel_64.S
25829 @@ -11,6 +11,7 @@
25830 #include <asm/kexec.h>
25831 #include <asm/processor-flags.h>
25832 #include <asm/pgtable_types.h>
25833 +#include <asm/alternative-asm.h>
25834
25835 /*
25836 * Must be relocatable PIC code callable as a C function
25837 @@ -96,8 +97,7 @@ relocate_kernel:
25838
25839 /* jump to identity mapped page */
25840 addq $(identity_mapped - relocate_kernel), %r8
25841 - pushq %r8
25842 - ret
25843 + jmp *%r8
25844
25845 identity_mapped:
25846 /* set return address to 0 if not preserving context */
25847 @@ -167,6 +167,7 @@ identity_mapped:
25848 xorl %r14d, %r14d
25849 xorl %r15d, %r15d
25850
25851 + pax_force_retaddr 0, 1
25852 ret
25853
25854 1:
25855 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25856 index f0de629..a4978a8f 100644
25857 --- a/arch/x86/kernel/setup.c
25858 +++ b/arch/x86/kernel/setup.c
25859 @@ -110,6 +110,7 @@
25860 #include <asm/mce.h>
25861 #include <asm/alternative.h>
25862 #include <asm/prom.h>
25863 +#include <asm/boot.h>
25864
25865 /*
25866 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25867 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25868 #endif
25869
25870
25871 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25872 -__visible unsigned long mmu_cr4_features;
25873 +#ifdef CONFIG_X86_64
25874 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25875 +#elif defined(CONFIG_X86_PAE)
25876 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25877 #else
25878 -__visible unsigned long mmu_cr4_features = X86_CR4_PAE;
25879 +__visible unsigned long mmu_cr4_features __read_only;
25880 #endif
25881
25882 +void set_in_cr4(unsigned long mask)
25883 +{
25884 + unsigned long cr4 = read_cr4();
25885 +
25886 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25887 + return;
25888 +
25889 + pax_open_kernel();
25890 + mmu_cr4_features |= mask;
25891 + pax_close_kernel();
25892 +
25893 + if (trampoline_cr4_features)
25894 + *trampoline_cr4_features = mmu_cr4_features;
25895 + cr4 |= mask;
25896 + write_cr4(cr4);
25897 +}
25898 +EXPORT_SYMBOL(set_in_cr4);
25899 +
25900 +void clear_in_cr4(unsigned long mask)
25901 +{
25902 + unsigned long cr4 = read_cr4();
25903 +
25904 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25905 + return;
25906 +
25907 + pax_open_kernel();
25908 + mmu_cr4_features &= ~mask;
25909 + pax_close_kernel();
25910 +
25911 + if (trampoline_cr4_features)
25912 + *trampoline_cr4_features = mmu_cr4_features;
25913 + cr4 &= ~mask;
25914 + write_cr4(cr4);
25915 +}
25916 +EXPORT_SYMBOL(clear_in_cr4);
25917 +
25918 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25919 int bootloader_type, bootloader_version;
25920
25921 @@ -768,7 +807,7 @@ static void __init trim_bios_range(void)
25922 * area (640->1Mb) as ram even though it is not.
25923 * take them out.
25924 */
25925 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25926 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25927
25928 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25929 }
25930 @@ -776,7 +815,7 @@ static void __init trim_bios_range(void)
25931 /* called before trim_bios_range() to spare extra sanitize */
25932 static void __init e820_add_kernel_range(void)
25933 {
25934 - u64 start = __pa_symbol(_text);
25935 + u64 start = __pa_symbol(ktla_ktva(_text));
25936 u64 size = __pa_symbol(_end) - start;
25937
25938 /*
25939 @@ -838,8 +877,12 @@ static void __init trim_low_memory_range(void)
25940
25941 void __init setup_arch(char **cmdline_p)
25942 {
25943 +#ifdef CONFIG_X86_32
25944 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25945 +#else
25946 memblock_reserve(__pa_symbol(_text),
25947 (unsigned long)__bss_stop - (unsigned long)_text);
25948 +#endif
25949
25950 early_reserve_initrd();
25951
25952 @@ -931,14 +974,14 @@ void __init setup_arch(char **cmdline_p)
25953
25954 if (!boot_params.hdr.root_flags)
25955 root_mountflags &= ~MS_RDONLY;
25956 - init_mm.start_code = (unsigned long) _text;
25957 - init_mm.end_code = (unsigned long) _etext;
25958 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25959 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25960 init_mm.end_data = (unsigned long) _edata;
25961 init_mm.brk = _brk_end;
25962
25963 - code_resource.start = __pa_symbol(_text);
25964 - code_resource.end = __pa_symbol(_etext)-1;
25965 - data_resource.start = __pa_symbol(_etext);
25966 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25967 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25968 + data_resource.start = __pa_symbol(_sdata);
25969 data_resource.end = __pa_symbol(_edata)-1;
25970 bss_resource.start = __pa_symbol(__bss_start);
25971 bss_resource.end = __pa_symbol(__bss_stop)-1;
25972 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25973 index 5cdff03..80fa283 100644
25974 --- a/arch/x86/kernel/setup_percpu.c
25975 +++ b/arch/x86/kernel/setup_percpu.c
25976 @@ -21,19 +21,17 @@
25977 #include <asm/cpu.h>
25978 #include <asm/stackprotector.h>
25979
25980 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25981 +#ifdef CONFIG_SMP
25982 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25983 EXPORT_PER_CPU_SYMBOL(cpu_number);
25984 +#endif
25985
25986 -#ifdef CONFIG_X86_64
25987 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25988 -#else
25989 -#define BOOT_PERCPU_OFFSET 0
25990 -#endif
25991
25992 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25993 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25994
25995 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25996 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25997 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25998 };
25999 EXPORT_SYMBOL(__per_cpu_offset);
26000 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
26001 {
26002 #ifdef CONFIG_NEED_MULTIPLE_NODES
26003 pg_data_t *last = NULL;
26004 - unsigned int cpu;
26005 + int cpu;
26006
26007 for_each_possible_cpu(cpu) {
26008 int node = early_cpu_to_node(cpu);
26009 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
26010 {
26011 #ifdef CONFIG_X86_32
26012 struct desc_struct gdt;
26013 + unsigned long base = per_cpu_offset(cpu);
26014
26015 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
26016 - 0x2 | DESCTYPE_S, 0x8);
26017 - gdt.s = 1;
26018 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
26019 + 0x83 | DESCTYPE_S, 0xC);
26020 write_gdt_entry(get_cpu_gdt_table(cpu),
26021 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
26022 #endif
26023 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
26024 /* alrighty, percpu areas up and running */
26025 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
26026 for_each_possible_cpu(cpu) {
26027 +#ifdef CONFIG_CC_STACKPROTECTOR
26028 +#ifdef CONFIG_X86_32
26029 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
26030 +#endif
26031 +#endif
26032 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
26033 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
26034 per_cpu(cpu_number, cpu) = cpu;
26035 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
26036 */
26037 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
26038 #endif
26039 +#ifdef CONFIG_CC_STACKPROTECTOR
26040 +#ifdef CONFIG_X86_32
26041 + if (!cpu)
26042 + per_cpu(stack_canary.canary, cpu) = canary;
26043 +#endif
26044 +#endif
26045 /*
26046 * Up to this point, the boot CPU has been using .init.data
26047 * area. Reload any changed state for the boot CPU.
26048 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
26049 index 9e5de68..16c53cb 100644
26050 --- a/arch/x86/kernel/signal.c
26051 +++ b/arch/x86/kernel/signal.c
26052 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
26053 * Align the stack pointer according to the i386 ABI,
26054 * i.e. so that on function entry ((sp + 4) & 15) == 0.
26055 */
26056 - sp = ((sp + 4) & -16ul) - 4;
26057 + sp = ((sp - 12) & -16ul) - 4;
26058 #else /* !CONFIG_X86_32 */
26059 sp = round_down(sp, 16) - 8;
26060 #endif
26061 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
26062 }
26063
26064 if (current->mm->context.vdso)
26065 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
26066 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
26067 else
26068 - restorer = &frame->retcode;
26069 + restorer = (void __user *)&frame->retcode;
26070 if (ksig->ka.sa.sa_flags & SA_RESTORER)
26071 restorer = ksig->ka.sa.sa_restorer;
26072
26073 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
26074 * reasons and because gdb uses it as a signature to notice
26075 * signal handler stack frames.
26076 */
26077 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
26078 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
26079
26080 if (err)
26081 return -EFAULT;
26082 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
26083 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
26084
26085 /* Set up to return from userspace. */
26086 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
26087 + if (current->mm->context.vdso)
26088 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
26089 + else
26090 + restorer = (void __user *)&frame->retcode;
26091 if (ksig->ka.sa.sa_flags & SA_RESTORER)
26092 restorer = ksig->ka.sa.sa_restorer;
26093 put_user_ex(restorer, &frame->pretcode);
26094 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
26095 * reasons and because gdb uses it as a signature to notice
26096 * signal handler stack frames.
26097 */
26098 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
26099 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
26100 } put_user_catch(err);
26101
26102 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
26103 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
26104 {
26105 int usig = signr_convert(ksig->sig);
26106 sigset_t *set = sigmask_to_save();
26107 - compat_sigset_t *cset = (compat_sigset_t *) set;
26108 + sigset_t sigcopy;
26109 + compat_sigset_t *cset;
26110 +
26111 + sigcopy = *set;
26112 +
26113 + cset = (compat_sigset_t *) &sigcopy;
26114
26115 /* Set up the stack frame */
26116 if (is_ia32_frame()) {
26117 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
26118 } else if (is_x32_frame()) {
26119 return x32_setup_rt_frame(ksig, cset, regs);
26120 } else {
26121 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
26122 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
26123 }
26124 }
26125
26126 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
26127 index 7c3a5a6..f0a8961 100644
26128 --- a/arch/x86/kernel/smp.c
26129 +++ b/arch/x86/kernel/smp.c
26130 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
26131
26132 __setup("nonmi_ipi", nonmi_ipi_setup);
26133
26134 -struct smp_ops smp_ops = {
26135 +struct smp_ops smp_ops __read_only = {
26136 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
26137 .smp_prepare_cpus = native_smp_prepare_cpus,
26138 .smp_cpus_done = native_smp_cpus_done,
26139 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
26140 index 6cacab6..750636a 100644
26141 --- a/arch/x86/kernel/smpboot.c
26142 +++ b/arch/x86/kernel/smpboot.c
26143 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
26144
26145 enable_start_cpu0 = 0;
26146
26147 -#ifdef CONFIG_X86_32
26148 - /* switch away from the initial page table */
26149 - load_cr3(swapper_pg_dir);
26150 - __flush_tlb_all();
26151 -#endif
26152 -
26153 /* otherwise gcc will move up smp_processor_id before the cpu_init */
26154 barrier();
26155 +
26156 + /* switch away from the initial page table */
26157 +#ifdef CONFIG_PAX_PER_CPU_PGD
26158 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
26159 + __flush_tlb_all();
26160 +#elif defined(CONFIG_X86_32)
26161 + load_cr3(swapper_pg_dir);
26162 + __flush_tlb_all();
26163 +#endif
26164 +
26165 /*
26166 * Check TSC synchronization with the BP:
26167 */
26168 @@ -749,6 +753,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
26169 idle->thread.sp = (unsigned long) (((struct pt_regs *)
26170 (THREAD_SIZE + task_stack_page(idle))) - 1);
26171 per_cpu(current_task, cpu) = idle;
26172 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
26173
26174 #ifdef CONFIG_X86_32
26175 /* Stack for startup_32 can be just as for start_secondary onwards */
26176 @@ -756,11 +761,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
26177 #else
26178 clear_tsk_thread_flag(idle, TIF_FORK);
26179 initial_gs = per_cpu_offset(cpu);
26180 - per_cpu(kernel_stack, cpu) =
26181 - (unsigned long)task_stack_page(idle) -
26182 - KERNEL_STACK_OFFSET + THREAD_SIZE;
26183 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
26184 #endif
26185 +
26186 + pax_open_kernel();
26187 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
26188 + pax_close_kernel();
26189 +
26190 initial_code = (unsigned long)start_secondary;
26191 stack_start = idle->thread.sp;
26192
26193 @@ -909,6 +916,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
26194 /* the FPU context is blank, nobody can own it */
26195 __cpu_disable_lazy_restore(cpu);
26196
26197 +#ifdef CONFIG_PAX_PER_CPU_PGD
26198 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
26199 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
26200 + KERNEL_PGD_PTRS);
26201 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
26202 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
26203 + KERNEL_PGD_PTRS);
26204 +#endif
26205 +
26206 err = do_boot_cpu(apicid, cpu, tidle);
26207 if (err) {
26208 pr_debug("do_boot_cpu failed %d\n", err);
26209 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
26210 index 9b4d51d..5d28b58 100644
26211 --- a/arch/x86/kernel/step.c
26212 +++ b/arch/x86/kernel/step.c
26213 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
26214 struct desc_struct *desc;
26215 unsigned long base;
26216
26217 - seg &= ~7UL;
26218 + seg >>= 3;
26219
26220 mutex_lock(&child->mm->context.lock);
26221 - if (unlikely((seg >> 3) >= child->mm->context.size))
26222 + if (unlikely(seg >= child->mm->context.size))
26223 addr = -1L; /* bogus selector, access would fault */
26224 else {
26225 desc = child->mm->context.ldt + seg;
26226 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
26227 addr += base;
26228 }
26229 mutex_unlock(&child->mm->context.lock);
26230 - }
26231 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
26232 + addr = ktla_ktva(addr);
26233
26234 return addr;
26235 }
26236 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
26237 unsigned char opcode[15];
26238 unsigned long addr = convert_ip_to_linear(child, regs);
26239
26240 + if (addr == -EINVAL)
26241 + return 0;
26242 +
26243 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
26244 for (i = 0; i < copied; i++) {
26245 switch (opcode[i]) {
26246 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
26247 new file mode 100644
26248 index 0000000..5877189
26249 --- /dev/null
26250 +++ b/arch/x86/kernel/sys_i386_32.c
26251 @@ -0,0 +1,189 @@
26252 +/*
26253 + * This file contains various random system calls that
26254 + * have a non-standard calling sequence on the Linux/i386
26255 + * platform.
26256 + */
26257 +
26258 +#include <linux/errno.h>
26259 +#include <linux/sched.h>
26260 +#include <linux/mm.h>
26261 +#include <linux/fs.h>
26262 +#include <linux/smp.h>
26263 +#include <linux/sem.h>
26264 +#include <linux/msg.h>
26265 +#include <linux/shm.h>
26266 +#include <linux/stat.h>
26267 +#include <linux/syscalls.h>
26268 +#include <linux/mman.h>
26269 +#include <linux/file.h>
26270 +#include <linux/utsname.h>
26271 +#include <linux/ipc.h>
26272 +#include <linux/elf.h>
26273 +
26274 +#include <linux/uaccess.h>
26275 +#include <linux/unistd.h>
26276 +
26277 +#include <asm/syscalls.h>
26278 +
26279 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
26280 +{
26281 + unsigned long pax_task_size = TASK_SIZE;
26282 +
26283 +#ifdef CONFIG_PAX_SEGMEXEC
26284 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
26285 + pax_task_size = SEGMEXEC_TASK_SIZE;
26286 +#endif
26287 +
26288 + if (flags & MAP_FIXED)
26289 + if (len > pax_task_size || addr > pax_task_size - len)
26290 + return -EINVAL;
26291 +
26292 + return 0;
26293 +}
26294 +
26295 +/*
26296 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
26297 + */
26298 +static unsigned long get_align_mask(void)
26299 +{
26300 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
26301 + return 0;
26302 +
26303 + if (!(current->flags & PF_RANDOMIZE))
26304 + return 0;
26305 +
26306 + return va_align.mask;
26307 +}
26308 +
26309 +unsigned long
26310 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
26311 + unsigned long len, unsigned long pgoff, unsigned long flags)
26312 +{
26313 + struct mm_struct *mm = current->mm;
26314 + struct vm_area_struct *vma;
26315 + unsigned long pax_task_size = TASK_SIZE;
26316 + struct vm_unmapped_area_info info;
26317 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26318 +
26319 +#ifdef CONFIG_PAX_SEGMEXEC
26320 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
26321 + pax_task_size = SEGMEXEC_TASK_SIZE;
26322 +#endif
26323 +
26324 + pax_task_size -= PAGE_SIZE;
26325 +
26326 + if (len > pax_task_size)
26327 + return -ENOMEM;
26328 +
26329 + if (flags & MAP_FIXED)
26330 + return addr;
26331 +
26332 +#ifdef CONFIG_PAX_RANDMMAP
26333 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26334 +#endif
26335 +
26336 + if (addr) {
26337 + addr = PAGE_ALIGN(addr);
26338 + if (pax_task_size - len >= addr) {
26339 + vma = find_vma(mm, addr);
26340 + if (check_heap_stack_gap(vma, addr, len, offset))
26341 + return addr;
26342 + }
26343 + }
26344 +
26345 + info.flags = 0;
26346 + info.length = len;
26347 + info.align_mask = filp ? get_align_mask() : 0;
26348 + info.align_offset = pgoff << PAGE_SHIFT;
26349 + info.threadstack_offset = offset;
26350 +
26351 +#ifdef CONFIG_PAX_PAGEEXEC
26352 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
26353 + info.low_limit = 0x00110000UL;
26354 + info.high_limit = mm->start_code;
26355 +
26356 +#ifdef CONFIG_PAX_RANDMMAP
26357 + if (mm->pax_flags & MF_PAX_RANDMMAP)
26358 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
26359 +#endif
26360 +
26361 + if (info.low_limit < info.high_limit) {
26362 + addr = vm_unmapped_area(&info);
26363 + if (!IS_ERR_VALUE(addr))
26364 + return addr;
26365 + }
26366 + } else
26367 +#endif
26368 +
26369 + info.low_limit = mm->mmap_base;
26370 + info.high_limit = pax_task_size;
26371 +
26372 + return vm_unmapped_area(&info);
26373 +}
26374 +
26375 +unsigned long
26376 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26377 + const unsigned long len, const unsigned long pgoff,
26378 + const unsigned long flags)
26379 +{
26380 + struct vm_area_struct *vma;
26381 + struct mm_struct *mm = current->mm;
26382 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
26383 + struct vm_unmapped_area_info info;
26384 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26385 +
26386 +#ifdef CONFIG_PAX_SEGMEXEC
26387 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
26388 + pax_task_size = SEGMEXEC_TASK_SIZE;
26389 +#endif
26390 +
26391 + pax_task_size -= PAGE_SIZE;
26392 +
26393 + /* requested length too big for entire address space */
26394 + if (len > pax_task_size)
26395 + return -ENOMEM;
26396 +
26397 + if (flags & MAP_FIXED)
26398 + return addr;
26399 +
26400 +#ifdef CONFIG_PAX_PAGEEXEC
26401 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
26402 + goto bottomup;
26403 +#endif
26404 +
26405 +#ifdef CONFIG_PAX_RANDMMAP
26406 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26407 +#endif
26408 +
26409 + /* requesting a specific address */
26410 + if (addr) {
26411 + addr = PAGE_ALIGN(addr);
26412 + if (pax_task_size - len >= addr) {
26413 + vma = find_vma(mm, addr);
26414 + if (check_heap_stack_gap(vma, addr, len, offset))
26415 + return addr;
26416 + }
26417 + }
26418 +
26419 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
26420 + info.length = len;
26421 + info.low_limit = PAGE_SIZE;
26422 + info.high_limit = mm->mmap_base;
26423 + info.align_mask = filp ? get_align_mask() : 0;
26424 + info.align_offset = pgoff << PAGE_SHIFT;
26425 + info.threadstack_offset = offset;
26426 +
26427 + addr = vm_unmapped_area(&info);
26428 + if (!(addr & ~PAGE_MASK))
26429 + return addr;
26430 + VM_BUG_ON(addr != -ENOMEM);
26431 +
26432 +bottomup:
26433 + /*
26434 + * A failed mmap() very likely causes application failure,
26435 + * so fall back to the bottom-up function here. This scenario
26436 + * can happen with large stack limits and large mmap()
26437 + * allocations.
26438 + */
26439 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
26440 +}
26441 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
26442 index 30277e2..5664a29 100644
26443 --- a/arch/x86/kernel/sys_x86_64.c
26444 +++ b/arch/x86/kernel/sys_x86_64.c
26445 @@ -81,8 +81,8 @@ out:
26446 return error;
26447 }
26448
26449 -static void find_start_end(unsigned long flags, unsigned long *begin,
26450 - unsigned long *end)
26451 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
26452 + unsigned long *begin, unsigned long *end)
26453 {
26454 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
26455 unsigned long new_begin;
26456 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
26457 *begin = new_begin;
26458 }
26459 } else {
26460 - *begin = current->mm->mmap_legacy_base;
26461 + *begin = mm->mmap_legacy_base;
26462 *end = TASK_SIZE;
26463 }
26464 }
26465 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
26466 struct vm_area_struct *vma;
26467 struct vm_unmapped_area_info info;
26468 unsigned long begin, end;
26469 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26470
26471 if (flags & MAP_FIXED)
26472 return addr;
26473
26474 - find_start_end(flags, &begin, &end);
26475 + find_start_end(mm, flags, &begin, &end);
26476
26477 if (len > end)
26478 return -ENOMEM;
26479
26480 +#ifdef CONFIG_PAX_RANDMMAP
26481 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26482 +#endif
26483 +
26484 if (addr) {
26485 addr = PAGE_ALIGN(addr);
26486 vma = find_vma(mm, addr);
26487 - if (end - len >= addr &&
26488 - (!vma || addr + len <= vma->vm_start))
26489 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
26490 return addr;
26491 }
26492
26493 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
26494 info.high_limit = end;
26495 info.align_mask = filp ? get_align_mask() : 0;
26496 info.align_offset = pgoff << PAGE_SHIFT;
26497 + info.threadstack_offset = offset;
26498 return vm_unmapped_area(&info);
26499 }
26500
26501 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26502 struct mm_struct *mm = current->mm;
26503 unsigned long addr = addr0;
26504 struct vm_unmapped_area_info info;
26505 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26506
26507 /* requested length too big for entire address space */
26508 if (len > TASK_SIZE)
26509 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26510 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
26511 goto bottomup;
26512
26513 +#ifdef CONFIG_PAX_RANDMMAP
26514 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26515 +#endif
26516 +
26517 /* requesting a specific address */
26518 if (addr) {
26519 addr = PAGE_ALIGN(addr);
26520 vma = find_vma(mm, addr);
26521 - if (TASK_SIZE - len >= addr &&
26522 - (!vma || addr + len <= vma->vm_start))
26523 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
26524 return addr;
26525 }
26526
26527 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26528 info.high_limit = mm->mmap_base;
26529 info.align_mask = filp ? get_align_mask() : 0;
26530 info.align_offset = pgoff << PAGE_SHIFT;
26531 + info.threadstack_offset = offset;
26532 addr = vm_unmapped_area(&info);
26533 if (!(addr & ~PAGE_MASK))
26534 return addr;
26535 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
26536 index 91a4496..1730bff 100644
26537 --- a/arch/x86/kernel/tboot.c
26538 +++ b/arch/x86/kernel/tboot.c
26539 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
26540
26541 void tboot_shutdown(u32 shutdown_type)
26542 {
26543 - void (*shutdown)(void);
26544 + void (* __noreturn shutdown)(void);
26545
26546 if (!tboot_enabled())
26547 return;
26548 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
26549
26550 switch_to_tboot_pt();
26551
26552 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
26553 + shutdown = (void *)tboot->shutdown_entry;
26554 shutdown();
26555
26556 /* should not reach here */
26557 @@ -310,7 +310,7 @@ static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
26558 return -ENODEV;
26559 }
26560
26561 -static atomic_t ap_wfs_count;
26562 +static atomic_unchecked_t ap_wfs_count;
26563
26564 static int tboot_wait_for_aps(int num_aps)
26565 {
26566 @@ -334,9 +334,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
26567 {
26568 switch (action) {
26569 case CPU_DYING:
26570 - atomic_inc(&ap_wfs_count);
26571 + atomic_inc_unchecked(&ap_wfs_count);
26572 if (num_online_cpus() == 1)
26573 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
26574 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
26575 return NOTIFY_BAD;
26576 break;
26577 }
26578 @@ -422,7 +422,7 @@ static __init int tboot_late_init(void)
26579
26580 tboot_create_trampoline();
26581
26582 - atomic_set(&ap_wfs_count, 0);
26583 + atomic_set_unchecked(&ap_wfs_count, 0);
26584 register_hotcpu_notifier(&tboot_cpu_notifier);
26585
26586 #ifdef CONFIG_DEBUG_FS
26587 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
26588 index 24d3c91..d06b473 100644
26589 --- a/arch/x86/kernel/time.c
26590 +++ b/arch/x86/kernel/time.c
26591 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
26592 {
26593 unsigned long pc = instruction_pointer(regs);
26594
26595 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
26596 + if (!user_mode(regs) && in_lock_functions(pc)) {
26597 #ifdef CONFIG_FRAME_POINTER
26598 - return *(unsigned long *)(regs->bp + sizeof(long));
26599 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
26600 #else
26601 unsigned long *sp =
26602 (unsigned long *)kernel_stack_pointer(regs);
26603 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
26604 * or above a saved flags. Eflags has bits 22-31 zero,
26605 * kernel addresses don't.
26606 */
26607 +
26608 +#ifdef CONFIG_PAX_KERNEXEC
26609 + return ktla_ktva(sp[0]);
26610 +#else
26611 if (sp[0] >> 22)
26612 return sp[0];
26613 if (sp[1] >> 22)
26614 return sp[1];
26615 #endif
26616 +
26617 +#endif
26618 }
26619 return pc;
26620 }
26621 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
26622 index f7fec09..9991981 100644
26623 --- a/arch/x86/kernel/tls.c
26624 +++ b/arch/x86/kernel/tls.c
26625 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
26626 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
26627 return -EINVAL;
26628
26629 +#ifdef CONFIG_PAX_SEGMEXEC
26630 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
26631 + return -EINVAL;
26632 +#endif
26633 +
26634 set_tls_desc(p, idx, &info, 1);
26635
26636 return 0;
26637 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
26638
26639 if (kbuf)
26640 info = kbuf;
26641 - else if (__copy_from_user(infobuf, ubuf, count))
26642 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
26643 return -EFAULT;
26644 else
26645 info = infobuf;
26646 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
26647 index 1c113db..287b42e 100644
26648 --- a/arch/x86/kernel/tracepoint.c
26649 +++ b/arch/x86/kernel/tracepoint.c
26650 @@ -9,11 +9,11 @@
26651 #include <linux/atomic.h>
26652
26653 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
26654 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
26655 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
26656 (unsigned long) trace_idt_table };
26657
26658 /* No need to be aligned, but done to keep all IDTs defined the same way. */
26659 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
26660 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
26661
26662 static int trace_irq_vector_refcount;
26663 static DEFINE_MUTEX(irq_vector_mutex);
26664 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
26665 index 8c8093b..c93f581 100644
26666 --- a/arch/x86/kernel/traps.c
26667 +++ b/arch/x86/kernel/traps.c
26668 @@ -66,7 +66,7 @@
26669 #include <asm/proto.h>
26670
26671 /* No need to be aligned, but done to keep all IDTs defined the same way. */
26672 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
26673 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
26674 #else
26675 #include <asm/processor-flags.h>
26676 #include <asm/setup.h>
26677 @@ -75,7 +75,7 @@ asmlinkage int system_call(void);
26678 #endif
26679
26680 /* Must be page-aligned because the real IDT is used in a fixmap. */
26681 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
26682 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
26683
26684 DECLARE_BITMAP(used_vectors, NR_VECTORS);
26685 EXPORT_SYMBOL_GPL(used_vectors);
26686 @@ -107,11 +107,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
26687 }
26688
26689 static int __kprobes
26690 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26691 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
26692 struct pt_regs *regs, long error_code)
26693 {
26694 #ifdef CONFIG_X86_32
26695 - if (regs->flags & X86_VM_MASK) {
26696 + if (v8086_mode(regs)) {
26697 /*
26698 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
26699 * On nmi (interrupt 2), do_trap should not be called.
26700 @@ -124,12 +124,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26701 return -1;
26702 }
26703 #endif
26704 - if (!user_mode(regs)) {
26705 + if (!user_mode_novm(regs)) {
26706 if (!fixup_exception(regs)) {
26707 tsk->thread.error_code = error_code;
26708 tsk->thread.trap_nr = trapnr;
26709 +
26710 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26711 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
26712 + str = "PAX: suspicious stack segment fault";
26713 +#endif
26714 +
26715 die(str, regs, error_code);
26716 }
26717 +
26718 +#ifdef CONFIG_PAX_REFCOUNT
26719 + if (trapnr == 4)
26720 + pax_report_refcount_overflow(regs);
26721 +#endif
26722 +
26723 return 0;
26724 }
26725
26726 @@ -137,7 +149,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26727 }
26728
26729 static void __kprobes
26730 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
26731 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
26732 long error_code, siginfo_t *info)
26733 {
26734 struct task_struct *tsk = current;
26735 @@ -161,7 +173,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
26736 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
26737 printk_ratelimit()) {
26738 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
26739 - tsk->comm, tsk->pid, str,
26740 + tsk->comm, task_pid_nr(tsk), str,
26741 regs->ip, regs->sp, error_code);
26742 print_vma_addr(" in ", regs->ip);
26743 pr_cont("\n");
26744 @@ -277,7 +289,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
26745 conditional_sti(regs);
26746
26747 #ifdef CONFIG_X86_32
26748 - if (regs->flags & X86_VM_MASK) {
26749 + if (v8086_mode(regs)) {
26750 local_irq_enable();
26751 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
26752 goto exit;
26753 @@ -285,18 +297,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
26754 #endif
26755
26756 tsk = current;
26757 - if (!user_mode(regs)) {
26758 + if (!user_mode_novm(regs)) {
26759 if (fixup_exception(regs))
26760 goto exit;
26761
26762 tsk->thread.error_code = error_code;
26763 tsk->thread.trap_nr = X86_TRAP_GP;
26764 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
26765 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
26766 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
26767 +
26768 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26769 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
26770 + die("PAX: suspicious general protection fault", regs, error_code);
26771 + else
26772 +#endif
26773 +
26774 die("general protection fault", regs, error_code);
26775 + }
26776 goto exit;
26777 }
26778
26779 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
26780 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
26781 + struct mm_struct *mm = tsk->mm;
26782 + unsigned long limit;
26783 +
26784 + down_write(&mm->mmap_sem);
26785 + limit = mm->context.user_cs_limit;
26786 + if (limit < TASK_SIZE) {
26787 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
26788 + up_write(&mm->mmap_sem);
26789 + return;
26790 + }
26791 + up_write(&mm->mmap_sem);
26792 + }
26793 +#endif
26794 +
26795 tsk->thread.error_code = error_code;
26796 tsk->thread.trap_nr = X86_TRAP_GP;
26797
26798 @@ -457,7 +493,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26799 /* It's safe to allow irq's after DR6 has been saved */
26800 preempt_conditional_sti(regs);
26801
26802 - if (regs->flags & X86_VM_MASK) {
26803 + if (v8086_mode(regs)) {
26804 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
26805 X86_TRAP_DB);
26806 preempt_conditional_cli(regs);
26807 @@ -472,7 +508,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26808 * We already checked v86 mode above, so we can check for kernel mode
26809 * by just checking the CPL of CS.
26810 */
26811 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26812 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26813 tsk->thread.debugreg6 &= ~DR_STEP;
26814 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26815 regs->flags &= ~X86_EFLAGS_TF;
26816 @@ -504,7 +540,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26817 return;
26818 conditional_sti(regs);
26819
26820 - if (!user_mode_vm(regs))
26821 + if (!user_mode(regs))
26822 {
26823 if (!fixup_exception(regs)) {
26824 task->thread.error_code = error_code;
26825 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26826 index 2ed8459..7cf329f 100644
26827 --- a/arch/x86/kernel/uprobes.c
26828 +++ b/arch/x86/kernel/uprobes.c
26829 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26830 int ret = NOTIFY_DONE;
26831
26832 /* We are only interested in userspace traps */
26833 - if (regs && !user_mode_vm(regs))
26834 + if (regs && !user_mode(regs))
26835 return NOTIFY_DONE;
26836
26837 switch (val) {
26838 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26839
26840 if (ncopied != rasize) {
26841 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26842 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26843 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26844
26845 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26846 }
26847 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26848 index b9242ba..50c5edd 100644
26849 --- a/arch/x86/kernel/verify_cpu.S
26850 +++ b/arch/x86/kernel/verify_cpu.S
26851 @@ -20,6 +20,7 @@
26852 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26853 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26854 * arch/x86/kernel/head_32.S: processor startup
26855 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26856 *
26857 * verify_cpu, returns the status of longmode and SSE in register %eax.
26858 * 0: Success 1: Failure
26859 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26860 index e8edcf5..27f9344 100644
26861 --- a/arch/x86/kernel/vm86_32.c
26862 +++ b/arch/x86/kernel/vm86_32.c
26863 @@ -44,6 +44,7 @@
26864 #include <linux/ptrace.h>
26865 #include <linux/audit.h>
26866 #include <linux/stddef.h>
26867 +#include <linux/grsecurity.h>
26868
26869 #include <asm/uaccess.h>
26870 #include <asm/io.h>
26871 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26872 do_exit(SIGSEGV);
26873 }
26874
26875 - tss = &per_cpu(init_tss, get_cpu());
26876 + tss = init_tss + get_cpu();
26877 current->thread.sp0 = current->thread.saved_sp0;
26878 current->thread.sysenter_cs = __KERNEL_CS;
26879 load_sp0(tss, &current->thread);
26880 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26881
26882 if (tsk->thread.saved_sp0)
26883 return -EPERM;
26884 +
26885 +#ifdef CONFIG_GRKERNSEC_VM86
26886 + if (!capable(CAP_SYS_RAWIO)) {
26887 + gr_handle_vm86();
26888 + return -EPERM;
26889 + }
26890 +#endif
26891 +
26892 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26893 offsetof(struct kernel_vm86_struct, vm86plus) -
26894 sizeof(info.regs));
26895 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26896 int tmp;
26897 struct vm86plus_struct __user *v86;
26898
26899 +#ifdef CONFIG_GRKERNSEC_VM86
26900 + if (!capable(CAP_SYS_RAWIO)) {
26901 + gr_handle_vm86();
26902 + return -EPERM;
26903 + }
26904 +#endif
26905 +
26906 tsk = current;
26907 switch (cmd) {
26908 case VM86_REQUEST_IRQ:
26909 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26910 tsk->thread.saved_fs = info->regs32->fs;
26911 tsk->thread.saved_gs = get_user_gs(info->regs32);
26912
26913 - tss = &per_cpu(init_tss, get_cpu());
26914 + tss = init_tss + get_cpu();
26915 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26916 if (cpu_has_sep)
26917 tsk->thread.sysenter_cs = 0;
26918 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26919 goto cannot_handle;
26920 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26921 goto cannot_handle;
26922 - intr_ptr = (unsigned long __user *) (i << 2);
26923 + intr_ptr = (__force unsigned long __user *) (i << 2);
26924 if (get_user(segoffs, intr_ptr))
26925 goto cannot_handle;
26926 if ((segoffs >> 16) == BIOSSEG)
26927 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26928 index 10c4f30..65408b9 100644
26929 --- a/arch/x86/kernel/vmlinux.lds.S
26930 +++ b/arch/x86/kernel/vmlinux.lds.S
26931 @@ -26,6 +26,13 @@
26932 #include <asm/page_types.h>
26933 #include <asm/cache.h>
26934 #include <asm/boot.h>
26935 +#include <asm/segment.h>
26936 +
26937 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26938 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26939 +#else
26940 +#define __KERNEL_TEXT_OFFSET 0
26941 +#endif
26942
26943 #undef i386 /* in case the preprocessor is a 32bit one */
26944
26945 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26946
26947 PHDRS {
26948 text PT_LOAD FLAGS(5); /* R_E */
26949 +#ifdef CONFIG_X86_32
26950 + module PT_LOAD FLAGS(5); /* R_E */
26951 +#endif
26952 +#ifdef CONFIG_XEN
26953 + rodata PT_LOAD FLAGS(5); /* R_E */
26954 +#else
26955 + rodata PT_LOAD FLAGS(4); /* R__ */
26956 +#endif
26957 data PT_LOAD FLAGS(6); /* RW_ */
26958 -#ifdef CONFIG_X86_64
26959 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26960 #ifdef CONFIG_SMP
26961 percpu PT_LOAD FLAGS(6); /* RW_ */
26962 #endif
26963 + text.init PT_LOAD FLAGS(5); /* R_E */
26964 + text.exit PT_LOAD FLAGS(5); /* R_E */
26965 init PT_LOAD FLAGS(7); /* RWE */
26966 -#endif
26967 note PT_NOTE FLAGS(0); /* ___ */
26968 }
26969
26970 SECTIONS
26971 {
26972 #ifdef CONFIG_X86_32
26973 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26974 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26975 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26976 #else
26977 - . = __START_KERNEL;
26978 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26979 + . = __START_KERNEL;
26980 #endif
26981
26982 /* Text and read-only data */
26983 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26984 - _text = .;
26985 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26986 /* bootstrapping code */
26987 +#ifdef CONFIG_X86_32
26988 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26989 +#else
26990 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26991 +#endif
26992 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26993 + _text = .;
26994 HEAD_TEXT
26995 . = ALIGN(8);
26996 _stext = .;
26997 @@ -104,13 +124,47 @@ SECTIONS
26998 IRQENTRY_TEXT
26999 *(.fixup)
27000 *(.gnu.warning)
27001 - /* End of text section */
27002 - _etext = .;
27003 } :text = 0x9090
27004
27005 - NOTES :text :note
27006 + . += __KERNEL_TEXT_OFFSET;
27007
27008 - EXCEPTION_TABLE(16) :text = 0x9090
27009 +#ifdef CONFIG_X86_32
27010 + . = ALIGN(PAGE_SIZE);
27011 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
27012 +
27013 +#ifdef CONFIG_PAX_KERNEXEC
27014 + MODULES_EXEC_VADDR = .;
27015 + BYTE(0)
27016 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
27017 + . = ALIGN(HPAGE_SIZE) - 1;
27018 + MODULES_EXEC_END = .;
27019 +#endif
27020 +
27021 + } :module
27022 +#endif
27023 +
27024 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
27025 + /* End of text section */
27026 + BYTE(0)
27027 + _etext = . - __KERNEL_TEXT_OFFSET;
27028 + }
27029 +
27030 +#ifdef CONFIG_X86_32
27031 + . = ALIGN(PAGE_SIZE);
27032 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
27033 + . = ALIGN(PAGE_SIZE);
27034 + *(.empty_zero_page)
27035 + *(.initial_pg_fixmap)
27036 + *(.initial_pg_pmd)
27037 + *(.initial_page_table)
27038 + *(.swapper_pg_dir)
27039 + } :rodata
27040 +#endif
27041 +
27042 + . = ALIGN(PAGE_SIZE);
27043 + NOTES :rodata :note
27044 +
27045 + EXCEPTION_TABLE(16) :rodata
27046
27047 #if defined(CONFIG_DEBUG_RODATA)
27048 /* .text should occupy whole number of pages */
27049 @@ -122,16 +176,20 @@ SECTIONS
27050
27051 /* Data */
27052 .data : AT(ADDR(.data) - LOAD_OFFSET) {
27053 +
27054 +#ifdef CONFIG_PAX_KERNEXEC
27055 + . = ALIGN(HPAGE_SIZE);
27056 +#else
27057 + . = ALIGN(PAGE_SIZE);
27058 +#endif
27059 +
27060 /* Start of data section */
27061 _sdata = .;
27062
27063 /* init_task */
27064 INIT_TASK_DATA(THREAD_SIZE)
27065
27066 -#ifdef CONFIG_X86_32
27067 - /* 32 bit has nosave before _edata */
27068 NOSAVE_DATA
27069 -#endif
27070
27071 PAGE_ALIGNED_DATA(PAGE_SIZE)
27072
27073 @@ -172,12 +230,19 @@ SECTIONS
27074 #endif /* CONFIG_X86_64 */
27075
27076 /* Init code and data - will be freed after init */
27077 - . = ALIGN(PAGE_SIZE);
27078 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
27079 + BYTE(0)
27080 +
27081 +#ifdef CONFIG_PAX_KERNEXEC
27082 + . = ALIGN(HPAGE_SIZE);
27083 +#else
27084 + . = ALIGN(PAGE_SIZE);
27085 +#endif
27086 +
27087 __init_begin = .; /* paired with __init_end */
27088 - }
27089 + } :init.begin
27090
27091 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
27092 +#ifdef CONFIG_SMP
27093 /*
27094 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
27095 * output PHDR, so the next output section - .init.text - should
27096 @@ -186,12 +251,27 @@ SECTIONS
27097 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
27098 #endif
27099
27100 - INIT_TEXT_SECTION(PAGE_SIZE)
27101 -#ifdef CONFIG_X86_64
27102 - :init
27103 -#endif
27104 + . = ALIGN(PAGE_SIZE);
27105 + init_begin = .;
27106 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
27107 + VMLINUX_SYMBOL(_sinittext) = .;
27108 + INIT_TEXT
27109 + VMLINUX_SYMBOL(_einittext) = .;
27110 + . = ALIGN(PAGE_SIZE);
27111 + } :text.init
27112
27113 - INIT_DATA_SECTION(16)
27114 + /*
27115 + * .exit.text is discard at runtime, not link time, to deal with
27116 + * references from .altinstructions and .eh_frame
27117 + */
27118 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
27119 + EXIT_TEXT
27120 + . = ALIGN(16);
27121 + } :text.exit
27122 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
27123 +
27124 + . = ALIGN(PAGE_SIZE);
27125 + INIT_DATA_SECTION(16) :init
27126
27127 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
27128 __x86_cpu_dev_start = .;
27129 @@ -253,19 +333,12 @@ SECTIONS
27130 }
27131
27132 . = ALIGN(8);
27133 - /*
27134 - * .exit.text is discard at runtime, not link time, to deal with
27135 - * references from .altinstructions and .eh_frame
27136 - */
27137 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
27138 - EXIT_TEXT
27139 - }
27140
27141 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
27142 EXIT_DATA
27143 }
27144
27145 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
27146 +#ifndef CONFIG_SMP
27147 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
27148 #endif
27149
27150 @@ -284,16 +357,10 @@ SECTIONS
27151 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
27152 __smp_locks = .;
27153 *(.smp_locks)
27154 - . = ALIGN(PAGE_SIZE);
27155 __smp_locks_end = .;
27156 + . = ALIGN(PAGE_SIZE);
27157 }
27158
27159 -#ifdef CONFIG_X86_64
27160 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
27161 - NOSAVE_DATA
27162 - }
27163 -#endif
27164 -
27165 /* BSS */
27166 . = ALIGN(PAGE_SIZE);
27167 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
27168 @@ -309,6 +376,7 @@ SECTIONS
27169 __brk_base = .;
27170 . += 64 * 1024; /* 64k alignment slop space */
27171 *(.brk_reservation) /* areas brk users have reserved */
27172 + . = ALIGN(HPAGE_SIZE);
27173 __brk_limit = .;
27174 }
27175
27176 @@ -335,13 +403,12 @@ SECTIONS
27177 * for the boot processor.
27178 */
27179 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
27180 -INIT_PER_CPU(gdt_page);
27181 INIT_PER_CPU(irq_stack_union);
27182
27183 /*
27184 * Build-time check on the image size:
27185 */
27186 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
27187 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
27188 "kernel image bigger than KERNEL_IMAGE_SIZE");
27189
27190 #ifdef CONFIG_SMP
27191 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
27192 index 1f96f93..d5c8f7a 100644
27193 --- a/arch/x86/kernel/vsyscall_64.c
27194 +++ b/arch/x86/kernel/vsyscall_64.c
27195 @@ -56,15 +56,13 @@
27196 DEFINE_VVAR(int, vgetcpu_mode);
27197 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
27198
27199 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
27200 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
27201
27202 static int __init vsyscall_setup(char *str)
27203 {
27204 if (str) {
27205 if (!strcmp("emulate", str))
27206 vsyscall_mode = EMULATE;
27207 - else if (!strcmp("native", str))
27208 - vsyscall_mode = NATIVE;
27209 else if (!strcmp("none", str))
27210 vsyscall_mode = NONE;
27211 else
27212 @@ -323,8 +321,7 @@ do_ret:
27213 return true;
27214
27215 sigsegv:
27216 - force_sig(SIGSEGV, current);
27217 - return true;
27218 + do_group_exit(SIGKILL);
27219 }
27220
27221 /*
27222 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
27223 extern char __vvar_page;
27224 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
27225
27226 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
27227 - vsyscall_mode == NATIVE
27228 - ? PAGE_KERNEL_VSYSCALL
27229 - : PAGE_KERNEL_VVAR);
27230 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
27231 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
27232 (unsigned long)VSYSCALL_START);
27233
27234 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
27235 index b014d94..e775258 100644
27236 --- a/arch/x86/kernel/x8664_ksyms_64.c
27237 +++ b/arch/x86/kernel/x8664_ksyms_64.c
27238 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
27239 EXPORT_SYMBOL(copy_user_generic_unrolled);
27240 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
27241 EXPORT_SYMBOL(__copy_user_nocache);
27242 -EXPORT_SYMBOL(_copy_from_user);
27243 -EXPORT_SYMBOL(_copy_to_user);
27244
27245 EXPORT_SYMBOL(copy_page);
27246 EXPORT_SYMBOL(clear_page);
27247 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
27248 #ifndef CONFIG_PARAVIRT
27249 EXPORT_SYMBOL(native_load_gs_index);
27250 #endif
27251 +
27252 +#ifdef CONFIG_PAX_PER_CPU_PGD
27253 +EXPORT_SYMBOL(cpu_pgd);
27254 +#endif
27255 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
27256 index 8ce0072..431a0e7 100644
27257 --- a/arch/x86/kernel/x86_init.c
27258 +++ b/arch/x86/kernel/x86_init.c
27259 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
27260 static void default_nmi_init(void) { };
27261 static int default_i8042_detect(void) { return 1; };
27262
27263 -struct x86_platform_ops x86_platform = {
27264 +struct x86_platform_ops x86_platform __read_only = {
27265 .calibrate_tsc = native_calibrate_tsc,
27266 .get_wallclock = mach_get_cmos_time,
27267 .set_wallclock = mach_set_rtc_mmss,
27268 @@ -109,7 +109,7 @@ struct x86_platform_ops x86_platform = {
27269 EXPORT_SYMBOL_GPL(x86_platform);
27270
27271 #if defined(CONFIG_PCI_MSI)
27272 -struct x86_msi_ops x86_msi = {
27273 +struct x86_msi_ops x86_msi __read_only = {
27274 .setup_msi_irqs = native_setup_msi_irqs,
27275 .compose_msi_msg = native_compose_msi_msg,
27276 .teardown_msi_irq = native_teardown_msi_irq,
27277 @@ -140,7 +140,7 @@ void arch_restore_msi_irqs(struct pci_dev *dev, int irq)
27278 }
27279 #endif
27280
27281 -struct x86_io_apic_ops x86_io_apic_ops = {
27282 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
27283 .init = native_io_apic_init_mappings,
27284 .read = native_io_apic_read,
27285 .write = native_io_apic_write,
27286 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
27287 index 422fd82..c3687ca 100644
27288 --- a/arch/x86/kernel/xsave.c
27289 +++ b/arch/x86/kernel/xsave.c
27290 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
27291 {
27292 int err;
27293
27294 + buf = (struct xsave_struct __user *)____m(buf);
27295 if (use_xsave())
27296 err = xsave_user(buf);
27297 else if (use_fxsr())
27298 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
27299 */
27300 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
27301 {
27302 + buf = (void __user *)____m(buf);
27303 if (use_xsave()) {
27304 if ((unsigned long)buf % 64 || fx_only) {
27305 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
27306 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
27307 index b110fe6..d9c19f2 100644
27308 --- a/arch/x86/kvm/cpuid.c
27309 +++ b/arch/x86/kvm/cpuid.c
27310 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
27311 struct kvm_cpuid2 *cpuid,
27312 struct kvm_cpuid_entry2 __user *entries)
27313 {
27314 - int r;
27315 + int r, i;
27316
27317 r = -E2BIG;
27318 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
27319 goto out;
27320 r = -EFAULT;
27321 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
27322 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
27323 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
27324 goto out;
27325 + for (i = 0; i < cpuid->nent; ++i) {
27326 + struct kvm_cpuid_entry2 cpuid_entry;
27327 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
27328 + goto out;
27329 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
27330 + }
27331 vcpu->arch.cpuid_nent = cpuid->nent;
27332 kvm_apic_set_version(vcpu);
27333 kvm_x86_ops->cpuid_update(vcpu);
27334 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
27335 struct kvm_cpuid2 *cpuid,
27336 struct kvm_cpuid_entry2 __user *entries)
27337 {
27338 - int r;
27339 + int r, i;
27340
27341 r = -E2BIG;
27342 if (cpuid->nent < vcpu->arch.cpuid_nent)
27343 goto out;
27344 r = -EFAULT;
27345 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
27346 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
27347 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
27348 goto out;
27349 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
27350 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
27351 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
27352 + goto out;
27353 + }
27354 return 0;
27355
27356 out:
27357 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
27358 index 1673940..4bce95e 100644
27359 --- a/arch/x86/kvm/lapic.c
27360 +++ b/arch/x86/kvm/lapic.c
27361 @@ -55,7 +55,7 @@
27362 #define APIC_BUS_CYCLE_NS 1
27363
27364 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
27365 -#define apic_debug(fmt, arg...)
27366 +#define apic_debug(fmt, arg...) do {} while (0)
27367
27368 #define APIC_LVT_NUM 6
27369 /* 14 is the version for Xeon and Pentium 8.4.8*/
27370 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
27371 index ad75d77..a679d32 100644
27372 --- a/arch/x86/kvm/paging_tmpl.h
27373 +++ b/arch/x86/kvm/paging_tmpl.h
27374 @@ -331,7 +331,7 @@ retry_walk:
27375 if (unlikely(kvm_is_error_hva(host_addr)))
27376 goto error;
27377
27378 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
27379 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
27380 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
27381 goto error;
27382 walker->ptep_user[walker->level - 1] = ptep_user;
27383 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
27384 index c0bc803..6837a50 100644
27385 --- a/arch/x86/kvm/svm.c
27386 +++ b/arch/x86/kvm/svm.c
27387 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
27388 int cpu = raw_smp_processor_id();
27389
27390 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
27391 +
27392 + pax_open_kernel();
27393 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
27394 + pax_close_kernel();
27395 +
27396 load_TR_desc();
27397 }
27398
27399 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
27400 #endif
27401 #endif
27402
27403 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
27404 + __set_fs(current_thread_info()->addr_limit);
27405 +#endif
27406 +
27407 reload_tss(vcpu);
27408
27409 local_irq_disable();
27410 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
27411 index 6128914..8be1dd2 100644
27412 --- a/arch/x86/kvm/vmx.c
27413 +++ b/arch/x86/kvm/vmx.c
27414 @@ -1316,12 +1316,12 @@ static void vmcs_write64(unsigned long field, u64 value)
27415 #endif
27416 }
27417
27418 -static void vmcs_clear_bits(unsigned long field, u32 mask)
27419 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
27420 {
27421 vmcs_writel(field, vmcs_readl(field) & ~mask);
27422 }
27423
27424 -static void vmcs_set_bits(unsigned long field, u32 mask)
27425 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
27426 {
27427 vmcs_writel(field, vmcs_readl(field) | mask);
27428 }
27429 @@ -1522,7 +1522,11 @@ static void reload_tss(void)
27430 struct desc_struct *descs;
27431
27432 descs = (void *)gdt->address;
27433 +
27434 + pax_open_kernel();
27435 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
27436 + pax_close_kernel();
27437 +
27438 load_TR_desc();
27439 }
27440
27441 @@ -1746,6 +1750,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
27442 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
27443 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
27444
27445 +#ifdef CONFIG_PAX_PER_CPU_PGD
27446 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
27447 +#endif
27448 +
27449 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
27450 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
27451 vmx->loaded_vmcs->cpu = cpu;
27452 @@ -2037,7 +2045,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
27453 * reads and returns guest's timestamp counter "register"
27454 * guest_tsc = host_tsc + tsc_offset -- 21.3
27455 */
27456 -static u64 guest_read_tsc(void)
27457 +static u64 __intentional_overflow(-1) guest_read_tsc(void)
27458 {
27459 u64 host_tsc, tsc_offset;
27460
27461 @@ -2982,8 +2990,11 @@ static __init int hardware_setup(void)
27462 if (!cpu_has_vmx_flexpriority())
27463 flexpriority_enabled = 0;
27464
27465 - if (!cpu_has_vmx_tpr_shadow())
27466 - kvm_x86_ops->update_cr8_intercept = NULL;
27467 + if (!cpu_has_vmx_tpr_shadow()) {
27468 + pax_open_kernel();
27469 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
27470 + pax_close_kernel();
27471 + }
27472
27473 if (enable_ept && !cpu_has_vmx_ept_2m_page())
27474 kvm_disable_largepages();
27475 @@ -2994,13 +3005,15 @@ static __init int hardware_setup(void)
27476 if (!cpu_has_vmx_apicv())
27477 enable_apicv = 0;
27478
27479 + pax_open_kernel();
27480 if (enable_apicv)
27481 - kvm_x86_ops->update_cr8_intercept = NULL;
27482 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
27483 else {
27484 - kvm_x86_ops->hwapic_irr_update = NULL;
27485 - kvm_x86_ops->deliver_posted_interrupt = NULL;
27486 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
27487 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
27488 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
27489 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
27490 }
27491 + pax_close_kernel();
27492
27493 if (nested)
27494 nested_vmx_setup_ctls_msrs();
27495 @@ -4127,7 +4140,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
27496
27497 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
27498 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
27499 +
27500 +#ifndef CONFIG_PAX_PER_CPU_PGD
27501 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
27502 +#endif
27503
27504 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
27505 #ifdef CONFIG_X86_64
27506 @@ -4149,7 +4165,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
27507 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
27508 vmx->host_idt_base = dt.address;
27509
27510 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
27511 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
27512
27513 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
27514 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
27515 @@ -7191,6 +7207,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27516 "jmp 2f \n\t"
27517 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
27518 "2: "
27519 +
27520 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27521 + "ljmp %[cs],$3f\n\t"
27522 + "3: "
27523 +#endif
27524 +
27525 /* Save guest registers, load host registers, keep flags */
27526 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
27527 "pop %0 \n\t"
27528 @@ -7243,6 +7265,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27529 #endif
27530 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
27531 [wordsize]"i"(sizeof(ulong))
27532 +
27533 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27534 + ,[cs]"i"(__KERNEL_CS)
27535 +#endif
27536 +
27537 : "cc", "memory"
27538 #ifdef CONFIG_X86_64
27539 , "rax", "rbx", "rdi", "rsi"
27540 @@ -7256,7 +7283,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27541 if (debugctlmsr)
27542 update_debugctlmsr(debugctlmsr);
27543
27544 -#ifndef CONFIG_X86_64
27545 +#ifdef CONFIG_X86_32
27546 /*
27547 * The sysexit path does not restore ds/es, so we must set them to
27548 * a reasonable value ourselves.
27549 @@ -7265,8 +7292,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27550 * may be executed in interrupt context, which saves and restore segments
27551 * around it, nullifying its effect.
27552 */
27553 - loadsegment(ds, __USER_DS);
27554 - loadsegment(es, __USER_DS);
27555 + loadsegment(ds, __KERNEL_DS);
27556 + loadsegment(es, __KERNEL_DS);
27557 + loadsegment(ss, __KERNEL_DS);
27558 +
27559 +#ifdef CONFIG_PAX_KERNEXEC
27560 + loadsegment(fs, __KERNEL_PERCPU);
27561 +#endif
27562 +
27563 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27564 + __set_fs(current_thread_info()->addr_limit);
27565 +#endif
27566 +
27567 #endif
27568
27569 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
27570 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
27571 index eb9b9c9..0f30b12 100644
27572 --- a/arch/x86/kvm/x86.c
27573 +++ b/arch/x86/kvm/x86.c
27574 @@ -1779,8 +1779,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
27575 {
27576 struct kvm *kvm = vcpu->kvm;
27577 int lm = is_long_mode(vcpu);
27578 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
27579 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
27580 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
27581 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
27582 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
27583 : kvm->arch.xen_hvm_config.blob_size_32;
27584 u32 page_num = data & ~PAGE_MASK;
27585 @@ -2663,6 +2663,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
27586 if (n < msr_list.nmsrs)
27587 goto out;
27588 r = -EFAULT;
27589 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
27590 + goto out;
27591 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
27592 num_msrs_to_save * sizeof(u32)))
27593 goto out;
27594 @@ -5461,7 +5463,7 @@ static struct notifier_block pvclock_gtod_notifier = {
27595 };
27596 #endif
27597
27598 -int kvm_arch_init(void *opaque)
27599 +int kvm_arch_init(const void *opaque)
27600 {
27601 int r;
27602 struct kvm_x86_ops *ops = opaque;
27603 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
27604 index bdf8532..f63c587 100644
27605 --- a/arch/x86/lguest/boot.c
27606 +++ b/arch/x86/lguest/boot.c
27607 @@ -1206,9 +1206,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
27608 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
27609 * Launcher to reboot us.
27610 */
27611 -static void lguest_restart(char *reason)
27612 +static __noreturn void lguest_restart(char *reason)
27613 {
27614 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
27615 + BUG();
27616 }
27617
27618 /*G:050
27619 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
27620 index 00933d5..3a64af9 100644
27621 --- a/arch/x86/lib/atomic64_386_32.S
27622 +++ b/arch/x86/lib/atomic64_386_32.S
27623 @@ -48,6 +48,10 @@ BEGIN(read)
27624 movl (v), %eax
27625 movl 4(v), %edx
27626 RET_ENDP
27627 +BEGIN(read_unchecked)
27628 + movl (v), %eax
27629 + movl 4(v), %edx
27630 +RET_ENDP
27631 #undef v
27632
27633 #define v %esi
27634 @@ -55,6 +59,10 @@ BEGIN(set)
27635 movl %ebx, (v)
27636 movl %ecx, 4(v)
27637 RET_ENDP
27638 +BEGIN(set_unchecked)
27639 + movl %ebx, (v)
27640 + movl %ecx, 4(v)
27641 +RET_ENDP
27642 #undef v
27643
27644 #define v %esi
27645 @@ -70,6 +78,20 @@ RET_ENDP
27646 BEGIN(add)
27647 addl %eax, (v)
27648 adcl %edx, 4(v)
27649 +
27650 +#ifdef CONFIG_PAX_REFCOUNT
27651 + jno 0f
27652 + subl %eax, (v)
27653 + sbbl %edx, 4(v)
27654 + int $4
27655 +0:
27656 + _ASM_EXTABLE(0b, 0b)
27657 +#endif
27658 +
27659 +RET_ENDP
27660 +BEGIN(add_unchecked)
27661 + addl %eax, (v)
27662 + adcl %edx, 4(v)
27663 RET_ENDP
27664 #undef v
27665
27666 @@ -77,6 +99,24 @@ RET_ENDP
27667 BEGIN(add_return)
27668 addl (v), %eax
27669 adcl 4(v), %edx
27670 +
27671 +#ifdef CONFIG_PAX_REFCOUNT
27672 + into
27673 +1234:
27674 + _ASM_EXTABLE(1234b, 2f)
27675 +#endif
27676 +
27677 + movl %eax, (v)
27678 + movl %edx, 4(v)
27679 +
27680 +#ifdef CONFIG_PAX_REFCOUNT
27681 +2:
27682 +#endif
27683 +
27684 +RET_ENDP
27685 +BEGIN(add_return_unchecked)
27686 + addl (v), %eax
27687 + adcl 4(v), %edx
27688 movl %eax, (v)
27689 movl %edx, 4(v)
27690 RET_ENDP
27691 @@ -86,6 +126,20 @@ RET_ENDP
27692 BEGIN(sub)
27693 subl %eax, (v)
27694 sbbl %edx, 4(v)
27695 +
27696 +#ifdef CONFIG_PAX_REFCOUNT
27697 + jno 0f
27698 + addl %eax, (v)
27699 + adcl %edx, 4(v)
27700 + int $4
27701 +0:
27702 + _ASM_EXTABLE(0b, 0b)
27703 +#endif
27704 +
27705 +RET_ENDP
27706 +BEGIN(sub_unchecked)
27707 + subl %eax, (v)
27708 + sbbl %edx, 4(v)
27709 RET_ENDP
27710 #undef v
27711
27712 @@ -96,6 +150,27 @@ BEGIN(sub_return)
27713 sbbl $0, %edx
27714 addl (v), %eax
27715 adcl 4(v), %edx
27716 +
27717 +#ifdef CONFIG_PAX_REFCOUNT
27718 + into
27719 +1234:
27720 + _ASM_EXTABLE(1234b, 2f)
27721 +#endif
27722 +
27723 + movl %eax, (v)
27724 + movl %edx, 4(v)
27725 +
27726 +#ifdef CONFIG_PAX_REFCOUNT
27727 +2:
27728 +#endif
27729 +
27730 +RET_ENDP
27731 +BEGIN(sub_return_unchecked)
27732 + negl %edx
27733 + negl %eax
27734 + sbbl $0, %edx
27735 + addl (v), %eax
27736 + adcl 4(v), %edx
27737 movl %eax, (v)
27738 movl %edx, 4(v)
27739 RET_ENDP
27740 @@ -105,6 +180,20 @@ RET_ENDP
27741 BEGIN(inc)
27742 addl $1, (v)
27743 adcl $0, 4(v)
27744 +
27745 +#ifdef CONFIG_PAX_REFCOUNT
27746 + jno 0f
27747 + subl $1, (v)
27748 + sbbl $0, 4(v)
27749 + int $4
27750 +0:
27751 + _ASM_EXTABLE(0b, 0b)
27752 +#endif
27753 +
27754 +RET_ENDP
27755 +BEGIN(inc_unchecked)
27756 + addl $1, (v)
27757 + adcl $0, 4(v)
27758 RET_ENDP
27759 #undef v
27760
27761 @@ -114,6 +203,26 @@ BEGIN(inc_return)
27762 movl 4(v), %edx
27763 addl $1, %eax
27764 adcl $0, %edx
27765 +
27766 +#ifdef CONFIG_PAX_REFCOUNT
27767 + into
27768 +1234:
27769 + _ASM_EXTABLE(1234b, 2f)
27770 +#endif
27771 +
27772 + movl %eax, (v)
27773 + movl %edx, 4(v)
27774 +
27775 +#ifdef CONFIG_PAX_REFCOUNT
27776 +2:
27777 +#endif
27778 +
27779 +RET_ENDP
27780 +BEGIN(inc_return_unchecked)
27781 + movl (v), %eax
27782 + movl 4(v), %edx
27783 + addl $1, %eax
27784 + adcl $0, %edx
27785 movl %eax, (v)
27786 movl %edx, 4(v)
27787 RET_ENDP
27788 @@ -123,6 +232,20 @@ RET_ENDP
27789 BEGIN(dec)
27790 subl $1, (v)
27791 sbbl $0, 4(v)
27792 +
27793 +#ifdef CONFIG_PAX_REFCOUNT
27794 + jno 0f
27795 + addl $1, (v)
27796 + adcl $0, 4(v)
27797 + int $4
27798 +0:
27799 + _ASM_EXTABLE(0b, 0b)
27800 +#endif
27801 +
27802 +RET_ENDP
27803 +BEGIN(dec_unchecked)
27804 + subl $1, (v)
27805 + sbbl $0, 4(v)
27806 RET_ENDP
27807 #undef v
27808
27809 @@ -132,6 +255,26 @@ BEGIN(dec_return)
27810 movl 4(v), %edx
27811 subl $1, %eax
27812 sbbl $0, %edx
27813 +
27814 +#ifdef CONFIG_PAX_REFCOUNT
27815 + into
27816 +1234:
27817 + _ASM_EXTABLE(1234b, 2f)
27818 +#endif
27819 +
27820 + movl %eax, (v)
27821 + movl %edx, 4(v)
27822 +
27823 +#ifdef CONFIG_PAX_REFCOUNT
27824 +2:
27825 +#endif
27826 +
27827 +RET_ENDP
27828 +BEGIN(dec_return_unchecked)
27829 + movl (v), %eax
27830 + movl 4(v), %edx
27831 + subl $1, %eax
27832 + sbbl $0, %edx
27833 movl %eax, (v)
27834 movl %edx, 4(v)
27835 RET_ENDP
27836 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27837 adcl %edx, %edi
27838 addl (v), %eax
27839 adcl 4(v), %edx
27840 +
27841 +#ifdef CONFIG_PAX_REFCOUNT
27842 + into
27843 +1234:
27844 + _ASM_EXTABLE(1234b, 2f)
27845 +#endif
27846 +
27847 cmpl %eax, %ecx
27848 je 3f
27849 1:
27850 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27851 1:
27852 addl $1, %eax
27853 adcl $0, %edx
27854 +
27855 +#ifdef CONFIG_PAX_REFCOUNT
27856 + into
27857 +1234:
27858 + _ASM_EXTABLE(1234b, 2f)
27859 +#endif
27860 +
27861 movl %eax, (v)
27862 movl %edx, 4(v)
27863 movl $1, %eax
27864 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27865 movl 4(v), %edx
27866 subl $1, %eax
27867 sbbl $0, %edx
27868 +
27869 +#ifdef CONFIG_PAX_REFCOUNT
27870 + into
27871 +1234:
27872 + _ASM_EXTABLE(1234b, 1f)
27873 +#endif
27874 +
27875 js 1f
27876 movl %eax, (v)
27877 movl %edx, 4(v)
27878 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27879 index f5cc9eb..51fa319 100644
27880 --- a/arch/x86/lib/atomic64_cx8_32.S
27881 +++ b/arch/x86/lib/atomic64_cx8_32.S
27882 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27883 CFI_STARTPROC
27884
27885 read64 %ecx
27886 + pax_force_retaddr
27887 ret
27888 CFI_ENDPROC
27889 ENDPROC(atomic64_read_cx8)
27890
27891 +ENTRY(atomic64_read_unchecked_cx8)
27892 + CFI_STARTPROC
27893 +
27894 + read64 %ecx
27895 + pax_force_retaddr
27896 + ret
27897 + CFI_ENDPROC
27898 +ENDPROC(atomic64_read_unchecked_cx8)
27899 +
27900 ENTRY(atomic64_set_cx8)
27901 CFI_STARTPROC
27902
27903 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27904 cmpxchg8b (%esi)
27905 jne 1b
27906
27907 + pax_force_retaddr
27908 ret
27909 CFI_ENDPROC
27910 ENDPROC(atomic64_set_cx8)
27911
27912 +ENTRY(atomic64_set_unchecked_cx8)
27913 + CFI_STARTPROC
27914 +
27915 +1:
27916 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27917 + * are atomic on 586 and newer */
27918 + cmpxchg8b (%esi)
27919 + jne 1b
27920 +
27921 + pax_force_retaddr
27922 + ret
27923 + CFI_ENDPROC
27924 +ENDPROC(atomic64_set_unchecked_cx8)
27925 +
27926 ENTRY(atomic64_xchg_cx8)
27927 CFI_STARTPROC
27928
27929 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27930 cmpxchg8b (%esi)
27931 jne 1b
27932
27933 + pax_force_retaddr
27934 ret
27935 CFI_ENDPROC
27936 ENDPROC(atomic64_xchg_cx8)
27937
27938 -.macro addsub_return func ins insc
27939 -ENTRY(atomic64_\func\()_return_cx8)
27940 +.macro addsub_return func ins insc unchecked=""
27941 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27942 CFI_STARTPROC
27943 SAVE ebp
27944 SAVE ebx
27945 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27946 movl %edx, %ecx
27947 \ins\()l %esi, %ebx
27948 \insc\()l %edi, %ecx
27949 +
27950 +.ifb \unchecked
27951 +#ifdef CONFIG_PAX_REFCOUNT
27952 + into
27953 +2:
27954 + _ASM_EXTABLE(2b, 3f)
27955 +#endif
27956 +.endif
27957 +
27958 LOCK_PREFIX
27959 cmpxchg8b (%ebp)
27960 jne 1b
27961 -
27962 -10:
27963 movl %ebx, %eax
27964 movl %ecx, %edx
27965 +
27966 +.ifb \unchecked
27967 +#ifdef CONFIG_PAX_REFCOUNT
27968 +3:
27969 +#endif
27970 +.endif
27971 +
27972 RESTORE edi
27973 RESTORE esi
27974 RESTORE ebx
27975 RESTORE ebp
27976 + pax_force_retaddr
27977 ret
27978 CFI_ENDPROC
27979 -ENDPROC(atomic64_\func\()_return_cx8)
27980 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27981 .endm
27982
27983 addsub_return add add adc
27984 addsub_return sub sub sbb
27985 +addsub_return add add adc _unchecked
27986 +addsub_return sub sub sbb _unchecked
27987
27988 -.macro incdec_return func ins insc
27989 -ENTRY(atomic64_\func\()_return_cx8)
27990 +.macro incdec_return func ins insc unchecked=""
27991 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27992 CFI_STARTPROC
27993 SAVE ebx
27994
27995 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27996 movl %edx, %ecx
27997 \ins\()l $1, %ebx
27998 \insc\()l $0, %ecx
27999 +
28000 +.ifb \unchecked
28001 +#ifdef CONFIG_PAX_REFCOUNT
28002 + into
28003 +2:
28004 + _ASM_EXTABLE(2b, 3f)
28005 +#endif
28006 +.endif
28007 +
28008 LOCK_PREFIX
28009 cmpxchg8b (%esi)
28010 jne 1b
28011
28012 -10:
28013 movl %ebx, %eax
28014 movl %ecx, %edx
28015 +
28016 +.ifb \unchecked
28017 +#ifdef CONFIG_PAX_REFCOUNT
28018 +3:
28019 +#endif
28020 +.endif
28021 +
28022 RESTORE ebx
28023 + pax_force_retaddr
28024 ret
28025 CFI_ENDPROC
28026 -ENDPROC(atomic64_\func\()_return_cx8)
28027 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
28028 .endm
28029
28030 incdec_return inc add adc
28031 incdec_return dec sub sbb
28032 +incdec_return inc add adc _unchecked
28033 +incdec_return dec sub sbb _unchecked
28034
28035 ENTRY(atomic64_dec_if_positive_cx8)
28036 CFI_STARTPROC
28037 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
28038 movl %edx, %ecx
28039 subl $1, %ebx
28040 sbb $0, %ecx
28041 +
28042 +#ifdef CONFIG_PAX_REFCOUNT
28043 + into
28044 +1234:
28045 + _ASM_EXTABLE(1234b, 2f)
28046 +#endif
28047 +
28048 js 2f
28049 LOCK_PREFIX
28050 cmpxchg8b (%esi)
28051 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
28052 movl %ebx, %eax
28053 movl %ecx, %edx
28054 RESTORE ebx
28055 + pax_force_retaddr
28056 ret
28057 CFI_ENDPROC
28058 ENDPROC(atomic64_dec_if_positive_cx8)
28059 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
28060 movl %edx, %ecx
28061 addl %ebp, %ebx
28062 adcl %edi, %ecx
28063 +
28064 +#ifdef CONFIG_PAX_REFCOUNT
28065 + into
28066 +1234:
28067 + _ASM_EXTABLE(1234b, 3f)
28068 +#endif
28069 +
28070 LOCK_PREFIX
28071 cmpxchg8b (%esi)
28072 jne 1b
28073 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
28074 CFI_ADJUST_CFA_OFFSET -8
28075 RESTORE ebx
28076 RESTORE ebp
28077 + pax_force_retaddr
28078 ret
28079 4:
28080 cmpl %edx, 4(%esp)
28081 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
28082 xorl %ecx, %ecx
28083 addl $1, %ebx
28084 adcl %edx, %ecx
28085 +
28086 +#ifdef CONFIG_PAX_REFCOUNT
28087 + into
28088 +1234:
28089 + _ASM_EXTABLE(1234b, 3f)
28090 +#endif
28091 +
28092 LOCK_PREFIX
28093 cmpxchg8b (%esi)
28094 jne 1b
28095 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
28096 movl $1, %eax
28097 3:
28098 RESTORE ebx
28099 + pax_force_retaddr
28100 ret
28101 CFI_ENDPROC
28102 ENDPROC(atomic64_inc_not_zero_cx8)
28103 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
28104 index e78b8ee..7e173a8 100644
28105 --- a/arch/x86/lib/checksum_32.S
28106 +++ b/arch/x86/lib/checksum_32.S
28107 @@ -29,7 +29,8 @@
28108 #include <asm/dwarf2.h>
28109 #include <asm/errno.h>
28110 #include <asm/asm.h>
28111 -
28112 +#include <asm/segment.h>
28113 +
28114 /*
28115 * computes a partial checksum, e.g. for TCP/UDP fragments
28116 */
28117 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
28118
28119 #define ARGBASE 16
28120 #define FP 12
28121 -
28122 -ENTRY(csum_partial_copy_generic)
28123 +
28124 +ENTRY(csum_partial_copy_generic_to_user)
28125 CFI_STARTPROC
28126 +
28127 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28128 + pushl_cfi %gs
28129 + popl_cfi %es
28130 + jmp csum_partial_copy_generic
28131 +#endif
28132 +
28133 +ENTRY(csum_partial_copy_generic_from_user)
28134 +
28135 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28136 + pushl_cfi %gs
28137 + popl_cfi %ds
28138 +#endif
28139 +
28140 +ENTRY(csum_partial_copy_generic)
28141 subl $4,%esp
28142 CFI_ADJUST_CFA_OFFSET 4
28143 pushl_cfi %edi
28144 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
28145 jmp 4f
28146 SRC(1: movw (%esi), %bx )
28147 addl $2, %esi
28148 -DST( movw %bx, (%edi) )
28149 +DST( movw %bx, %es:(%edi) )
28150 addl $2, %edi
28151 addw %bx, %ax
28152 adcl $0, %eax
28153 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
28154 SRC(1: movl (%esi), %ebx )
28155 SRC( movl 4(%esi), %edx )
28156 adcl %ebx, %eax
28157 -DST( movl %ebx, (%edi) )
28158 +DST( movl %ebx, %es:(%edi) )
28159 adcl %edx, %eax
28160 -DST( movl %edx, 4(%edi) )
28161 +DST( movl %edx, %es:4(%edi) )
28162
28163 SRC( movl 8(%esi), %ebx )
28164 SRC( movl 12(%esi), %edx )
28165 adcl %ebx, %eax
28166 -DST( movl %ebx, 8(%edi) )
28167 +DST( movl %ebx, %es:8(%edi) )
28168 adcl %edx, %eax
28169 -DST( movl %edx, 12(%edi) )
28170 +DST( movl %edx, %es:12(%edi) )
28171
28172 SRC( movl 16(%esi), %ebx )
28173 SRC( movl 20(%esi), %edx )
28174 adcl %ebx, %eax
28175 -DST( movl %ebx, 16(%edi) )
28176 +DST( movl %ebx, %es:16(%edi) )
28177 adcl %edx, %eax
28178 -DST( movl %edx, 20(%edi) )
28179 +DST( movl %edx, %es:20(%edi) )
28180
28181 SRC( movl 24(%esi), %ebx )
28182 SRC( movl 28(%esi), %edx )
28183 adcl %ebx, %eax
28184 -DST( movl %ebx, 24(%edi) )
28185 +DST( movl %ebx, %es:24(%edi) )
28186 adcl %edx, %eax
28187 -DST( movl %edx, 28(%edi) )
28188 +DST( movl %edx, %es:28(%edi) )
28189
28190 lea 32(%esi), %esi
28191 lea 32(%edi), %edi
28192 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
28193 shrl $2, %edx # This clears CF
28194 SRC(3: movl (%esi), %ebx )
28195 adcl %ebx, %eax
28196 -DST( movl %ebx, (%edi) )
28197 +DST( movl %ebx, %es:(%edi) )
28198 lea 4(%esi), %esi
28199 lea 4(%edi), %edi
28200 dec %edx
28201 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
28202 jb 5f
28203 SRC( movw (%esi), %cx )
28204 leal 2(%esi), %esi
28205 -DST( movw %cx, (%edi) )
28206 +DST( movw %cx, %es:(%edi) )
28207 leal 2(%edi), %edi
28208 je 6f
28209 shll $16,%ecx
28210 SRC(5: movb (%esi), %cl )
28211 -DST( movb %cl, (%edi) )
28212 +DST( movb %cl, %es:(%edi) )
28213 6: addl %ecx, %eax
28214 adcl $0, %eax
28215 7:
28216 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
28217
28218 6001:
28219 movl ARGBASE+20(%esp), %ebx # src_err_ptr
28220 - movl $-EFAULT, (%ebx)
28221 + movl $-EFAULT, %ss:(%ebx)
28222
28223 # zero the complete destination - computing the rest
28224 # is too much work
28225 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
28226
28227 6002:
28228 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
28229 - movl $-EFAULT,(%ebx)
28230 + movl $-EFAULT,%ss:(%ebx)
28231 jmp 5000b
28232
28233 .previous
28234
28235 + pushl_cfi %ss
28236 + popl_cfi %ds
28237 + pushl_cfi %ss
28238 + popl_cfi %es
28239 popl_cfi %ebx
28240 CFI_RESTORE ebx
28241 popl_cfi %esi
28242 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
28243 popl_cfi %ecx # equivalent to addl $4,%esp
28244 ret
28245 CFI_ENDPROC
28246 -ENDPROC(csum_partial_copy_generic)
28247 +ENDPROC(csum_partial_copy_generic_to_user)
28248
28249 #else
28250
28251 /* Version for PentiumII/PPro */
28252
28253 #define ROUND1(x) \
28254 + nop; nop; nop; \
28255 SRC(movl x(%esi), %ebx ) ; \
28256 addl %ebx, %eax ; \
28257 - DST(movl %ebx, x(%edi) ) ;
28258 + DST(movl %ebx, %es:x(%edi)) ;
28259
28260 #define ROUND(x) \
28261 + nop; nop; nop; \
28262 SRC(movl x(%esi), %ebx ) ; \
28263 adcl %ebx, %eax ; \
28264 - DST(movl %ebx, x(%edi) ) ;
28265 + DST(movl %ebx, %es:x(%edi)) ;
28266
28267 #define ARGBASE 12
28268 -
28269 -ENTRY(csum_partial_copy_generic)
28270 +
28271 +ENTRY(csum_partial_copy_generic_to_user)
28272 CFI_STARTPROC
28273 +
28274 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28275 + pushl_cfi %gs
28276 + popl_cfi %es
28277 + jmp csum_partial_copy_generic
28278 +#endif
28279 +
28280 +ENTRY(csum_partial_copy_generic_from_user)
28281 +
28282 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28283 + pushl_cfi %gs
28284 + popl_cfi %ds
28285 +#endif
28286 +
28287 +ENTRY(csum_partial_copy_generic)
28288 pushl_cfi %ebx
28289 CFI_REL_OFFSET ebx, 0
28290 pushl_cfi %edi
28291 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
28292 subl %ebx, %edi
28293 lea -1(%esi),%edx
28294 andl $-32,%edx
28295 - lea 3f(%ebx,%ebx), %ebx
28296 + lea 3f(%ebx,%ebx,2), %ebx
28297 testl %esi, %esi
28298 jmp *%ebx
28299 1: addl $64,%esi
28300 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
28301 jb 5f
28302 SRC( movw (%esi), %dx )
28303 leal 2(%esi), %esi
28304 -DST( movw %dx, (%edi) )
28305 +DST( movw %dx, %es:(%edi) )
28306 leal 2(%edi), %edi
28307 je 6f
28308 shll $16,%edx
28309 5:
28310 SRC( movb (%esi), %dl )
28311 -DST( movb %dl, (%edi) )
28312 +DST( movb %dl, %es:(%edi) )
28313 6: addl %edx, %eax
28314 adcl $0, %eax
28315 7:
28316 .section .fixup, "ax"
28317 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
28318 - movl $-EFAULT, (%ebx)
28319 + movl $-EFAULT, %ss:(%ebx)
28320 # zero the complete destination (computing the rest is too much work)
28321 movl ARGBASE+8(%esp),%edi # dst
28322 movl ARGBASE+12(%esp),%ecx # len
28323 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
28324 rep; stosb
28325 jmp 7b
28326 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
28327 - movl $-EFAULT, (%ebx)
28328 + movl $-EFAULT, %ss:(%ebx)
28329 jmp 7b
28330 .previous
28331
28332 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28333 + pushl_cfi %ss
28334 + popl_cfi %ds
28335 + pushl_cfi %ss
28336 + popl_cfi %es
28337 +#endif
28338 +
28339 popl_cfi %esi
28340 CFI_RESTORE esi
28341 popl_cfi %edi
28342 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
28343 CFI_RESTORE ebx
28344 ret
28345 CFI_ENDPROC
28346 -ENDPROC(csum_partial_copy_generic)
28347 +ENDPROC(csum_partial_copy_generic_to_user)
28348
28349 #undef ROUND
28350 #undef ROUND1
28351 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
28352 index f2145cf..cea889d 100644
28353 --- a/arch/x86/lib/clear_page_64.S
28354 +++ b/arch/x86/lib/clear_page_64.S
28355 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
28356 movl $4096/8,%ecx
28357 xorl %eax,%eax
28358 rep stosq
28359 + pax_force_retaddr
28360 ret
28361 CFI_ENDPROC
28362 ENDPROC(clear_page_c)
28363 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
28364 movl $4096,%ecx
28365 xorl %eax,%eax
28366 rep stosb
28367 + pax_force_retaddr
28368 ret
28369 CFI_ENDPROC
28370 ENDPROC(clear_page_c_e)
28371 @@ -43,6 +45,7 @@ ENTRY(clear_page)
28372 leaq 64(%rdi),%rdi
28373 jnz .Lloop
28374 nop
28375 + pax_force_retaddr
28376 ret
28377 CFI_ENDPROC
28378 .Lclear_page_end:
28379 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
28380
28381 #include <asm/cpufeature.h>
28382
28383 - .section .altinstr_replacement,"ax"
28384 + .section .altinstr_replacement,"a"
28385 1: .byte 0xeb /* jmp <disp8> */
28386 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
28387 2: .byte 0xeb /* jmp <disp8> */
28388 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
28389 index 1e572c5..2a162cd 100644
28390 --- a/arch/x86/lib/cmpxchg16b_emu.S
28391 +++ b/arch/x86/lib/cmpxchg16b_emu.S
28392 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
28393
28394 popf
28395 mov $1, %al
28396 + pax_force_retaddr
28397 ret
28398
28399 not_same:
28400 popf
28401 xor %al,%al
28402 + pax_force_retaddr
28403 ret
28404
28405 CFI_ENDPROC
28406 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
28407 index 176cca6..e0d658e 100644
28408 --- a/arch/x86/lib/copy_page_64.S
28409 +++ b/arch/x86/lib/copy_page_64.S
28410 @@ -9,6 +9,7 @@ copy_page_rep:
28411 CFI_STARTPROC
28412 movl $4096/8, %ecx
28413 rep movsq
28414 + pax_force_retaddr
28415 ret
28416 CFI_ENDPROC
28417 ENDPROC(copy_page_rep)
28418 @@ -24,8 +25,8 @@ ENTRY(copy_page)
28419 CFI_ADJUST_CFA_OFFSET 2*8
28420 movq %rbx, (%rsp)
28421 CFI_REL_OFFSET rbx, 0
28422 - movq %r12, 1*8(%rsp)
28423 - CFI_REL_OFFSET r12, 1*8
28424 + movq %r13, 1*8(%rsp)
28425 + CFI_REL_OFFSET r13, 1*8
28426
28427 movl $(4096/64)-5, %ecx
28428 .p2align 4
28429 @@ -38,7 +39,7 @@ ENTRY(copy_page)
28430 movq 0x8*4(%rsi), %r9
28431 movq 0x8*5(%rsi), %r10
28432 movq 0x8*6(%rsi), %r11
28433 - movq 0x8*7(%rsi), %r12
28434 + movq 0x8*7(%rsi), %r13
28435
28436 prefetcht0 5*64(%rsi)
28437
28438 @@ -49,7 +50,7 @@ ENTRY(copy_page)
28439 movq %r9, 0x8*4(%rdi)
28440 movq %r10, 0x8*5(%rdi)
28441 movq %r11, 0x8*6(%rdi)
28442 - movq %r12, 0x8*7(%rdi)
28443 + movq %r13, 0x8*7(%rdi)
28444
28445 leaq 64 (%rsi), %rsi
28446 leaq 64 (%rdi), %rdi
28447 @@ -68,7 +69,7 @@ ENTRY(copy_page)
28448 movq 0x8*4(%rsi), %r9
28449 movq 0x8*5(%rsi), %r10
28450 movq 0x8*6(%rsi), %r11
28451 - movq 0x8*7(%rsi), %r12
28452 + movq 0x8*7(%rsi), %r13
28453
28454 movq %rax, 0x8*0(%rdi)
28455 movq %rbx, 0x8*1(%rdi)
28456 @@ -77,7 +78,7 @@ ENTRY(copy_page)
28457 movq %r9, 0x8*4(%rdi)
28458 movq %r10, 0x8*5(%rdi)
28459 movq %r11, 0x8*6(%rdi)
28460 - movq %r12, 0x8*7(%rdi)
28461 + movq %r13, 0x8*7(%rdi)
28462
28463 leaq 64(%rdi), %rdi
28464 leaq 64(%rsi), %rsi
28465 @@ -85,10 +86,11 @@ ENTRY(copy_page)
28466
28467 movq (%rsp), %rbx
28468 CFI_RESTORE rbx
28469 - movq 1*8(%rsp), %r12
28470 - CFI_RESTORE r12
28471 + movq 1*8(%rsp), %r13
28472 + CFI_RESTORE r13
28473 addq $2*8, %rsp
28474 CFI_ADJUST_CFA_OFFSET -2*8
28475 + pax_force_retaddr
28476 ret
28477 .Lcopy_page_end:
28478 CFI_ENDPROC
28479 @@ -99,7 +101,7 @@ ENDPROC(copy_page)
28480
28481 #include <asm/cpufeature.h>
28482
28483 - .section .altinstr_replacement,"ax"
28484 + .section .altinstr_replacement,"a"
28485 1: .byte 0xeb /* jmp <disp8> */
28486 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
28487 2:
28488 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
28489 index a30ca15..407412b 100644
28490 --- a/arch/x86/lib/copy_user_64.S
28491 +++ b/arch/x86/lib/copy_user_64.S
28492 @@ -18,31 +18,7 @@
28493 #include <asm/alternative-asm.h>
28494 #include <asm/asm.h>
28495 #include <asm/smap.h>
28496 -
28497 -/*
28498 - * By placing feature2 after feature1 in altinstructions section, we logically
28499 - * implement:
28500 - * If CPU has feature2, jmp to alt2 is used
28501 - * else if CPU has feature1, jmp to alt1 is used
28502 - * else jmp to orig is used.
28503 - */
28504 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
28505 -0:
28506 - .byte 0xe9 /* 32bit jump */
28507 - .long \orig-1f /* by default jump to orig */
28508 -1:
28509 - .section .altinstr_replacement,"ax"
28510 -2: .byte 0xe9 /* near jump with 32bit immediate */
28511 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
28512 -3: .byte 0xe9 /* near jump with 32bit immediate */
28513 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
28514 - .previous
28515 -
28516 - .section .altinstructions,"a"
28517 - altinstruction_entry 0b,2b,\feature1,5,5
28518 - altinstruction_entry 0b,3b,\feature2,5,5
28519 - .previous
28520 - .endm
28521 +#include <asm/pgtable.h>
28522
28523 .macro ALIGN_DESTINATION
28524 #ifdef FIX_ALIGNMENT
28525 @@ -70,52 +46,6 @@
28526 #endif
28527 .endm
28528
28529 -/* Standard copy_to_user with segment limit checking */
28530 -ENTRY(_copy_to_user)
28531 - CFI_STARTPROC
28532 - GET_THREAD_INFO(%rax)
28533 - movq %rdi,%rcx
28534 - addq %rdx,%rcx
28535 - jc bad_to_user
28536 - cmpq TI_addr_limit(%rax),%rcx
28537 - ja bad_to_user
28538 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
28539 - copy_user_generic_unrolled,copy_user_generic_string, \
28540 - copy_user_enhanced_fast_string
28541 - CFI_ENDPROC
28542 -ENDPROC(_copy_to_user)
28543 -
28544 -/* Standard copy_from_user with segment limit checking */
28545 -ENTRY(_copy_from_user)
28546 - CFI_STARTPROC
28547 - GET_THREAD_INFO(%rax)
28548 - movq %rsi,%rcx
28549 - addq %rdx,%rcx
28550 - jc bad_from_user
28551 - cmpq TI_addr_limit(%rax),%rcx
28552 - ja bad_from_user
28553 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
28554 - copy_user_generic_unrolled,copy_user_generic_string, \
28555 - copy_user_enhanced_fast_string
28556 - CFI_ENDPROC
28557 -ENDPROC(_copy_from_user)
28558 -
28559 - .section .fixup,"ax"
28560 - /* must zero dest */
28561 -ENTRY(bad_from_user)
28562 -bad_from_user:
28563 - CFI_STARTPROC
28564 - movl %edx,%ecx
28565 - xorl %eax,%eax
28566 - rep
28567 - stosb
28568 -bad_to_user:
28569 - movl %edx,%eax
28570 - ret
28571 - CFI_ENDPROC
28572 -ENDPROC(bad_from_user)
28573 - .previous
28574 -
28575 /*
28576 * copy_user_generic_unrolled - memory copy with exception handling.
28577 * This version is for CPUs like P4 that don't have efficient micro
28578 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
28579 */
28580 ENTRY(copy_user_generic_unrolled)
28581 CFI_STARTPROC
28582 + ASM_PAX_OPEN_USERLAND
28583 ASM_STAC
28584 cmpl $8,%edx
28585 jb 20f /* less then 8 bytes, go to byte copy loop */
28586 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
28587 jnz 21b
28588 23: xor %eax,%eax
28589 ASM_CLAC
28590 + ASM_PAX_CLOSE_USERLAND
28591 + pax_force_retaddr
28592 ret
28593
28594 .section .fixup,"ax"
28595 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
28596 */
28597 ENTRY(copy_user_generic_string)
28598 CFI_STARTPROC
28599 + ASM_PAX_OPEN_USERLAND
28600 ASM_STAC
28601 andl %edx,%edx
28602 jz 4f
28603 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
28604 movsb
28605 4: xorl %eax,%eax
28606 ASM_CLAC
28607 + ASM_PAX_CLOSE_USERLAND
28608 + pax_force_retaddr
28609 ret
28610
28611 .section .fixup,"ax"
28612 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
28613 */
28614 ENTRY(copy_user_enhanced_fast_string)
28615 CFI_STARTPROC
28616 + ASM_PAX_OPEN_USERLAND
28617 ASM_STAC
28618 andl %edx,%edx
28619 jz 2f
28620 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
28621 movsb
28622 2: xorl %eax,%eax
28623 ASM_CLAC
28624 + ASM_PAX_CLOSE_USERLAND
28625 + pax_force_retaddr
28626 ret
28627
28628 .section .fixup,"ax"
28629 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
28630 index 6a4f43c..c70fb52 100644
28631 --- a/arch/x86/lib/copy_user_nocache_64.S
28632 +++ b/arch/x86/lib/copy_user_nocache_64.S
28633 @@ -8,6 +8,7 @@
28634
28635 #include <linux/linkage.h>
28636 #include <asm/dwarf2.h>
28637 +#include <asm/alternative-asm.h>
28638
28639 #define FIX_ALIGNMENT 1
28640
28641 @@ -16,6 +17,7 @@
28642 #include <asm/thread_info.h>
28643 #include <asm/asm.h>
28644 #include <asm/smap.h>
28645 +#include <asm/pgtable.h>
28646
28647 .macro ALIGN_DESTINATION
28648 #ifdef FIX_ALIGNMENT
28649 @@ -49,6 +51,16 @@
28650 */
28651 ENTRY(__copy_user_nocache)
28652 CFI_STARTPROC
28653 +
28654 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28655 + mov pax_user_shadow_base,%rcx
28656 + cmp %rcx,%rsi
28657 + jae 1f
28658 + add %rcx,%rsi
28659 +1:
28660 +#endif
28661 +
28662 + ASM_PAX_OPEN_USERLAND
28663 ASM_STAC
28664 cmpl $8,%edx
28665 jb 20f /* less then 8 bytes, go to byte copy loop */
28666 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
28667 jnz 21b
28668 23: xorl %eax,%eax
28669 ASM_CLAC
28670 + ASM_PAX_CLOSE_USERLAND
28671 sfence
28672 + pax_force_retaddr
28673 ret
28674
28675 .section .fixup,"ax"
28676 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
28677 index 2419d5f..fe52d0e 100644
28678 --- a/arch/x86/lib/csum-copy_64.S
28679 +++ b/arch/x86/lib/csum-copy_64.S
28680 @@ -9,6 +9,7 @@
28681 #include <asm/dwarf2.h>
28682 #include <asm/errno.h>
28683 #include <asm/asm.h>
28684 +#include <asm/alternative-asm.h>
28685
28686 /*
28687 * Checksum copy with exception handling.
28688 @@ -56,8 +57,8 @@ ENTRY(csum_partial_copy_generic)
28689 CFI_ADJUST_CFA_OFFSET 7*8
28690 movq %rbx, 2*8(%rsp)
28691 CFI_REL_OFFSET rbx, 2*8
28692 - movq %r12, 3*8(%rsp)
28693 - CFI_REL_OFFSET r12, 3*8
28694 + movq %r15, 3*8(%rsp)
28695 + CFI_REL_OFFSET r15, 3*8
28696 movq %r14, 4*8(%rsp)
28697 CFI_REL_OFFSET r14, 4*8
28698 movq %r13, 5*8(%rsp)
28699 @@ -72,16 +73,16 @@ ENTRY(csum_partial_copy_generic)
28700 movl %edx, %ecx
28701
28702 xorl %r9d, %r9d
28703 - movq %rcx, %r12
28704 + movq %rcx, %r15
28705
28706 - shrq $6, %r12
28707 + shrq $6, %r15
28708 jz .Lhandle_tail /* < 64 */
28709
28710 clc
28711
28712 /* main loop. clear in 64 byte blocks */
28713 /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
28714 - /* r11: temp3, rdx: temp4, r12 loopcnt */
28715 + /* r11: temp3, rdx: temp4, r15 loopcnt */
28716 /* r10: temp5, rbp: temp6, r14 temp7, r13 temp8 */
28717 .p2align 4
28718 .Lloop:
28719 @@ -115,7 +116,7 @@ ENTRY(csum_partial_copy_generic)
28720 adcq %r14, %rax
28721 adcq %r13, %rax
28722
28723 - decl %r12d
28724 + decl %r15d
28725
28726 dest
28727 movq %rbx, (%rsi)
28728 @@ -210,8 +211,8 @@ ENTRY(csum_partial_copy_generic)
28729 .Lende:
28730 movq 2*8(%rsp), %rbx
28731 CFI_RESTORE rbx
28732 - movq 3*8(%rsp), %r12
28733 - CFI_RESTORE r12
28734 + movq 3*8(%rsp), %r15
28735 + CFI_RESTORE r15
28736 movq 4*8(%rsp), %r14
28737 CFI_RESTORE r14
28738 movq 5*8(%rsp), %r13
28739 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
28740 CFI_RESTORE rbp
28741 addq $7*8, %rsp
28742 CFI_ADJUST_CFA_OFFSET -7*8
28743 + pax_force_retaddr
28744 ret
28745 CFI_RESTORE_STATE
28746
28747 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
28748 index 7609e0e..b449b98 100644
28749 --- a/arch/x86/lib/csum-wrappers_64.c
28750 +++ b/arch/x86/lib/csum-wrappers_64.c
28751 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
28752 len -= 2;
28753 }
28754 }
28755 + pax_open_userland();
28756 stac();
28757 - isum = csum_partial_copy_generic((__force const void *)src,
28758 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
28759 dst, len, isum, errp, NULL);
28760 clac();
28761 + pax_close_userland();
28762 if (unlikely(*errp))
28763 goto out_err;
28764
28765 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
28766 }
28767
28768 *errp = 0;
28769 + pax_open_userland();
28770 stac();
28771 - ret = csum_partial_copy_generic(src, (void __force *)dst,
28772 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
28773 len, isum, NULL, errp);
28774 clac();
28775 + pax_close_userland();
28776 return ret;
28777 }
28778 EXPORT_SYMBOL(csum_partial_copy_to_user);
28779 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
28780 index a451235..1daa956 100644
28781 --- a/arch/x86/lib/getuser.S
28782 +++ b/arch/x86/lib/getuser.S
28783 @@ -33,17 +33,40 @@
28784 #include <asm/thread_info.h>
28785 #include <asm/asm.h>
28786 #include <asm/smap.h>
28787 +#include <asm/segment.h>
28788 +#include <asm/pgtable.h>
28789 +#include <asm/alternative-asm.h>
28790 +
28791 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28792 +#define __copyuser_seg gs;
28793 +#else
28794 +#define __copyuser_seg
28795 +#endif
28796
28797 .text
28798 ENTRY(__get_user_1)
28799 CFI_STARTPROC
28800 +
28801 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28802 GET_THREAD_INFO(%_ASM_DX)
28803 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28804 jae bad_get_user
28805 ASM_STAC
28806 -1: movzbl (%_ASM_AX),%edx
28807 +
28808 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28809 + mov pax_user_shadow_base,%_ASM_DX
28810 + cmp %_ASM_DX,%_ASM_AX
28811 + jae 1234f
28812 + add %_ASM_DX,%_ASM_AX
28813 +1234:
28814 +#endif
28815 +
28816 +#endif
28817 +
28818 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28819 xor %eax,%eax
28820 ASM_CLAC
28821 + pax_force_retaddr
28822 ret
28823 CFI_ENDPROC
28824 ENDPROC(__get_user_1)
28825 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28826 ENTRY(__get_user_2)
28827 CFI_STARTPROC
28828 add $1,%_ASM_AX
28829 +
28830 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28831 jc bad_get_user
28832 GET_THREAD_INFO(%_ASM_DX)
28833 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28834 jae bad_get_user
28835 ASM_STAC
28836 -2: movzwl -1(%_ASM_AX),%edx
28837 +
28838 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28839 + mov pax_user_shadow_base,%_ASM_DX
28840 + cmp %_ASM_DX,%_ASM_AX
28841 + jae 1234f
28842 + add %_ASM_DX,%_ASM_AX
28843 +1234:
28844 +#endif
28845 +
28846 +#endif
28847 +
28848 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28849 xor %eax,%eax
28850 ASM_CLAC
28851 + pax_force_retaddr
28852 ret
28853 CFI_ENDPROC
28854 ENDPROC(__get_user_2)
28855 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28856 ENTRY(__get_user_4)
28857 CFI_STARTPROC
28858 add $3,%_ASM_AX
28859 +
28860 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28861 jc bad_get_user
28862 GET_THREAD_INFO(%_ASM_DX)
28863 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28864 jae bad_get_user
28865 ASM_STAC
28866 -3: movl -3(%_ASM_AX),%edx
28867 +
28868 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28869 + mov pax_user_shadow_base,%_ASM_DX
28870 + cmp %_ASM_DX,%_ASM_AX
28871 + jae 1234f
28872 + add %_ASM_DX,%_ASM_AX
28873 +1234:
28874 +#endif
28875 +
28876 +#endif
28877 +
28878 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28879 xor %eax,%eax
28880 ASM_CLAC
28881 + pax_force_retaddr
28882 ret
28883 CFI_ENDPROC
28884 ENDPROC(__get_user_4)
28885 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28886 GET_THREAD_INFO(%_ASM_DX)
28887 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28888 jae bad_get_user
28889 +
28890 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28891 + mov pax_user_shadow_base,%_ASM_DX
28892 + cmp %_ASM_DX,%_ASM_AX
28893 + jae 1234f
28894 + add %_ASM_DX,%_ASM_AX
28895 +1234:
28896 +#endif
28897 +
28898 ASM_STAC
28899 4: movq -7(%_ASM_AX),%rdx
28900 xor %eax,%eax
28901 ASM_CLAC
28902 + pax_force_retaddr
28903 ret
28904 #else
28905 add $7,%_ASM_AX
28906 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28907 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28908 jae bad_get_user_8
28909 ASM_STAC
28910 -4: movl -7(%_ASM_AX),%edx
28911 -5: movl -3(%_ASM_AX),%ecx
28912 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28913 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28914 xor %eax,%eax
28915 ASM_CLAC
28916 + pax_force_retaddr
28917 ret
28918 #endif
28919 CFI_ENDPROC
28920 @@ -113,6 +175,7 @@ bad_get_user:
28921 xor %edx,%edx
28922 mov $(-EFAULT),%_ASM_AX
28923 ASM_CLAC
28924 + pax_force_retaddr
28925 ret
28926 CFI_ENDPROC
28927 END(bad_get_user)
28928 @@ -124,6 +187,7 @@ bad_get_user_8:
28929 xor %ecx,%ecx
28930 mov $(-EFAULT),%_ASM_AX
28931 ASM_CLAC
28932 + pax_force_retaddr
28933 ret
28934 CFI_ENDPROC
28935 END(bad_get_user_8)
28936 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28937 index 54fcffe..7be149e 100644
28938 --- a/arch/x86/lib/insn.c
28939 +++ b/arch/x86/lib/insn.c
28940 @@ -20,8 +20,10 @@
28941
28942 #ifdef __KERNEL__
28943 #include <linux/string.h>
28944 +#include <asm/pgtable_types.h>
28945 #else
28946 #include <string.h>
28947 +#define ktla_ktva(addr) addr
28948 #endif
28949 #include <asm/inat.h>
28950 #include <asm/insn.h>
28951 @@ -53,8 +55,8 @@
28952 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28953 {
28954 memset(insn, 0, sizeof(*insn));
28955 - insn->kaddr = kaddr;
28956 - insn->next_byte = kaddr;
28957 + insn->kaddr = ktla_ktva(kaddr);
28958 + insn->next_byte = ktla_ktva(kaddr);
28959 insn->x86_64 = x86_64 ? 1 : 0;
28960 insn->opnd_bytes = 4;
28961 if (x86_64)
28962 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28963 index 05a95e7..326f2fa 100644
28964 --- a/arch/x86/lib/iomap_copy_64.S
28965 +++ b/arch/x86/lib/iomap_copy_64.S
28966 @@ -17,6 +17,7 @@
28967
28968 #include <linux/linkage.h>
28969 #include <asm/dwarf2.h>
28970 +#include <asm/alternative-asm.h>
28971
28972 /*
28973 * override generic version in lib/iomap_copy.c
28974 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28975 CFI_STARTPROC
28976 movl %edx,%ecx
28977 rep movsd
28978 + pax_force_retaddr
28979 ret
28980 CFI_ENDPROC
28981 ENDPROC(__iowrite32_copy)
28982 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28983 index 56313a3..0db417e 100644
28984 --- a/arch/x86/lib/memcpy_64.S
28985 +++ b/arch/x86/lib/memcpy_64.S
28986 @@ -24,7 +24,7 @@
28987 * This gets patched over the unrolled variant (below) via the
28988 * alternative instructions framework:
28989 */
28990 - .section .altinstr_replacement, "ax", @progbits
28991 + .section .altinstr_replacement, "a", @progbits
28992 .Lmemcpy_c:
28993 movq %rdi, %rax
28994 movq %rdx, %rcx
28995 @@ -33,6 +33,7 @@
28996 rep movsq
28997 movl %edx, %ecx
28998 rep movsb
28999 + pax_force_retaddr
29000 ret
29001 .Lmemcpy_e:
29002 .previous
29003 @@ -44,11 +45,12 @@
29004 * This gets patched over the unrolled variant (below) via the
29005 * alternative instructions framework:
29006 */
29007 - .section .altinstr_replacement, "ax", @progbits
29008 + .section .altinstr_replacement, "a", @progbits
29009 .Lmemcpy_c_e:
29010 movq %rdi, %rax
29011 movq %rdx, %rcx
29012 rep movsb
29013 + pax_force_retaddr
29014 ret
29015 .Lmemcpy_e_e:
29016 .previous
29017 @@ -136,6 +138,7 @@ ENTRY(memcpy)
29018 movq %r9, 1*8(%rdi)
29019 movq %r10, -2*8(%rdi, %rdx)
29020 movq %r11, -1*8(%rdi, %rdx)
29021 + pax_force_retaddr
29022 retq
29023 .p2align 4
29024 .Lless_16bytes:
29025 @@ -148,6 +151,7 @@ ENTRY(memcpy)
29026 movq -1*8(%rsi, %rdx), %r9
29027 movq %r8, 0*8(%rdi)
29028 movq %r9, -1*8(%rdi, %rdx)
29029 + pax_force_retaddr
29030 retq
29031 .p2align 4
29032 .Lless_8bytes:
29033 @@ -161,6 +165,7 @@ ENTRY(memcpy)
29034 movl -4(%rsi, %rdx), %r8d
29035 movl %ecx, (%rdi)
29036 movl %r8d, -4(%rdi, %rdx)
29037 + pax_force_retaddr
29038 retq
29039 .p2align 4
29040 .Lless_3bytes:
29041 @@ -179,6 +184,7 @@ ENTRY(memcpy)
29042 movb %cl, (%rdi)
29043
29044 .Lend:
29045 + pax_force_retaddr
29046 retq
29047 CFI_ENDPROC
29048 ENDPROC(memcpy)
29049 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
29050 index 65268a6..dd1de11 100644
29051 --- a/arch/x86/lib/memmove_64.S
29052 +++ b/arch/x86/lib/memmove_64.S
29053 @@ -202,14 +202,16 @@ ENTRY(memmove)
29054 movb (%rsi), %r11b
29055 movb %r11b, (%rdi)
29056 13:
29057 + pax_force_retaddr
29058 retq
29059 CFI_ENDPROC
29060
29061 - .section .altinstr_replacement,"ax"
29062 + .section .altinstr_replacement,"a"
29063 .Lmemmove_begin_forward_efs:
29064 /* Forward moving data. */
29065 movq %rdx, %rcx
29066 rep movsb
29067 + pax_force_retaddr
29068 retq
29069 .Lmemmove_end_forward_efs:
29070 .previous
29071 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
29072 index 2dcb380..2eb79fe 100644
29073 --- a/arch/x86/lib/memset_64.S
29074 +++ b/arch/x86/lib/memset_64.S
29075 @@ -16,7 +16,7 @@
29076 *
29077 * rax original destination
29078 */
29079 - .section .altinstr_replacement, "ax", @progbits
29080 + .section .altinstr_replacement, "a", @progbits
29081 .Lmemset_c:
29082 movq %rdi,%r9
29083 movq %rdx,%rcx
29084 @@ -30,6 +30,7 @@
29085 movl %edx,%ecx
29086 rep stosb
29087 movq %r9,%rax
29088 + pax_force_retaddr
29089 ret
29090 .Lmemset_e:
29091 .previous
29092 @@ -45,13 +46,14 @@
29093 *
29094 * rax original destination
29095 */
29096 - .section .altinstr_replacement, "ax", @progbits
29097 + .section .altinstr_replacement, "a", @progbits
29098 .Lmemset_c_e:
29099 movq %rdi,%r9
29100 movb %sil,%al
29101 movq %rdx,%rcx
29102 rep stosb
29103 movq %r9,%rax
29104 + pax_force_retaddr
29105 ret
29106 .Lmemset_e_e:
29107 .previous
29108 @@ -118,6 +120,7 @@ ENTRY(__memset)
29109
29110 .Lende:
29111 movq %r10,%rax
29112 + pax_force_retaddr
29113 ret
29114
29115 CFI_RESTORE_STATE
29116 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
29117 index c9f2d9b..e7fd2c0 100644
29118 --- a/arch/x86/lib/mmx_32.c
29119 +++ b/arch/x86/lib/mmx_32.c
29120 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
29121 {
29122 void *p;
29123 int i;
29124 + unsigned long cr0;
29125
29126 if (unlikely(in_interrupt()))
29127 return __memcpy(to, from, len);
29128 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
29129 kernel_fpu_begin();
29130
29131 __asm__ __volatile__ (
29132 - "1: prefetch (%0)\n" /* This set is 28 bytes */
29133 - " prefetch 64(%0)\n"
29134 - " prefetch 128(%0)\n"
29135 - " prefetch 192(%0)\n"
29136 - " prefetch 256(%0)\n"
29137 + "1: prefetch (%1)\n" /* This set is 28 bytes */
29138 + " prefetch 64(%1)\n"
29139 + " prefetch 128(%1)\n"
29140 + " prefetch 192(%1)\n"
29141 + " prefetch 256(%1)\n"
29142 "2: \n"
29143 ".section .fixup, \"ax\"\n"
29144 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29145 + "3: \n"
29146 +
29147 +#ifdef CONFIG_PAX_KERNEXEC
29148 + " movl %%cr0, %0\n"
29149 + " movl %0, %%eax\n"
29150 + " andl $0xFFFEFFFF, %%eax\n"
29151 + " movl %%eax, %%cr0\n"
29152 +#endif
29153 +
29154 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29155 +
29156 +#ifdef CONFIG_PAX_KERNEXEC
29157 + " movl %0, %%cr0\n"
29158 +#endif
29159 +
29160 " jmp 2b\n"
29161 ".previous\n"
29162 _ASM_EXTABLE(1b, 3b)
29163 - : : "r" (from));
29164 + : "=&r" (cr0) : "r" (from) : "ax");
29165
29166 for ( ; i > 5; i--) {
29167 __asm__ __volatile__ (
29168 - "1: prefetch 320(%0)\n"
29169 - "2: movq (%0), %%mm0\n"
29170 - " movq 8(%0), %%mm1\n"
29171 - " movq 16(%0), %%mm2\n"
29172 - " movq 24(%0), %%mm3\n"
29173 - " movq %%mm0, (%1)\n"
29174 - " movq %%mm1, 8(%1)\n"
29175 - " movq %%mm2, 16(%1)\n"
29176 - " movq %%mm3, 24(%1)\n"
29177 - " movq 32(%0), %%mm0\n"
29178 - " movq 40(%0), %%mm1\n"
29179 - " movq 48(%0), %%mm2\n"
29180 - " movq 56(%0), %%mm3\n"
29181 - " movq %%mm0, 32(%1)\n"
29182 - " movq %%mm1, 40(%1)\n"
29183 - " movq %%mm2, 48(%1)\n"
29184 - " movq %%mm3, 56(%1)\n"
29185 + "1: prefetch 320(%1)\n"
29186 + "2: movq (%1), %%mm0\n"
29187 + " movq 8(%1), %%mm1\n"
29188 + " movq 16(%1), %%mm2\n"
29189 + " movq 24(%1), %%mm3\n"
29190 + " movq %%mm0, (%2)\n"
29191 + " movq %%mm1, 8(%2)\n"
29192 + " movq %%mm2, 16(%2)\n"
29193 + " movq %%mm3, 24(%2)\n"
29194 + " movq 32(%1), %%mm0\n"
29195 + " movq 40(%1), %%mm1\n"
29196 + " movq 48(%1), %%mm2\n"
29197 + " movq 56(%1), %%mm3\n"
29198 + " movq %%mm0, 32(%2)\n"
29199 + " movq %%mm1, 40(%2)\n"
29200 + " movq %%mm2, 48(%2)\n"
29201 + " movq %%mm3, 56(%2)\n"
29202 ".section .fixup, \"ax\"\n"
29203 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29204 + "3:\n"
29205 +
29206 +#ifdef CONFIG_PAX_KERNEXEC
29207 + " movl %%cr0, %0\n"
29208 + " movl %0, %%eax\n"
29209 + " andl $0xFFFEFFFF, %%eax\n"
29210 + " movl %%eax, %%cr0\n"
29211 +#endif
29212 +
29213 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29214 +
29215 +#ifdef CONFIG_PAX_KERNEXEC
29216 + " movl %0, %%cr0\n"
29217 +#endif
29218 +
29219 " jmp 2b\n"
29220 ".previous\n"
29221 _ASM_EXTABLE(1b, 3b)
29222 - : : "r" (from), "r" (to) : "memory");
29223 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
29224
29225 from += 64;
29226 to += 64;
29227 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
29228 static void fast_copy_page(void *to, void *from)
29229 {
29230 int i;
29231 + unsigned long cr0;
29232
29233 kernel_fpu_begin();
29234
29235 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
29236 * but that is for later. -AV
29237 */
29238 __asm__ __volatile__(
29239 - "1: prefetch (%0)\n"
29240 - " prefetch 64(%0)\n"
29241 - " prefetch 128(%0)\n"
29242 - " prefetch 192(%0)\n"
29243 - " prefetch 256(%0)\n"
29244 + "1: prefetch (%1)\n"
29245 + " prefetch 64(%1)\n"
29246 + " prefetch 128(%1)\n"
29247 + " prefetch 192(%1)\n"
29248 + " prefetch 256(%1)\n"
29249 "2: \n"
29250 ".section .fixup, \"ax\"\n"
29251 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29252 + "3: \n"
29253 +
29254 +#ifdef CONFIG_PAX_KERNEXEC
29255 + " movl %%cr0, %0\n"
29256 + " movl %0, %%eax\n"
29257 + " andl $0xFFFEFFFF, %%eax\n"
29258 + " movl %%eax, %%cr0\n"
29259 +#endif
29260 +
29261 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29262 +
29263 +#ifdef CONFIG_PAX_KERNEXEC
29264 + " movl %0, %%cr0\n"
29265 +#endif
29266 +
29267 " jmp 2b\n"
29268 ".previous\n"
29269 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
29270 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
29271
29272 for (i = 0; i < (4096-320)/64; i++) {
29273 __asm__ __volatile__ (
29274 - "1: prefetch 320(%0)\n"
29275 - "2: movq (%0), %%mm0\n"
29276 - " movntq %%mm0, (%1)\n"
29277 - " movq 8(%0), %%mm1\n"
29278 - " movntq %%mm1, 8(%1)\n"
29279 - " movq 16(%0), %%mm2\n"
29280 - " movntq %%mm2, 16(%1)\n"
29281 - " movq 24(%0), %%mm3\n"
29282 - " movntq %%mm3, 24(%1)\n"
29283 - " movq 32(%0), %%mm4\n"
29284 - " movntq %%mm4, 32(%1)\n"
29285 - " movq 40(%0), %%mm5\n"
29286 - " movntq %%mm5, 40(%1)\n"
29287 - " movq 48(%0), %%mm6\n"
29288 - " movntq %%mm6, 48(%1)\n"
29289 - " movq 56(%0), %%mm7\n"
29290 - " movntq %%mm7, 56(%1)\n"
29291 + "1: prefetch 320(%1)\n"
29292 + "2: movq (%1), %%mm0\n"
29293 + " movntq %%mm0, (%2)\n"
29294 + " movq 8(%1), %%mm1\n"
29295 + " movntq %%mm1, 8(%2)\n"
29296 + " movq 16(%1), %%mm2\n"
29297 + " movntq %%mm2, 16(%2)\n"
29298 + " movq 24(%1), %%mm3\n"
29299 + " movntq %%mm3, 24(%2)\n"
29300 + " movq 32(%1), %%mm4\n"
29301 + " movntq %%mm4, 32(%2)\n"
29302 + " movq 40(%1), %%mm5\n"
29303 + " movntq %%mm5, 40(%2)\n"
29304 + " movq 48(%1), %%mm6\n"
29305 + " movntq %%mm6, 48(%2)\n"
29306 + " movq 56(%1), %%mm7\n"
29307 + " movntq %%mm7, 56(%2)\n"
29308 ".section .fixup, \"ax\"\n"
29309 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29310 + "3:\n"
29311 +
29312 +#ifdef CONFIG_PAX_KERNEXEC
29313 + " movl %%cr0, %0\n"
29314 + " movl %0, %%eax\n"
29315 + " andl $0xFFFEFFFF, %%eax\n"
29316 + " movl %%eax, %%cr0\n"
29317 +#endif
29318 +
29319 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29320 +
29321 +#ifdef CONFIG_PAX_KERNEXEC
29322 + " movl %0, %%cr0\n"
29323 +#endif
29324 +
29325 " jmp 2b\n"
29326 ".previous\n"
29327 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
29328 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
29329
29330 from += 64;
29331 to += 64;
29332 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
29333 static void fast_copy_page(void *to, void *from)
29334 {
29335 int i;
29336 + unsigned long cr0;
29337
29338 kernel_fpu_begin();
29339
29340 __asm__ __volatile__ (
29341 - "1: prefetch (%0)\n"
29342 - " prefetch 64(%0)\n"
29343 - " prefetch 128(%0)\n"
29344 - " prefetch 192(%0)\n"
29345 - " prefetch 256(%0)\n"
29346 + "1: prefetch (%1)\n"
29347 + " prefetch 64(%1)\n"
29348 + " prefetch 128(%1)\n"
29349 + " prefetch 192(%1)\n"
29350 + " prefetch 256(%1)\n"
29351 "2: \n"
29352 ".section .fixup, \"ax\"\n"
29353 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29354 + "3: \n"
29355 +
29356 +#ifdef CONFIG_PAX_KERNEXEC
29357 + " movl %%cr0, %0\n"
29358 + " movl %0, %%eax\n"
29359 + " andl $0xFFFEFFFF, %%eax\n"
29360 + " movl %%eax, %%cr0\n"
29361 +#endif
29362 +
29363 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29364 +
29365 +#ifdef CONFIG_PAX_KERNEXEC
29366 + " movl %0, %%cr0\n"
29367 +#endif
29368 +
29369 " jmp 2b\n"
29370 ".previous\n"
29371 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
29372 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
29373
29374 for (i = 0; i < 4096/64; i++) {
29375 __asm__ __volatile__ (
29376 - "1: prefetch 320(%0)\n"
29377 - "2: movq (%0), %%mm0\n"
29378 - " movq 8(%0), %%mm1\n"
29379 - " movq 16(%0), %%mm2\n"
29380 - " movq 24(%0), %%mm3\n"
29381 - " movq %%mm0, (%1)\n"
29382 - " movq %%mm1, 8(%1)\n"
29383 - " movq %%mm2, 16(%1)\n"
29384 - " movq %%mm3, 24(%1)\n"
29385 - " movq 32(%0), %%mm0\n"
29386 - " movq 40(%0), %%mm1\n"
29387 - " movq 48(%0), %%mm2\n"
29388 - " movq 56(%0), %%mm3\n"
29389 - " movq %%mm0, 32(%1)\n"
29390 - " movq %%mm1, 40(%1)\n"
29391 - " movq %%mm2, 48(%1)\n"
29392 - " movq %%mm3, 56(%1)\n"
29393 + "1: prefetch 320(%1)\n"
29394 + "2: movq (%1), %%mm0\n"
29395 + " movq 8(%1), %%mm1\n"
29396 + " movq 16(%1), %%mm2\n"
29397 + " movq 24(%1), %%mm3\n"
29398 + " movq %%mm0, (%2)\n"
29399 + " movq %%mm1, 8(%2)\n"
29400 + " movq %%mm2, 16(%2)\n"
29401 + " movq %%mm3, 24(%2)\n"
29402 + " movq 32(%1), %%mm0\n"
29403 + " movq 40(%1), %%mm1\n"
29404 + " movq 48(%1), %%mm2\n"
29405 + " movq 56(%1), %%mm3\n"
29406 + " movq %%mm0, 32(%2)\n"
29407 + " movq %%mm1, 40(%2)\n"
29408 + " movq %%mm2, 48(%2)\n"
29409 + " movq %%mm3, 56(%2)\n"
29410 ".section .fixup, \"ax\"\n"
29411 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29412 + "3:\n"
29413 +
29414 +#ifdef CONFIG_PAX_KERNEXEC
29415 + " movl %%cr0, %0\n"
29416 + " movl %0, %%eax\n"
29417 + " andl $0xFFFEFFFF, %%eax\n"
29418 + " movl %%eax, %%cr0\n"
29419 +#endif
29420 +
29421 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29422 +
29423 +#ifdef CONFIG_PAX_KERNEXEC
29424 + " movl %0, %%cr0\n"
29425 +#endif
29426 +
29427 " jmp 2b\n"
29428 ".previous\n"
29429 _ASM_EXTABLE(1b, 3b)
29430 - : : "r" (from), "r" (to) : "memory");
29431 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
29432
29433 from += 64;
29434 to += 64;
29435 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
29436 index f6d13ee..d789440 100644
29437 --- a/arch/x86/lib/msr-reg.S
29438 +++ b/arch/x86/lib/msr-reg.S
29439 @@ -3,6 +3,7 @@
29440 #include <asm/dwarf2.h>
29441 #include <asm/asm.h>
29442 #include <asm/msr.h>
29443 +#include <asm/alternative-asm.h>
29444
29445 #ifdef CONFIG_X86_64
29446 /*
29447 @@ -37,6 +38,7 @@ ENTRY(\op\()_safe_regs)
29448 movl %edi, 28(%r10)
29449 popq_cfi %rbp
29450 popq_cfi %rbx
29451 + pax_force_retaddr
29452 ret
29453 3:
29454 CFI_RESTORE_STATE
29455 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
29456 index fc6ba17..d4d989d 100644
29457 --- a/arch/x86/lib/putuser.S
29458 +++ b/arch/x86/lib/putuser.S
29459 @@ -16,7 +16,9 @@
29460 #include <asm/errno.h>
29461 #include <asm/asm.h>
29462 #include <asm/smap.h>
29463 -
29464 +#include <asm/segment.h>
29465 +#include <asm/pgtable.h>
29466 +#include <asm/alternative-asm.h>
29467
29468 /*
29469 * __put_user_X
29470 @@ -30,57 +32,125 @@
29471 * as they get called from within inline assembly.
29472 */
29473
29474 -#define ENTER CFI_STARTPROC ; \
29475 - GET_THREAD_INFO(%_ASM_BX)
29476 -#define EXIT ASM_CLAC ; \
29477 - ret ; \
29478 +#define ENTER CFI_STARTPROC
29479 +#define EXIT ASM_CLAC ; \
29480 + pax_force_retaddr ; \
29481 + ret ; \
29482 CFI_ENDPROC
29483
29484 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29485 +#define _DEST %_ASM_CX,%_ASM_BX
29486 +#else
29487 +#define _DEST %_ASM_CX
29488 +#endif
29489 +
29490 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
29491 +#define __copyuser_seg gs;
29492 +#else
29493 +#define __copyuser_seg
29494 +#endif
29495 +
29496 .text
29497 ENTRY(__put_user_1)
29498 ENTER
29499 +
29500 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29501 + GET_THREAD_INFO(%_ASM_BX)
29502 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
29503 jae bad_put_user
29504 ASM_STAC
29505 -1: movb %al,(%_ASM_CX)
29506 +
29507 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29508 + mov pax_user_shadow_base,%_ASM_BX
29509 + cmp %_ASM_BX,%_ASM_CX
29510 + jb 1234f
29511 + xor %ebx,%ebx
29512 +1234:
29513 +#endif
29514 +
29515 +#endif
29516 +
29517 +1: __copyuser_seg movb %al,(_DEST)
29518 xor %eax,%eax
29519 EXIT
29520 ENDPROC(__put_user_1)
29521
29522 ENTRY(__put_user_2)
29523 ENTER
29524 +
29525 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29526 + GET_THREAD_INFO(%_ASM_BX)
29527 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29528 sub $1,%_ASM_BX
29529 cmp %_ASM_BX,%_ASM_CX
29530 jae bad_put_user
29531 ASM_STAC
29532 -2: movw %ax,(%_ASM_CX)
29533 +
29534 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29535 + mov pax_user_shadow_base,%_ASM_BX
29536 + cmp %_ASM_BX,%_ASM_CX
29537 + jb 1234f
29538 + xor %ebx,%ebx
29539 +1234:
29540 +#endif
29541 +
29542 +#endif
29543 +
29544 +2: __copyuser_seg movw %ax,(_DEST)
29545 xor %eax,%eax
29546 EXIT
29547 ENDPROC(__put_user_2)
29548
29549 ENTRY(__put_user_4)
29550 ENTER
29551 +
29552 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29553 + GET_THREAD_INFO(%_ASM_BX)
29554 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29555 sub $3,%_ASM_BX
29556 cmp %_ASM_BX,%_ASM_CX
29557 jae bad_put_user
29558 ASM_STAC
29559 -3: movl %eax,(%_ASM_CX)
29560 +
29561 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29562 + mov pax_user_shadow_base,%_ASM_BX
29563 + cmp %_ASM_BX,%_ASM_CX
29564 + jb 1234f
29565 + xor %ebx,%ebx
29566 +1234:
29567 +#endif
29568 +
29569 +#endif
29570 +
29571 +3: __copyuser_seg movl %eax,(_DEST)
29572 xor %eax,%eax
29573 EXIT
29574 ENDPROC(__put_user_4)
29575
29576 ENTRY(__put_user_8)
29577 ENTER
29578 +
29579 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29580 + GET_THREAD_INFO(%_ASM_BX)
29581 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29582 sub $7,%_ASM_BX
29583 cmp %_ASM_BX,%_ASM_CX
29584 jae bad_put_user
29585 ASM_STAC
29586 -4: mov %_ASM_AX,(%_ASM_CX)
29587 +
29588 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29589 + mov pax_user_shadow_base,%_ASM_BX
29590 + cmp %_ASM_BX,%_ASM_CX
29591 + jb 1234f
29592 + xor %ebx,%ebx
29593 +1234:
29594 +#endif
29595 +
29596 +#endif
29597 +
29598 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
29599 #ifdef CONFIG_X86_32
29600 -5: movl %edx,4(%_ASM_CX)
29601 +5: __copyuser_seg movl %edx,4(_DEST)
29602 #endif
29603 xor %eax,%eax
29604 EXIT
29605 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
29606 index 1cad221..de671ee 100644
29607 --- a/arch/x86/lib/rwlock.S
29608 +++ b/arch/x86/lib/rwlock.S
29609 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
29610 FRAME
29611 0: LOCK_PREFIX
29612 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29613 +
29614 +#ifdef CONFIG_PAX_REFCOUNT
29615 + jno 1234f
29616 + LOCK_PREFIX
29617 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29618 + int $4
29619 +1234:
29620 + _ASM_EXTABLE(1234b, 1234b)
29621 +#endif
29622 +
29623 1: rep; nop
29624 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
29625 jne 1b
29626 LOCK_PREFIX
29627 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29628 +
29629 +#ifdef CONFIG_PAX_REFCOUNT
29630 + jno 1234f
29631 + LOCK_PREFIX
29632 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29633 + int $4
29634 +1234:
29635 + _ASM_EXTABLE(1234b, 1234b)
29636 +#endif
29637 +
29638 jnz 0b
29639 ENDFRAME
29640 + pax_force_retaddr
29641 ret
29642 CFI_ENDPROC
29643 END(__write_lock_failed)
29644 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29645 FRAME
29646 0: LOCK_PREFIX
29647 READ_LOCK_SIZE(inc) (%__lock_ptr)
29648 +
29649 +#ifdef CONFIG_PAX_REFCOUNT
29650 + jno 1234f
29651 + LOCK_PREFIX
29652 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29653 + int $4
29654 +1234:
29655 + _ASM_EXTABLE(1234b, 1234b)
29656 +#endif
29657 +
29658 1: rep; nop
29659 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29660 js 1b
29661 LOCK_PREFIX
29662 READ_LOCK_SIZE(dec) (%__lock_ptr)
29663 +
29664 +#ifdef CONFIG_PAX_REFCOUNT
29665 + jno 1234f
29666 + LOCK_PREFIX
29667 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29668 + int $4
29669 +1234:
29670 + _ASM_EXTABLE(1234b, 1234b)
29671 +#endif
29672 +
29673 js 0b
29674 ENDFRAME
29675 + pax_force_retaddr
29676 ret
29677 CFI_ENDPROC
29678 END(__read_lock_failed)
29679 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29680 index 5dff5f0..cadebf4 100644
29681 --- a/arch/x86/lib/rwsem.S
29682 +++ b/arch/x86/lib/rwsem.S
29683 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29684 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29685 CFI_RESTORE __ASM_REG(dx)
29686 restore_common_regs
29687 + pax_force_retaddr
29688 ret
29689 CFI_ENDPROC
29690 ENDPROC(call_rwsem_down_read_failed)
29691 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29692 movq %rax,%rdi
29693 call rwsem_down_write_failed
29694 restore_common_regs
29695 + pax_force_retaddr
29696 ret
29697 CFI_ENDPROC
29698 ENDPROC(call_rwsem_down_write_failed)
29699 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29700 movq %rax,%rdi
29701 call rwsem_wake
29702 restore_common_regs
29703 -1: ret
29704 +1: pax_force_retaddr
29705 + ret
29706 CFI_ENDPROC
29707 ENDPROC(call_rwsem_wake)
29708
29709 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29710 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29711 CFI_RESTORE __ASM_REG(dx)
29712 restore_common_regs
29713 + pax_force_retaddr
29714 ret
29715 CFI_ENDPROC
29716 ENDPROC(call_rwsem_downgrade_wake)
29717 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29718 index a63efd6..8149fbe 100644
29719 --- a/arch/x86/lib/thunk_64.S
29720 +++ b/arch/x86/lib/thunk_64.S
29721 @@ -8,6 +8,7 @@
29722 #include <linux/linkage.h>
29723 #include <asm/dwarf2.h>
29724 #include <asm/calling.h>
29725 +#include <asm/alternative-asm.h>
29726
29727 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29728 .macro THUNK name, func, put_ret_addr_in_rdi=0
29729 @@ -15,11 +16,11 @@
29730 \name:
29731 CFI_STARTPROC
29732
29733 - /* this one pushes 9 elems, the next one would be %rIP */
29734 - SAVE_ARGS
29735 + /* this one pushes 15+1 elems, the next one would be %rIP */
29736 + SAVE_ARGS 8
29737
29738 .if \put_ret_addr_in_rdi
29739 - movq_cfi_restore 9*8, rdi
29740 + movq_cfi_restore RIP, rdi
29741 .endif
29742
29743 call \func
29744 @@ -38,8 +39,9 @@
29745
29746 /* SAVE_ARGS below is used only for the .cfi directives it contains. */
29747 CFI_STARTPROC
29748 - SAVE_ARGS
29749 + SAVE_ARGS 8
29750 restore:
29751 - RESTORE_ARGS
29752 + RESTORE_ARGS 1,8
29753 + pax_force_retaddr
29754 ret
29755 CFI_ENDPROC
29756 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29757 index 3eb18ac..4b22130 100644
29758 --- a/arch/x86/lib/usercopy_32.c
29759 +++ b/arch/x86/lib/usercopy_32.c
29760 @@ -42,11 +42,13 @@ do { \
29761 int __d0; \
29762 might_fault(); \
29763 __asm__ __volatile__( \
29764 + __COPYUSER_SET_ES \
29765 ASM_STAC "\n" \
29766 "0: rep; stosl\n" \
29767 " movl %2,%0\n" \
29768 "1: rep; stosb\n" \
29769 "2: " ASM_CLAC "\n" \
29770 + __COPYUSER_RESTORE_ES \
29771 ".section .fixup,\"ax\"\n" \
29772 "3: lea 0(%2,%0,4),%0\n" \
29773 " jmp 2b\n" \
29774 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29775
29776 #ifdef CONFIG_X86_INTEL_USERCOPY
29777 static unsigned long
29778 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29779 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29780 {
29781 int d0, d1;
29782 __asm__ __volatile__(
29783 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29784 " .align 2,0x90\n"
29785 "3: movl 0(%4), %%eax\n"
29786 "4: movl 4(%4), %%edx\n"
29787 - "5: movl %%eax, 0(%3)\n"
29788 - "6: movl %%edx, 4(%3)\n"
29789 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29790 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29791 "7: movl 8(%4), %%eax\n"
29792 "8: movl 12(%4),%%edx\n"
29793 - "9: movl %%eax, 8(%3)\n"
29794 - "10: movl %%edx, 12(%3)\n"
29795 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29796 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29797 "11: movl 16(%4), %%eax\n"
29798 "12: movl 20(%4), %%edx\n"
29799 - "13: movl %%eax, 16(%3)\n"
29800 - "14: movl %%edx, 20(%3)\n"
29801 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29802 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29803 "15: movl 24(%4), %%eax\n"
29804 "16: movl 28(%4), %%edx\n"
29805 - "17: movl %%eax, 24(%3)\n"
29806 - "18: movl %%edx, 28(%3)\n"
29807 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29808 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29809 "19: movl 32(%4), %%eax\n"
29810 "20: movl 36(%4), %%edx\n"
29811 - "21: movl %%eax, 32(%3)\n"
29812 - "22: movl %%edx, 36(%3)\n"
29813 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29814 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29815 "23: movl 40(%4), %%eax\n"
29816 "24: movl 44(%4), %%edx\n"
29817 - "25: movl %%eax, 40(%3)\n"
29818 - "26: movl %%edx, 44(%3)\n"
29819 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29820 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29821 "27: movl 48(%4), %%eax\n"
29822 "28: movl 52(%4), %%edx\n"
29823 - "29: movl %%eax, 48(%3)\n"
29824 - "30: movl %%edx, 52(%3)\n"
29825 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29826 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29827 "31: movl 56(%4), %%eax\n"
29828 "32: movl 60(%4), %%edx\n"
29829 - "33: movl %%eax, 56(%3)\n"
29830 - "34: movl %%edx, 60(%3)\n"
29831 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29832 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29833 " addl $-64, %0\n"
29834 " addl $64, %4\n"
29835 " addl $64, %3\n"
29836 @@ -149,10 +151,116 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29837 " shrl $2, %0\n"
29838 " andl $3, %%eax\n"
29839 " cld\n"
29840 + __COPYUSER_SET_ES
29841 "99: rep; movsl\n"
29842 "36: movl %%eax, %0\n"
29843 "37: rep; movsb\n"
29844 "100:\n"
29845 + __COPYUSER_RESTORE_ES
29846 + ".section .fixup,\"ax\"\n"
29847 + "101: lea 0(%%eax,%0,4),%0\n"
29848 + " jmp 100b\n"
29849 + ".previous\n"
29850 + _ASM_EXTABLE(1b,100b)
29851 + _ASM_EXTABLE(2b,100b)
29852 + _ASM_EXTABLE(3b,100b)
29853 + _ASM_EXTABLE(4b,100b)
29854 + _ASM_EXTABLE(5b,100b)
29855 + _ASM_EXTABLE(6b,100b)
29856 + _ASM_EXTABLE(7b,100b)
29857 + _ASM_EXTABLE(8b,100b)
29858 + _ASM_EXTABLE(9b,100b)
29859 + _ASM_EXTABLE(10b,100b)
29860 + _ASM_EXTABLE(11b,100b)
29861 + _ASM_EXTABLE(12b,100b)
29862 + _ASM_EXTABLE(13b,100b)
29863 + _ASM_EXTABLE(14b,100b)
29864 + _ASM_EXTABLE(15b,100b)
29865 + _ASM_EXTABLE(16b,100b)
29866 + _ASM_EXTABLE(17b,100b)
29867 + _ASM_EXTABLE(18b,100b)
29868 + _ASM_EXTABLE(19b,100b)
29869 + _ASM_EXTABLE(20b,100b)
29870 + _ASM_EXTABLE(21b,100b)
29871 + _ASM_EXTABLE(22b,100b)
29872 + _ASM_EXTABLE(23b,100b)
29873 + _ASM_EXTABLE(24b,100b)
29874 + _ASM_EXTABLE(25b,100b)
29875 + _ASM_EXTABLE(26b,100b)
29876 + _ASM_EXTABLE(27b,100b)
29877 + _ASM_EXTABLE(28b,100b)
29878 + _ASM_EXTABLE(29b,100b)
29879 + _ASM_EXTABLE(30b,100b)
29880 + _ASM_EXTABLE(31b,100b)
29881 + _ASM_EXTABLE(32b,100b)
29882 + _ASM_EXTABLE(33b,100b)
29883 + _ASM_EXTABLE(34b,100b)
29884 + _ASM_EXTABLE(35b,100b)
29885 + _ASM_EXTABLE(36b,100b)
29886 + _ASM_EXTABLE(37b,100b)
29887 + _ASM_EXTABLE(99b,101b)
29888 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29889 + : "1"(to), "2"(from), "0"(size)
29890 + : "eax", "edx", "memory");
29891 + return size;
29892 +}
29893 +
29894 +static unsigned long
29895 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29896 +{
29897 + int d0, d1;
29898 + __asm__ __volatile__(
29899 + " .align 2,0x90\n"
29900 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29901 + " cmpl $67, %0\n"
29902 + " jbe 3f\n"
29903 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29904 + " .align 2,0x90\n"
29905 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29906 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29907 + "5: movl %%eax, 0(%3)\n"
29908 + "6: movl %%edx, 4(%3)\n"
29909 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29910 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29911 + "9: movl %%eax, 8(%3)\n"
29912 + "10: movl %%edx, 12(%3)\n"
29913 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29914 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29915 + "13: movl %%eax, 16(%3)\n"
29916 + "14: movl %%edx, 20(%3)\n"
29917 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29918 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29919 + "17: movl %%eax, 24(%3)\n"
29920 + "18: movl %%edx, 28(%3)\n"
29921 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29922 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29923 + "21: movl %%eax, 32(%3)\n"
29924 + "22: movl %%edx, 36(%3)\n"
29925 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29926 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29927 + "25: movl %%eax, 40(%3)\n"
29928 + "26: movl %%edx, 44(%3)\n"
29929 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29930 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29931 + "29: movl %%eax, 48(%3)\n"
29932 + "30: movl %%edx, 52(%3)\n"
29933 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29934 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29935 + "33: movl %%eax, 56(%3)\n"
29936 + "34: movl %%edx, 60(%3)\n"
29937 + " addl $-64, %0\n"
29938 + " addl $64, %4\n"
29939 + " addl $64, %3\n"
29940 + " cmpl $63, %0\n"
29941 + " ja 1b\n"
29942 + "35: movl %0, %%eax\n"
29943 + " shrl $2, %0\n"
29944 + " andl $3, %%eax\n"
29945 + " cld\n"
29946 + "99: rep; "__copyuser_seg" movsl\n"
29947 + "36: movl %%eax, %0\n"
29948 + "37: rep; "__copyuser_seg" movsb\n"
29949 + "100:\n"
29950 ".section .fixup,\"ax\"\n"
29951 "101: lea 0(%%eax,%0,4),%0\n"
29952 " jmp 100b\n"
29953 @@ -207,41 +315,41 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29954 int d0, d1;
29955 __asm__ __volatile__(
29956 " .align 2,0x90\n"
29957 - "0: movl 32(%4), %%eax\n"
29958 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29959 " cmpl $67, %0\n"
29960 " jbe 2f\n"
29961 - "1: movl 64(%4), %%eax\n"
29962 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29963 " .align 2,0x90\n"
29964 - "2: movl 0(%4), %%eax\n"
29965 - "21: movl 4(%4), %%edx\n"
29966 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29967 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29968 " movl %%eax, 0(%3)\n"
29969 " movl %%edx, 4(%3)\n"
29970 - "3: movl 8(%4), %%eax\n"
29971 - "31: movl 12(%4),%%edx\n"
29972 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29973 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29974 " movl %%eax, 8(%3)\n"
29975 " movl %%edx, 12(%3)\n"
29976 - "4: movl 16(%4), %%eax\n"
29977 - "41: movl 20(%4), %%edx\n"
29978 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29979 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29980 " movl %%eax, 16(%3)\n"
29981 " movl %%edx, 20(%3)\n"
29982 - "10: movl 24(%4), %%eax\n"
29983 - "51: movl 28(%4), %%edx\n"
29984 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29985 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29986 " movl %%eax, 24(%3)\n"
29987 " movl %%edx, 28(%3)\n"
29988 - "11: movl 32(%4), %%eax\n"
29989 - "61: movl 36(%4), %%edx\n"
29990 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29991 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29992 " movl %%eax, 32(%3)\n"
29993 " movl %%edx, 36(%3)\n"
29994 - "12: movl 40(%4), %%eax\n"
29995 - "71: movl 44(%4), %%edx\n"
29996 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29997 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29998 " movl %%eax, 40(%3)\n"
29999 " movl %%edx, 44(%3)\n"
30000 - "13: movl 48(%4), %%eax\n"
30001 - "81: movl 52(%4), %%edx\n"
30002 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
30003 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
30004 " movl %%eax, 48(%3)\n"
30005 " movl %%edx, 52(%3)\n"
30006 - "14: movl 56(%4), %%eax\n"
30007 - "91: movl 60(%4), %%edx\n"
30008 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
30009 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
30010 " movl %%eax, 56(%3)\n"
30011 " movl %%edx, 60(%3)\n"
30012 " addl $-64, %0\n"
30013 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
30014 " shrl $2, %0\n"
30015 " andl $3, %%eax\n"
30016 " cld\n"
30017 - "6: rep; movsl\n"
30018 + "6: rep; "__copyuser_seg" movsl\n"
30019 " movl %%eax,%0\n"
30020 - "7: rep; movsb\n"
30021 + "7: rep; "__copyuser_seg" movsb\n"
30022 "8:\n"
30023 ".section .fixup,\"ax\"\n"
30024 "9: lea 0(%%eax,%0,4),%0\n"
30025 @@ -305,41 +413,41 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
30026
30027 __asm__ __volatile__(
30028 " .align 2,0x90\n"
30029 - "0: movl 32(%4), %%eax\n"
30030 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
30031 " cmpl $67, %0\n"
30032 " jbe 2f\n"
30033 - "1: movl 64(%4), %%eax\n"
30034 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
30035 " .align 2,0x90\n"
30036 - "2: movl 0(%4), %%eax\n"
30037 - "21: movl 4(%4), %%edx\n"
30038 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
30039 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
30040 " movnti %%eax, 0(%3)\n"
30041 " movnti %%edx, 4(%3)\n"
30042 - "3: movl 8(%4), %%eax\n"
30043 - "31: movl 12(%4),%%edx\n"
30044 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
30045 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
30046 " movnti %%eax, 8(%3)\n"
30047 " movnti %%edx, 12(%3)\n"
30048 - "4: movl 16(%4), %%eax\n"
30049 - "41: movl 20(%4), %%edx\n"
30050 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
30051 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
30052 " movnti %%eax, 16(%3)\n"
30053 " movnti %%edx, 20(%3)\n"
30054 - "10: movl 24(%4), %%eax\n"
30055 - "51: movl 28(%4), %%edx\n"
30056 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
30057 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
30058 " movnti %%eax, 24(%3)\n"
30059 " movnti %%edx, 28(%3)\n"
30060 - "11: movl 32(%4), %%eax\n"
30061 - "61: movl 36(%4), %%edx\n"
30062 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
30063 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
30064 " movnti %%eax, 32(%3)\n"
30065 " movnti %%edx, 36(%3)\n"
30066 - "12: movl 40(%4), %%eax\n"
30067 - "71: movl 44(%4), %%edx\n"
30068 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
30069 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
30070 " movnti %%eax, 40(%3)\n"
30071 " movnti %%edx, 44(%3)\n"
30072 - "13: movl 48(%4), %%eax\n"
30073 - "81: movl 52(%4), %%edx\n"
30074 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
30075 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
30076 " movnti %%eax, 48(%3)\n"
30077 " movnti %%edx, 52(%3)\n"
30078 - "14: movl 56(%4), %%eax\n"
30079 - "91: movl 60(%4), %%edx\n"
30080 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
30081 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
30082 " movnti %%eax, 56(%3)\n"
30083 " movnti %%edx, 60(%3)\n"
30084 " addl $-64, %0\n"
30085 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
30086 " shrl $2, %0\n"
30087 " andl $3, %%eax\n"
30088 " cld\n"
30089 - "6: rep; movsl\n"
30090 + "6: rep; "__copyuser_seg" movsl\n"
30091 " movl %%eax,%0\n"
30092 - "7: rep; movsb\n"
30093 + "7: rep; "__copyuser_seg" movsb\n"
30094 "8:\n"
30095 ".section .fixup,\"ax\"\n"
30096 "9: lea 0(%%eax,%0,4),%0\n"
30097 @@ -399,41 +507,41 @@ static unsigned long __copy_user_intel_nocache(void *to,
30098
30099 __asm__ __volatile__(
30100 " .align 2,0x90\n"
30101 - "0: movl 32(%4), %%eax\n"
30102 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
30103 " cmpl $67, %0\n"
30104 " jbe 2f\n"
30105 - "1: movl 64(%4), %%eax\n"
30106 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
30107 " .align 2,0x90\n"
30108 - "2: movl 0(%4), %%eax\n"
30109 - "21: movl 4(%4), %%edx\n"
30110 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
30111 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
30112 " movnti %%eax, 0(%3)\n"
30113 " movnti %%edx, 4(%3)\n"
30114 - "3: movl 8(%4), %%eax\n"
30115 - "31: movl 12(%4),%%edx\n"
30116 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
30117 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
30118 " movnti %%eax, 8(%3)\n"
30119 " movnti %%edx, 12(%3)\n"
30120 - "4: movl 16(%4), %%eax\n"
30121 - "41: movl 20(%4), %%edx\n"
30122 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
30123 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
30124 " movnti %%eax, 16(%3)\n"
30125 " movnti %%edx, 20(%3)\n"
30126 - "10: movl 24(%4), %%eax\n"
30127 - "51: movl 28(%4), %%edx\n"
30128 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
30129 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
30130 " movnti %%eax, 24(%3)\n"
30131 " movnti %%edx, 28(%3)\n"
30132 - "11: movl 32(%4), %%eax\n"
30133 - "61: movl 36(%4), %%edx\n"
30134 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
30135 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
30136 " movnti %%eax, 32(%3)\n"
30137 " movnti %%edx, 36(%3)\n"
30138 - "12: movl 40(%4), %%eax\n"
30139 - "71: movl 44(%4), %%edx\n"
30140 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
30141 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
30142 " movnti %%eax, 40(%3)\n"
30143 " movnti %%edx, 44(%3)\n"
30144 - "13: movl 48(%4), %%eax\n"
30145 - "81: movl 52(%4), %%edx\n"
30146 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
30147 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
30148 " movnti %%eax, 48(%3)\n"
30149 " movnti %%edx, 52(%3)\n"
30150 - "14: movl 56(%4), %%eax\n"
30151 - "91: movl 60(%4), %%edx\n"
30152 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
30153 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
30154 " movnti %%eax, 56(%3)\n"
30155 " movnti %%edx, 60(%3)\n"
30156 " addl $-64, %0\n"
30157 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
30158 " shrl $2, %0\n"
30159 " andl $3, %%eax\n"
30160 " cld\n"
30161 - "6: rep; movsl\n"
30162 + "6: rep; "__copyuser_seg" movsl\n"
30163 " movl %%eax,%0\n"
30164 - "7: rep; movsb\n"
30165 + "7: rep; "__copyuser_seg" movsb\n"
30166 "8:\n"
30167 ".section .fixup,\"ax\"\n"
30168 "9: lea 0(%%eax,%0,4),%0\n"
30169 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
30170 */
30171 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
30172 unsigned long size);
30173 -unsigned long __copy_user_intel(void __user *to, const void *from,
30174 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
30175 + unsigned long size);
30176 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
30177 unsigned long size);
30178 unsigned long __copy_user_zeroing_intel_nocache(void *to,
30179 const void __user *from, unsigned long size);
30180 #endif /* CONFIG_X86_INTEL_USERCOPY */
30181
30182 /* Generic arbitrary sized copy. */
30183 -#define __copy_user(to, from, size) \
30184 +#define __copy_user(to, from, size, prefix, set, restore) \
30185 do { \
30186 int __d0, __d1, __d2; \
30187 __asm__ __volatile__( \
30188 + set \
30189 " cmp $7,%0\n" \
30190 " jbe 1f\n" \
30191 " movl %1,%0\n" \
30192 " negl %0\n" \
30193 " andl $7,%0\n" \
30194 " subl %0,%3\n" \
30195 - "4: rep; movsb\n" \
30196 + "4: rep; "prefix"movsb\n" \
30197 " movl %3,%0\n" \
30198 " shrl $2,%0\n" \
30199 " andl $3,%3\n" \
30200 " .align 2,0x90\n" \
30201 - "0: rep; movsl\n" \
30202 + "0: rep; "prefix"movsl\n" \
30203 " movl %3,%0\n" \
30204 - "1: rep; movsb\n" \
30205 + "1: rep; "prefix"movsb\n" \
30206 "2:\n" \
30207 + restore \
30208 ".section .fixup,\"ax\"\n" \
30209 "5: addl %3,%0\n" \
30210 " jmp 2b\n" \
30211 @@ -538,14 +650,14 @@ do { \
30212 " negl %0\n" \
30213 " andl $7,%0\n" \
30214 " subl %0,%3\n" \
30215 - "4: rep; movsb\n" \
30216 + "4: rep; "__copyuser_seg"movsb\n" \
30217 " movl %3,%0\n" \
30218 " shrl $2,%0\n" \
30219 " andl $3,%3\n" \
30220 " .align 2,0x90\n" \
30221 - "0: rep; movsl\n" \
30222 + "0: rep; "__copyuser_seg"movsl\n" \
30223 " movl %3,%0\n" \
30224 - "1: rep; movsb\n" \
30225 + "1: rep; "__copyuser_seg"movsb\n" \
30226 "2:\n" \
30227 ".section .fixup,\"ax\"\n" \
30228 "5: addl %3,%0\n" \
30229 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
30230 {
30231 stac();
30232 if (movsl_is_ok(to, from, n))
30233 - __copy_user(to, from, n);
30234 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
30235 else
30236 - n = __copy_user_intel(to, from, n);
30237 + n = __generic_copy_to_user_intel(to, from, n);
30238 clac();
30239 return n;
30240 }
30241 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
30242 {
30243 stac();
30244 if (movsl_is_ok(to, from, n))
30245 - __copy_user(to, from, n);
30246 + __copy_user(to, from, n, __copyuser_seg, "", "");
30247 else
30248 - n = __copy_user_intel((void __user *)to,
30249 - (const void *)from, n);
30250 + n = __generic_copy_from_user_intel(to, from, n);
30251 clac();
30252 return n;
30253 }
30254 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
30255 if (n > 64 && cpu_has_xmm2)
30256 n = __copy_user_intel_nocache(to, from, n);
30257 else
30258 - __copy_user(to, from, n);
30259 + __copy_user(to, from, n, __copyuser_seg, "", "");
30260 #else
30261 - __copy_user(to, from, n);
30262 + __copy_user(to, from, n, __copyuser_seg, "", "");
30263 #endif
30264 clac();
30265 return n;
30266 }
30267 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
30268
30269 -/**
30270 - * copy_to_user: - Copy a block of data into user space.
30271 - * @to: Destination address, in user space.
30272 - * @from: Source address, in kernel space.
30273 - * @n: Number of bytes to copy.
30274 - *
30275 - * Context: User context only. This function may sleep.
30276 - *
30277 - * Copy data from kernel space to user space.
30278 - *
30279 - * Returns number of bytes that could not be copied.
30280 - * On success, this will be zero.
30281 - */
30282 -unsigned long
30283 -copy_to_user(void __user *to, const void *from, unsigned long n)
30284 +#ifdef CONFIG_PAX_MEMORY_UDEREF
30285 +void __set_fs(mm_segment_t x)
30286 {
30287 - if (access_ok(VERIFY_WRITE, to, n))
30288 - n = __copy_to_user(to, from, n);
30289 - return n;
30290 + switch (x.seg) {
30291 + case 0:
30292 + loadsegment(gs, 0);
30293 + break;
30294 + case TASK_SIZE_MAX:
30295 + loadsegment(gs, __USER_DS);
30296 + break;
30297 + case -1UL:
30298 + loadsegment(gs, __KERNEL_DS);
30299 + break;
30300 + default:
30301 + BUG();
30302 + }
30303 }
30304 -EXPORT_SYMBOL(copy_to_user);
30305 +EXPORT_SYMBOL(__set_fs);
30306
30307 -/**
30308 - * copy_from_user: - Copy a block of data from user space.
30309 - * @to: Destination address, in kernel space.
30310 - * @from: Source address, in user space.
30311 - * @n: Number of bytes to copy.
30312 - *
30313 - * Context: User context only. This function may sleep.
30314 - *
30315 - * Copy data from user space to kernel space.
30316 - *
30317 - * Returns number of bytes that could not be copied.
30318 - * On success, this will be zero.
30319 - *
30320 - * If some data could not be copied, this function will pad the copied
30321 - * data to the requested size using zero bytes.
30322 - */
30323 -unsigned long
30324 -_copy_from_user(void *to, const void __user *from, unsigned long n)
30325 +void set_fs(mm_segment_t x)
30326 {
30327 - if (access_ok(VERIFY_READ, from, n))
30328 - n = __copy_from_user(to, from, n);
30329 - else
30330 - memset(to, 0, n);
30331 - return n;
30332 + current_thread_info()->addr_limit = x;
30333 + __set_fs(x);
30334 }
30335 -EXPORT_SYMBOL(_copy_from_user);
30336 +EXPORT_SYMBOL(set_fs);
30337 +#endif
30338 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
30339 index c905e89..01ab928 100644
30340 --- a/arch/x86/lib/usercopy_64.c
30341 +++ b/arch/x86/lib/usercopy_64.c
30342 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
30343 might_fault();
30344 /* no memory constraint because it doesn't change any memory gcc knows
30345 about */
30346 + pax_open_userland();
30347 stac();
30348 asm volatile(
30349 " testq %[size8],%[size8]\n"
30350 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
30351 _ASM_EXTABLE(0b,3b)
30352 _ASM_EXTABLE(1b,2b)
30353 : [size8] "=&c"(size), [dst] "=&D" (__d0)
30354 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
30355 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
30356 [zero] "r" (0UL), [eight] "r" (8UL));
30357 clac();
30358 + pax_close_userland();
30359 return size;
30360 }
30361 EXPORT_SYMBOL(__clear_user);
30362 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
30363 }
30364 EXPORT_SYMBOL(clear_user);
30365
30366 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
30367 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
30368 {
30369 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
30370 - return copy_user_generic((__force void *)to, (__force void *)from, len);
30371 - }
30372 - return len;
30373 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
30374 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
30375 + return len;
30376 }
30377 EXPORT_SYMBOL(copy_in_user);
30378
30379 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
30380 * it is not necessary to optimize tail handling.
30381 */
30382 __visible unsigned long
30383 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
30384 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
30385 {
30386 char c;
30387 unsigned zero_len;
30388
30389 + clac();
30390 + pax_close_userland();
30391 for (; len; --len, to++) {
30392 if (__get_user_nocheck(c, from++, sizeof(char)))
30393 break;
30394 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
30395 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
30396 if (__put_user_nocheck(c, to++, sizeof(char)))
30397 break;
30398 - clac();
30399 return len;
30400 }
30401 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
30402 index 23d8e5f..9ccc13a 100644
30403 --- a/arch/x86/mm/Makefile
30404 +++ b/arch/x86/mm/Makefile
30405 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
30406 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
30407
30408 obj-$(CONFIG_MEMTEST) += memtest.o
30409 +
30410 +quote:="
30411 +obj-$(CONFIG_X86_64) += uderef_64.o
30412 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
30413 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
30414 index 903ec1e..c4166b2 100644
30415 --- a/arch/x86/mm/extable.c
30416 +++ b/arch/x86/mm/extable.c
30417 @@ -6,12 +6,24 @@
30418 static inline unsigned long
30419 ex_insn_addr(const struct exception_table_entry *x)
30420 {
30421 - return (unsigned long)&x->insn + x->insn;
30422 + unsigned long reloc = 0;
30423 +
30424 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30425 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30426 +#endif
30427 +
30428 + return (unsigned long)&x->insn + x->insn + reloc;
30429 }
30430 static inline unsigned long
30431 ex_fixup_addr(const struct exception_table_entry *x)
30432 {
30433 - return (unsigned long)&x->fixup + x->fixup;
30434 + unsigned long reloc = 0;
30435 +
30436 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30437 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30438 +#endif
30439 +
30440 + return (unsigned long)&x->fixup + x->fixup + reloc;
30441 }
30442
30443 int fixup_exception(struct pt_regs *regs)
30444 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
30445 unsigned long new_ip;
30446
30447 #ifdef CONFIG_PNPBIOS
30448 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
30449 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
30450 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
30451 extern u32 pnp_bios_is_utter_crap;
30452 pnp_bios_is_utter_crap = 1;
30453 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
30454 i += 4;
30455 p->fixup -= i;
30456 i += 4;
30457 +
30458 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30459 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
30460 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30461 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30462 +#endif
30463 +
30464 }
30465 }
30466
30467 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
30468 index 3aaeffc..42ea9fb 100644
30469 --- a/arch/x86/mm/fault.c
30470 +++ b/arch/x86/mm/fault.c
30471 @@ -14,11 +14,18 @@
30472 #include <linux/hugetlb.h> /* hstate_index_to_shift */
30473 #include <linux/prefetch.h> /* prefetchw */
30474 #include <linux/context_tracking.h> /* exception_enter(), ... */
30475 +#include <linux/unistd.h>
30476 +#include <linux/compiler.h>
30477
30478 #include <asm/traps.h> /* dotraplinkage, ... */
30479 #include <asm/pgalloc.h> /* pgd_*(), ... */
30480 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
30481 #include <asm/fixmap.h> /* VSYSCALL_START */
30482 +#include <asm/tlbflush.h>
30483 +
30484 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30485 +#include <asm/stacktrace.h>
30486 +#endif
30487
30488 /*
30489 * Page fault error code bits:
30490 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
30491 int ret = 0;
30492
30493 /* kprobe_running() needs smp_processor_id() */
30494 - if (kprobes_built_in() && !user_mode_vm(regs)) {
30495 + if (kprobes_built_in() && !user_mode(regs)) {
30496 preempt_disable();
30497 if (kprobe_running() && kprobe_fault_handler(regs, 14))
30498 ret = 1;
30499 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
30500 return !instr_lo || (instr_lo>>1) == 1;
30501 case 0x00:
30502 /* Prefetch instruction is 0x0F0D or 0x0F18 */
30503 - if (probe_kernel_address(instr, opcode))
30504 + if (user_mode(regs)) {
30505 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
30506 + return 0;
30507 + } else if (probe_kernel_address(instr, opcode))
30508 return 0;
30509
30510 *prefetch = (instr_lo == 0xF) &&
30511 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
30512 while (instr < max_instr) {
30513 unsigned char opcode;
30514
30515 - if (probe_kernel_address(instr, opcode))
30516 + if (user_mode(regs)) {
30517 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
30518 + break;
30519 + } else if (probe_kernel_address(instr, opcode))
30520 break;
30521
30522 instr++;
30523 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
30524 force_sig_info(si_signo, &info, tsk);
30525 }
30526
30527 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30528 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
30529 +#endif
30530 +
30531 +#ifdef CONFIG_PAX_EMUTRAMP
30532 +static int pax_handle_fetch_fault(struct pt_regs *regs);
30533 +#endif
30534 +
30535 +#ifdef CONFIG_PAX_PAGEEXEC
30536 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
30537 +{
30538 + pgd_t *pgd;
30539 + pud_t *pud;
30540 + pmd_t *pmd;
30541 +
30542 + pgd = pgd_offset(mm, address);
30543 + if (!pgd_present(*pgd))
30544 + return NULL;
30545 + pud = pud_offset(pgd, address);
30546 + if (!pud_present(*pud))
30547 + return NULL;
30548 + pmd = pmd_offset(pud, address);
30549 + if (!pmd_present(*pmd))
30550 + return NULL;
30551 + return pmd;
30552 +}
30553 +#endif
30554 +
30555 DEFINE_SPINLOCK(pgd_lock);
30556 LIST_HEAD(pgd_list);
30557
30558 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
30559 for (address = VMALLOC_START & PMD_MASK;
30560 address >= TASK_SIZE && address < FIXADDR_TOP;
30561 address += PMD_SIZE) {
30562 +
30563 +#ifdef CONFIG_PAX_PER_CPU_PGD
30564 + unsigned long cpu;
30565 +#else
30566 struct page *page;
30567 +#endif
30568
30569 spin_lock(&pgd_lock);
30570 +
30571 +#ifdef CONFIG_PAX_PER_CPU_PGD
30572 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
30573 + pgd_t *pgd = get_cpu_pgd(cpu, user);
30574 + pmd_t *ret;
30575 +
30576 + ret = vmalloc_sync_one(pgd, address);
30577 + if (!ret)
30578 + break;
30579 + pgd = get_cpu_pgd(cpu, kernel);
30580 +#else
30581 list_for_each_entry(page, &pgd_list, lru) {
30582 + pgd_t *pgd;
30583 spinlock_t *pgt_lock;
30584 pmd_t *ret;
30585
30586 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
30587 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
30588
30589 spin_lock(pgt_lock);
30590 - ret = vmalloc_sync_one(page_address(page), address);
30591 + pgd = page_address(page);
30592 +#endif
30593 +
30594 + ret = vmalloc_sync_one(pgd, address);
30595 +
30596 +#ifndef CONFIG_PAX_PER_CPU_PGD
30597 spin_unlock(pgt_lock);
30598 +#endif
30599
30600 if (!ret)
30601 break;
30602 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30603 * an interrupt in the middle of a task switch..
30604 */
30605 pgd_paddr = read_cr3();
30606 +
30607 +#ifdef CONFIG_PAX_PER_CPU_PGD
30608 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
30609 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
30610 +#endif
30611 +
30612 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
30613 if (!pmd_k)
30614 return -1;
30615 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30616 * happen within a race in page table update. In the later
30617 * case just flush:
30618 */
30619 - pgd = pgd_offset(current->active_mm, address);
30620 +
30621 pgd_ref = pgd_offset_k(address);
30622 if (pgd_none(*pgd_ref))
30623 return -1;
30624
30625 +#ifdef CONFIG_PAX_PER_CPU_PGD
30626 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30627 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30628 + if (pgd_none(*pgd)) {
30629 + set_pgd(pgd, *pgd_ref);
30630 + arch_flush_lazy_mmu_mode();
30631 + } else {
30632 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30633 + }
30634 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30635 +#else
30636 + pgd = pgd_offset(current->active_mm, address);
30637 +#endif
30638 +
30639 if (pgd_none(*pgd)) {
30640 set_pgd(pgd, *pgd_ref);
30641 arch_flush_lazy_mmu_mode();
30642 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30643 static int is_errata100(struct pt_regs *regs, unsigned long address)
30644 {
30645 #ifdef CONFIG_X86_64
30646 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30647 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30648 return 1;
30649 #endif
30650 return 0;
30651 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30652 }
30653
30654 static const char nx_warning[] = KERN_CRIT
30655 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30656 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30657
30658 static void
30659 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30660 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30661 if (!oops_may_print())
30662 return;
30663
30664 - if (error_code & PF_INSTR) {
30665 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30666 unsigned int level;
30667
30668 pte_t *pte = lookup_address(address, &level);
30669
30670 if (pte && pte_present(*pte) && !pte_exec(*pte))
30671 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30672 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30673 }
30674
30675 +#ifdef CONFIG_PAX_KERNEXEC
30676 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30677 + if (current->signal->curr_ip)
30678 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30679 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30680 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30681 + else
30682 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30683 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30684 + }
30685 +#endif
30686 +
30687 printk(KERN_ALERT "BUG: unable to handle kernel ");
30688 if (address < PAGE_SIZE)
30689 printk(KERN_CONT "NULL pointer dereference");
30690 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30691 return;
30692 }
30693 #endif
30694 +
30695 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30696 + if (pax_is_fetch_fault(regs, error_code, address)) {
30697 +
30698 +#ifdef CONFIG_PAX_EMUTRAMP
30699 + switch (pax_handle_fetch_fault(regs)) {
30700 + case 2:
30701 + return;
30702 + }
30703 +#endif
30704 +
30705 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30706 + do_group_exit(SIGKILL);
30707 + }
30708 +#endif
30709 +
30710 /* Kernel addresses are always protection faults: */
30711 if (address >= TASK_SIZE)
30712 error_code |= PF_PROT;
30713 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30714 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30715 printk(KERN_ERR
30716 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30717 - tsk->comm, tsk->pid, address);
30718 + tsk->comm, task_pid_nr(tsk), address);
30719 code = BUS_MCEERR_AR;
30720 }
30721 #endif
30722 @@ -889,6 +1001,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30723 return 1;
30724 }
30725
30726 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30727 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30728 +{
30729 + pte_t *pte;
30730 + pmd_t *pmd;
30731 + spinlock_t *ptl;
30732 + unsigned char pte_mask;
30733 +
30734 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30735 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30736 + return 0;
30737 +
30738 + /* PaX: it's our fault, let's handle it if we can */
30739 +
30740 + /* PaX: take a look at read faults before acquiring any locks */
30741 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30742 + /* instruction fetch attempt from a protected page in user mode */
30743 + up_read(&mm->mmap_sem);
30744 +
30745 +#ifdef CONFIG_PAX_EMUTRAMP
30746 + switch (pax_handle_fetch_fault(regs)) {
30747 + case 2:
30748 + return 1;
30749 + }
30750 +#endif
30751 +
30752 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30753 + do_group_exit(SIGKILL);
30754 + }
30755 +
30756 + pmd = pax_get_pmd(mm, address);
30757 + if (unlikely(!pmd))
30758 + return 0;
30759 +
30760 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30761 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30762 + pte_unmap_unlock(pte, ptl);
30763 + return 0;
30764 + }
30765 +
30766 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30767 + /* write attempt to a protected page in user mode */
30768 + pte_unmap_unlock(pte, ptl);
30769 + return 0;
30770 + }
30771 +
30772 +#ifdef CONFIG_SMP
30773 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30774 +#else
30775 + if (likely(address > get_limit(regs->cs)))
30776 +#endif
30777 + {
30778 + set_pte(pte, pte_mkread(*pte));
30779 + __flush_tlb_one(address);
30780 + pte_unmap_unlock(pte, ptl);
30781 + up_read(&mm->mmap_sem);
30782 + return 1;
30783 + }
30784 +
30785 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30786 +
30787 + /*
30788 + * PaX: fill DTLB with user rights and retry
30789 + */
30790 + __asm__ __volatile__ (
30791 + "orb %2,(%1)\n"
30792 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30793 +/*
30794 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30795 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30796 + * page fault when examined during a TLB load attempt. this is true not only
30797 + * for PTEs holding a non-present entry but also present entries that will
30798 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30799 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30800 + * for our target pages since their PTEs are simply not in the TLBs at all.
30801 +
30802 + * the best thing in omitting it is that we gain around 15-20% speed in the
30803 + * fast path of the page fault handler and can get rid of tracing since we
30804 + * can no longer flush unintended entries.
30805 + */
30806 + "invlpg (%0)\n"
30807 +#endif
30808 + __copyuser_seg"testb $0,(%0)\n"
30809 + "xorb %3,(%1)\n"
30810 + :
30811 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30812 + : "memory", "cc");
30813 + pte_unmap_unlock(pte, ptl);
30814 + up_read(&mm->mmap_sem);
30815 + return 1;
30816 +}
30817 +#endif
30818 +
30819 /*
30820 * Handle a spurious fault caused by a stale TLB entry.
30821 *
30822 @@ -955,6 +1160,9 @@ int show_unhandled_signals = 1;
30823 static inline int
30824 access_error(unsigned long error_code, struct vm_area_struct *vma)
30825 {
30826 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30827 + return 1;
30828 +
30829 if (error_code & PF_WRITE) {
30830 /* write, present and write, not present: */
30831 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30832 @@ -983,7 +1191,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30833 if (error_code & PF_USER)
30834 return false;
30835
30836 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30837 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30838 return false;
30839
30840 return true;
30841 @@ -1010,6 +1218,22 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30842 /* Get the faulting address: */
30843 address = read_cr2();
30844
30845 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30846 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30847 + if (!search_exception_tables(regs->ip)) {
30848 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30849 + bad_area_nosemaphore(regs, error_code, address);
30850 + return;
30851 + }
30852 + if (address < pax_user_shadow_base) {
30853 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30854 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30855 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30856 + } else
30857 + address -= pax_user_shadow_base;
30858 + }
30859 +#endif
30860 +
30861 /*
30862 * Detect and handle instructions that would cause a page fault for
30863 * both a tracked kernel page and a userspace page.
30864 @@ -1069,7 +1293,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30865 * User-mode registers count as a user access even for any
30866 * potential system fault or CPU buglet:
30867 */
30868 - if (user_mode_vm(regs)) {
30869 + if (user_mode(regs)) {
30870 local_irq_enable();
30871 error_code |= PF_USER;
30872 flags |= FAULT_FLAG_USER;
30873 @@ -1135,6 +1359,11 @@ retry:
30874 might_sleep();
30875 }
30876
30877 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30878 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30879 + return;
30880 +#endif
30881 +
30882 vma = find_vma(mm, address);
30883 if (unlikely(!vma)) {
30884 bad_area(regs, error_code, address);
30885 @@ -1146,18 +1375,24 @@ retry:
30886 bad_area(regs, error_code, address);
30887 return;
30888 }
30889 - if (error_code & PF_USER) {
30890 - /*
30891 - * Accessing the stack below %sp is always a bug.
30892 - * The large cushion allows instructions like enter
30893 - * and pusha to work. ("enter $65535, $31" pushes
30894 - * 32 pointers and then decrements %sp by 65535.)
30895 - */
30896 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30897 - bad_area(regs, error_code, address);
30898 - return;
30899 - }
30900 + /*
30901 + * Accessing the stack below %sp is always a bug.
30902 + * The large cushion allows instructions like enter
30903 + * and pusha to work. ("enter $65535, $31" pushes
30904 + * 32 pointers and then decrements %sp by 65535.)
30905 + */
30906 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30907 + bad_area(regs, error_code, address);
30908 + return;
30909 }
30910 +
30911 +#ifdef CONFIG_PAX_SEGMEXEC
30912 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30913 + bad_area(regs, error_code, address);
30914 + return;
30915 + }
30916 +#endif
30917 +
30918 if (unlikely(expand_stack(vma, address))) {
30919 bad_area(regs, error_code, address);
30920 return;
30921 @@ -1231,3 +1466,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30922 __do_page_fault(regs, error_code);
30923 exception_exit(prev_state);
30924 }
30925 +
30926 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30927 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30928 +{
30929 + struct mm_struct *mm = current->mm;
30930 + unsigned long ip = regs->ip;
30931 +
30932 + if (v8086_mode(regs))
30933 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30934 +
30935 +#ifdef CONFIG_PAX_PAGEEXEC
30936 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30937 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30938 + return true;
30939 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30940 + return true;
30941 + return false;
30942 + }
30943 +#endif
30944 +
30945 +#ifdef CONFIG_PAX_SEGMEXEC
30946 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30947 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30948 + return true;
30949 + return false;
30950 + }
30951 +#endif
30952 +
30953 + return false;
30954 +}
30955 +#endif
30956 +
30957 +#ifdef CONFIG_PAX_EMUTRAMP
30958 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30959 +{
30960 + int err;
30961 +
30962 + do { /* PaX: libffi trampoline emulation */
30963 + unsigned char mov, jmp;
30964 + unsigned int addr1, addr2;
30965 +
30966 +#ifdef CONFIG_X86_64
30967 + if ((regs->ip + 9) >> 32)
30968 + break;
30969 +#endif
30970 +
30971 + err = get_user(mov, (unsigned char __user *)regs->ip);
30972 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30973 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30974 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30975 +
30976 + if (err)
30977 + break;
30978 +
30979 + if (mov == 0xB8 && jmp == 0xE9) {
30980 + regs->ax = addr1;
30981 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30982 + return 2;
30983 + }
30984 + } while (0);
30985 +
30986 + do { /* PaX: gcc trampoline emulation #1 */
30987 + unsigned char mov1, mov2;
30988 + unsigned short jmp;
30989 + unsigned int addr1, addr2;
30990 +
30991 +#ifdef CONFIG_X86_64
30992 + if ((regs->ip + 11) >> 32)
30993 + break;
30994 +#endif
30995 +
30996 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30997 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30998 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30999 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
31000 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
31001 +
31002 + if (err)
31003 + break;
31004 +
31005 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
31006 + regs->cx = addr1;
31007 + regs->ax = addr2;
31008 + regs->ip = addr2;
31009 + return 2;
31010 + }
31011 + } while (0);
31012 +
31013 + do { /* PaX: gcc trampoline emulation #2 */
31014 + unsigned char mov, jmp;
31015 + unsigned int addr1, addr2;
31016 +
31017 +#ifdef CONFIG_X86_64
31018 + if ((regs->ip + 9) >> 32)
31019 + break;
31020 +#endif
31021 +
31022 + err = get_user(mov, (unsigned char __user *)regs->ip);
31023 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
31024 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
31025 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
31026 +
31027 + if (err)
31028 + break;
31029 +
31030 + if (mov == 0xB9 && jmp == 0xE9) {
31031 + regs->cx = addr1;
31032 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
31033 + return 2;
31034 + }
31035 + } while (0);
31036 +
31037 + return 1; /* PaX in action */
31038 +}
31039 +
31040 +#ifdef CONFIG_X86_64
31041 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
31042 +{
31043 + int err;
31044 +
31045 + do { /* PaX: libffi trampoline emulation */
31046 + unsigned short mov1, mov2, jmp1;
31047 + unsigned char stcclc, jmp2;
31048 + unsigned long addr1, addr2;
31049 +
31050 + err = get_user(mov1, (unsigned short __user *)regs->ip);
31051 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
31052 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
31053 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
31054 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
31055 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
31056 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
31057 +
31058 + if (err)
31059 + break;
31060 +
31061 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
31062 + regs->r11 = addr1;
31063 + regs->r10 = addr2;
31064 + if (stcclc == 0xF8)
31065 + regs->flags &= ~X86_EFLAGS_CF;
31066 + else
31067 + regs->flags |= X86_EFLAGS_CF;
31068 + regs->ip = addr1;
31069 + return 2;
31070 + }
31071 + } while (0);
31072 +
31073 + do { /* PaX: gcc trampoline emulation #1 */
31074 + unsigned short mov1, mov2, jmp1;
31075 + unsigned char jmp2;
31076 + unsigned int addr1;
31077 + unsigned long addr2;
31078 +
31079 + err = get_user(mov1, (unsigned short __user *)regs->ip);
31080 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
31081 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
31082 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
31083 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
31084 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
31085 +
31086 + if (err)
31087 + break;
31088 +
31089 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
31090 + regs->r11 = addr1;
31091 + regs->r10 = addr2;
31092 + regs->ip = addr1;
31093 + return 2;
31094 + }
31095 + } while (0);
31096 +
31097 + do { /* PaX: gcc trampoline emulation #2 */
31098 + unsigned short mov1, mov2, jmp1;
31099 + unsigned char jmp2;
31100 + unsigned long addr1, addr2;
31101 +
31102 + err = get_user(mov1, (unsigned short __user *)regs->ip);
31103 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
31104 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
31105 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
31106 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
31107 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
31108 +
31109 + if (err)
31110 + break;
31111 +
31112 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
31113 + regs->r11 = addr1;
31114 + regs->r10 = addr2;
31115 + regs->ip = addr1;
31116 + return 2;
31117 + }
31118 + } while (0);
31119 +
31120 + return 1; /* PaX in action */
31121 +}
31122 +#endif
31123 +
31124 +/*
31125 + * PaX: decide what to do with offenders (regs->ip = fault address)
31126 + *
31127 + * returns 1 when task should be killed
31128 + * 2 when gcc trampoline was detected
31129 + */
31130 +static int pax_handle_fetch_fault(struct pt_regs *regs)
31131 +{
31132 + if (v8086_mode(regs))
31133 + return 1;
31134 +
31135 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
31136 + return 1;
31137 +
31138 +#ifdef CONFIG_X86_32
31139 + return pax_handle_fetch_fault_32(regs);
31140 +#else
31141 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
31142 + return pax_handle_fetch_fault_32(regs);
31143 + else
31144 + return pax_handle_fetch_fault_64(regs);
31145 +#endif
31146 +}
31147 +#endif
31148 +
31149 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31150 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
31151 +{
31152 + long i;
31153 +
31154 + printk(KERN_ERR "PAX: bytes at PC: ");
31155 + for (i = 0; i < 20; i++) {
31156 + unsigned char c;
31157 + if (get_user(c, (unsigned char __force_user *)pc+i))
31158 + printk(KERN_CONT "?? ");
31159 + else
31160 + printk(KERN_CONT "%02x ", c);
31161 + }
31162 + printk("\n");
31163 +
31164 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
31165 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
31166 + unsigned long c;
31167 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
31168 +#ifdef CONFIG_X86_32
31169 + printk(KERN_CONT "???????? ");
31170 +#else
31171 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
31172 + printk(KERN_CONT "???????? ???????? ");
31173 + else
31174 + printk(KERN_CONT "???????????????? ");
31175 +#endif
31176 + } else {
31177 +#ifdef CONFIG_X86_64
31178 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
31179 + printk(KERN_CONT "%08x ", (unsigned int)c);
31180 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
31181 + } else
31182 +#endif
31183 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
31184 + }
31185 + }
31186 + printk("\n");
31187 +}
31188 +#endif
31189 +
31190 +/**
31191 + * probe_kernel_write(): safely attempt to write to a location
31192 + * @dst: address to write to
31193 + * @src: pointer to the data that shall be written
31194 + * @size: size of the data chunk
31195 + *
31196 + * Safely write to address @dst from the buffer at @src. If a kernel fault
31197 + * happens, handle that and return -EFAULT.
31198 + */
31199 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
31200 +{
31201 + long ret;
31202 + mm_segment_t old_fs = get_fs();
31203 +
31204 + set_fs(KERNEL_DS);
31205 + pagefault_disable();
31206 + pax_open_kernel();
31207 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
31208 + pax_close_kernel();
31209 + pagefault_enable();
31210 + set_fs(old_fs);
31211 +
31212 + return ret ? -EFAULT : 0;
31213 +}
31214 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
31215 index 0596e8e..9de0b1c 100644
31216 --- a/arch/x86/mm/gup.c
31217 +++ b/arch/x86/mm/gup.c
31218 @@ -268,7 +268,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
31219 addr = start;
31220 len = (unsigned long) nr_pages << PAGE_SHIFT;
31221 end = start + len;
31222 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
31223 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
31224 (void __user *)start, len)))
31225 return 0;
31226
31227 @@ -344,6 +344,10 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
31228 goto slow_irqon;
31229 #endif
31230
31231 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
31232 + (void __user *)start, len)))
31233 + return 0;
31234 +
31235 /*
31236 * XXX: batch / limit 'nr', to avoid large irq off latency
31237 * needs some instrumenting to determine the common sizes used by
31238 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
31239 index 4500142..53a363c 100644
31240 --- a/arch/x86/mm/highmem_32.c
31241 +++ b/arch/x86/mm/highmem_32.c
31242 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
31243 idx = type + KM_TYPE_NR*smp_processor_id();
31244 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31245 BUG_ON(!pte_none(*(kmap_pte-idx)));
31246 +
31247 + pax_open_kernel();
31248 set_pte(kmap_pte-idx, mk_pte(page, prot));
31249 + pax_close_kernel();
31250 +
31251 arch_flush_lazy_mmu_mode();
31252
31253 return (void *)vaddr;
31254 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
31255 index 9d980d8..6bbfacb 100644
31256 --- a/arch/x86/mm/hugetlbpage.c
31257 +++ b/arch/x86/mm/hugetlbpage.c
31258 @@ -92,23 +92,30 @@ int pmd_huge_support(void)
31259 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
31260 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
31261 unsigned long addr, unsigned long len,
31262 - unsigned long pgoff, unsigned long flags)
31263 + unsigned long pgoff, unsigned long flags, unsigned long offset)
31264 {
31265 struct hstate *h = hstate_file(file);
31266 struct vm_unmapped_area_info info;
31267 -
31268 +
31269 info.flags = 0;
31270 info.length = len;
31271 info.low_limit = TASK_UNMAPPED_BASE;
31272 +
31273 +#ifdef CONFIG_PAX_RANDMMAP
31274 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
31275 + info.low_limit += current->mm->delta_mmap;
31276 +#endif
31277 +
31278 info.high_limit = TASK_SIZE;
31279 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
31280 info.align_offset = 0;
31281 + info.threadstack_offset = offset;
31282 return vm_unmapped_area(&info);
31283 }
31284
31285 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
31286 unsigned long addr0, unsigned long len,
31287 - unsigned long pgoff, unsigned long flags)
31288 + unsigned long pgoff, unsigned long flags, unsigned long offset)
31289 {
31290 struct hstate *h = hstate_file(file);
31291 struct vm_unmapped_area_info info;
31292 @@ -120,6 +127,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
31293 info.high_limit = current->mm->mmap_base;
31294 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
31295 info.align_offset = 0;
31296 + info.threadstack_offset = offset;
31297 addr = vm_unmapped_area(&info);
31298
31299 /*
31300 @@ -132,6 +140,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
31301 VM_BUG_ON(addr != -ENOMEM);
31302 info.flags = 0;
31303 info.low_limit = TASK_UNMAPPED_BASE;
31304 +
31305 +#ifdef CONFIG_PAX_RANDMMAP
31306 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
31307 + info.low_limit += current->mm->delta_mmap;
31308 +#endif
31309 +
31310 info.high_limit = TASK_SIZE;
31311 addr = vm_unmapped_area(&info);
31312 }
31313 @@ -146,10 +160,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
31314 struct hstate *h = hstate_file(file);
31315 struct mm_struct *mm = current->mm;
31316 struct vm_area_struct *vma;
31317 + unsigned long pax_task_size = TASK_SIZE;
31318 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
31319
31320 if (len & ~huge_page_mask(h))
31321 return -EINVAL;
31322 - if (len > TASK_SIZE)
31323 +
31324 +#ifdef CONFIG_PAX_SEGMEXEC
31325 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31326 + pax_task_size = SEGMEXEC_TASK_SIZE;
31327 +#endif
31328 +
31329 + pax_task_size -= PAGE_SIZE;
31330 +
31331 + if (len > pax_task_size)
31332 return -ENOMEM;
31333
31334 if (flags & MAP_FIXED) {
31335 @@ -158,19 +182,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
31336 return addr;
31337 }
31338
31339 +#ifdef CONFIG_PAX_RANDMMAP
31340 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31341 +#endif
31342 +
31343 if (addr) {
31344 addr = ALIGN(addr, huge_page_size(h));
31345 vma = find_vma(mm, addr);
31346 - if (TASK_SIZE - len >= addr &&
31347 - (!vma || addr + len <= vma->vm_start))
31348 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
31349 return addr;
31350 }
31351 if (mm->get_unmapped_area == arch_get_unmapped_area)
31352 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
31353 - pgoff, flags);
31354 + pgoff, flags, offset);
31355 else
31356 return hugetlb_get_unmapped_area_topdown(file, addr, len,
31357 - pgoff, flags);
31358 + pgoff, flags, offset);
31359 }
31360
31361 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
31362 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
31363 index 04664cd..dae6e5d 100644
31364 --- a/arch/x86/mm/init.c
31365 +++ b/arch/x86/mm/init.c
31366 @@ -4,6 +4,7 @@
31367 #include <linux/swap.h>
31368 #include <linux/memblock.h>
31369 #include <linux/bootmem.h> /* for max_low_pfn */
31370 +#include <linux/tboot.h>
31371
31372 #include <asm/cacheflush.h>
31373 #include <asm/e820.h>
31374 @@ -17,6 +18,8 @@
31375 #include <asm/proto.h>
31376 #include <asm/dma.h> /* for MAX_DMA_PFN */
31377 #include <asm/microcode.h>
31378 +#include <asm/desc.h>
31379 +#include <asm/bios_ebda.h>
31380
31381 #include "mm_internal.h"
31382
31383 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
31384 early_ioremap_page_table_range_init();
31385 #endif
31386
31387 +#ifdef CONFIG_PAX_PER_CPU_PGD
31388 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
31389 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
31390 + KERNEL_PGD_PTRS);
31391 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
31392 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
31393 + KERNEL_PGD_PTRS);
31394 + load_cr3(get_cpu_pgd(0, kernel));
31395 +#else
31396 load_cr3(swapper_pg_dir);
31397 +#endif
31398 +
31399 __flush_tlb_all();
31400
31401 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
31402 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
31403 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
31404 * mmio resources as well as potential bios/acpi data regions.
31405 */
31406 +
31407 +#ifdef CONFIG_GRKERNSEC_KMEM
31408 +static unsigned int ebda_start __read_only;
31409 +static unsigned int ebda_end __read_only;
31410 +#endif
31411 +
31412 int devmem_is_allowed(unsigned long pagenr)
31413 {
31414 - if (pagenr < 256)
31415 +#ifdef CONFIG_GRKERNSEC_KMEM
31416 + /* allow BDA */
31417 + if (!pagenr)
31418 return 1;
31419 + /* allow EBDA */
31420 + if (pagenr >= ebda_start && pagenr < ebda_end)
31421 + return 1;
31422 + /* if tboot is in use, allow access to its hardcoded serial log range */
31423 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
31424 + return 1;
31425 +#else
31426 + if (!pagenr)
31427 + return 1;
31428 +#ifdef CONFIG_VM86
31429 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
31430 + return 1;
31431 +#endif
31432 +#endif
31433 +
31434 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
31435 + return 1;
31436 +#ifdef CONFIG_GRKERNSEC_KMEM
31437 + /* throw out everything else below 1MB */
31438 + if (pagenr <= 256)
31439 + return 0;
31440 +#endif
31441 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
31442 return 0;
31443 if (!page_is_ram(pagenr))
31444 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
31445 #endif
31446 }
31447
31448 +#ifdef CONFIG_GRKERNSEC_KMEM
31449 +static inline void gr_init_ebda(void)
31450 +{
31451 + unsigned int ebda_addr;
31452 + unsigned int ebda_size = 0;
31453 +
31454 + ebda_addr = get_bios_ebda();
31455 + if (ebda_addr) {
31456 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
31457 + ebda_size <<= 10;
31458 + }
31459 + if (ebda_addr && ebda_size) {
31460 + ebda_start = ebda_addr >> PAGE_SHIFT;
31461 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
31462 + } else {
31463 + ebda_start = 0x9f000 >> PAGE_SHIFT;
31464 + ebda_end = 0xa0000 >> PAGE_SHIFT;
31465 + }
31466 +}
31467 +#else
31468 +static inline void gr_init_ebda(void) { }
31469 +#endif
31470 +
31471 void free_initmem(void)
31472 {
31473 +#ifdef CONFIG_PAX_KERNEXEC
31474 +#ifdef CONFIG_X86_32
31475 + /* PaX: limit KERNEL_CS to actual size */
31476 + unsigned long addr, limit;
31477 + struct desc_struct d;
31478 + int cpu;
31479 +#else
31480 + pgd_t *pgd;
31481 + pud_t *pud;
31482 + pmd_t *pmd;
31483 + unsigned long addr, end;
31484 +#endif
31485 +#endif
31486 +
31487 + gr_init_ebda();
31488 +
31489 +#ifdef CONFIG_PAX_KERNEXEC
31490 +#ifdef CONFIG_X86_32
31491 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
31492 + limit = (limit - 1UL) >> PAGE_SHIFT;
31493 +
31494 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
31495 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
31496 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
31497 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
31498 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
31499 + }
31500 +
31501 + /* PaX: make KERNEL_CS read-only */
31502 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
31503 + if (!paravirt_enabled())
31504 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
31505 +/*
31506 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
31507 + pgd = pgd_offset_k(addr);
31508 + pud = pud_offset(pgd, addr);
31509 + pmd = pmd_offset(pud, addr);
31510 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31511 + }
31512 +*/
31513 +#ifdef CONFIG_X86_PAE
31514 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
31515 +/*
31516 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
31517 + pgd = pgd_offset_k(addr);
31518 + pud = pud_offset(pgd, addr);
31519 + pmd = pmd_offset(pud, addr);
31520 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
31521 + }
31522 +*/
31523 +#endif
31524 +
31525 +#ifdef CONFIG_MODULES
31526 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
31527 +#endif
31528 +
31529 +#else
31530 + /* PaX: make kernel code/rodata read-only, rest non-executable */
31531 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
31532 + pgd = pgd_offset_k(addr);
31533 + pud = pud_offset(pgd, addr);
31534 + pmd = pmd_offset(pud, addr);
31535 + if (!pmd_present(*pmd))
31536 + continue;
31537 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
31538 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31539 + else
31540 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
31541 + }
31542 +
31543 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
31544 + end = addr + KERNEL_IMAGE_SIZE;
31545 + for (; addr < end; addr += PMD_SIZE) {
31546 + pgd = pgd_offset_k(addr);
31547 + pud = pud_offset(pgd, addr);
31548 + pmd = pmd_offset(pud, addr);
31549 + if (!pmd_present(*pmd))
31550 + continue;
31551 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
31552 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31553 + }
31554 +#endif
31555 +
31556 + flush_tlb_all();
31557 +#endif
31558 +
31559 free_init_pages("unused kernel",
31560 (unsigned long)(&__init_begin),
31561 (unsigned long)(&__init_end));
31562 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
31563 index 4287f1f..3b99c71 100644
31564 --- a/arch/x86/mm/init_32.c
31565 +++ b/arch/x86/mm/init_32.c
31566 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
31567 bool __read_mostly __vmalloc_start_set = false;
31568
31569 /*
31570 - * Creates a middle page table and puts a pointer to it in the
31571 - * given global directory entry. This only returns the gd entry
31572 - * in non-PAE compilation mode, since the middle layer is folded.
31573 - */
31574 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
31575 -{
31576 - pud_t *pud;
31577 - pmd_t *pmd_table;
31578 -
31579 -#ifdef CONFIG_X86_PAE
31580 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
31581 - pmd_table = (pmd_t *)alloc_low_page();
31582 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
31583 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
31584 - pud = pud_offset(pgd, 0);
31585 - BUG_ON(pmd_table != pmd_offset(pud, 0));
31586 -
31587 - return pmd_table;
31588 - }
31589 -#endif
31590 - pud = pud_offset(pgd, 0);
31591 - pmd_table = pmd_offset(pud, 0);
31592 -
31593 - return pmd_table;
31594 -}
31595 -
31596 -/*
31597 * Create a page table and place a pointer to it in a middle page
31598 * directory entry:
31599 */
31600 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
31601 pte_t *page_table = (pte_t *)alloc_low_page();
31602
31603 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
31604 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31605 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
31606 +#else
31607 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
31608 +#endif
31609 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
31610 }
31611
31612 return pte_offset_kernel(pmd, 0);
31613 }
31614
31615 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
31616 +{
31617 + pud_t *pud;
31618 + pmd_t *pmd_table;
31619 +
31620 + pud = pud_offset(pgd, 0);
31621 + pmd_table = pmd_offset(pud, 0);
31622 +
31623 + return pmd_table;
31624 +}
31625 +
31626 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31627 {
31628 int pgd_idx = pgd_index(vaddr);
31629 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31630 int pgd_idx, pmd_idx;
31631 unsigned long vaddr;
31632 pgd_t *pgd;
31633 + pud_t *pud;
31634 pmd_t *pmd;
31635 pte_t *pte = NULL;
31636 unsigned long count = page_table_range_init_count(start, end);
31637 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31638 pgd = pgd_base + pgd_idx;
31639
31640 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31641 - pmd = one_md_table_init(pgd);
31642 - pmd = pmd + pmd_index(vaddr);
31643 + pud = pud_offset(pgd, vaddr);
31644 + pmd = pmd_offset(pud, vaddr);
31645 +
31646 +#ifdef CONFIG_X86_PAE
31647 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31648 +#endif
31649 +
31650 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31651 pmd++, pmd_idx++) {
31652 pte = page_table_kmap_check(one_page_table_init(pmd),
31653 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31654 }
31655 }
31656
31657 -static inline int is_kernel_text(unsigned long addr)
31658 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31659 {
31660 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31661 - return 1;
31662 - return 0;
31663 + if ((start > ktla_ktva((unsigned long)_etext) ||
31664 + end <= ktla_ktva((unsigned long)_stext)) &&
31665 + (start > ktla_ktva((unsigned long)_einittext) ||
31666 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31667 +
31668 +#ifdef CONFIG_ACPI_SLEEP
31669 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31670 +#endif
31671 +
31672 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31673 + return 0;
31674 + return 1;
31675 }
31676
31677 /*
31678 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31679 unsigned long last_map_addr = end;
31680 unsigned long start_pfn, end_pfn;
31681 pgd_t *pgd_base = swapper_pg_dir;
31682 - int pgd_idx, pmd_idx, pte_ofs;
31683 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31684 unsigned long pfn;
31685 pgd_t *pgd;
31686 + pud_t *pud;
31687 pmd_t *pmd;
31688 pte_t *pte;
31689 unsigned pages_2m, pages_4k;
31690 @@ -291,8 +295,13 @@ repeat:
31691 pfn = start_pfn;
31692 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31693 pgd = pgd_base + pgd_idx;
31694 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31695 - pmd = one_md_table_init(pgd);
31696 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31697 + pud = pud_offset(pgd, 0);
31698 + pmd = pmd_offset(pud, 0);
31699 +
31700 +#ifdef CONFIG_X86_PAE
31701 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31702 +#endif
31703
31704 if (pfn >= end_pfn)
31705 continue;
31706 @@ -304,14 +313,13 @@ repeat:
31707 #endif
31708 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31709 pmd++, pmd_idx++) {
31710 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31711 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31712
31713 /*
31714 * Map with big pages if possible, otherwise
31715 * create normal page tables:
31716 */
31717 if (use_pse) {
31718 - unsigned int addr2;
31719 pgprot_t prot = PAGE_KERNEL_LARGE;
31720 /*
31721 * first pass will use the same initial
31722 @@ -322,11 +330,7 @@ repeat:
31723 _PAGE_PSE);
31724
31725 pfn &= PMD_MASK >> PAGE_SHIFT;
31726 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31727 - PAGE_OFFSET + PAGE_SIZE-1;
31728 -
31729 - if (is_kernel_text(addr) ||
31730 - is_kernel_text(addr2))
31731 + if (is_kernel_text(address, address + PMD_SIZE))
31732 prot = PAGE_KERNEL_LARGE_EXEC;
31733
31734 pages_2m++;
31735 @@ -343,7 +347,7 @@ repeat:
31736 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31737 pte += pte_ofs;
31738 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31739 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31740 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31741 pgprot_t prot = PAGE_KERNEL;
31742 /*
31743 * first pass will use the same initial
31744 @@ -351,7 +355,7 @@ repeat:
31745 */
31746 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31747
31748 - if (is_kernel_text(addr))
31749 + if (is_kernel_text(address, address + PAGE_SIZE))
31750 prot = PAGE_KERNEL_EXEC;
31751
31752 pages_4k++;
31753 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31754
31755 pud = pud_offset(pgd, va);
31756 pmd = pmd_offset(pud, va);
31757 - if (!pmd_present(*pmd))
31758 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31759 break;
31760
31761 /* should not be large page here */
31762 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31763
31764 static void __init pagetable_init(void)
31765 {
31766 - pgd_t *pgd_base = swapper_pg_dir;
31767 -
31768 - permanent_kmaps_init(pgd_base);
31769 + permanent_kmaps_init(swapper_pg_dir);
31770 }
31771
31772 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31773 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31774 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31775
31776 /* user-defined highmem size */
31777 @@ -787,10 +789,10 @@ void __init mem_init(void)
31778 ((unsigned long)&__init_end -
31779 (unsigned long)&__init_begin) >> 10,
31780
31781 - (unsigned long)&_etext, (unsigned long)&_edata,
31782 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31783 + (unsigned long)&_sdata, (unsigned long)&_edata,
31784 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31785
31786 - (unsigned long)&_text, (unsigned long)&_etext,
31787 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31788 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31789
31790 /*
31791 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31792 if (!kernel_set_to_readonly)
31793 return;
31794
31795 + start = ktla_ktva(start);
31796 pr_debug("Set kernel text: %lx - %lx for read write\n",
31797 start, start+size);
31798
31799 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31800 if (!kernel_set_to_readonly)
31801 return;
31802
31803 + start = ktla_ktva(start);
31804 pr_debug("Set kernel text: %lx - %lx for read only\n",
31805 start, start+size);
31806
31807 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31808 unsigned long start = PFN_ALIGN(_text);
31809 unsigned long size = PFN_ALIGN(_etext) - start;
31810
31811 + start = ktla_ktva(start);
31812 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31813 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31814 size >> 10);
31815 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31816 index 104d56a..62ba13f1 100644
31817 --- a/arch/x86/mm/init_64.c
31818 +++ b/arch/x86/mm/init_64.c
31819 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31820 * around without checking the pgd every time.
31821 */
31822
31823 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31824 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31825 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31826
31827 int force_personality32;
31828 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31829
31830 for (address = start; address <= end; address += PGDIR_SIZE) {
31831 const pgd_t *pgd_ref = pgd_offset_k(address);
31832 +
31833 +#ifdef CONFIG_PAX_PER_CPU_PGD
31834 + unsigned long cpu;
31835 +#else
31836 struct page *page;
31837 +#endif
31838
31839 if (pgd_none(*pgd_ref))
31840 continue;
31841
31842 spin_lock(&pgd_lock);
31843 +
31844 +#ifdef CONFIG_PAX_PER_CPU_PGD
31845 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31846 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31847 +
31848 + if (pgd_none(*pgd))
31849 + set_pgd(pgd, *pgd_ref);
31850 + else
31851 + BUG_ON(pgd_page_vaddr(*pgd)
31852 + != pgd_page_vaddr(*pgd_ref));
31853 + pgd = pgd_offset_cpu(cpu, kernel, address);
31854 +#else
31855 list_for_each_entry(page, &pgd_list, lru) {
31856 pgd_t *pgd;
31857 spinlock_t *pgt_lock;
31858 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31859 /* the pgt_lock only for Xen */
31860 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31861 spin_lock(pgt_lock);
31862 +#endif
31863
31864 if (pgd_none(*pgd))
31865 set_pgd(pgd, *pgd_ref);
31866 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31867 BUG_ON(pgd_page_vaddr(*pgd)
31868 != pgd_page_vaddr(*pgd_ref));
31869
31870 +#ifndef CONFIG_PAX_PER_CPU_PGD
31871 spin_unlock(pgt_lock);
31872 +#endif
31873 +
31874 }
31875 spin_unlock(&pgd_lock);
31876 }
31877 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31878 {
31879 if (pgd_none(*pgd)) {
31880 pud_t *pud = (pud_t *)spp_getpage();
31881 - pgd_populate(&init_mm, pgd, pud);
31882 + pgd_populate_kernel(&init_mm, pgd, pud);
31883 if (pud != pud_offset(pgd, 0))
31884 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31885 pud, pud_offset(pgd, 0));
31886 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31887 {
31888 if (pud_none(*pud)) {
31889 pmd_t *pmd = (pmd_t *) spp_getpage();
31890 - pud_populate(&init_mm, pud, pmd);
31891 + pud_populate_kernel(&init_mm, pud, pmd);
31892 if (pmd != pmd_offset(pud, 0))
31893 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31894 pmd, pmd_offset(pud, 0));
31895 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31896 pmd = fill_pmd(pud, vaddr);
31897 pte = fill_pte(pmd, vaddr);
31898
31899 + pax_open_kernel();
31900 set_pte(pte, new_pte);
31901 + pax_close_kernel();
31902
31903 /*
31904 * It's enough to flush this one mapping.
31905 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31906 pgd = pgd_offset_k((unsigned long)__va(phys));
31907 if (pgd_none(*pgd)) {
31908 pud = (pud_t *) spp_getpage();
31909 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31910 - _PAGE_USER));
31911 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31912 }
31913 pud = pud_offset(pgd, (unsigned long)__va(phys));
31914 if (pud_none(*pud)) {
31915 pmd = (pmd_t *) spp_getpage();
31916 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31917 - _PAGE_USER));
31918 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31919 }
31920 pmd = pmd_offset(pud, phys);
31921 BUG_ON(!pmd_none(*pmd));
31922 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31923 prot);
31924
31925 spin_lock(&init_mm.page_table_lock);
31926 - pud_populate(&init_mm, pud, pmd);
31927 + pud_populate_kernel(&init_mm, pud, pmd);
31928 spin_unlock(&init_mm.page_table_lock);
31929 }
31930 __flush_tlb_all();
31931 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31932 page_size_mask);
31933
31934 spin_lock(&init_mm.page_table_lock);
31935 - pgd_populate(&init_mm, pgd, pud);
31936 + pgd_populate_kernel(&init_mm, pgd, pud);
31937 spin_unlock(&init_mm.page_table_lock);
31938 pgd_changed = true;
31939 }
31940 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31941 static struct vm_area_struct gate_vma = {
31942 .vm_start = VSYSCALL_START,
31943 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31944 - .vm_page_prot = PAGE_READONLY_EXEC,
31945 - .vm_flags = VM_READ | VM_EXEC
31946 + .vm_page_prot = PAGE_READONLY,
31947 + .vm_flags = VM_READ
31948 };
31949
31950 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31951 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31952
31953 const char *arch_vma_name(struct vm_area_struct *vma)
31954 {
31955 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31956 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31957 return "[vdso]";
31958 if (vma == &gate_vma)
31959 return "[vsyscall]";
31960 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31961 index 7b179b4..6bd17777 100644
31962 --- a/arch/x86/mm/iomap_32.c
31963 +++ b/arch/x86/mm/iomap_32.c
31964 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31965 type = kmap_atomic_idx_push();
31966 idx = type + KM_TYPE_NR * smp_processor_id();
31967 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31968 +
31969 + pax_open_kernel();
31970 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31971 + pax_close_kernel();
31972 +
31973 arch_flush_lazy_mmu_mode();
31974
31975 return (void *)vaddr;
31976 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31977 index 799580c..72f9fe0 100644
31978 --- a/arch/x86/mm/ioremap.c
31979 +++ b/arch/x86/mm/ioremap.c
31980 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31981 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31982 int is_ram = page_is_ram(pfn);
31983
31984 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31985 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31986 return NULL;
31987 WARN_ON_ONCE(is_ram);
31988 }
31989 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31990 *
31991 * Caller must ensure there is only one unmapping for the same pointer.
31992 */
31993 -void iounmap(volatile void __iomem *addr)
31994 +void iounmap(const volatile void __iomem *addr)
31995 {
31996 struct vm_struct *p, *o;
31997
31998 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31999
32000 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
32001 if (page_is_ram(start >> PAGE_SHIFT))
32002 +#ifdef CONFIG_HIGHMEM
32003 + if ((start >> PAGE_SHIFT) < max_low_pfn)
32004 +#endif
32005 return __va(phys);
32006
32007 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
32008 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
32009 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
32010 {
32011 if (page_is_ram(phys >> PAGE_SHIFT))
32012 +#ifdef CONFIG_HIGHMEM
32013 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
32014 +#endif
32015 return;
32016
32017 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
32018 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
32019 early_param("early_ioremap_debug", early_ioremap_debug_setup);
32020
32021 static __initdata int after_paging_init;
32022 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
32023 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
32024
32025 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
32026 {
32027 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
32028 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
32029
32030 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
32031 - memset(bm_pte, 0, sizeof(bm_pte));
32032 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
32033 + pmd_populate_user(&init_mm, pmd, bm_pte);
32034
32035 /*
32036 * The boot-ioremap range spans multiple pmds, for which
32037 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
32038 index d87dd6d..bf3fa66 100644
32039 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
32040 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
32041 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
32042 * memory (e.g. tracked pages)? For now, we need this to avoid
32043 * invoking kmemcheck for PnP BIOS calls.
32044 */
32045 - if (regs->flags & X86_VM_MASK)
32046 + if (v8086_mode(regs))
32047 return false;
32048 - if (regs->cs != __KERNEL_CS)
32049 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
32050 return false;
32051
32052 pte = kmemcheck_pte_lookup(address);
32053 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
32054 index 25e7e13..1964579 100644
32055 --- a/arch/x86/mm/mmap.c
32056 +++ b/arch/x86/mm/mmap.c
32057 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
32058 * Leave an at least ~128 MB hole with possible stack randomization.
32059 */
32060 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
32061 -#define MAX_GAP (TASK_SIZE/6*5)
32062 +#define MAX_GAP (pax_task_size/6*5)
32063
32064 static int mmap_is_legacy(void)
32065 {
32066 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
32067 return rnd << PAGE_SHIFT;
32068 }
32069
32070 -static unsigned long mmap_base(void)
32071 +static unsigned long mmap_base(struct mm_struct *mm)
32072 {
32073 unsigned long gap = rlimit(RLIMIT_STACK);
32074 + unsigned long pax_task_size = TASK_SIZE;
32075 +
32076 +#ifdef CONFIG_PAX_SEGMEXEC
32077 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
32078 + pax_task_size = SEGMEXEC_TASK_SIZE;
32079 +#endif
32080
32081 if (gap < MIN_GAP)
32082 gap = MIN_GAP;
32083 else if (gap > MAX_GAP)
32084 gap = MAX_GAP;
32085
32086 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
32087 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
32088 }
32089
32090 /*
32091 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
32092 * does, but not when emulating X86_32
32093 */
32094 -static unsigned long mmap_legacy_base(void)
32095 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
32096 {
32097 - if (mmap_is_ia32())
32098 + if (mmap_is_ia32()) {
32099 +
32100 +#ifdef CONFIG_PAX_SEGMEXEC
32101 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
32102 + return SEGMEXEC_TASK_UNMAPPED_BASE;
32103 + else
32104 +#endif
32105 +
32106 return TASK_UNMAPPED_BASE;
32107 - else
32108 + } else
32109 return TASK_UNMAPPED_BASE + mmap_rnd();
32110 }
32111
32112 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
32113 */
32114 void arch_pick_mmap_layout(struct mm_struct *mm)
32115 {
32116 - mm->mmap_legacy_base = mmap_legacy_base();
32117 - mm->mmap_base = mmap_base();
32118 + mm->mmap_legacy_base = mmap_legacy_base(mm);
32119 + mm->mmap_base = mmap_base(mm);
32120 +
32121 +#ifdef CONFIG_PAX_RANDMMAP
32122 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
32123 + mm->mmap_legacy_base += mm->delta_mmap;
32124 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
32125 + }
32126 +#endif
32127
32128 if (mmap_is_legacy()) {
32129 mm->mmap_base = mm->mmap_legacy_base;
32130 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
32131 index 0057a7a..95c7edd 100644
32132 --- a/arch/x86/mm/mmio-mod.c
32133 +++ b/arch/x86/mm/mmio-mod.c
32134 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
32135 break;
32136 default:
32137 {
32138 - unsigned char *ip = (unsigned char *)instptr;
32139 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
32140 my_trace->opcode = MMIO_UNKNOWN_OP;
32141 my_trace->width = 0;
32142 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
32143 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
32144 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
32145 void __iomem *addr)
32146 {
32147 - static atomic_t next_id;
32148 + static atomic_unchecked_t next_id;
32149 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
32150 /* These are page-unaligned. */
32151 struct mmiotrace_map map = {
32152 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
32153 .private = trace
32154 },
32155 .phys = offset,
32156 - .id = atomic_inc_return(&next_id)
32157 + .id = atomic_inc_return_unchecked(&next_id)
32158 };
32159 map.map_id = trace->id;
32160
32161 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
32162 ioremap_trace_core(offset, size, addr);
32163 }
32164
32165 -static void iounmap_trace_core(volatile void __iomem *addr)
32166 +static void iounmap_trace_core(const volatile void __iomem *addr)
32167 {
32168 struct mmiotrace_map map = {
32169 .phys = 0,
32170 @@ -328,7 +328,7 @@ not_enabled:
32171 }
32172 }
32173
32174 -void mmiotrace_iounmap(volatile void __iomem *addr)
32175 +void mmiotrace_iounmap(const volatile void __iomem *addr)
32176 {
32177 might_sleep();
32178 if (is_enabled()) /* recheck and proper locking in *_core() */
32179 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
32180 index 8bf93ba..dbcd670 100644
32181 --- a/arch/x86/mm/numa.c
32182 +++ b/arch/x86/mm/numa.c
32183 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
32184 return true;
32185 }
32186
32187 -static int __init numa_register_memblks(struct numa_meminfo *mi)
32188 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
32189 {
32190 unsigned long uninitialized_var(pfn_align);
32191 int i, nid;
32192 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
32193 index d0b1773..4c3327c 100644
32194 --- a/arch/x86/mm/pageattr-test.c
32195 +++ b/arch/x86/mm/pageattr-test.c
32196 @@ -36,7 +36,7 @@ enum {
32197
32198 static int pte_testbit(pte_t pte)
32199 {
32200 - return pte_flags(pte) & _PAGE_UNUSED1;
32201 + return pte_flags(pte) & _PAGE_CPA_TEST;
32202 }
32203
32204 struct split_state {
32205 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
32206 index bb32480..75f2f5e 100644
32207 --- a/arch/x86/mm/pageattr.c
32208 +++ b/arch/x86/mm/pageattr.c
32209 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32210 */
32211 #ifdef CONFIG_PCI_BIOS
32212 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
32213 - pgprot_val(forbidden) |= _PAGE_NX;
32214 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
32215 #endif
32216
32217 /*
32218 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32219 * Does not cover __inittext since that is gone later on. On
32220 * 64bit we do not enforce !NX on the low mapping
32221 */
32222 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
32223 - pgprot_val(forbidden) |= _PAGE_NX;
32224 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
32225 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
32226
32227 +#ifdef CONFIG_DEBUG_RODATA
32228 /*
32229 * The .rodata section needs to be read-only. Using the pfn
32230 * catches all aliases.
32231 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32232 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
32233 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
32234 pgprot_val(forbidden) |= _PAGE_RW;
32235 +#endif
32236
32237 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
32238 /*
32239 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32240 }
32241 #endif
32242
32243 +#ifdef CONFIG_PAX_KERNEXEC
32244 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
32245 + pgprot_val(forbidden) |= _PAGE_RW;
32246 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
32247 + }
32248 +#endif
32249 +
32250 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
32251
32252 return prot;
32253 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
32254 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
32255 {
32256 /* change init_mm */
32257 + pax_open_kernel();
32258 set_pte_atomic(kpte, pte);
32259 +
32260 #ifdef CONFIG_X86_32
32261 if (!SHARED_KERNEL_PMD) {
32262 +
32263 +#ifdef CONFIG_PAX_PER_CPU_PGD
32264 + unsigned long cpu;
32265 +#else
32266 struct page *page;
32267 +#endif
32268
32269 +#ifdef CONFIG_PAX_PER_CPU_PGD
32270 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
32271 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
32272 +#else
32273 list_for_each_entry(page, &pgd_list, lru) {
32274 - pgd_t *pgd;
32275 + pgd_t *pgd = (pgd_t *)page_address(page);
32276 +#endif
32277 +
32278 pud_t *pud;
32279 pmd_t *pmd;
32280
32281 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
32282 + pgd += pgd_index(address);
32283 pud = pud_offset(pgd, address);
32284 pmd = pmd_offset(pud, address);
32285 set_pte_atomic((pte_t *)pmd, pte);
32286 }
32287 }
32288 #endif
32289 + pax_close_kernel();
32290 }
32291
32292 static int
32293 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
32294 index 6574388..87e9bef 100644
32295 --- a/arch/x86/mm/pat.c
32296 +++ b/arch/x86/mm/pat.c
32297 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
32298
32299 if (!entry) {
32300 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
32301 - current->comm, current->pid, start, end - 1);
32302 + current->comm, task_pid_nr(current), start, end - 1);
32303 return -EINVAL;
32304 }
32305
32306 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
32307
32308 while (cursor < to) {
32309 if (!devmem_is_allowed(pfn)) {
32310 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
32311 - current->comm, from, to - 1);
32312 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
32313 + current->comm, from, to - 1, cursor);
32314 return 0;
32315 }
32316 cursor += PAGE_SIZE;
32317 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
32318 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
32319 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
32320 "for [mem %#010Lx-%#010Lx]\n",
32321 - current->comm, current->pid,
32322 + current->comm, task_pid_nr(current),
32323 cattr_name(flags),
32324 base, (unsigned long long)(base + size-1));
32325 return -EINVAL;
32326 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
32327 flags = lookup_memtype(paddr);
32328 if (want_flags != flags) {
32329 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
32330 - current->comm, current->pid,
32331 + current->comm, task_pid_nr(current),
32332 cattr_name(want_flags),
32333 (unsigned long long)paddr,
32334 (unsigned long long)(paddr + size - 1),
32335 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
32336 free_memtype(paddr, paddr + size);
32337 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
32338 " for [mem %#010Lx-%#010Lx], got %s\n",
32339 - current->comm, current->pid,
32340 + current->comm, task_pid_nr(current),
32341 cattr_name(want_flags),
32342 (unsigned long long)paddr,
32343 (unsigned long long)(paddr + size - 1),
32344 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
32345 index 415f6c4..d319983 100644
32346 --- a/arch/x86/mm/pat_rbtree.c
32347 +++ b/arch/x86/mm/pat_rbtree.c
32348 @@ -160,7 +160,7 @@ success:
32349
32350 failure:
32351 printk(KERN_INFO "%s:%d conflicting memory types "
32352 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
32353 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
32354 end, cattr_name(found_type), cattr_name(match->type));
32355 return -EBUSY;
32356 }
32357 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
32358 index 9f0614d..92ae64a 100644
32359 --- a/arch/x86/mm/pf_in.c
32360 +++ b/arch/x86/mm/pf_in.c
32361 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
32362 int i;
32363 enum reason_type rv = OTHERS;
32364
32365 - p = (unsigned char *)ins_addr;
32366 + p = (unsigned char *)ktla_ktva(ins_addr);
32367 p += skip_prefix(p, &prf);
32368 p += get_opcode(p, &opcode);
32369
32370 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
32371 struct prefix_bits prf;
32372 int i;
32373
32374 - p = (unsigned char *)ins_addr;
32375 + p = (unsigned char *)ktla_ktva(ins_addr);
32376 p += skip_prefix(p, &prf);
32377 p += get_opcode(p, &opcode);
32378
32379 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
32380 struct prefix_bits prf;
32381 int i;
32382
32383 - p = (unsigned char *)ins_addr;
32384 + p = (unsigned char *)ktla_ktva(ins_addr);
32385 p += skip_prefix(p, &prf);
32386 p += get_opcode(p, &opcode);
32387
32388 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
32389 struct prefix_bits prf;
32390 int i;
32391
32392 - p = (unsigned char *)ins_addr;
32393 + p = (unsigned char *)ktla_ktva(ins_addr);
32394 p += skip_prefix(p, &prf);
32395 p += get_opcode(p, &opcode);
32396 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
32397 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
32398 struct prefix_bits prf;
32399 int i;
32400
32401 - p = (unsigned char *)ins_addr;
32402 + p = (unsigned char *)ktla_ktva(ins_addr);
32403 p += skip_prefix(p, &prf);
32404 p += get_opcode(p, &opcode);
32405 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
32406 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
32407 index dfa537a..fd45c64 100644
32408 --- a/arch/x86/mm/pgtable.c
32409 +++ b/arch/x86/mm/pgtable.c
32410 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
32411 list_del(&page->lru);
32412 }
32413
32414 -#define UNSHARED_PTRS_PER_PGD \
32415 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
32416 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32417 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
32418
32419 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
32420 +{
32421 + unsigned int count = USER_PGD_PTRS;
32422
32423 + if (!pax_user_shadow_base)
32424 + return;
32425 +
32426 + while (count--)
32427 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
32428 +}
32429 +#endif
32430 +
32431 +#ifdef CONFIG_PAX_PER_CPU_PGD
32432 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
32433 +{
32434 + unsigned int count = USER_PGD_PTRS;
32435 +
32436 + while (count--) {
32437 + pgd_t pgd;
32438 +
32439 +#ifdef CONFIG_X86_64
32440 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
32441 +#else
32442 + pgd = *src++;
32443 +#endif
32444 +
32445 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32446 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
32447 +#endif
32448 +
32449 + *dst++ = pgd;
32450 + }
32451 +
32452 +}
32453 +#endif
32454 +
32455 +#ifdef CONFIG_X86_64
32456 +#define pxd_t pud_t
32457 +#define pyd_t pgd_t
32458 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
32459 +#define pxd_free(mm, pud) pud_free((mm), (pud))
32460 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
32461 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
32462 +#define PYD_SIZE PGDIR_SIZE
32463 +#else
32464 +#define pxd_t pmd_t
32465 +#define pyd_t pud_t
32466 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
32467 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
32468 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
32469 +#define pyd_offset(mm, address) pud_offset((mm), (address))
32470 +#define PYD_SIZE PUD_SIZE
32471 +#endif
32472 +
32473 +#ifdef CONFIG_PAX_PER_CPU_PGD
32474 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
32475 +static inline void pgd_dtor(pgd_t *pgd) {}
32476 +#else
32477 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
32478 {
32479 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
32480 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
32481 pgd_list_del(pgd);
32482 spin_unlock(&pgd_lock);
32483 }
32484 +#endif
32485
32486 /*
32487 * List of all pgd's needed for non-PAE so it can invalidate entries
32488 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
32489 * -- nyc
32490 */
32491
32492 -#ifdef CONFIG_X86_PAE
32493 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
32494 /*
32495 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
32496 * updating the top-level pagetable entries to guarantee the
32497 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
32498 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
32499 * and initialize the kernel pmds here.
32500 */
32501 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
32502 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
32503
32504 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
32505 {
32506 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
32507 */
32508 flush_tlb_mm(mm);
32509 }
32510 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
32511 +#define PREALLOCATED_PXDS USER_PGD_PTRS
32512 #else /* !CONFIG_X86_PAE */
32513
32514 /* No need to prepopulate any pagetable entries in non-PAE modes. */
32515 -#define PREALLOCATED_PMDS 0
32516 +#define PREALLOCATED_PXDS 0
32517
32518 #endif /* CONFIG_X86_PAE */
32519
32520 -static void free_pmds(pmd_t *pmds[])
32521 +static void free_pxds(pxd_t *pxds[])
32522 {
32523 int i;
32524
32525 - for(i = 0; i < PREALLOCATED_PMDS; i++)
32526 - if (pmds[i])
32527 - free_page((unsigned long)pmds[i]);
32528 + for(i = 0; i < PREALLOCATED_PXDS; i++)
32529 + if (pxds[i])
32530 + free_page((unsigned long)pxds[i]);
32531 }
32532
32533 -static int preallocate_pmds(pmd_t *pmds[])
32534 +static int preallocate_pxds(pxd_t *pxds[])
32535 {
32536 int i;
32537 bool failed = false;
32538
32539 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
32540 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
32541 - if (pmd == NULL)
32542 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
32543 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
32544 + if (pxd == NULL)
32545 failed = true;
32546 - pmds[i] = pmd;
32547 + pxds[i] = pxd;
32548 }
32549
32550 if (failed) {
32551 - free_pmds(pmds);
32552 + free_pxds(pxds);
32553 return -ENOMEM;
32554 }
32555
32556 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
32557 * preallocate which never got a corresponding vma will need to be
32558 * freed manually.
32559 */
32560 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
32561 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
32562 {
32563 int i;
32564
32565 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
32566 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
32567 pgd_t pgd = pgdp[i];
32568
32569 if (pgd_val(pgd) != 0) {
32570 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
32571 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
32572
32573 - pgdp[i] = native_make_pgd(0);
32574 + set_pgd(pgdp + i, native_make_pgd(0));
32575
32576 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
32577 - pmd_free(mm, pmd);
32578 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
32579 + pxd_free(mm, pxd);
32580 }
32581 }
32582 }
32583
32584 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
32585 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
32586 {
32587 - pud_t *pud;
32588 + pyd_t *pyd;
32589 int i;
32590
32591 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
32592 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
32593 return;
32594
32595 - pud = pud_offset(pgd, 0);
32596 -
32597 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
32598 - pmd_t *pmd = pmds[i];
32599 +#ifdef CONFIG_X86_64
32600 + pyd = pyd_offset(mm, 0L);
32601 +#else
32602 + pyd = pyd_offset(pgd, 0L);
32603 +#endif
32604
32605 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
32606 + pxd_t *pxd = pxds[i];
32607 if (i >= KERNEL_PGD_BOUNDARY)
32608 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32609 - sizeof(pmd_t) * PTRS_PER_PMD);
32610 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32611 + sizeof(pxd_t) * PTRS_PER_PMD);
32612
32613 - pud_populate(mm, pud, pmd);
32614 + pyd_populate(mm, pyd, pxd);
32615 }
32616 }
32617
32618 pgd_t *pgd_alloc(struct mm_struct *mm)
32619 {
32620 pgd_t *pgd;
32621 - pmd_t *pmds[PREALLOCATED_PMDS];
32622 + pxd_t *pxds[PREALLOCATED_PXDS];
32623
32624 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32625
32626 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32627
32628 mm->pgd = pgd;
32629
32630 - if (preallocate_pmds(pmds) != 0)
32631 + if (preallocate_pxds(pxds) != 0)
32632 goto out_free_pgd;
32633
32634 if (paravirt_pgd_alloc(mm) != 0)
32635 - goto out_free_pmds;
32636 + goto out_free_pxds;
32637
32638 /*
32639 * Make sure that pre-populating the pmds is atomic with
32640 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32641 spin_lock(&pgd_lock);
32642
32643 pgd_ctor(mm, pgd);
32644 - pgd_prepopulate_pmd(mm, pgd, pmds);
32645 + pgd_prepopulate_pxd(mm, pgd, pxds);
32646
32647 spin_unlock(&pgd_lock);
32648
32649 return pgd;
32650
32651 -out_free_pmds:
32652 - free_pmds(pmds);
32653 +out_free_pxds:
32654 + free_pxds(pxds);
32655 out_free_pgd:
32656 free_page((unsigned long)pgd);
32657 out:
32658 @@ -300,7 +363,7 @@ out:
32659
32660 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32661 {
32662 - pgd_mop_up_pmds(mm, pgd);
32663 + pgd_mop_up_pxds(mm, pgd);
32664 pgd_dtor(pgd);
32665 paravirt_pgd_free(mm, pgd);
32666 free_page((unsigned long)pgd);
32667 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32668 index a69bcb8..19068ab 100644
32669 --- a/arch/x86/mm/pgtable_32.c
32670 +++ b/arch/x86/mm/pgtable_32.c
32671 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32672 return;
32673 }
32674 pte = pte_offset_kernel(pmd, vaddr);
32675 +
32676 + pax_open_kernel();
32677 if (pte_val(pteval))
32678 set_pte_at(&init_mm, vaddr, pte, pteval);
32679 else
32680 pte_clear(&init_mm, vaddr, pte);
32681 + pax_close_kernel();
32682
32683 /*
32684 * It's enough to flush this one mapping.
32685 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32686 index e666cbb..61788c45 100644
32687 --- a/arch/x86/mm/physaddr.c
32688 +++ b/arch/x86/mm/physaddr.c
32689 @@ -10,7 +10,7 @@
32690 #ifdef CONFIG_X86_64
32691
32692 #ifdef CONFIG_DEBUG_VIRTUAL
32693 -unsigned long __phys_addr(unsigned long x)
32694 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32695 {
32696 unsigned long y = x - __START_KERNEL_map;
32697
32698 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32699 #else
32700
32701 #ifdef CONFIG_DEBUG_VIRTUAL
32702 -unsigned long __phys_addr(unsigned long x)
32703 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32704 {
32705 unsigned long phys_addr = x - PAGE_OFFSET;
32706 /* VMALLOC_* aren't constants */
32707 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32708 index 90555bf..f5f1828 100644
32709 --- a/arch/x86/mm/setup_nx.c
32710 +++ b/arch/x86/mm/setup_nx.c
32711 @@ -5,8 +5,10 @@
32712 #include <asm/pgtable.h>
32713 #include <asm/proto.h>
32714
32715 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32716 static int disable_nx;
32717
32718 +#ifndef CONFIG_PAX_PAGEEXEC
32719 /*
32720 * noexec = on|off
32721 *
32722 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32723 return 0;
32724 }
32725 early_param("noexec", noexec_setup);
32726 +#endif
32727 +
32728 +#endif
32729
32730 void x86_configure_nx(void)
32731 {
32732 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32733 if (cpu_has_nx && !disable_nx)
32734 __supported_pte_mask |= _PAGE_NX;
32735 else
32736 +#endif
32737 __supported_pte_mask &= ~_PAGE_NX;
32738 }
32739
32740 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32741 index ae699b3..f1b2ad2 100644
32742 --- a/arch/x86/mm/tlb.c
32743 +++ b/arch/x86/mm/tlb.c
32744 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32745 BUG();
32746 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32747 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32748 +
32749 +#ifndef CONFIG_PAX_PER_CPU_PGD
32750 load_cr3(swapper_pg_dir);
32751 +#endif
32752 +
32753 }
32754 }
32755 EXPORT_SYMBOL_GPL(leave_mm);
32756 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32757 new file mode 100644
32758 index 0000000..dace51c
32759 --- /dev/null
32760 +++ b/arch/x86/mm/uderef_64.c
32761 @@ -0,0 +1,37 @@
32762 +#include <linux/mm.h>
32763 +#include <asm/pgtable.h>
32764 +#include <asm/uaccess.h>
32765 +
32766 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32767 +/* PaX: due to the special call convention these functions must
32768 + * - remain leaf functions under all configurations,
32769 + * - never be called directly, only dereferenced from the wrappers.
32770 + */
32771 +void __pax_open_userland(void)
32772 +{
32773 + unsigned int cpu;
32774 +
32775 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32776 + return;
32777 +
32778 + cpu = raw_get_cpu();
32779 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32780 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32781 + raw_put_cpu_no_resched();
32782 +}
32783 +EXPORT_SYMBOL(__pax_open_userland);
32784 +
32785 +void __pax_close_userland(void)
32786 +{
32787 + unsigned int cpu;
32788 +
32789 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32790 + return;
32791 +
32792 + cpu = raw_get_cpu();
32793 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32794 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32795 + raw_put_cpu_no_resched();
32796 +}
32797 +EXPORT_SYMBOL(__pax_close_userland);
32798 +#endif
32799 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32800 index 877b9a1..a8ecf42 100644
32801 --- a/arch/x86/net/bpf_jit.S
32802 +++ b/arch/x86/net/bpf_jit.S
32803 @@ -9,6 +9,7 @@
32804 */
32805 #include <linux/linkage.h>
32806 #include <asm/dwarf2.h>
32807 +#include <asm/alternative-asm.h>
32808
32809 /*
32810 * Calling convention :
32811 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32812 jle bpf_slow_path_word
32813 mov (SKBDATA,%rsi),%eax
32814 bswap %eax /* ntohl() */
32815 + pax_force_retaddr
32816 ret
32817
32818 sk_load_half:
32819 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32820 jle bpf_slow_path_half
32821 movzwl (SKBDATA,%rsi),%eax
32822 rol $8,%ax # ntohs()
32823 + pax_force_retaddr
32824 ret
32825
32826 sk_load_byte:
32827 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32828 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32829 jle bpf_slow_path_byte
32830 movzbl (SKBDATA,%rsi),%eax
32831 + pax_force_retaddr
32832 ret
32833
32834 /**
32835 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32836 movzbl (SKBDATA,%rsi),%ebx
32837 and $15,%bl
32838 shl $2,%bl
32839 + pax_force_retaddr
32840 ret
32841
32842 /* rsi contains offset and can be scratched */
32843 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32844 js bpf_error
32845 mov -12(%rbp),%eax
32846 bswap %eax
32847 + pax_force_retaddr
32848 ret
32849
32850 bpf_slow_path_half:
32851 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32852 mov -12(%rbp),%ax
32853 rol $8,%ax
32854 movzwl %ax,%eax
32855 + pax_force_retaddr
32856 ret
32857
32858 bpf_slow_path_byte:
32859 bpf_slow_path_common(1)
32860 js bpf_error
32861 movzbl -12(%rbp),%eax
32862 + pax_force_retaddr
32863 ret
32864
32865 bpf_slow_path_byte_msh:
32866 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32867 and $15,%al
32868 shl $2,%al
32869 xchg %eax,%ebx
32870 + pax_force_retaddr
32871 ret
32872
32873 #define sk_negative_common(SIZE) \
32874 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32875 sk_negative_common(4)
32876 mov (%rax), %eax
32877 bswap %eax
32878 + pax_force_retaddr
32879 ret
32880
32881 bpf_slow_path_half_neg:
32882 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32883 mov (%rax),%ax
32884 rol $8,%ax
32885 movzwl %ax,%eax
32886 + pax_force_retaddr
32887 ret
32888
32889 bpf_slow_path_byte_neg:
32890 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32891 .globl sk_load_byte_negative_offset
32892 sk_negative_common(1)
32893 movzbl (%rax), %eax
32894 + pax_force_retaddr
32895 ret
32896
32897 bpf_slow_path_byte_msh_neg:
32898 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32899 and $15,%al
32900 shl $2,%al
32901 xchg %eax,%ebx
32902 + pax_force_retaddr
32903 ret
32904
32905 bpf_error:
32906 @@ -197,4 +210,5 @@ bpf_error:
32907 xor %eax,%eax
32908 mov -8(%rbp),%rbx
32909 leaveq
32910 + pax_force_retaddr
32911 ret
32912 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32913 index 26328e8..5f96c25 100644
32914 --- a/arch/x86/net/bpf_jit_comp.c
32915 +++ b/arch/x86/net/bpf_jit_comp.c
32916 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32917 return ptr + len;
32918 }
32919
32920 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32921 +#define MAX_INSTR_CODE_SIZE 96
32922 +#else
32923 +#define MAX_INSTR_CODE_SIZE 64
32924 +#endif
32925 +
32926 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32927
32928 #define EMIT1(b1) EMIT(b1, 1)
32929 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32930 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32931 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32932 +
32933 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32934 +/* original constant will appear in ecx */
32935 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32936 +do { \
32937 + /* mov ecx, randkey */ \
32938 + EMIT1(0xb9); \
32939 + EMIT(_key, 4); \
32940 + /* xor ecx, randkey ^ off */ \
32941 + EMIT2(0x81, 0xf1); \
32942 + EMIT((_key) ^ (_off), 4); \
32943 +} while (0)
32944 +
32945 +#define EMIT1_off32(b1, _off) \
32946 +do { \
32947 + switch (b1) { \
32948 + case 0x05: /* add eax, imm32 */ \
32949 + case 0x2d: /* sub eax, imm32 */ \
32950 + case 0x25: /* and eax, imm32 */ \
32951 + case 0x0d: /* or eax, imm32 */ \
32952 + case 0xb8: /* mov eax, imm32 */ \
32953 + case 0x35: /* xor eax, imm32 */ \
32954 + case 0x3d: /* cmp eax, imm32 */ \
32955 + case 0xa9: /* test eax, imm32 */ \
32956 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32957 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32958 + break; \
32959 + case 0xbb: /* mov ebx, imm32 */ \
32960 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32961 + /* mov ebx, ecx */ \
32962 + EMIT2(0x89, 0xcb); \
32963 + break; \
32964 + case 0xbe: /* mov esi, imm32 */ \
32965 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32966 + /* mov esi, ecx */ \
32967 + EMIT2(0x89, 0xce); \
32968 + break; \
32969 + case 0xe8: /* call rel imm32, always to known funcs */ \
32970 + EMIT1(b1); \
32971 + EMIT(_off, 4); \
32972 + break; \
32973 + case 0xe9: /* jmp rel imm32 */ \
32974 + EMIT1(b1); \
32975 + EMIT(_off, 4); \
32976 + /* prevent fall-through, we're not called if off = 0 */ \
32977 + EMIT(0xcccccccc, 4); \
32978 + EMIT(0xcccccccc, 4); \
32979 + break; \
32980 + default: \
32981 + BUILD_BUG(); \
32982 + } \
32983 +} while (0)
32984 +
32985 +#define EMIT2_off32(b1, b2, _off) \
32986 +do { \
32987 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32988 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32989 + EMIT(randkey, 4); \
32990 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32991 + EMIT((_off) - randkey, 4); \
32992 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32993 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32994 + /* imul eax, ecx */ \
32995 + EMIT3(0x0f, 0xaf, 0xc1); \
32996 + } else { \
32997 + BUILD_BUG(); \
32998 + } \
32999 +} while (0)
33000 +#else
33001 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
33002 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
33003 +#endif
33004
33005 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
33006 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
33007 @@ -91,6 +168,24 @@ do { \
33008 #define X86_JBE 0x76
33009 #define X86_JA 0x77
33010
33011 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33012 +#define APPEND_FLOW_VERIFY() \
33013 +do { \
33014 + /* mov ecx, randkey */ \
33015 + EMIT1(0xb9); \
33016 + EMIT(randkey, 4); \
33017 + /* cmp ecx, randkey */ \
33018 + EMIT2(0x81, 0xf9); \
33019 + EMIT(randkey, 4); \
33020 + /* jz after 8 int 3s */ \
33021 + EMIT2(0x74, 0x08); \
33022 + EMIT(0xcccccccc, 4); \
33023 + EMIT(0xcccccccc, 4); \
33024 +} while (0)
33025 +#else
33026 +#define APPEND_FLOW_VERIFY() do { } while (0)
33027 +#endif
33028 +
33029 #define EMIT_COND_JMP(op, offset) \
33030 do { \
33031 if (is_near(offset)) \
33032 @@ -98,6 +193,7 @@ do { \
33033 else { \
33034 EMIT2(0x0f, op + 0x10); \
33035 EMIT(offset, 4); /* jxx .+off32 */ \
33036 + APPEND_FLOW_VERIFY(); \
33037 } \
33038 } while (0)
33039
33040 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
33041 return -1;
33042 }
33043
33044 -struct bpf_binary_header {
33045 - unsigned int pages;
33046 - /* Note : for security reasons, bpf code will follow a randomly
33047 - * sized amount of int3 instructions
33048 - */
33049 - u8 image[];
33050 -};
33051 -
33052 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
33053 +/* Note : for security reasons, bpf code will follow a randomly
33054 + * sized amount of int3 instructions
33055 + */
33056 +static u8 *bpf_alloc_binary(unsigned int proglen,
33057 u8 **image_ptr)
33058 {
33059 unsigned int sz, hole;
33060 - struct bpf_binary_header *header;
33061 + u8 *header;
33062
33063 /* Most of BPF filters are really small,
33064 * but if some of them fill a page, allow at least
33065 * 128 extra bytes to insert a random section of int3
33066 */
33067 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
33068 - header = module_alloc(sz);
33069 + sz = round_up(proglen + 128, PAGE_SIZE);
33070 + header = module_alloc_exec(sz);
33071 if (!header)
33072 return NULL;
33073
33074 + pax_open_kernel();
33075 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
33076 + pax_close_kernel();
33077
33078 - header->pages = sz / PAGE_SIZE;
33079 - hole = sz - (proglen + sizeof(*header));
33080 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
33081
33082 /* insert a random number of int3 instructions before BPF code */
33083 - *image_ptr = &header->image[prandom_u32() % hole];
33084 + *image_ptr = &header[prandom_u32() % hole];
33085 return header;
33086 }
33087
33088 void bpf_jit_compile(struct sk_filter *fp)
33089 {
33090 - u8 temp[64];
33091 + u8 temp[MAX_INSTR_CODE_SIZE];
33092 u8 *prog;
33093 unsigned int proglen, oldproglen = 0;
33094 int ilen, i;
33095 int t_offset, f_offset;
33096 u8 t_op, f_op, seen = 0, pass;
33097 u8 *image = NULL;
33098 - struct bpf_binary_header *header = NULL;
33099 + u8 *header = NULL;
33100 u8 *func;
33101 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
33102 unsigned int cleanup_addr; /* epilogue code offset */
33103 unsigned int *addrs;
33104 const struct sock_filter *filter = fp->insns;
33105 int flen = fp->len;
33106 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33107 + unsigned int randkey;
33108 +#endif
33109
33110 if (!bpf_jit_enable)
33111 return;
33112 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
33113 if (addrs == NULL)
33114 return;
33115
33116 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33117 + randkey = get_random_int();
33118 +#endif
33119 +
33120 /* Before first pass, make a rough estimation of addrs[]
33121 - * each bpf instruction is translated to less than 64 bytes
33122 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
33123 */
33124 for (proglen = 0, i = 0; i < flen; i++) {
33125 - proglen += 64;
33126 + proglen += MAX_INSTR_CODE_SIZE;
33127 addrs[i] = proglen;
33128 }
33129 cleanup_addr = proglen; /* epilogue address */
33130 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
33131 case BPF_S_ALU_MUL_K: /* A *= K */
33132 if (is_imm8(K))
33133 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
33134 - else {
33135 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
33136 - EMIT(K, 4);
33137 - }
33138 + else
33139 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
33140 break;
33141 case BPF_S_ALU_DIV_X: /* A /= X; */
33142 seen |= SEEN_XREG;
33143 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
33144 break;
33145 case BPF_S_ALU_MOD_K: /* A %= K; */
33146 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
33147 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33148 + DILUTE_CONST_SEQUENCE(K, randkey);
33149 +#else
33150 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
33151 +#endif
33152 EMIT2(0xf7, 0xf1); /* div %ecx */
33153 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
33154 break;
33155 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
33156 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33157 + DILUTE_CONST_SEQUENCE(K, randkey);
33158 + // imul rax, rcx
33159 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
33160 +#else
33161 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
33162 EMIT(K, 4);
33163 +#endif
33164 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
33165 break;
33166 case BPF_S_ALU_AND_X:
33167 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
33168 if (is_imm8(K)) {
33169 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
33170 } else {
33171 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
33172 - EMIT(K, 4);
33173 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
33174 }
33175 } else {
33176 EMIT2(0x89,0xde); /* mov %ebx,%esi */
33177 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
33178 if (unlikely(proglen + ilen > oldproglen)) {
33179 pr_err("bpb_jit_compile fatal error\n");
33180 kfree(addrs);
33181 - module_free(NULL, header);
33182 + module_free_exec(NULL, image);
33183 return;
33184 }
33185 + pax_open_kernel();
33186 memcpy(image + proglen, temp, ilen);
33187 + pax_close_kernel();
33188 }
33189 proglen += ilen;
33190 addrs[i] = proglen;
33191 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
33192
33193 if (image) {
33194 bpf_flush_icache(header, image + proglen);
33195 - set_memory_ro((unsigned long)header, header->pages);
33196 fp->bpf_func = (void *)image;
33197 }
33198 out:
33199 @@ -776,10 +883,9 @@ static void bpf_jit_free_deferred(struct work_struct *work)
33200 {
33201 struct sk_filter *fp = container_of(work, struct sk_filter, work);
33202 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
33203 - struct bpf_binary_header *header = (void *)addr;
33204
33205 - set_memory_rw(addr, header->pages);
33206 - module_free(NULL, header);
33207 + set_memory_rw(addr, 1);
33208 + module_free_exec(NULL, (void *)addr);
33209 kfree(fp);
33210 }
33211
33212 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
33213 index d6aa6e8..266395a 100644
33214 --- a/arch/x86/oprofile/backtrace.c
33215 +++ b/arch/x86/oprofile/backtrace.c
33216 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
33217 struct stack_frame_ia32 *fp;
33218 unsigned long bytes;
33219
33220 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
33221 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
33222 if (bytes != sizeof(bufhead))
33223 return NULL;
33224
33225 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
33226 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
33227
33228 oprofile_add_trace(bufhead[0].return_address);
33229
33230 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
33231 struct stack_frame bufhead[2];
33232 unsigned long bytes;
33233
33234 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
33235 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
33236 if (bytes != sizeof(bufhead))
33237 return NULL;
33238
33239 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
33240 {
33241 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
33242
33243 - if (!user_mode_vm(regs)) {
33244 + if (!user_mode(regs)) {
33245 unsigned long stack = kernel_stack_pointer(regs);
33246 if (depth)
33247 dump_trace(NULL, regs, (unsigned long *)stack, 0,
33248 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
33249 index 6890d84..1dad1f1 100644
33250 --- a/arch/x86/oprofile/nmi_int.c
33251 +++ b/arch/x86/oprofile/nmi_int.c
33252 @@ -23,6 +23,7 @@
33253 #include <asm/nmi.h>
33254 #include <asm/msr.h>
33255 #include <asm/apic.h>
33256 +#include <asm/pgtable.h>
33257
33258 #include "op_counter.h"
33259 #include "op_x86_model.h"
33260 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
33261 if (ret)
33262 return ret;
33263
33264 - if (!model->num_virt_counters)
33265 - model->num_virt_counters = model->num_counters;
33266 + if (!model->num_virt_counters) {
33267 + pax_open_kernel();
33268 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
33269 + pax_close_kernel();
33270 + }
33271
33272 mux_init(ops);
33273
33274 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
33275 index 50d86c0..7985318 100644
33276 --- a/arch/x86/oprofile/op_model_amd.c
33277 +++ b/arch/x86/oprofile/op_model_amd.c
33278 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
33279 num_counters = AMD64_NUM_COUNTERS;
33280 }
33281
33282 - op_amd_spec.num_counters = num_counters;
33283 - op_amd_spec.num_controls = num_counters;
33284 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
33285 + pax_open_kernel();
33286 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
33287 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
33288 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
33289 + pax_close_kernel();
33290
33291 return 0;
33292 }
33293 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
33294 index d90528e..0127e2b 100644
33295 --- a/arch/x86/oprofile/op_model_ppro.c
33296 +++ b/arch/x86/oprofile/op_model_ppro.c
33297 @@ -19,6 +19,7 @@
33298 #include <asm/msr.h>
33299 #include <asm/apic.h>
33300 #include <asm/nmi.h>
33301 +#include <asm/pgtable.h>
33302
33303 #include "op_x86_model.h"
33304 #include "op_counter.h"
33305 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
33306
33307 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
33308
33309 - op_arch_perfmon_spec.num_counters = num_counters;
33310 - op_arch_perfmon_spec.num_controls = num_counters;
33311 + pax_open_kernel();
33312 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
33313 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
33314 + pax_close_kernel();
33315 }
33316
33317 static int arch_perfmon_init(struct oprofile_operations *ignore)
33318 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
33319 index 71e8a67..6a313bb 100644
33320 --- a/arch/x86/oprofile/op_x86_model.h
33321 +++ b/arch/x86/oprofile/op_x86_model.h
33322 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
33323 void (*switch_ctrl)(struct op_x86_model_spec const *model,
33324 struct op_msrs const * const msrs);
33325 #endif
33326 -};
33327 +} __do_const;
33328
33329 struct op_counter_config;
33330
33331 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
33332 index 372e9b8..e775a6c 100644
33333 --- a/arch/x86/pci/irq.c
33334 +++ b/arch/x86/pci/irq.c
33335 @@ -50,7 +50,7 @@ struct irq_router {
33336 struct irq_router_handler {
33337 u16 vendor;
33338 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
33339 -};
33340 +} __do_const;
33341
33342 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
33343 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
33344 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
33345 return 0;
33346 }
33347
33348 -static __initdata struct irq_router_handler pirq_routers[] = {
33349 +static __initconst const struct irq_router_handler pirq_routers[] = {
33350 { PCI_VENDOR_ID_INTEL, intel_router_probe },
33351 { PCI_VENDOR_ID_AL, ali_router_probe },
33352 { PCI_VENDOR_ID_ITE, ite_router_probe },
33353 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
33354 static void __init pirq_find_router(struct irq_router *r)
33355 {
33356 struct irq_routing_table *rt = pirq_table;
33357 - struct irq_router_handler *h;
33358 + const struct irq_router_handler *h;
33359
33360 #ifdef CONFIG_PCI_BIOS
33361 if (!rt->signature) {
33362 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
33363 return 0;
33364 }
33365
33366 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
33367 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
33368 {
33369 .callback = fix_broken_hp_bios_irq9,
33370 .ident = "HP Pavilion N5400 Series Laptop",
33371 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
33372 index 903fded..94b0d88 100644
33373 --- a/arch/x86/pci/mrst.c
33374 +++ b/arch/x86/pci/mrst.c
33375 @@ -241,7 +241,9 @@ int __init pci_mrst_init(void)
33376 pr_info("Intel MID platform detected, using MID PCI ops\n");
33377 pci_mmcfg_late_init();
33378 pcibios_enable_irq = mrst_pci_irq_enable;
33379 - pci_root_ops = pci_mrst_ops;
33380 + pax_open_kernel();
33381 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
33382 + pax_close_kernel();
33383 pci_soc_mode = 1;
33384 /* Continue with standard init */
33385 return 1;
33386 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
33387 index c77b24a..c979855 100644
33388 --- a/arch/x86/pci/pcbios.c
33389 +++ b/arch/x86/pci/pcbios.c
33390 @@ -79,7 +79,7 @@ union bios32 {
33391 static struct {
33392 unsigned long address;
33393 unsigned short segment;
33394 -} bios32_indirect = { 0, __KERNEL_CS };
33395 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
33396
33397 /*
33398 * Returns the entry point for the given service, NULL on error
33399 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
33400 unsigned long length; /* %ecx */
33401 unsigned long entry; /* %edx */
33402 unsigned long flags;
33403 + struct desc_struct d, *gdt;
33404
33405 local_irq_save(flags);
33406 - __asm__("lcall *(%%edi); cld"
33407 +
33408 + gdt = get_cpu_gdt_table(smp_processor_id());
33409 +
33410 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
33411 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
33412 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
33413 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
33414 +
33415 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
33416 : "=a" (return_code),
33417 "=b" (address),
33418 "=c" (length),
33419 "=d" (entry)
33420 : "0" (service),
33421 "1" (0),
33422 - "D" (&bios32_indirect));
33423 + "D" (&bios32_indirect),
33424 + "r"(__PCIBIOS_DS)
33425 + : "memory");
33426 +
33427 + pax_open_kernel();
33428 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
33429 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
33430 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
33431 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
33432 + pax_close_kernel();
33433 +
33434 local_irq_restore(flags);
33435
33436 switch (return_code) {
33437 - case 0:
33438 - return address + entry;
33439 - case 0x80: /* Not present */
33440 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
33441 - return 0;
33442 - default: /* Shouldn't happen */
33443 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
33444 - service, return_code);
33445 + case 0: {
33446 + int cpu;
33447 + unsigned char flags;
33448 +
33449 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
33450 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
33451 + printk(KERN_WARNING "bios32_service: not valid\n");
33452 return 0;
33453 + }
33454 + address = address + PAGE_OFFSET;
33455 + length += 16UL; /* some BIOSs underreport this... */
33456 + flags = 4;
33457 + if (length >= 64*1024*1024) {
33458 + length >>= PAGE_SHIFT;
33459 + flags |= 8;
33460 + }
33461 +
33462 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
33463 + gdt = get_cpu_gdt_table(cpu);
33464 + pack_descriptor(&d, address, length, 0x9b, flags);
33465 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
33466 + pack_descriptor(&d, address, length, 0x93, flags);
33467 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
33468 + }
33469 + return entry;
33470 + }
33471 + case 0x80: /* Not present */
33472 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
33473 + return 0;
33474 + default: /* Shouldn't happen */
33475 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
33476 + service, return_code);
33477 + return 0;
33478 }
33479 }
33480
33481 static struct {
33482 unsigned long address;
33483 unsigned short segment;
33484 -} pci_indirect = { 0, __KERNEL_CS };
33485 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
33486
33487 -static int pci_bios_present;
33488 +static int pci_bios_present __read_only;
33489
33490 static int check_pcibios(void)
33491 {
33492 @@ -131,11 +174,13 @@ static int check_pcibios(void)
33493 unsigned long flags, pcibios_entry;
33494
33495 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
33496 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
33497 + pci_indirect.address = pcibios_entry;
33498
33499 local_irq_save(flags);
33500 - __asm__(
33501 - "lcall *(%%edi); cld\n\t"
33502 + __asm__("movw %w6, %%ds\n\t"
33503 + "lcall *%%ss:(%%edi); cld\n\t"
33504 + "push %%ss\n\t"
33505 + "pop %%ds\n\t"
33506 "jc 1f\n\t"
33507 "xor %%ah, %%ah\n"
33508 "1:"
33509 @@ -144,7 +189,8 @@ static int check_pcibios(void)
33510 "=b" (ebx),
33511 "=c" (ecx)
33512 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
33513 - "D" (&pci_indirect)
33514 + "D" (&pci_indirect),
33515 + "r" (__PCIBIOS_DS)
33516 : "memory");
33517 local_irq_restore(flags);
33518
33519 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33520
33521 switch (len) {
33522 case 1:
33523 - __asm__("lcall *(%%esi); cld\n\t"
33524 + __asm__("movw %w6, %%ds\n\t"
33525 + "lcall *%%ss:(%%esi); cld\n\t"
33526 + "push %%ss\n\t"
33527 + "pop %%ds\n\t"
33528 "jc 1f\n\t"
33529 "xor %%ah, %%ah\n"
33530 "1:"
33531 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33532 : "1" (PCIBIOS_READ_CONFIG_BYTE),
33533 "b" (bx),
33534 "D" ((long)reg),
33535 - "S" (&pci_indirect));
33536 + "S" (&pci_indirect),
33537 + "r" (__PCIBIOS_DS));
33538 /*
33539 * Zero-extend the result beyond 8 bits, do not trust the
33540 * BIOS having done it:
33541 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33542 *value &= 0xff;
33543 break;
33544 case 2:
33545 - __asm__("lcall *(%%esi); cld\n\t"
33546 + __asm__("movw %w6, %%ds\n\t"
33547 + "lcall *%%ss:(%%esi); cld\n\t"
33548 + "push %%ss\n\t"
33549 + "pop %%ds\n\t"
33550 "jc 1f\n\t"
33551 "xor %%ah, %%ah\n"
33552 "1:"
33553 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33554 : "1" (PCIBIOS_READ_CONFIG_WORD),
33555 "b" (bx),
33556 "D" ((long)reg),
33557 - "S" (&pci_indirect));
33558 + "S" (&pci_indirect),
33559 + "r" (__PCIBIOS_DS));
33560 /*
33561 * Zero-extend the result beyond 16 bits, do not trust the
33562 * BIOS having done it:
33563 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33564 *value &= 0xffff;
33565 break;
33566 case 4:
33567 - __asm__("lcall *(%%esi); cld\n\t"
33568 + __asm__("movw %w6, %%ds\n\t"
33569 + "lcall *%%ss:(%%esi); cld\n\t"
33570 + "push %%ss\n\t"
33571 + "pop %%ds\n\t"
33572 "jc 1f\n\t"
33573 "xor %%ah, %%ah\n"
33574 "1:"
33575 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33576 : "1" (PCIBIOS_READ_CONFIG_DWORD),
33577 "b" (bx),
33578 "D" ((long)reg),
33579 - "S" (&pci_indirect));
33580 + "S" (&pci_indirect),
33581 + "r" (__PCIBIOS_DS));
33582 break;
33583 }
33584
33585 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33586
33587 switch (len) {
33588 case 1:
33589 - __asm__("lcall *(%%esi); cld\n\t"
33590 + __asm__("movw %w6, %%ds\n\t"
33591 + "lcall *%%ss:(%%esi); cld\n\t"
33592 + "push %%ss\n\t"
33593 + "pop %%ds\n\t"
33594 "jc 1f\n\t"
33595 "xor %%ah, %%ah\n"
33596 "1:"
33597 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33598 "c" (value),
33599 "b" (bx),
33600 "D" ((long)reg),
33601 - "S" (&pci_indirect));
33602 + "S" (&pci_indirect),
33603 + "r" (__PCIBIOS_DS));
33604 break;
33605 case 2:
33606 - __asm__("lcall *(%%esi); cld\n\t"
33607 + __asm__("movw %w6, %%ds\n\t"
33608 + "lcall *%%ss:(%%esi); cld\n\t"
33609 + "push %%ss\n\t"
33610 + "pop %%ds\n\t"
33611 "jc 1f\n\t"
33612 "xor %%ah, %%ah\n"
33613 "1:"
33614 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33615 "c" (value),
33616 "b" (bx),
33617 "D" ((long)reg),
33618 - "S" (&pci_indirect));
33619 + "S" (&pci_indirect),
33620 + "r" (__PCIBIOS_DS));
33621 break;
33622 case 4:
33623 - __asm__("lcall *(%%esi); cld\n\t"
33624 + __asm__("movw %w6, %%ds\n\t"
33625 + "lcall *%%ss:(%%esi); cld\n\t"
33626 + "push %%ss\n\t"
33627 + "pop %%ds\n\t"
33628 "jc 1f\n\t"
33629 "xor %%ah, %%ah\n"
33630 "1:"
33631 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33632 "c" (value),
33633 "b" (bx),
33634 "D" ((long)reg),
33635 - "S" (&pci_indirect));
33636 + "S" (&pci_indirect),
33637 + "r" (__PCIBIOS_DS));
33638 break;
33639 }
33640
33641 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33642
33643 DBG("PCI: Fetching IRQ routing table... ");
33644 __asm__("push %%es\n\t"
33645 + "movw %w8, %%ds\n\t"
33646 "push %%ds\n\t"
33647 "pop %%es\n\t"
33648 - "lcall *(%%esi); cld\n\t"
33649 + "lcall *%%ss:(%%esi); cld\n\t"
33650 "pop %%es\n\t"
33651 + "push %%ss\n\t"
33652 + "pop %%ds\n"
33653 "jc 1f\n\t"
33654 "xor %%ah, %%ah\n"
33655 "1:"
33656 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33657 "1" (0),
33658 "D" ((long) &opt),
33659 "S" (&pci_indirect),
33660 - "m" (opt)
33661 + "m" (opt),
33662 + "r" (__PCIBIOS_DS)
33663 : "memory");
33664 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33665 if (ret & 0xff00)
33666 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33667 {
33668 int ret;
33669
33670 - __asm__("lcall *(%%esi); cld\n\t"
33671 + __asm__("movw %w5, %%ds\n\t"
33672 + "lcall *%%ss:(%%esi); cld\n\t"
33673 + "push %%ss\n\t"
33674 + "pop %%ds\n"
33675 "jc 1f\n\t"
33676 "xor %%ah, %%ah\n"
33677 "1:"
33678 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33679 : "0" (PCIBIOS_SET_PCI_HW_INT),
33680 "b" ((dev->bus->number << 8) | dev->devfn),
33681 "c" ((irq << 8) | (pin + 10)),
33682 - "S" (&pci_indirect));
33683 + "S" (&pci_indirect),
33684 + "r" (__PCIBIOS_DS));
33685 return !(ret & 0xff00);
33686 }
33687 EXPORT_SYMBOL(pcibios_set_irq_routing);
33688 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33689 index 40e4469..d915bf9 100644
33690 --- a/arch/x86/platform/efi/efi_32.c
33691 +++ b/arch/x86/platform/efi/efi_32.c
33692 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33693 {
33694 struct desc_ptr gdt_descr;
33695
33696 +#ifdef CONFIG_PAX_KERNEXEC
33697 + struct desc_struct d;
33698 +#endif
33699 +
33700 local_irq_save(efi_rt_eflags);
33701
33702 load_cr3(initial_page_table);
33703 __flush_tlb_all();
33704
33705 +#ifdef CONFIG_PAX_KERNEXEC
33706 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33707 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33708 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33709 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33710 +#endif
33711 +
33712 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33713 gdt_descr.size = GDT_SIZE - 1;
33714 load_gdt(&gdt_descr);
33715 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33716 {
33717 struct desc_ptr gdt_descr;
33718
33719 +#ifdef CONFIG_PAX_KERNEXEC
33720 + struct desc_struct d;
33721 +
33722 + memset(&d, 0, sizeof d);
33723 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33724 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33725 +#endif
33726 +
33727 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33728 gdt_descr.size = GDT_SIZE - 1;
33729 load_gdt(&gdt_descr);
33730
33731 +#ifdef CONFIG_PAX_PER_CPU_PGD
33732 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33733 +#else
33734 load_cr3(swapper_pg_dir);
33735 +#endif
33736 +
33737 __flush_tlb_all();
33738
33739 local_irq_restore(efi_rt_eflags);
33740 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33741 index 39a0e7f1..872396e 100644
33742 --- a/arch/x86/platform/efi/efi_64.c
33743 +++ b/arch/x86/platform/efi/efi_64.c
33744 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33745 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33746 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33747 }
33748 +
33749 +#ifdef CONFIG_PAX_PER_CPU_PGD
33750 + load_cr3(swapper_pg_dir);
33751 +#endif
33752 +
33753 __flush_tlb_all();
33754 }
33755
33756 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33757 for (pgd = 0; pgd < n_pgds; pgd++)
33758 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33759 kfree(save_pgd);
33760 +
33761 +#ifdef CONFIG_PAX_PER_CPU_PGD
33762 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33763 +#endif
33764 +
33765 __flush_tlb_all();
33766 local_irq_restore(efi_flags);
33767 early_code_mapping_set_exec(0);
33768 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33769 index fbe66e6..eae5e38 100644
33770 --- a/arch/x86/platform/efi/efi_stub_32.S
33771 +++ b/arch/x86/platform/efi/efi_stub_32.S
33772 @@ -6,7 +6,9 @@
33773 */
33774
33775 #include <linux/linkage.h>
33776 +#include <linux/init.h>
33777 #include <asm/page_types.h>
33778 +#include <asm/segment.h>
33779
33780 /*
33781 * efi_call_phys(void *, ...) is a function with variable parameters.
33782 @@ -20,7 +22,7 @@
33783 * service functions will comply with gcc calling convention, too.
33784 */
33785
33786 -.text
33787 +__INIT
33788 ENTRY(efi_call_phys)
33789 /*
33790 * 0. The function can only be called in Linux kernel. So CS has been
33791 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33792 * The mapping of lower virtual memory has been created in prelog and
33793 * epilog.
33794 */
33795 - movl $1f, %edx
33796 - subl $__PAGE_OFFSET, %edx
33797 - jmp *%edx
33798 +#ifdef CONFIG_PAX_KERNEXEC
33799 + movl $(__KERNEXEC_EFI_DS), %edx
33800 + mov %edx, %ds
33801 + mov %edx, %es
33802 + mov %edx, %ss
33803 + addl $2f,(1f)
33804 + ljmp *(1f)
33805 +
33806 +__INITDATA
33807 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33808 +.previous
33809 +
33810 +2:
33811 + subl $2b,(1b)
33812 +#else
33813 + jmp 1f-__PAGE_OFFSET
33814 1:
33815 +#endif
33816
33817 /*
33818 * 2. Now on the top of stack is the return
33819 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33820 * parameter 2, ..., param n. To make things easy, we save the return
33821 * address of efi_call_phys in a global variable.
33822 */
33823 - popl %edx
33824 - movl %edx, saved_return_addr
33825 - /* get the function pointer into ECX*/
33826 - popl %ecx
33827 - movl %ecx, efi_rt_function_ptr
33828 - movl $2f, %edx
33829 - subl $__PAGE_OFFSET, %edx
33830 - pushl %edx
33831 + popl (saved_return_addr)
33832 + popl (efi_rt_function_ptr)
33833
33834 /*
33835 * 3. Clear PG bit in %CR0.
33836 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33837 /*
33838 * 5. Call the physical function.
33839 */
33840 - jmp *%ecx
33841 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33842
33843 -2:
33844 /*
33845 * 6. After EFI runtime service returns, control will return to
33846 * following instruction. We'd better readjust stack pointer first.
33847 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33848 movl %cr0, %edx
33849 orl $0x80000000, %edx
33850 movl %edx, %cr0
33851 - jmp 1f
33852 -1:
33853 +
33854 /*
33855 * 8. Now restore the virtual mode from flat mode by
33856 * adding EIP with PAGE_OFFSET.
33857 */
33858 - movl $1f, %edx
33859 - jmp *%edx
33860 +#ifdef CONFIG_PAX_KERNEXEC
33861 + movl $(__KERNEL_DS), %edx
33862 + mov %edx, %ds
33863 + mov %edx, %es
33864 + mov %edx, %ss
33865 + ljmp $(__KERNEL_CS),$1f
33866 +#else
33867 + jmp 1f+__PAGE_OFFSET
33868 +#endif
33869 1:
33870
33871 /*
33872 * 9. Balance the stack. And because EAX contain the return value,
33873 * we'd better not clobber it.
33874 */
33875 - leal efi_rt_function_ptr, %edx
33876 - movl (%edx), %ecx
33877 - pushl %ecx
33878 + pushl (efi_rt_function_ptr)
33879
33880 /*
33881 - * 10. Push the saved return address onto the stack and return.
33882 + * 10. Return to the saved return address.
33883 */
33884 - leal saved_return_addr, %edx
33885 - movl (%edx), %ecx
33886 - pushl %ecx
33887 - ret
33888 + jmpl *(saved_return_addr)
33889 ENDPROC(efi_call_phys)
33890 .previous
33891
33892 -.data
33893 +__INITDATA
33894 saved_return_addr:
33895 .long 0
33896 efi_rt_function_ptr:
33897 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33898 index 4c07cca..2c8427d 100644
33899 --- a/arch/x86/platform/efi/efi_stub_64.S
33900 +++ b/arch/x86/platform/efi/efi_stub_64.S
33901 @@ -7,6 +7,7 @@
33902 */
33903
33904 #include <linux/linkage.h>
33905 +#include <asm/alternative-asm.h>
33906
33907 #define SAVE_XMM \
33908 mov %rsp, %rax; \
33909 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33910 call *%rdi
33911 addq $32, %rsp
33912 RESTORE_XMM
33913 + pax_force_retaddr 0, 1
33914 ret
33915 ENDPROC(efi_call0)
33916
33917 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33918 call *%rdi
33919 addq $32, %rsp
33920 RESTORE_XMM
33921 + pax_force_retaddr 0, 1
33922 ret
33923 ENDPROC(efi_call1)
33924
33925 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33926 call *%rdi
33927 addq $32, %rsp
33928 RESTORE_XMM
33929 + pax_force_retaddr 0, 1
33930 ret
33931 ENDPROC(efi_call2)
33932
33933 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33934 call *%rdi
33935 addq $32, %rsp
33936 RESTORE_XMM
33937 + pax_force_retaddr 0, 1
33938 ret
33939 ENDPROC(efi_call3)
33940
33941 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33942 call *%rdi
33943 addq $32, %rsp
33944 RESTORE_XMM
33945 + pax_force_retaddr 0, 1
33946 ret
33947 ENDPROC(efi_call4)
33948
33949 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33950 call *%rdi
33951 addq $48, %rsp
33952 RESTORE_XMM
33953 + pax_force_retaddr 0, 1
33954 ret
33955 ENDPROC(efi_call5)
33956
33957 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33958 call *%rdi
33959 addq $48, %rsp
33960 RESTORE_XMM
33961 + pax_force_retaddr 0, 1
33962 ret
33963 ENDPROC(efi_call6)
33964 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33965 index 3ca5957..7909c18 100644
33966 --- a/arch/x86/platform/mrst/mrst.c
33967 +++ b/arch/x86/platform/mrst/mrst.c
33968 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33969 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33970 int sfi_mrtc_num;
33971
33972 -static void mrst_power_off(void)
33973 +static __noreturn void mrst_power_off(void)
33974 {
33975 + BUG();
33976 }
33977
33978 -static void mrst_reboot(void)
33979 +static __noreturn void mrst_reboot(void)
33980 {
33981 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33982 + BUG();
33983 }
33984
33985 /* parse all the mtimer info to a static mtimer array */
33986 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33987 index d6ee929..3637cb5 100644
33988 --- a/arch/x86/platform/olpc/olpc_dt.c
33989 +++ b/arch/x86/platform/olpc/olpc_dt.c
33990 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33991 return res;
33992 }
33993
33994 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33995 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33996 .nextprop = olpc_dt_nextprop,
33997 .getproplen = olpc_dt_getproplen,
33998 .getproperty = olpc_dt_getproperty,
33999 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
34000 index 424f4c9..f2a2988 100644
34001 --- a/arch/x86/power/cpu.c
34002 +++ b/arch/x86/power/cpu.c
34003 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
34004 static void fix_processor_context(void)
34005 {
34006 int cpu = smp_processor_id();
34007 - struct tss_struct *t = &per_cpu(init_tss, cpu);
34008 -#ifdef CONFIG_X86_64
34009 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
34010 - tss_desc tss;
34011 -#endif
34012 + struct tss_struct *t = init_tss + cpu;
34013 +
34014 set_tss_desc(cpu, t); /*
34015 * This just modifies memory; should not be
34016 * necessary. But... This is necessary, because
34017 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
34018 */
34019
34020 #ifdef CONFIG_X86_64
34021 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
34022 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
34023 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
34024 -
34025 syscall_init(); /* This sets MSR_*STAR and related */
34026 #endif
34027 load_TR_desc(); /* This does ltr */
34028 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
34029 index a44f457..9140171 100644
34030 --- a/arch/x86/realmode/init.c
34031 +++ b/arch/x86/realmode/init.c
34032 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
34033 __va(real_mode_header->trampoline_header);
34034
34035 #ifdef CONFIG_X86_32
34036 - trampoline_header->start = __pa_symbol(startup_32_smp);
34037 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
34038 +
34039 +#ifdef CONFIG_PAX_KERNEXEC
34040 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
34041 +#endif
34042 +
34043 + trampoline_header->boot_cs = __BOOT_CS;
34044 trampoline_header->gdt_limit = __BOOT_DS + 7;
34045 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
34046 #else
34047 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
34048 *trampoline_cr4_features = read_cr4();
34049
34050 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
34051 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
34052 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
34053 trampoline_pgd[511] = init_level4_pgt[511].pgd;
34054 #endif
34055 }
34056 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
34057 index 9cac825..4890b25 100644
34058 --- a/arch/x86/realmode/rm/Makefile
34059 +++ b/arch/x86/realmode/rm/Makefile
34060 @@ -79,5 +79,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
34061 $(call cc-option, -fno-unit-at-a-time)) \
34062 $(call cc-option, -fno-stack-protector) \
34063 $(call cc-option, -mpreferred-stack-boundary=2)
34064 +ifdef CONSTIFY_PLUGIN
34065 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
34066 +endif
34067 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
34068 GCOV_PROFILE := n
34069 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
34070 index a28221d..93c40f1 100644
34071 --- a/arch/x86/realmode/rm/header.S
34072 +++ b/arch/x86/realmode/rm/header.S
34073 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
34074 #endif
34075 /* APM/BIOS reboot */
34076 .long pa_machine_real_restart_asm
34077 -#ifdef CONFIG_X86_64
34078 +#ifdef CONFIG_X86_32
34079 + .long __KERNEL_CS
34080 +#else
34081 .long __KERNEL32_CS
34082 #endif
34083 END(real_mode_header)
34084 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
34085 index c1b2791..f9e31c7 100644
34086 --- a/arch/x86/realmode/rm/trampoline_32.S
34087 +++ b/arch/x86/realmode/rm/trampoline_32.S
34088 @@ -25,6 +25,12 @@
34089 #include <asm/page_types.h>
34090 #include "realmode.h"
34091
34092 +#ifdef CONFIG_PAX_KERNEXEC
34093 +#define ta(X) (X)
34094 +#else
34095 +#define ta(X) (pa_ ## X)
34096 +#endif
34097 +
34098 .text
34099 .code16
34100
34101 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
34102
34103 cli # We should be safe anyway
34104
34105 - movl tr_start, %eax # where we need to go
34106 -
34107 movl $0xA5A5A5A5, trampoline_status
34108 # write marker for master knows we're running
34109
34110 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
34111 movw $1, %dx # protected mode (PE) bit
34112 lmsw %dx # into protected mode
34113
34114 - ljmpl $__BOOT_CS, $pa_startup_32
34115 + ljmpl *(trampoline_header)
34116
34117 .section ".text32","ax"
34118 .code32
34119 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
34120 .balign 8
34121 GLOBAL(trampoline_header)
34122 tr_start: .space 4
34123 - tr_gdt_pad: .space 2
34124 + tr_boot_cs: .space 2
34125 tr_gdt: .space 6
34126 END(trampoline_header)
34127
34128 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
34129 index bb360dc..d0fd8f8 100644
34130 --- a/arch/x86/realmode/rm/trampoline_64.S
34131 +++ b/arch/x86/realmode/rm/trampoline_64.S
34132 @@ -94,6 +94,7 @@ ENTRY(startup_32)
34133 movl %edx, %gs
34134
34135 movl pa_tr_cr4, %eax
34136 + andl $~X86_CR4_PCIDE, %eax
34137 movl %eax, %cr4 # Enable PAE mode
34138
34139 # Setup trampoline 4 level pagetables
34140 @@ -107,7 +108,7 @@ ENTRY(startup_32)
34141 wrmsr
34142
34143 # Enable paging and in turn activate Long Mode
34144 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
34145 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
34146 movl %eax, %cr0
34147
34148 /*
34149 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
34150 index e812034..c747134 100644
34151 --- a/arch/x86/tools/Makefile
34152 +++ b/arch/x86/tools/Makefile
34153 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
34154
34155 $(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
34156
34157 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
34158 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
34159 hostprogs-y += relocs
34160 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
34161 relocs: $(obj)/relocs
34162 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
34163 index f7bab68..b6d9886 100644
34164 --- a/arch/x86/tools/relocs.c
34165 +++ b/arch/x86/tools/relocs.c
34166 @@ -1,5 +1,7 @@
34167 /* This is included from relocs_32/64.c */
34168
34169 +#include "../../../include/generated/autoconf.h"
34170 +
34171 #define ElfW(type) _ElfW(ELF_BITS, type)
34172 #define _ElfW(bits, type) __ElfW(bits, type)
34173 #define __ElfW(bits, type) Elf##bits##_##type
34174 @@ -11,6 +13,7 @@
34175 #define Elf_Sym ElfW(Sym)
34176
34177 static Elf_Ehdr ehdr;
34178 +static Elf_Phdr *phdr;
34179
34180 struct relocs {
34181 uint32_t *offset;
34182 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
34183 }
34184 }
34185
34186 +static void read_phdrs(FILE *fp)
34187 +{
34188 + unsigned int i;
34189 +
34190 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
34191 + if (!phdr) {
34192 + die("Unable to allocate %d program headers\n",
34193 + ehdr.e_phnum);
34194 + }
34195 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
34196 + die("Seek to %d failed: %s\n",
34197 + ehdr.e_phoff, strerror(errno));
34198 + }
34199 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
34200 + die("Cannot read ELF program headers: %s\n",
34201 + strerror(errno));
34202 + }
34203 + for(i = 0; i < ehdr.e_phnum; i++) {
34204 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
34205 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
34206 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
34207 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
34208 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
34209 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
34210 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
34211 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
34212 + }
34213 +
34214 +}
34215 +
34216 static void read_shdrs(FILE *fp)
34217 {
34218 - int i;
34219 + unsigned int i;
34220 Elf_Shdr shdr;
34221
34222 secs = calloc(ehdr.e_shnum, sizeof(struct section));
34223 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
34224
34225 static void read_strtabs(FILE *fp)
34226 {
34227 - int i;
34228 + unsigned int i;
34229 for (i = 0; i < ehdr.e_shnum; i++) {
34230 struct section *sec = &secs[i];
34231 if (sec->shdr.sh_type != SHT_STRTAB) {
34232 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
34233
34234 static void read_symtabs(FILE *fp)
34235 {
34236 - int i,j;
34237 + unsigned int i,j;
34238 for (i = 0; i < ehdr.e_shnum; i++) {
34239 struct section *sec = &secs[i];
34240 if (sec->shdr.sh_type != SHT_SYMTAB) {
34241 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
34242 }
34243
34244
34245 -static void read_relocs(FILE *fp)
34246 +static void read_relocs(FILE *fp, int use_real_mode)
34247 {
34248 - int i,j;
34249 + unsigned int i,j;
34250 + uint32_t base;
34251 +
34252 for (i = 0; i < ehdr.e_shnum; i++) {
34253 struct section *sec = &secs[i];
34254 if (sec->shdr.sh_type != SHT_REL_TYPE) {
34255 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
34256 die("Cannot read symbol table: %s\n",
34257 strerror(errno));
34258 }
34259 + base = 0;
34260 +
34261 +#ifdef CONFIG_X86_32
34262 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
34263 + if (phdr[j].p_type != PT_LOAD )
34264 + continue;
34265 + 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)
34266 + continue;
34267 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
34268 + break;
34269 + }
34270 +#endif
34271 +
34272 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
34273 Elf_Rel *rel = &sec->reltab[j];
34274 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
34275 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
34276 rel->r_info = elf_xword_to_cpu(rel->r_info);
34277 #if (SHT_REL_TYPE == SHT_RELA)
34278 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
34279 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
34280
34281 static void print_absolute_symbols(void)
34282 {
34283 - int i;
34284 + unsigned int i;
34285 const char *format;
34286
34287 if (ELF_BITS == 64)
34288 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
34289 for (i = 0; i < ehdr.e_shnum; i++) {
34290 struct section *sec = &secs[i];
34291 char *sym_strtab;
34292 - int j;
34293 + unsigned int j;
34294
34295 if (sec->shdr.sh_type != SHT_SYMTAB) {
34296 continue;
34297 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
34298
34299 static void print_absolute_relocs(void)
34300 {
34301 - int i, printed = 0;
34302 + unsigned int i, printed = 0;
34303 const char *format;
34304
34305 if (ELF_BITS == 64)
34306 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
34307 struct section *sec_applies, *sec_symtab;
34308 char *sym_strtab;
34309 Elf_Sym *sh_symtab;
34310 - int j;
34311 + unsigned int j;
34312 if (sec->shdr.sh_type != SHT_REL_TYPE) {
34313 continue;
34314 }
34315 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
34316 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
34317 Elf_Sym *sym, const char *symname))
34318 {
34319 - int i;
34320 + unsigned int i;
34321 /* Walk through the relocations */
34322 for (i = 0; i < ehdr.e_shnum; i++) {
34323 char *sym_strtab;
34324 Elf_Sym *sh_symtab;
34325 struct section *sec_applies, *sec_symtab;
34326 - int j;
34327 + unsigned int j;
34328 struct section *sec = &secs[i];
34329
34330 if (sec->shdr.sh_type != SHT_REL_TYPE) {
34331 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
34332 {
34333 unsigned r_type = ELF32_R_TYPE(rel->r_info);
34334 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
34335 + char *sym_strtab = sec->link->link->strtab;
34336 +
34337 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
34338 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
34339 + return 0;
34340 +
34341 +#ifdef CONFIG_PAX_KERNEXEC
34342 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
34343 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
34344 + return 0;
34345 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
34346 + return 0;
34347 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
34348 + return 0;
34349 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
34350 + return 0;
34351 +#endif
34352
34353 switch (r_type) {
34354 case R_386_NONE:
34355 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
34356
34357 static void emit_relocs(int as_text, int use_real_mode)
34358 {
34359 - int i;
34360 + unsigned int i;
34361 int (*write_reloc)(uint32_t, FILE *) = write32;
34362 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
34363 const char *symname);
34364 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
34365 {
34366 regex_init(use_real_mode);
34367 read_ehdr(fp);
34368 + read_phdrs(fp);
34369 read_shdrs(fp);
34370 read_strtabs(fp);
34371 read_symtabs(fp);
34372 - read_relocs(fp);
34373 + read_relocs(fp, use_real_mode);
34374 if (ELF_BITS == 64)
34375 percpu_init();
34376 if (show_absolute_syms) {
34377 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
34378 index 80ffa5b..a33bd15 100644
34379 --- a/arch/x86/um/tls_32.c
34380 +++ b/arch/x86/um/tls_32.c
34381 @@ -260,7 +260,7 @@ out:
34382 if (unlikely(task == current &&
34383 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
34384 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
34385 - "without flushed TLS.", current->pid);
34386 + "without flushed TLS.", task_pid_nr(current));
34387 }
34388
34389 return 0;
34390 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
34391 index fd14be1..e3c79c0 100644
34392 --- a/arch/x86/vdso/Makefile
34393 +++ b/arch/x86/vdso/Makefile
34394 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
34395 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
34396 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
34397
34398 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
34399 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
34400 GCOV_PROFILE := n
34401
34402 #
34403 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
34404 index d6bfb87..876ee18 100644
34405 --- a/arch/x86/vdso/vdso32-setup.c
34406 +++ b/arch/x86/vdso/vdso32-setup.c
34407 @@ -25,6 +25,7 @@
34408 #include <asm/tlbflush.h>
34409 #include <asm/vdso.h>
34410 #include <asm/proto.h>
34411 +#include <asm/mman.h>
34412
34413 enum {
34414 VDSO_DISABLED = 0,
34415 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
34416 void enable_sep_cpu(void)
34417 {
34418 int cpu = get_cpu();
34419 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
34420 + struct tss_struct *tss = init_tss + cpu;
34421
34422 if (!boot_cpu_has(X86_FEATURE_SEP)) {
34423 put_cpu();
34424 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
34425 gate_vma.vm_start = FIXADDR_USER_START;
34426 gate_vma.vm_end = FIXADDR_USER_END;
34427 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
34428 - gate_vma.vm_page_prot = __P101;
34429 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
34430
34431 return 0;
34432 }
34433 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
34434 if (compat)
34435 addr = VDSO_HIGH_BASE;
34436 else {
34437 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
34438 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
34439 if (IS_ERR_VALUE(addr)) {
34440 ret = addr;
34441 goto up_fail;
34442 }
34443 }
34444
34445 - current->mm->context.vdso = (void *)addr;
34446 + current->mm->context.vdso = addr;
34447
34448 if (compat_uses_vma || !compat) {
34449 /*
34450 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
34451 }
34452
34453 current_thread_info()->sysenter_return =
34454 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
34455 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
34456
34457 up_fail:
34458 if (ret)
34459 - current->mm->context.vdso = NULL;
34460 + current->mm->context.vdso = 0;
34461
34462 up_write(&mm->mmap_sem);
34463
34464 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
34465
34466 const char *arch_vma_name(struct vm_area_struct *vma)
34467 {
34468 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
34469 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
34470 return "[vdso]";
34471 +
34472 +#ifdef CONFIG_PAX_SEGMEXEC
34473 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
34474 + return "[vdso]";
34475 +#endif
34476 +
34477 return NULL;
34478 }
34479
34480 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
34481 * Check to see if the corresponding task was created in compat vdso
34482 * mode.
34483 */
34484 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
34485 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
34486 return &gate_vma;
34487 return NULL;
34488 }
34489 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
34490 index 431e875..cbb23f3 100644
34491 --- a/arch/x86/vdso/vma.c
34492 +++ b/arch/x86/vdso/vma.c
34493 @@ -16,8 +16,6 @@
34494 #include <asm/vdso.h>
34495 #include <asm/page.h>
34496
34497 -unsigned int __read_mostly vdso_enabled = 1;
34498 -
34499 extern char vdso_start[], vdso_end[];
34500 extern unsigned short vdso_sync_cpuid;
34501
34502 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
34503 * unaligned here as a result of stack start randomization.
34504 */
34505 addr = PAGE_ALIGN(addr);
34506 - addr = align_vdso_addr(addr);
34507
34508 return addr;
34509 }
34510 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
34511 unsigned size)
34512 {
34513 struct mm_struct *mm = current->mm;
34514 - unsigned long addr;
34515 + unsigned long addr = 0;
34516 int ret;
34517
34518 - if (!vdso_enabled)
34519 - return 0;
34520 -
34521 down_write(&mm->mmap_sem);
34522 +
34523 +#ifdef CONFIG_PAX_RANDMMAP
34524 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
34525 +#endif
34526 +
34527 addr = vdso_addr(mm->start_stack, size);
34528 + addr = align_vdso_addr(addr);
34529 addr = get_unmapped_area(NULL, addr, size, 0, 0);
34530 if (IS_ERR_VALUE(addr)) {
34531 ret = addr;
34532 goto up_fail;
34533 }
34534
34535 - current->mm->context.vdso = (void *)addr;
34536 + mm->context.vdso = addr;
34537
34538 ret = install_special_mapping(mm, addr, size,
34539 VM_READ|VM_EXEC|
34540 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
34541 pages);
34542 - if (ret) {
34543 - current->mm->context.vdso = NULL;
34544 - goto up_fail;
34545 - }
34546 + if (ret)
34547 + mm->context.vdso = 0;
34548
34549 up_fail:
34550 up_write(&mm->mmap_sem);
34551 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
34552 vdsox32_size);
34553 }
34554 #endif
34555 -
34556 -static __init int vdso_setup(char *s)
34557 -{
34558 - vdso_enabled = simple_strtoul(s, NULL, 0);
34559 - return 0;
34560 -}
34561 -__setup("vdso=", vdso_setup);
34562 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
34563 index fa6ade7..73da73a5 100644
34564 --- a/arch/x86/xen/enlighten.c
34565 +++ b/arch/x86/xen/enlighten.c
34566 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
34567
34568 struct shared_info xen_dummy_shared_info;
34569
34570 -void *xen_initial_gdt;
34571 -
34572 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
34573 __read_mostly int xen_have_vector_callback;
34574 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
34575 @@ -541,8 +539,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
34576 {
34577 unsigned long va = dtr->address;
34578 unsigned int size = dtr->size + 1;
34579 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
34580 - unsigned long frames[pages];
34581 + unsigned long frames[65536 / PAGE_SIZE];
34582 int f;
34583
34584 /*
34585 @@ -590,8 +587,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
34586 {
34587 unsigned long va = dtr->address;
34588 unsigned int size = dtr->size + 1;
34589 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
34590 - unsigned long frames[pages];
34591 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
34592 int f;
34593
34594 /*
34595 @@ -599,7 +595,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
34596 * 8-byte entries, or 16 4k pages..
34597 */
34598
34599 - BUG_ON(size > 65536);
34600 + BUG_ON(size > GDT_SIZE);
34601 BUG_ON(va & ~PAGE_MASK);
34602
34603 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
34604 @@ -988,7 +984,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
34605 return 0;
34606 }
34607
34608 -static void set_xen_basic_apic_ops(void)
34609 +static void __init set_xen_basic_apic_ops(void)
34610 {
34611 apic->read = xen_apic_read;
34612 apic->write = xen_apic_write;
34613 @@ -1293,30 +1289,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
34614 #endif
34615 };
34616
34617 -static void xen_reboot(int reason)
34618 +static __noreturn void xen_reboot(int reason)
34619 {
34620 struct sched_shutdown r = { .reason = reason };
34621
34622 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34623 - BUG();
34624 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34625 + BUG();
34626 }
34627
34628 -static void xen_restart(char *msg)
34629 +static __noreturn void xen_restart(char *msg)
34630 {
34631 xen_reboot(SHUTDOWN_reboot);
34632 }
34633
34634 -static void xen_emergency_restart(void)
34635 +static __noreturn void xen_emergency_restart(void)
34636 {
34637 xen_reboot(SHUTDOWN_reboot);
34638 }
34639
34640 -static void xen_machine_halt(void)
34641 +static __noreturn void xen_machine_halt(void)
34642 {
34643 xen_reboot(SHUTDOWN_poweroff);
34644 }
34645
34646 -static void xen_machine_power_off(void)
34647 +static __noreturn void xen_machine_power_off(void)
34648 {
34649 if (pm_power_off)
34650 pm_power_off();
34651 @@ -1467,7 +1463,17 @@ asmlinkage void __init xen_start_kernel(void)
34652 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34653
34654 /* Work out if we support NX */
34655 - x86_configure_nx();
34656 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34657 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34658 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34659 + unsigned l, h;
34660 +
34661 + __supported_pte_mask |= _PAGE_NX;
34662 + rdmsr(MSR_EFER, l, h);
34663 + l |= EFER_NX;
34664 + wrmsr(MSR_EFER, l, h);
34665 + }
34666 +#endif
34667
34668 xen_setup_features();
34669
34670 @@ -1498,13 +1504,6 @@ asmlinkage void __init xen_start_kernel(void)
34671
34672 machine_ops = xen_machine_ops;
34673
34674 - /*
34675 - * The only reliable way to retain the initial address of the
34676 - * percpu gdt_page is to remember it here, so we can go and
34677 - * mark it RW later, when the initial percpu area is freed.
34678 - */
34679 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34680 -
34681 xen_smp_init();
34682
34683 #ifdef CONFIG_ACPI_NUMA
34684 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34685 index fdc3ba2..23cae00 100644
34686 --- a/arch/x86/xen/mmu.c
34687 +++ b/arch/x86/xen/mmu.c
34688 @@ -379,7 +379,7 @@ static pteval_t pte_mfn_to_pfn(pteval_t val)
34689 return val;
34690 }
34691
34692 -static pteval_t pte_pfn_to_mfn(pteval_t val)
34693 +static pteval_t __intentional_overflow(-1) pte_pfn_to_mfn(pteval_t val)
34694 {
34695 if (val & _PAGE_PRESENT) {
34696 unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
34697 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34698 /* L3_k[510] -> level2_kernel_pgt
34699 * L3_i[511] -> level2_fixmap_pgt */
34700 convert_pfn_mfn(level3_kernel_pgt);
34701 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34702 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34703 + convert_pfn_mfn(level3_vmemmap_pgt);
34704
34705 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34706 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34707 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34708 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34709 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34710 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34711 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34712 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34713 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34714 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34715 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34716 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34717 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34718 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34719
34720 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34721 pv_mmu_ops.set_pud = xen_set_pud;
34722 #if PAGETABLE_LEVELS == 4
34723 pv_mmu_ops.set_pgd = xen_set_pgd;
34724 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34725 #endif
34726
34727 /* This will work as long as patching hasn't happened yet
34728 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34729 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34730 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34731 .set_pgd = xen_set_pgd_hyper,
34732 + .set_pgd_batched = xen_set_pgd_hyper,
34733
34734 .alloc_pud = xen_alloc_pmd_init,
34735 .release_pud = xen_release_pmd_init,
34736 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34737 index 31d0475..51af671 100644
34738 --- a/arch/x86/xen/smp.c
34739 +++ b/arch/x86/xen/smp.c
34740 @@ -274,17 +274,13 @@ static void __init xen_smp_prepare_boot_cpu(void)
34741 native_smp_prepare_boot_cpu();
34742
34743 if (xen_pv_domain()) {
34744 - /* We've switched to the "real" per-cpu gdt, so make sure the
34745 - old memory can be recycled */
34746 - make_lowmem_page_readwrite(xen_initial_gdt);
34747 -
34748 #ifdef CONFIG_X86_32
34749 /*
34750 * Xen starts us with XEN_FLAT_RING1_DS, but linux code
34751 * expects __USER_DS
34752 */
34753 - loadsegment(ds, __USER_DS);
34754 - loadsegment(es, __USER_DS);
34755 + loadsegment(ds, __KERNEL_DS);
34756 + loadsegment(es, __KERNEL_DS);
34757 #endif
34758
34759 xen_filter_cpu_maps();
34760 @@ -364,7 +360,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34761 ctxt->user_regs.ss = __KERNEL_DS;
34762 #ifdef CONFIG_X86_32
34763 ctxt->user_regs.fs = __KERNEL_PERCPU;
34764 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34765 + savesegment(gs, ctxt->user_regs.gs);
34766 #else
34767 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34768 #endif
34769 @@ -374,8 +370,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34770
34771 {
34772 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34773 - ctxt->user_regs.ds = __USER_DS;
34774 - ctxt->user_regs.es = __USER_DS;
34775 + ctxt->user_regs.ds = __KERNEL_DS;
34776 + ctxt->user_regs.es = __KERNEL_DS;
34777
34778 xen_copy_trap_info(ctxt->trap_ctxt);
34779
34780 @@ -420,13 +416,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34781 int rc;
34782
34783 per_cpu(current_task, cpu) = idle;
34784 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34785 #ifdef CONFIG_X86_32
34786 irq_ctx_init(cpu);
34787 #else
34788 clear_tsk_thread_flag(idle, TIF_FORK);
34789 - per_cpu(kernel_stack, cpu) =
34790 - (unsigned long)task_stack_page(idle) -
34791 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34792 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34793 #endif
34794 xen_setup_runstate_info(cpu);
34795 xen_setup_timer(cpu);
34796 @@ -702,7 +697,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34797
34798 void __init xen_smp_init(void)
34799 {
34800 - smp_ops = xen_smp_ops;
34801 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34802 xen_fill_possible_map();
34803 }
34804
34805 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34806 index 33ca6e4..0ded929 100644
34807 --- a/arch/x86/xen/xen-asm_32.S
34808 +++ b/arch/x86/xen/xen-asm_32.S
34809 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34810 ESP_OFFSET=4 # bytes pushed onto stack
34811
34812 /*
34813 - * Store vcpu_info pointer for easy access. Do it this way to
34814 - * avoid having to reload %fs
34815 + * Store vcpu_info pointer for easy access.
34816 */
34817 #ifdef CONFIG_SMP
34818 - GET_THREAD_INFO(%eax)
34819 - movl %ss:TI_cpu(%eax), %eax
34820 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34821 - mov %ss:xen_vcpu(%eax), %eax
34822 + push %fs
34823 + mov $(__KERNEL_PERCPU), %eax
34824 + mov %eax, %fs
34825 + mov PER_CPU_VAR(xen_vcpu), %eax
34826 + pop %fs
34827 #else
34828 movl %ss:xen_vcpu, %eax
34829 #endif
34830 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34831 index 7faed58..ba4427c 100644
34832 --- a/arch/x86/xen/xen-head.S
34833 +++ b/arch/x86/xen/xen-head.S
34834 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34835 #ifdef CONFIG_X86_32
34836 mov %esi,xen_start_info
34837 mov $init_thread_union+THREAD_SIZE,%esp
34838 +#ifdef CONFIG_SMP
34839 + movl $cpu_gdt_table,%edi
34840 + movl $__per_cpu_load,%eax
34841 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34842 + rorl $16,%eax
34843 + movb %al,__KERNEL_PERCPU + 4(%edi)
34844 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34845 + movl $__per_cpu_end - 1,%eax
34846 + subl $__per_cpu_start,%eax
34847 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34848 +#endif
34849 #else
34850 mov %rsi,xen_start_info
34851 mov $init_thread_union+THREAD_SIZE,%rsp
34852 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34853 index 95f8c61..611d6e8 100644
34854 --- a/arch/x86/xen/xen-ops.h
34855 +++ b/arch/x86/xen/xen-ops.h
34856 @@ -10,8 +10,6 @@
34857 extern const char xen_hypervisor_callback[];
34858 extern const char xen_failsafe_callback[];
34859
34860 -extern void *xen_initial_gdt;
34861 -
34862 struct trap_info;
34863 void xen_copy_trap_info(struct trap_info *traps);
34864
34865 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34866 index 525bd3d..ef888b1 100644
34867 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34868 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34869 @@ -119,9 +119,9 @@
34870 ----------------------------------------------------------------------*/
34871
34872 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34873 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34874 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34875 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34876 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34877
34878 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34879 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34880 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34881 index 2f33760..835e50a 100644
34882 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34883 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34884 @@ -11,6 +11,7 @@
34885 #ifndef _XTENSA_CORE_H
34886 #define _XTENSA_CORE_H
34887
34888 +#include <linux/const.h>
34889
34890 /****************************************************************************
34891 Parameters Useful for Any Code, USER or PRIVILEGED
34892 @@ -112,9 +113,9 @@
34893 ----------------------------------------------------------------------*/
34894
34895 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34896 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34897 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34898 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34899 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34900
34901 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34902 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34903 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34904 index af00795..2bb8105 100644
34905 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34906 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34907 @@ -11,6 +11,7 @@
34908 #ifndef _XTENSA_CORE_CONFIGURATION_H
34909 #define _XTENSA_CORE_CONFIGURATION_H
34910
34911 +#include <linux/const.h>
34912
34913 /****************************************************************************
34914 Parameters Useful for Any Code, USER or PRIVILEGED
34915 @@ -118,9 +119,9 @@
34916 ----------------------------------------------------------------------*/
34917
34918 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34919 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34920 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34921 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34922 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34923
34924 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34925 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34926 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34927 index 4e491d9..c8e18e4 100644
34928 --- a/block/blk-cgroup.c
34929 +++ b/block/blk-cgroup.c
34930 @@ -812,7 +812,7 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
34931 static struct cgroup_subsys_state *
34932 blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
34933 {
34934 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34935 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34936 struct blkcg *blkcg;
34937
34938 if (!parent_css) {
34939 @@ -826,7 +826,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
34940
34941 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34942 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34943 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34944 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34945 done:
34946 spin_lock_init(&blkcg->lock);
34947 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34948 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34949 index 4b8d9b54..a7178c0 100644
34950 --- a/block/blk-iopoll.c
34951 +++ b/block/blk-iopoll.c
34952 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34953 }
34954 EXPORT_SYMBOL(blk_iopoll_complete);
34955
34956 -static void blk_iopoll_softirq(struct softirq_action *h)
34957 +static __latent_entropy void blk_iopoll_softirq(void)
34958 {
34959 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34960 int rearm = 0, budget = blk_iopoll_budget;
34961 diff --git a/block/blk-map.c b/block/blk-map.c
34962 index 623e1cd..ca1e109 100644
34963 --- a/block/blk-map.c
34964 +++ b/block/blk-map.c
34965 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34966 if (!len || !kbuf)
34967 return -EINVAL;
34968
34969 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34970 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34971 if (do_copy)
34972 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34973 else
34974 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34975 index ec9e606..3f38839 100644
34976 --- a/block/blk-softirq.c
34977 +++ b/block/blk-softirq.c
34978 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34979 * Softirq action handler - move entries to local list and loop over them
34980 * while passing them to the queue registered handler.
34981 */
34982 -static void blk_done_softirq(struct softirq_action *h)
34983 +static __latent_entropy void blk_done_softirq(void)
34984 {
34985 struct list_head *cpu_list, local_list;
34986
34987 diff --git a/block/bsg.c b/block/bsg.c
34988 index 420a5a9..23834aa 100644
34989 --- a/block/bsg.c
34990 +++ b/block/bsg.c
34991 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34992 struct sg_io_v4 *hdr, struct bsg_device *bd,
34993 fmode_t has_write_perm)
34994 {
34995 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34996 + unsigned char *cmdptr;
34997 +
34998 if (hdr->request_len > BLK_MAX_CDB) {
34999 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
35000 if (!rq->cmd)
35001 return -ENOMEM;
35002 - }
35003 + cmdptr = rq->cmd;
35004 + } else
35005 + cmdptr = tmpcmd;
35006
35007 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
35008 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
35009 hdr->request_len))
35010 return -EFAULT;
35011
35012 + if (cmdptr != rq->cmd)
35013 + memcpy(rq->cmd, cmdptr, hdr->request_len);
35014 +
35015 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
35016 if (blk_verify_command(rq->cmd, has_write_perm))
35017 return -EPERM;
35018 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
35019 index fbd5a67..5d631b5 100644
35020 --- a/block/compat_ioctl.c
35021 +++ b/block/compat_ioctl.c
35022 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
35023 err |= __get_user(f->spec1, &uf->spec1);
35024 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
35025 err |= __get_user(name, &uf->name);
35026 - f->name = compat_ptr(name);
35027 + f->name = (void __force_kernel *)compat_ptr(name);
35028 if (err) {
35029 err = -EFAULT;
35030 goto out;
35031 diff --git a/block/genhd.c b/block/genhd.c
35032 index 791f419..89f21c4 100644
35033 --- a/block/genhd.c
35034 +++ b/block/genhd.c
35035 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
35036
35037 /*
35038 * Register device numbers dev..(dev+range-1)
35039 - * range must be nonzero
35040 + * Noop if @range is zero.
35041 * The hash chain is sorted on range, so that subranges can override.
35042 */
35043 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
35044 struct kobject *(*probe)(dev_t, int *, void *),
35045 int (*lock)(dev_t, void *), void *data)
35046 {
35047 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
35048 + if (range)
35049 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
35050 }
35051
35052 EXPORT_SYMBOL(blk_register_region);
35053
35054 +/* undo blk_register_region(), noop if @range is zero */
35055 void blk_unregister_region(dev_t devt, unsigned long range)
35056 {
35057 - kobj_unmap(bdev_map, devt, range);
35058 + if (range)
35059 + kobj_unmap(bdev_map, devt, range);
35060 }
35061
35062 EXPORT_SYMBOL(blk_unregister_region);
35063 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
35064 index a8287b4..241a48e 100644
35065 --- a/block/partitions/efi.c
35066 +++ b/block/partitions/efi.c
35067 @@ -292,14 +292,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
35068 if (!gpt)
35069 return NULL;
35070
35071 + if (!le32_to_cpu(gpt->num_partition_entries))
35072 + return NULL;
35073 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
35074 + if (!pte)
35075 + return NULL;
35076 +
35077 count = le32_to_cpu(gpt->num_partition_entries) *
35078 le32_to_cpu(gpt->sizeof_partition_entry);
35079 - if (!count)
35080 - return NULL;
35081 - pte = kmalloc(count, GFP_KERNEL);
35082 - if (!pte)
35083 - return NULL;
35084 -
35085 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
35086 (u8 *) pte, count) < count) {
35087 kfree(pte);
35088 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
35089 index a5ffcc9..e057498 100644
35090 --- a/block/scsi_ioctl.c
35091 +++ b/block/scsi_ioctl.c
35092 @@ -67,7 +67,7 @@ static int scsi_get_bus(struct request_queue *q, int __user *p)
35093 return put_user(0, p);
35094 }
35095
35096 -static int sg_get_timeout(struct request_queue *q)
35097 +static int __intentional_overflow(-1) sg_get_timeout(struct request_queue *q)
35098 {
35099 return jiffies_to_clock_t(q->sg_timeout);
35100 }
35101 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
35102 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
35103 struct sg_io_hdr *hdr, fmode_t mode)
35104 {
35105 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
35106 + unsigned char tmpcmd[sizeof(rq->__cmd)];
35107 + unsigned char *cmdptr;
35108 +
35109 + if (rq->cmd != rq->__cmd)
35110 + cmdptr = rq->cmd;
35111 + else
35112 + cmdptr = tmpcmd;
35113 +
35114 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
35115 return -EFAULT;
35116 +
35117 + if (cmdptr != rq->cmd)
35118 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
35119 +
35120 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
35121 return -EPERM;
35122
35123 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
35124 int err;
35125 unsigned int in_len, out_len, bytes, opcode, cmdlen;
35126 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
35127 + unsigned char tmpcmd[sizeof(rq->__cmd)];
35128 + unsigned char *cmdptr;
35129
35130 if (!sic)
35131 return -EINVAL;
35132 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
35133 */
35134 err = -EFAULT;
35135 rq->cmd_len = cmdlen;
35136 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
35137 +
35138 + if (rq->cmd != rq->__cmd)
35139 + cmdptr = rq->cmd;
35140 + else
35141 + cmdptr = tmpcmd;
35142 +
35143 + if (copy_from_user(cmdptr, sic->data, cmdlen))
35144 goto error;
35145
35146 + if (rq->cmd != cmdptr)
35147 + memcpy(rq->cmd, cmdptr, cmdlen);
35148 +
35149 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
35150 goto error;
35151
35152 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
35153 index 7bdd61b..afec999 100644
35154 --- a/crypto/cryptd.c
35155 +++ b/crypto/cryptd.c
35156 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
35157
35158 struct cryptd_blkcipher_request_ctx {
35159 crypto_completion_t complete;
35160 -};
35161 +} __no_const;
35162
35163 struct cryptd_hash_ctx {
35164 struct crypto_shash *child;
35165 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
35166
35167 struct cryptd_aead_request_ctx {
35168 crypto_completion_t complete;
35169 -};
35170 +} __no_const;
35171
35172 static void cryptd_queue_worker(struct work_struct *work);
35173
35174 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
35175 index f8c920c..ab2cb5a 100644
35176 --- a/crypto/pcrypt.c
35177 +++ b/crypto/pcrypt.c
35178 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
35179 int ret;
35180
35181 pinst->kobj.kset = pcrypt_kset;
35182 - ret = kobject_add(&pinst->kobj, NULL, name);
35183 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
35184 if (!ret)
35185 kobject_uevent(&pinst->kobj, KOBJ_ADD);
35186
35187 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
35188 index f220d64..d359ad6 100644
35189 --- a/drivers/acpi/apei/apei-internal.h
35190 +++ b/drivers/acpi/apei/apei-internal.h
35191 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
35192 struct apei_exec_ins_type {
35193 u32 flags;
35194 apei_exec_ins_func_t run;
35195 -};
35196 +} __do_const;
35197
35198 struct apei_exec_context {
35199 u32 ip;
35200 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
35201 index 33dc6a0..4b24b47 100644
35202 --- a/drivers/acpi/apei/cper.c
35203 +++ b/drivers/acpi/apei/cper.c
35204 @@ -39,12 +39,12 @@
35205 */
35206 u64 cper_next_record_id(void)
35207 {
35208 - static atomic64_t seq;
35209 + static atomic64_unchecked_t seq;
35210
35211 - if (!atomic64_read(&seq))
35212 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
35213 + if (!atomic64_read_unchecked(&seq))
35214 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
35215
35216 - return atomic64_inc_return(&seq);
35217 + return atomic64_inc_return_unchecked(&seq);
35218 }
35219 EXPORT_SYMBOL_GPL(cper_next_record_id);
35220
35221 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
35222 index 8ec37bb..b0716e5 100644
35223 --- a/drivers/acpi/apei/ghes.c
35224 +++ b/drivers/acpi/apei/ghes.c
35225 @@ -498,7 +498,7 @@ static void __ghes_print_estatus(const char *pfx,
35226 const struct acpi_hest_generic *generic,
35227 const struct acpi_hest_generic_status *estatus)
35228 {
35229 - static atomic_t seqno;
35230 + static atomic_unchecked_t seqno;
35231 unsigned int curr_seqno;
35232 char pfx_seq[64];
35233
35234 @@ -509,7 +509,7 @@ static void __ghes_print_estatus(const char *pfx,
35235 else
35236 pfx = KERN_ERR;
35237 }
35238 - curr_seqno = atomic_inc_return(&seqno);
35239 + curr_seqno = atomic_inc_return_unchecked(&seqno);
35240 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
35241 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
35242 pfx_seq, generic->header.source_id);
35243 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
35244 index a83e3c6..c3d617f 100644
35245 --- a/drivers/acpi/bgrt.c
35246 +++ b/drivers/acpi/bgrt.c
35247 @@ -86,8 +86,10 @@ static int __init bgrt_init(void)
35248 if (!bgrt_image)
35249 return -ENODEV;
35250
35251 - bin_attr_image.private = bgrt_image;
35252 - bin_attr_image.size = bgrt_image_size;
35253 + pax_open_kernel();
35254 + *(void **)&bin_attr_image.private = bgrt_image;
35255 + *(size_t *)&bin_attr_image.size = bgrt_image_size;
35256 + pax_close_kernel();
35257
35258 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
35259 if (!bgrt_kobj)
35260 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
35261 index 9515f18..4b149c9 100644
35262 --- a/drivers/acpi/blacklist.c
35263 +++ b/drivers/acpi/blacklist.c
35264 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
35265 u32 is_critical_error;
35266 };
35267
35268 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
35269 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
35270
35271 /*
35272 * POLICY: If *anything* doesn't work, put it on the blacklist.
35273 @@ -199,7 +199,7 @@ static int __init dmi_disable_osi_win8(const struct dmi_system_id *d)
35274 return 0;
35275 }
35276
35277 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
35278 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
35279 {
35280 .callback = dmi_disable_osi_vista,
35281 .ident = "Fujitsu Siemens",
35282 diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
35283 index 12b62f2..dc2aac8 100644
35284 --- a/drivers/acpi/custom_method.c
35285 +++ b/drivers/acpi/custom_method.c
35286 @@ -29,6 +29,10 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
35287 struct acpi_table_header table;
35288 acpi_status status;
35289
35290 +#ifdef CONFIG_GRKERNSEC_KMEM
35291 + return -EPERM;
35292 +#endif
35293 +
35294 if (!(*ppos)) {
35295 /* parse the table header to get the table length */
35296 if (count <= sizeof(struct acpi_table_header))
35297 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
35298 index c7414a5..d5afd71 100644
35299 --- a/drivers/acpi/processor_idle.c
35300 +++ b/drivers/acpi/processor_idle.c
35301 @@ -966,7 +966,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
35302 {
35303 int i, count = CPUIDLE_DRIVER_STATE_START;
35304 struct acpi_processor_cx *cx;
35305 - struct cpuidle_state *state;
35306 + cpuidle_state_no_const *state;
35307 struct cpuidle_driver *drv = &acpi_idle_driver;
35308
35309 if (!pr->flags.power_setup_done)
35310 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
35311 index 05306a5..733d1f0 100644
35312 --- a/drivers/acpi/sysfs.c
35313 +++ b/drivers/acpi/sysfs.c
35314 @@ -423,11 +423,11 @@ static u32 num_counters;
35315 static struct attribute **all_attrs;
35316 static u32 acpi_gpe_count;
35317
35318 -static struct attribute_group interrupt_stats_attr_group = {
35319 +static attribute_group_no_const interrupt_stats_attr_group = {
35320 .name = "interrupts",
35321 };
35322
35323 -static struct kobj_attribute *counter_attrs;
35324 +static kobj_attribute_no_const *counter_attrs;
35325
35326 static void delete_gpe_attr_array(void)
35327 {
35328 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
35329 index cfb7447..98f2149 100644
35330 --- a/drivers/ata/libahci.c
35331 +++ b/drivers/ata/libahci.c
35332 @@ -1239,7 +1239,7 @@ int ahci_kick_engine(struct ata_port *ap)
35333 }
35334 EXPORT_SYMBOL_GPL(ahci_kick_engine);
35335
35336 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
35337 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
35338 struct ata_taskfile *tf, int is_cmd, u16 flags,
35339 unsigned long timeout_msec)
35340 {
35341 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
35342 index 2c2780a..5ebc310 100644
35343 --- a/drivers/ata/libata-core.c
35344 +++ b/drivers/ata/libata-core.c
35345 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
35346 static void ata_dev_xfermask(struct ata_device *dev);
35347 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
35348
35349 -atomic_t ata_print_id = ATOMIC_INIT(0);
35350 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
35351
35352 struct ata_force_param {
35353 const char *name;
35354 @@ -4823,7 +4823,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
35355 struct ata_port *ap;
35356 unsigned int tag;
35357
35358 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35359 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35360 ap = qc->ap;
35361
35362 qc->flags = 0;
35363 @@ -4839,7 +4839,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
35364 struct ata_port *ap;
35365 struct ata_link *link;
35366
35367 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35368 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35369 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
35370 ap = qc->ap;
35371 link = qc->dev->link;
35372 @@ -5958,6 +5958,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
35373 return;
35374
35375 spin_lock(&lock);
35376 + pax_open_kernel();
35377
35378 for (cur = ops->inherits; cur; cur = cur->inherits) {
35379 void **inherit = (void **)cur;
35380 @@ -5971,8 +5972,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
35381 if (IS_ERR(*pp))
35382 *pp = NULL;
35383
35384 - ops->inherits = NULL;
35385 + *(struct ata_port_operations **)&ops->inherits = NULL;
35386
35387 + pax_close_kernel();
35388 spin_unlock(&lock);
35389 }
35390
35391 @@ -6165,7 +6167,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
35392
35393 /* give ports names and add SCSI hosts */
35394 for (i = 0; i < host->n_ports; i++) {
35395 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
35396 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
35397 host->ports[i]->local_port_no = i + 1;
35398 }
35399
35400 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
35401 index 377eb88..8591b44 100644
35402 --- a/drivers/ata/libata-scsi.c
35403 +++ b/drivers/ata/libata-scsi.c
35404 @@ -4135,7 +4135,7 @@ int ata_sas_port_init(struct ata_port *ap)
35405
35406 if (rc)
35407 return rc;
35408 - ap->print_id = atomic_inc_return(&ata_print_id);
35409 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
35410 return 0;
35411 }
35412 EXPORT_SYMBOL_GPL(ata_sas_port_init);
35413 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
35414 index 45b5ab3..98446b8 100644
35415 --- a/drivers/ata/libata.h
35416 +++ b/drivers/ata/libata.h
35417 @@ -53,7 +53,7 @@ enum {
35418 ATA_DNXFER_QUIET = (1 << 31),
35419 };
35420
35421 -extern atomic_t ata_print_id;
35422 +extern atomic_unchecked_t ata_print_id;
35423 extern int atapi_passthru16;
35424 extern int libata_fua;
35425 extern int libata_noacpi;
35426 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
35427 index 853f610..97d24da 100644
35428 --- a/drivers/ata/pata_arasan_cf.c
35429 +++ b/drivers/ata/pata_arasan_cf.c
35430 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
35431 /* Handle platform specific quirks */
35432 if (quirk) {
35433 if (quirk & CF_BROKEN_PIO) {
35434 - ap->ops->set_piomode = NULL;
35435 + pax_open_kernel();
35436 + *(void **)&ap->ops->set_piomode = NULL;
35437 + pax_close_kernel();
35438 ap->pio_mask = 0;
35439 }
35440 if (quirk & CF_BROKEN_MWDMA)
35441 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
35442 index f9b983a..887b9d8 100644
35443 --- a/drivers/atm/adummy.c
35444 +++ b/drivers/atm/adummy.c
35445 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
35446 vcc->pop(vcc, skb);
35447 else
35448 dev_kfree_skb_any(skb);
35449 - atomic_inc(&vcc->stats->tx);
35450 + atomic_inc_unchecked(&vcc->stats->tx);
35451
35452 return 0;
35453 }
35454 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
35455 index 62a7607..cc4be104 100644
35456 --- a/drivers/atm/ambassador.c
35457 +++ b/drivers/atm/ambassador.c
35458 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
35459 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
35460
35461 // VC layer stats
35462 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35463 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35464
35465 // free the descriptor
35466 kfree (tx_descr);
35467 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
35468 dump_skb ("<<<", vc, skb);
35469
35470 // VC layer stats
35471 - atomic_inc(&atm_vcc->stats->rx);
35472 + atomic_inc_unchecked(&atm_vcc->stats->rx);
35473 __net_timestamp(skb);
35474 // end of our responsibility
35475 atm_vcc->push (atm_vcc, skb);
35476 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
35477 } else {
35478 PRINTK (KERN_INFO, "dropped over-size frame");
35479 // should we count this?
35480 - atomic_inc(&atm_vcc->stats->rx_drop);
35481 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35482 }
35483
35484 } else {
35485 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
35486 }
35487
35488 if (check_area (skb->data, skb->len)) {
35489 - atomic_inc(&atm_vcc->stats->tx_err);
35490 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
35491 return -ENOMEM; // ?
35492 }
35493
35494 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
35495 index 0e3f8f9..765a7a5 100644
35496 --- a/drivers/atm/atmtcp.c
35497 +++ b/drivers/atm/atmtcp.c
35498 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
35499 if (vcc->pop) vcc->pop(vcc,skb);
35500 else dev_kfree_skb(skb);
35501 if (dev_data) return 0;
35502 - atomic_inc(&vcc->stats->tx_err);
35503 + atomic_inc_unchecked(&vcc->stats->tx_err);
35504 return -ENOLINK;
35505 }
35506 size = skb->len+sizeof(struct atmtcp_hdr);
35507 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
35508 if (!new_skb) {
35509 if (vcc->pop) vcc->pop(vcc,skb);
35510 else dev_kfree_skb(skb);
35511 - atomic_inc(&vcc->stats->tx_err);
35512 + atomic_inc_unchecked(&vcc->stats->tx_err);
35513 return -ENOBUFS;
35514 }
35515 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
35516 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
35517 if (vcc->pop) vcc->pop(vcc,skb);
35518 else dev_kfree_skb(skb);
35519 out_vcc->push(out_vcc,new_skb);
35520 - atomic_inc(&vcc->stats->tx);
35521 - atomic_inc(&out_vcc->stats->rx);
35522 + atomic_inc_unchecked(&vcc->stats->tx);
35523 + atomic_inc_unchecked(&out_vcc->stats->rx);
35524 return 0;
35525 }
35526
35527 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
35528 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
35529 read_unlock(&vcc_sklist_lock);
35530 if (!out_vcc) {
35531 - atomic_inc(&vcc->stats->tx_err);
35532 + atomic_inc_unchecked(&vcc->stats->tx_err);
35533 goto done;
35534 }
35535 skb_pull(skb,sizeof(struct atmtcp_hdr));
35536 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
35537 __net_timestamp(new_skb);
35538 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
35539 out_vcc->push(out_vcc,new_skb);
35540 - atomic_inc(&vcc->stats->tx);
35541 - atomic_inc(&out_vcc->stats->rx);
35542 + atomic_inc_unchecked(&vcc->stats->tx);
35543 + atomic_inc_unchecked(&out_vcc->stats->rx);
35544 done:
35545 if (vcc->pop) vcc->pop(vcc,skb);
35546 else dev_kfree_skb(skb);
35547 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
35548 index b1955ba..b179940 100644
35549 --- a/drivers/atm/eni.c
35550 +++ b/drivers/atm/eni.c
35551 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
35552 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
35553 vcc->dev->number);
35554 length = 0;
35555 - atomic_inc(&vcc->stats->rx_err);
35556 + atomic_inc_unchecked(&vcc->stats->rx_err);
35557 }
35558 else {
35559 length = ATM_CELL_SIZE-1; /* no HEC */
35560 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
35561 size);
35562 }
35563 eff = length = 0;
35564 - atomic_inc(&vcc->stats->rx_err);
35565 + atomic_inc_unchecked(&vcc->stats->rx_err);
35566 }
35567 else {
35568 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
35569 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
35570 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
35571 vcc->dev->number,vcc->vci,length,size << 2,descr);
35572 length = eff = 0;
35573 - atomic_inc(&vcc->stats->rx_err);
35574 + atomic_inc_unchecked(&vcc->stats->rx_err);
35575 }
35576 }
35577 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
35578 @@ -767,7 +767,7 @@ rx_dequeued++;
35579 vcc->push(vcc,skb);
35580 pushed++;
35581 }
35582 - atomic_inc(&vcc->stats->rx);
35583 + atomic_inc_unchecked(&vcc->stats->rx);
35584 }
35585 wake_up(&eni_dev->rx_wait);
35586 }
35587 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
35588 PCI_DMA_TODEVICE);
35589 if (vcc->pop) vcc->pop(vcc,skb);
35590 else dev_kfree_skb_irq(skb);
35591 - atomic_inc(&vcc->stats->tx);
35592 + atomic_inc_unchecked(&vcc->stats->tx);
35593 wake_up(&eni_dev->tx_wait);
35594 dma_complete++;
35595 }
35596 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
35597 index b41c948..a002b17 100644
35598 --- a/drivers/atm/firestream.c
35599 +++ b/drivers/atm/firestream.c
35600 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
35601 }
35602 }
35603
35604 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35605 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35606
35607 fs_dprintk (FS_DEBUG_TXMEM, "i");
35608 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
35609 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
35610 #endif
35611 skb_put (skb, qe->p1 & 0xffff);
35612 ATM_SKB(skb)->vcc = atm_vcc;
35613 - atomic_inc(&atm_vcc->stats->rx);
35614 + atomic_inc_unchecked(&atm_vcc->stats->rx);
35615 __net_timestamp(skb);
35616 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
35617 atm_vcc->push (atm_vcc, skb);
35618 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
35619 kfree (pe);
35620 }
35621 if (atm_vcc)
35622 - atomic_inc(&atm_vcc->stats->rx_drop);
35623 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35624 break;
35625 case 0x1f: /* Reassembly abort: no buffers. */
35626 /* Silently increment error counter. */
35627 if (atm_vcc)
35628 - atomic_inc(&atm_vcc->stats->rx_drop);
35629 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35630 break;
35631 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
35632 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
35633 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
35634 index 204814e..cede831 100644
35635 --- a/drivers/atm/fore200e.c
35636 +++ b/drivers/atm/fore200e.c
35637 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
35638 #endif
35639 /* check error condition */
35640 if (*entry->status & STATUS_ERROR)
35641 - atomic_inc(&vcc->stats->tx_err);
35642 + atomic_inc_unchecked(&vcc->stats->tx_err);
35643 else
35644 - atomic_inc(&vcc->stats->tx);
35645 + atomic_inc_unchecked(&vcc->stats->tx);
35646 }
35647 }
35648
35649 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35650 if (skb == NULL) {
35651 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
35652
35653 - atomic_inc(&vcc->stats->rx_drop);
35654 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35655 return -ENOMEM;
35656 }
35657
35658 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35659
35660 dev_kfree_skb_any(skb);
35661
35662 - atomic_inc(&vcc->stats->rx_drop);
35663 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35664 return -ENOMEM;
35665 }
35666
35667 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35668
35669 vcc->push(vcc, skb);
35670 - atomic_inc(&vcc->stats->rx);
35671 + atomic_inc_unchecked(&vcc->stats->rx);
35672
35673 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35674
35675 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35676 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35677 fore200e->atm_dev->number,
35678 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35679 - atomic_inc(&vcc->stats->rx_err);
35680 + atomic_inc_unchecked(&vcc->stats->rx_err);
35681 }
35682 }
35683
35684 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35685 goto retry_here;
35686 }
35687
35688 - atomic_inc(&vcc->stats->tx_err);
35689 + atomic_inc_unchecked(&vcc->stats->tx_err);
35690
35691 fore200e->tx_sat++;
35692 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35693 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35694 index 8557adc..3fb5d55 100644
35695 --- a/drivers/atm/he.c
35696 +++ b/drivers/atm/he.c
35697 @@ -1691,7 +1691,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35698
35699 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35700 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35701 - atomic_inc(&vcc->stats->rx_drop);
35702 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35703 goto return_host_buffers;
35704 }
35705
35706 @@ -1718,7 +1718,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35707 RBRQ_LEN_ERR(he_dev->rbrq_head)
35708 ? "LEN_ERR" : "",
35709 vcc->vpi, vcc->vci);
35710 - atomic_inc(&vcc->stats->rx_err);
35711 + atomic_inc_unchecked(&vcc->stats->rx_err);
35712 goto return_host_buffers;
35713 }
35714
35715 @@ -1770,7 +1770,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35716 vcc->push(vcc, skb);
35717 spin_lock(&he_dev->global_lock);
35718
35719 - atomic_inc(&vcc->stats->rx);
35720 + atomic_inc_unchecked(&vcc->stats->rx);
35721
35722 return_host_buffers:
35723 ++pdus_assembled;
35724 @@ -2096,7 +2096,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35725 tpd->vcc->pop(tpd->vcc, tpd->skb);
35726 else
35727 dev_kfree_skb_any(tpd->skb);
35728 - atomic_inc(&tpd->vcc->stats->tx_err);
35729 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35730 }
35731 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35732 return;
35733 @@ -2508,7 +2508,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35734 vcc->pop(vcc, skb);
35735 else
35736 dev_kfree_skb_any(skb);
35737 - atomic_inc(&vcc->stats->tx_err);
35738 + atomic_inc_unchecked(&vcc->stats->tx_err);
35739 return -EINVAL;
35740 }
35741
35742 @@ -2519,7 +2519,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35743 vcc->pop(vcc, skb);
35744 else
35745 dev_kfree_skb_any(skb);
35746 - atomic_inc(&vcc->stats->tx_err);
35747 + atomic_inc_unchecked(&vcc->stats->tx_err);
35748 return -EINVAL;
35749 }
35750 #endif
35751 @@ -2531,7 +2531,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35752 vcc->pop(vcc, skb);
35753 else
35754 dev_kfree_skb_any(skb);
35755 - atomic_inc(&vcc->stats->tx_err);
35756 + atomic_inc_unchecked(&vcc->stats->tx_err);
35757 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35758 return -ENOMEM;
35759 }
35760 @@ -2573,7 +2573,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35761 vcc->pop(vcc, skb);
35762 else
35763 dev_kfree_skb_any(skb);
35764 - atomic_inc(&vcc->stats->tx_err);
35765 + atomic_inc_unchecked(&vcc->stats->tx_err);
35766 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35767 return -ENOMEM;
35768 }
35769 @@ -2604,7 +2604,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35770 __enqueue_tpd(he_dev, tpd, cid);
35771 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35772
35773 - atomic_inc(&vcc->stats->tx);
35774 + atomic_inc_unchecked(&vcc->stats->tx);
35775
35776 return 0;
35777 }
35778 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35779 index 1dc0519..1aadaf7 100644
35780 --- a/drivers/atm/horizon.c
35781 +++ b/drivers/atm/horizon.c
35782 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35783 {
35784 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35785 // VC layer stats
35786 - atomic_inc(&vcc->stats->rx);
35787 + atomic_inc_unchecked(&vcc->stats->rx);
35788 __net_timestamp(skb);
35789 // end of our responsibility
35790 vcc->push (vcc, skb);
35791 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35792 dev->tx_iovec = NULL;
35793
35794 // VC layer stats
35795 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35796 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35797
35798 // free the skb
35799 hrz_kfree_skb (skb);
35800 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35801 index 1bdf104..9dc44b1 100644
35802 --- a/drivers/atm/idt77252.c
35803 +++ b/drivers/atm/idt77252.c
35804 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35805 else
35806 dev_kfree_skb(skb);
35807
35808 - atomic_inc(&vcc->stats->tx);
35809 + atomic_inc_unchecked(&vcc->stats->tx);
35810 }
35811
35812 atomic_dec(&scq->used);
35813 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35814 if ((sb = dev_alloc_skb(64)) == NULL) {
35815 printk("%s: Can't allocate buffers for aal0.\n",
35816 card->name);
35817 - atomic_add(i, &vcc->stats->rx_drop);
35818 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35819 break;
35820 }
35821 if (!atm_charge(vcc, sb->truesize)) {
35822 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35823 card->name);
35824 - atomic_add(i - 1, &vcc->stats->rx_drop);
35825 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35826 dev_kfree_skb(sb);
35827 break;
35828 }
35829 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35830 ATM_SKB(sb)->vcc = vcc;
35831 __net_timestamp(sb);
35832 vcc->push(vcc, sb);
35833 - atomic_inc(&vcc->stats->rx);
35834 + atomic_inc_unchecked(&vcc->stats->rx);
35835
35836 cell += ATM_CELL_PAYLOAD;
35837 }
35838 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35839 "(CDC: %08x)\n",
35840 card->name, len, rpp->len, readl(SAR_REG_CDC));
35841 recycle_rx_pool_skb(card, rpp);
35842 - atomic_inc(&vcc->stats->rx_err);
35843 + atomic_inc_unchecked(&vcc->stats->rx_err);
35844 return;
35845 }
35846 if (stat & SAR_RSQE_CRC) {
35847 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35848 recycle_rx_pool_skb(card, rpp);
35849 - atomic_inc(&vcc->stats->rx_err);
35850 + atomic_inc_unchecked(&vcc->stats->rx_err);
35851 return;
35852 }
35853 if (skb_queue_len(&rpp->queue) > 1) {
35854 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35855 RXPRINTK("%s: Can't alloc RX skb.\n",
35856 card->name);
35857 recycle_rx_pool_skb(card, rpp);
35858 - atomic_inc(&vcc->stats->rx_err);
35859 + atomic_inc_unchecked(&vcc->stats->rx_err);
35860 return;
35861 }
35862 if (!atm_charge(vcc, skb->truesize)) {
35863 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35864 __net_timestamp(skb);
35865
35866 vcc->push(vcc, skb);
35867 - atomic_inc(&vcc->stats->rx);
35868 + atomic_inc_unchecked(&vcc->stats->rx);
35869
35870 return;
35871 }
35872 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35873 __net_timestamp(skb);
35874
35875 vcc->push(vcc, skb);
35876 - atomic_inc(&vcc->stats->rx);
35877 + atomic_inc_unchecked(&vcc->stats->rx);
35878
35879 if (skb->truesize > SAR_FB_SIZE_3)
35880 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35881 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35882 if (vcc->qos.aal != ATM_AAL0) {
35883 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35884 card->name, vpi, vci);
35885 - atomic_inc(&vcc->stats->rx_drop);
35886 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35887 goto drop;
35888 }
35889
35890 if ((sb = dev_alloc_skb(64)) == NULL) {
35891 printk("%s: Can't allocate buffers for AAL0.\n",
35892 card->name);
35893 - atomic_inc(&vcc->stats->rx_err);
35894 + atomic_inc_unchecked(&vcc->stats->rx_err);
35895 goto drop;
35896 }
35897
35898 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35899 ATM_SKB(sb)->vcc = vcc;
35900 __net_timestamp(sb);
35901 vcc->push(vcc, sb);
35902 - atomic_inc(&vcc->stats->rx);
35903 + atomic_inc_unchecked(&vcc->stats->rx);
35904
35905 drop:
35906 skb_pull(queue, 64);
35907 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35908
35909 if (vc == NULL) {
35910 printk("%s: NULL connection in send().\n", card->name);
35911 - atomic_inc(&vcc->stats->tx_err);
35912 + atomic_inc_unchecked(&vcc->stats->tx_err);
35913 dev_kfree_skb(skb);
35914 return -EINVAL;
35915 }
35916 if (!test_bit(VCF_TX, &vc->flags)) {
35917 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35918 - atomic_inc(&vcc->stats->tx_err);
35919 + atomic_inc_unchecked(&vcc->stats->tx_err);
35920 dev_kfree_skb(skb);
35921 return -EINVAL;
35922 }
35923 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35924 break;
35925 default:
35926 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35927 - atomic_inc(&vcc->stats->tx_err);
35928 + atomic_inc_unchecked(&vcc->stats->tx_err);
35929 dev_kfree_skb(skb);
35930 return -EINVAL;
35931 }
35932
35933 if (skb_shinfo(skb)->nr_frags != 0) {
35934 printk("%s: No scatter-gather yet.\n", card->name);
35935 - atomic_inc(&vcc->stats->tx_err);
35936 + atomic_inc_unchecked(&vcc->stats->tx_err);
35937 dev_kfree_skb(skb);
35938 return -EINVAL;
35939 }
35940 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35941
35942 err = queue_skb(card, vc, skb, oam);
35943 if (err) {
35944 - atomic_inc(&vcc->stats->tx_err);
35945 + atomic_inc_unchecked(&vcc->stats->tx_err);
35946 dev_kfree_skb(skb);
35947 return err;
35948 }
35949 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35950 skb = dev_alloc_skb(64);
35951 if (!skb) {
35952 printk("%s: Out of memory in send_oam().\n", card->name);
35953 - atomic_inc(&vcc->stats->tx_err);
35954 + atomic_inc_unchecked(&vcc->stats->tx_err);
35955 return -ENOMEM;
35956 }
35957 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35958 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35959 index 4217f29..88f547a 100644
35960 --- a/drivers/atm/iphase.c
35961 +++ b/drivers/atm/iphase.c
35962 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35963 status = (u_short) (buf_desc_ptr->desc_mode);
35964 if (status & (RX_CER | RX_PTE | RX_OFL))
35965 {
35966 - atomic_inc(&vcc->stats->rx_err);
35967 + atomic_inc_unchecked(&vcc->stats->rx_err);
35968 IF_ERR(printk("IA: bad packet, dropping it");)
35969 if (status & RX_CER) {
35970 IF_ERR(printk(" cause: packet CRC error\n");)
35971 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35972 len = dma_addr - buf_addr;
35973 if (len > iadev->rx_buf_sz) {
35974 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35975 - atomic_inc(&vcc->stats->rx_err);
35976 + atomic_inc_unchecked(&vcc->stats->rx_err);
35977 goto out_free_desc;
35978 }
35979
35980 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35981 ia_vcc = INPH_IA_VCC(vcc);
35982 if (ia_vcc == NULL)
35983 {
35984 - atomic_inc(&vcc->stats->rx_err);
35985 + atomic_inc_unchecked(&vcc->stats->rx_err);
35986 atm_return(vcc, skb->truesize);
35987 dev_kfree_skb_any(skb);
35988 goto INCR_DLE;
35989 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35990 if ((length > iadev->rx_buf_sz) || (length >
35991 (skb->len - sizeof(struct cpcs_trailer))))
35992 {
35993 - atomic_inc(&vcc->stats->rx_err);
35994 + atomic_inc_unchecked(&vcc->stats->rx_err);
35995 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35996 length, skb->len);)
35997 atm_return(vcc, skb->truesize);
35998 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35999
36000 IF_RX(printk("rx_dle_intr: skb push");)
36001 vcc->push(vcc,skb);
36002 - atomic_inc(&vcc->stats->rx);
36003 + atomic_inc_unchecked(&vcc->stats->rx);
36004 iadev->rx_pkt_cnt++;
36005 }
36006 INCR_DLE:
36007 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
36008 {
36009 struct k_sonet_stats *stats;
36010 stats = &PRIV(_ia_dev[board])->sonet_stats;
36011 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
36012 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
36013 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
36014 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
36015 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
36016 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
36017 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
36018 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
36019 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
36020 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
36021 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
36022 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
36023 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
36024 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
36025 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
36026 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
36027 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
36028 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
36029 }
36030 ia_cmds.status = 0;
36031 break;
36032 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
36033 if ((desc == 0) || (desc > iadev->num_tx_desc))
36034 {
36035 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
36036 - atomic_inc(&vcc->stats->tx);
36037 + atomic_inc_unchecked(&vcc->stats->tx);
36038 if (vcc->pop)
36039 vcc->pop(vcc, skb);
36040 else
36041 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
36042 ATM_DESC(skb) = vcc->vci;
36043 skb_queue_tail(&iadev->tx_dma_q, skb);
36044
36045 - atomic_inc(&vcc->stats->tx);
36046 + atomic_inc_unchecked(&vcc->stats->tx);
36047 iadev->tx_pkt_cnt++;
36048 /* Increment transaction counter */
36049 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
36050
36051 #if 0
36052 /* add flow control logic */
36053 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
36054 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
36055 if (iavcc->vc_desc_cnt > 10) {
36056 vcc->tx_quota = vcc->tx_quota * 3 / 4;
36057 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
36058 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
36059 index fa7d701..1e404c7 100644
36060 --- a/drivers/atm/lanai.c
36061 +++ b/drivers/atm/lanai.c
36062 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
36063 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
36064 lanai_endtx(lanai, lvcc);
36065 lanai_free_skb(lvcc->tx.atmvcc, skb);
36066 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
36067 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
36068 }
36069
36070 /* Try to fill the buffer - don't call unless there is backlog */
36071 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
36072 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
36073 __net_timestamp(skb);
36074 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
36075 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
36076 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
36077 out:
36078 lvcc->rx.buf.ptr = end;
36079 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
36080 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36081 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
36082 "vcc %d\n", lanai->number, (unsigned int) s, vci);
36083 lanai->stats.service_rxnotaal5++;
36084 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36085 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36086 return 0;
36087 }
36088 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
36089 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36090 int bytes;
36091 read_unlock(&vcc_sklist_lock);
36092 DPRINTK("got trashed rx pdu on vci %d\n", vci);
36093 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36094 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36095 lvcc->stats.x.aal5.service_trash++;
36096 bytes = (SERVICE_GET_END(s) * 16) -
36097 (((unsigned long) lvcc->rx.buf.ptr) -
36098 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36099 }
36100 if (s & SERVICE_STREAM) {
36101 read_unlock(&vcc_sklist_lock);
36102 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36103 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36104 lvcc->stats.x.aal5.service_stream++;
36105 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
36106 "PDU on VCI %d!\n", lanai->number, vci);
36107 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36108 return 0;
36109 }
36110 DPRINTK("got rx crc error on vci %d\n", vci);
36111 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36112 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36113 lvcc->stats.x.aal5.service_rxcrc++;
36114 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
36115 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
36116 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
36117 index 5aca5f4..ce3a6b0 100644
36118 --- a/drivers/atm/nicstar.c
36119 +++ b/drivers/atm/nicstar.c
36120 @@ -1640,7 +1640,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
36121 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
36122 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
36123 card->index);
36124 - atomic_inc(&vcc->stats->tx_err);
36125 + atomic_inc_unchecked(&vcc->stats->tx_err);
36126 dev_kfree_skb_any(skb);
36127 return -EINVAL;
36128 }
36129 @@ -1648,7 +1648,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
36130 if (!vc->tx) {
36131 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
36132 card->index);
36133 - atomic_inc(&vcc->stats->tx_err);
36134 + atomic_inc_unchecked(&vcc->stats->tx_err);
36135 dev_kfree_skb_any(skb);
36136 return -EINVAL;
36137 }
36138 @@ -1656,14 +1656,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
36139 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
36140 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
36141 card->index);
36142 - atomic_inc(&vcc->stats->tx_err);
36143 + atomic_inc_unchecked(&vcc->stats->tx_err);
36144 dev_kfree_skb_any(skb);
36145 return -EINVAL;
36146 }
36147
36148 if (skb_shinfo(skb)->nr_frags != 0) {
36149 printk("nicstar%d: No scatter-gather yet.\n", card->index);
36150 - atomic_inc(&vcc->stats->tx_err);
36151 + atomic_inc_unchecked(&vcc->stats->tx_err);
36152 dev_kfree_skb_any(skb);
36153 return -EINVAL;
36154 }
36155 @@ -1711,11 +1711,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
36156 }
36157
36158 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
36159 - atomic_inc(&vcc->stats->tx_err);
36160 + atomic_inc_unchecked(&vcc->stats->tx_err);
36161 dev_kfree_skb_any(skb);
36162 return -EIO;
36163 }
36164 - atomic_inc(&vcc->stats->tx);
36165 + atomic_inc_unchecked(&vcc->stats->tx);
36166
36167 return 0;
36168 }
36169 @@ -2032,14 +2032,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36170 printk
36171 ("nicstar%d: Can't allocate buffers for aal0.\n",
36172 card->index);
36173 - atomic_add(i, &vcc->stats->rx_drop);
36174 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
36175 break;
36176 }
36177 if (!atm_charge(vcc, sb->truesize)) {
36178 RXPRINTK
36179 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
36180 card->index);
36181 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
36182 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
36183 dev_kfree_skb_any(sb);
36184 break;
36185 }
36186 @@ -2054,7 +2054,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36187 ATM_SKB(sb)->vcc = vcc;
36188 __net_timestamp(sb);
36189 vcc->push(vcc, sb);
36190 - atomic_inc(&vcc->stats->rx);
36191 + atomic_inc_unchecked(&vcc->stats->rx);
36192 cell += ATM_CELL_PAYLOAD;
36193 }
36194
36195 @@ -2071,7 +2071,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36196 if (iovb == NULL) {
36197 printk("nicstar%d: Out of iovec buffers.\n",
36198 card->index);
36199 - atomic_inc(&vcc->stats->rx_drop);
36200 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36201 recycle_rx_buf(card, skb);
36202 return;
36203 }
36204 @@ -2095,7 +2095,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36205 small or large buffer itself. */
36206 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
36207 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
36208 - atomic_inc(&vcc->stats->rx_err);
36209 + atomic_inc_unchecked(&vcc->stats->rx_err);
36210 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
36211 NS_MAX_IOVECS);
36212 NS_PRV_IOVCNT(iovb) = 0;
36213 @@ -2115,7 +2115,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36214 ("nicstar%d: Expected a small buffer, and this is not one.\n",
36215 card->index);
36216 which_list(card, skb);
36217 - atomic_inc(&vcc->stats->rx_err);
36218 + atomic_inc_unchecked(&vcc->stats->rx_err);
36219 recycle_rx_buf(card, skb);
36220 vc->rx_iov = NULL;
36221 recycle_iov_buf(card, iovb);
36222 @@ -2128,7 +2128,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36223 ("nicstar%d: Expected a large buffer, and this is not one.\n",
36224 card->index);
36225 which_list(card, skb);
36226 - atomic_inc(&vcc->stats->rx_err);
36227 + atomic_inc_unchecked(&vcc->stats->rx_err);
36228 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
36229 NS_PRV_IOVCNT(iovb));
36230 vc->rx_iov = NULL;
36231 @@ -2151,7 +2151,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36232 printk(" - PDU size mismatch.\n");
36233 else
36234 printk(".\n");
36235 - atomic_inc(&vcc->stats->rx_err);
36236 + atomic_inc_unchecked(&vcc->stats->rx_err);
36237 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
36238 NS_PRV_IOVCNT(iovb));
36239 vc->rx_iov = NULL;
36240 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36241 /* skb points to a small buffer */
36242 if (!atm_charge(vcc, skb->truesize)) {
36243 push_rxbufs(card, skb);
36244 - atomic_inc(&vcc->stats->rx_drop);
36245 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36246 } else {
36247 skb_put(skb, len);
36248 dequeue_sm_buf(card, skb);
36249 @@ -2175,7 +2175,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36250 ATM_SKB(skb)->vcc = vcc;
36251 __net_timestamp(skb);
36252 vcc->push(vcc, skb);
36253 - atomic_inc(&vcc->stats->rx);
36254 + atomic_inc_unchecked(&vcc->stats->rx);
36255 }
36256 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
36257 struct sk_buff *sb;
36258 @@ -2186,7 +2186,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36259 if (len <= NS_SMBUFSIZE) {
36260 if (!atm_charge(vcc, sb->truesize)) {
36261 push_rxbufs(card, sb);
36262 - atomic_inc(&vcc->stats->rx_drop);
36263 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36264 } else {
36265 skb_put(sb, len);
36266 dequeue_sm_buf(card, sb);
36267 @@ -2196,7 +2196,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36268 ATM_SKB(sb)->vcc = vcc;
36269 __net_timestamp(sb);
36270 vcc->push(vcc, sb);
36271 - atomic_inc(&vcc->stats->rx);
36272 + atomic_inc_unchecked(&vcc->stats->rx);
36273 }
36274
36275 push_rxbufs(card, skb);
36276 @@ -2205,7 +2205,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36277
36278 if (!atm_charge(vcc, skb->truesize)) {
36279 push_rxbufs(card, skb);
36280 - atomic_inc(&vcc->stats->rx_drop);
36281 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36282 } else {
36283 dequeue_lg_buf(card, skb);
36284 #ifdef NS_USE_DESTRUCTORS
36285 @@ -2218,7 +2218,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36286 ATM_SKB(skb)->vcc = vcc;
36287 __net_timestamp(skb);
36288 vcc->push(vcc, skb);
36289 - atomic_inc(&vcc->stats->rx);
36290 + atomic_inc_unchecked(&vcc->stats->rx);
36291 }
36292
36293 push_rxbufs(card, sb);
36294 @@ -2239,7 +2239,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36295 printk
36296 ("nicstar%d: Out of huge buffers.\n",
36297 card->index);
36298 - atomic_inc(&vcc->stats->rx_drop);
36299 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36300 recycle_iovec_rx_bufs(card,
36301 (struct iovec *)
36302 iovb->data,
36303 @@ -2290,7 +2290,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36304 card->hbpool.count++;
36305 } else
36306 dev_kfree_skb_any(hb);
36307 - atomic_inc(&vcc->stats->rx_drop);
36308 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36309 } else {
36310 /* Copy the small buffer to the huge buffer */
36311 sb = (struct sk_buff *)iov->iov_base;
36312 @@ -2327,7 +2327,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36313 #endif /* NS_USE_DESTRUCTORS */
36314 __net_timestamp(hb);
36315 vcc->push(vcc, hb);
36316 - atomic_inc(&vcc->stats->rx);
36317 + atomic_inc_unchecked(&vcc->stats->rx);
36318 }
36319 }
36320
36321 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
36322 index 32784d1..4a8434a 100644
36323 --- a/drivers/atm/solos-pci.c
36324 +++ b/drivers/atm/solos-pci.c
36325 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
36326 }
36327 atm_charge(vcc, skb->truesize);
36328 vcc->push(vcc, skb);
36329 - atomic_inc(&vcc->stats->rx);
36330 + atomic_inc_unchecked(&vcc->stats->rx);
36331 break;
36332
36333 case PKT_STATUS:
36334 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
36335 vcc = SKB_CB(oldskb)->vcc;
36336
36337 if (vcc) {
36338 - atomic_inc(&vcc->stats->tx);
36339 + atomic_inc_unchecked(&vcc->stats->tx);
36340 solos_pop(vcc, oldskb);
36341 } else {
36342 dev_kfree_skb_irq(oldskb);
36343 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
36344 index 0215934..ce9f5b1 100644
36345 --- a/drivers/atm/suni.c
36346 +++ b/drivers/atm/suni.c
36347 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
36348
36349
36350 #define ADD_LIMITED(s,v) \
36351 - atomic_add((v),&stats->s); \
36352 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
36353 + atomic_add_unchecked((v),&stats->s); \
36354 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
36355
36356
36357 static void suni_hz(unsigned long from_timer)
36358 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
36359 index 5120a96..e2572bd 100644
36360 --- a/drivers/atm/uPD98402.c
36361 +++ b/drivers/atm/uPD98402.c
36362 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
36363 struct sonet_stats tmp;
36364 int error = 0;
36365
36366 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
36367 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
36368 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
36369 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
36370 if (zero && !error) {
36371 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
36372
36373
36374 #define ADD_LIMITED(s,v) \
36375 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
36376 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
36377 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
36378 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
36379 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
36380 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
36381
36382
36383 static void stat_event(struct atm_dev *dev)
36384 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
36385 if (reason & uPD98402_INT_PFM) stat_event(dev);
36386 if (reason & uPD98402_INT_PCO) {
36387 (void) GET(PCOCR); /* clear interrupt cause */
36388 - atomic_add(GET(HECCT),
36389 + atomic_add_unchecked(GET(HECCT),
36390 &PRIV(dev)->sonet_stats.uncorr_hcs);
36391 }
36392 if ((reason & uPD98402_INT_RFO) &&
36393 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
36394 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
36395 uPD98402_INT_LOS),PIMR); /* enable them */
36396 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
36397 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
36398 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
36399 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
36400 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
36401 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
36402 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
36403 return 0;
36404 }
36405
36406 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
36407 index 969c3c2..9b72956 100644
36408 --- a/drivers/atm/zatm.c
36409 +++ b/drivers/atm/zatm.c
36410 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
36411 }
36412 if (!size) {
36413 dev_kfree_skb_irq(skb);
36414 - if (vcc) atomic_inc(&vcc->stats->rx_err);
36415 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
36416 continue;
36417 }
36418 if (!atm_charge(vcc,skb->truesize)) {
36419 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
36420 skb->len = size;
36421 ATM_SKB(skb)->vcc = vcc;
36422 vcc->push(vcc,skb);
36423 - atomic_inc(&vcc->stats->rx);
36424 + atomic_inc_unchecked(&vcc->stats->rx);
36425 }
36426 zout(pos & 0xffff,MTA(mbx));
36427 #if 0 /* probably a stupid idea */
36428 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
36429 skb_queue_head(&zatm_vcc->backlog,skb);
36430 break;
36431 }
36432 - atomic_inc(&vcc->stats->tx);
36433 + atomic_inc_unchecked(&vcc->stats->tx);
36434 wake_up(&zatm_vcc->tx_wait);
36435 }
36436
36437 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
36438 index 4c289ab..de1c333 100644
36439 --- a/drivers/base/bus.c
36440 +++ b/drivers/base/bus.c
36441 @@ -1193,7 +1193,7 @@ int subsys_interface_register(struct subsys_interface *sif)
36442 return -EINVAL;
36443
36444 mutex_lock(&subsys->p->mutex);
36445 - list_add_tail(&sif->node, &subsys->p->interfaces);
36446 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
36447 if (sif->add_dev) {
36448 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
36449 while ((dev = subsys_dev_iter_next(&iter)))
36450 @@ -1218,7 +1218,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
36451 subsys = sif->subsys;
36452
36453 mutex_lock(&subsys->p->mutex);
36454 - list_del_init(&sif->node);
36455 + pax_list_del_init((struct list_head *)&sif->node);
36456 if (sif->remove_dev) {
36457 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
36458 while ((dev = subsys_dev_iter_next(&iter)))
36459 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
36460 index 7413d06..79155fa 100644
36461 --- a/drivers/base/devtmpfs.c
36462 +++ b/drivers/base/devtmpfs.c
36463 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
36464 if (!thread)
36465 return 0;
36466
36467 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
36468 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
36469 if (err)
36470 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
36471 else
36472 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
36473 *err = sys_unshare(CLONE_NEWNS);
36474 if (*err)
36475 goto out;
36476 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
36477 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
36478 if (*err)
36479 goto out;
36480 - sys_chdir("/.."); /* will traverse into overmounted root */
36481 - sys_chroot(".");
36482 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
36483 + sys_chroot((char __force_user *)".");
36484 complete(&setup_done);
36485 while (1) {
36486 spin_lock(&req_lock);
36487 diff --git a/drivers/base/node.c b/drivers/base/node.c
36488 index bc9f43b..29703b8 100644
36489 --- a/drivers/base/node.c
36490 +++ b/drivers/base/node.c
36491 @@ -620,7 +620,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
36492 struct node_attr {
36493 struct device_attribute attr;
36494 enum node_states state;
36495 -};
36496 +} __do_const;
36497
36498 static ssize_t show_node_state(struct device *dev,
36499 struct device_attribute *attr, char *buf)
36500 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
36501 index bfb8955..42c9b9a 100644
36502 --- a/drivers/base/power/domain.c
36503 +++ b/drivers/base/power/domain.c
36504 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
36505 {
36506 struct cpuidle_driver *cpuidle_drv;
36507 struct gpd_cpu_data *cpu_data;
36508 - struct cpuidle_state *idle_state;
36509 + cpuidle_state_no_const *idle_state;
36510 int ret = 0;
36511
36512 if (IS_ERR_OR_NULL(genpd) || state < 0)
36513 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
36514 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
36515 {
36516 struct gpd_cpu_data *cpu_data;
36517 - struct cpuidle_state *idle_state;
36518 + cpuidle_state_no_const *idle_state;
36519 int ret = 0;
36520
36521 if (IS_ERR_OR_NULL(genpd))
36522 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
36523 index 03e089a..0e9560c 100644
36524 --- a/drivers/base/power/sysfs.c
36525 +++ b/drivers/base/power/sysfs.c
36526 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
36527 return -EIO;
36528 }
36529 }
36530 - return sprintf(buf, p);
36531 + return sprintf(buf, "%s", p);
36532 }
36533
36534 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
36535 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
36536 index 2d56f41..8830f19 100644
36537 --- a/drivers/base/power/wakeup.c
36538 +++ b/drivers/base/power/wakeup.c
36539 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
36540 * They need to be modified together atomically, so it's better to use one
36541 * atomic variable to hold them both.
36542 */
36543 -static atomic_t combined_event_count = ATOMIC_INIT(0);
36544 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
36545
36546 #define IN_PROGRESS_BITS (sizeof(int) * 4)
36547 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
36548
36549 static void split_counters(unsigned int *cnt, unsigned int *inpr)
36550 {
36551 - unsigned int comb = atomic_read(&combined_event_count);
36552 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
36553
36554 *cnt = (comb >> IN_PROGRESS_BITS);
36555 *inpr = comb & MAX_IN_PROGRESS;
36556 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
36557 ws->start_prevent_time = ws->last_time;
36558
36559 /* Increment the counter of events in progress. */
36560 - cec = atomic_inc_return(&combined_event_count);
36561 + cec = atomic_inc_return_unchecked(&combined_event_count);
36562
36563 trace_wakeup_source_activate(ws->name, cec);
36564 }
36565 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
36566 * Increment the counter of registered wakeup events and decrement the
36567 * couter of wakeup events in progress simultaneously.
36568 */
36569 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
36570 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
36571 trace_wakeup_source_deactivate(ws->name, cec);
36572
36573 split_counters(&cnt, &inpr);
36574 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
36575 index e8d11b6..7b1b36f 100644
36576 --- a/drivers/base/syscore.c
36577 +++ b/drivers/base/syscore.c
36578 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
36579 void register_syscore_ops(struct syscore_ops *ops)
36580 {
36581 mutex_lock(&syscore_ops_lock);
36582 - list_add_tail(&ops->node, &syscore_ops_list);
36583 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
36584 mutex_unlock(&syscore_ops_lock);
36585 }
36586 EXPORT_SYMBOL_GPL(register_syscore_ops);
36587 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
36588 void unregister_syscore_ops(struct syscore_ops *ops)
36589 {
36590 mutex_lock(&syscore_ops_lock);
36591 - list_del(&ops->node);
36592 + pax_list_del((struct list_head *)&ops->node);
36593 mutex_unlock(&syscore_ops_lock);
36594 }
36595 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
36596 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
36597 index edfa251..1734d4d 100644
36598 --- a/drivers/block/cciss.c
36599 +++ b/drivers/block/cciss.c
36600 @@ -3011,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
36601 while (!list_empty(&h->reqQ)) {
36602 c = list_entry(h->reqQ.next, CommandList_struct, list);
36603 /* can't do anything if fifo is full */
36604 - if ((h->access.fifo_full(h))) {
36605 + if ((h->access->fifo_full(h))) {
36606 dev_warn(&h->pdev->dev, "fifo full\n");
36607 break;
36608 }
36609 @@ -3021,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
36610 h->Qdepth--;
36611
36612 /* Tell the controller execute command */
36613 - h->access.submit_command(h, c);
36614 + h->access->submit_command(h, c);
36615
36616 /* Put job onto the completed Q */
36617 addQ(&h->cmpQ, c);
36618 @@ -3447,17 +3447,17 @@ startio:
36619
36620 static inline unsigned long get_next_completion(ctlr_info_t *h)
36621 {
36622 - return h->access.command_completed(h);
36623 + return h->access->command_completed(h);
36624 }
36625
36626 static inline int interrupt_pending(ctlr_info_t *h)
36627 {
36628 - return h->access.intr_pending(h);
36629 + return h->access->intr_pending(h);
36630 }
36631
36632 static inline long interrupt_not_for_us(ctlr_info_t *h)
36633 {
36634 - return ((h->access.intr_pending(h) == 0) ||
36635 + return ((h->access->intr_pending(h) == 0) ||
36636 (h->interrupts_enabled == 0));
36637 }
36638
36639 @@ -3490,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
36640 u32 a;
36641
36642 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
36643 - return h->access.command_completed(h);
36644 + return h->access->command_completed(h);
36645
36646 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
36647 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
36648 @@ -4047,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
36649 trans_support & CFGTBL_Trans_use_short_tags);
36650
36651 /* Change the access methods to the performant access methods */
36652 - h->access = SA5_performant_access;
36653 + h->access = &SA5_performant_access;
36654 h->transMethod = CFGTBL_Trans_Performant;
36655
36656 return;
36657 @@ -4327,7 +4327,7 @@ static int cciss_pci_init(ctlr_info_t *h)
36658 if (prod_index < 0)
36659 return -ENODEV;
36660 h->product_name = products[prod_index].product_name;
36661 - h->access = *(products[prod_index].access);
36662 + h->access = products[prod_index].access;
36663
36664 if (cciss_board_disabled(h)) {
36665 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36666 @@ -5059,7 +5059,7 @@ reinit_after_soft_reset:
36667 }
36668
36669 /* make sure the board interrupts are off */
36670 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36671 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36672 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36673 if (rc)
36674 goto clean2;
36675 @@ -5109,7 +5109,7 @@ reinit_after_soft_reset:
36676 * fake ones to scoop up any residual completions.
36677 */
36678 spin_lock_irqsave(&h->lock, flags);
36679 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36680 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36681 spin_unlock_irqrestore(&h->lock, flags);
36682 free_irq(h->intr[h->intr_mode], h);
36683 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36684 @@ -5129,9 +5129,9 @@ reinit_after_soft_reset:
36685 dev_info(&h->pdev->dev, "Board READY.\n");
36686 dev_info(&h->pdev->dev,
36687 "Waiting for stale completions to drain.\n");
36688 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36689 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36690 msleep(10000);
36691 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36692 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36693
36694 rc = controller_reset_failed(h->cfgtable);
36695 if (rc)
36696 @@ -5154,7 +5154,7 @@ reinit_after_soft_reset:
36697 cciss_scsi_setup(h);
36698
36699 /* Turn the interrupts on so we can service requests */
36700 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36701 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36702
36703 /* Get the firmware version */
36704 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36705 @@ -5226,7 +5226,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36706 kfree(flush_buf);
36707 if (return_code != IO_OK)
36708 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36709 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36710 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36711 free_irq(h->intr[h->intr_mode], h);
36712 }
36713
36714 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36715 index 7fda30e..eb5dfe0 100644
36716 --- a/drivers/block/cciss.h
36717 +++ b/drivers/block/cciss.h
36718 @@ -101,7 +101,7 @@ struct ctlr_info
36719 /* information about each logical volume */
36720 drive_info_struct *drv[CISS_MAX_LUN];
36721
36722 - struct access_method access;
36723 + struct access_method *access;
36724
36725 /* queue and queue Info */
36726 struct list_head reqQ;
36727 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36728 index 2b94403..fd6ad1f 100644
36729 --- a/drivers/block/cpqarray.c
36730 +++ b/drivers/block/cpqarray.c
36731 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36732 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36733 goto Enomem4;
36734 }
36735 - hba[i]->access.set_intr_mask(hba[i], 0);
36736 + hba[i]->access->set_intr_mask(hba[i], 0);
36737 if (request_irq(hba[i]->intr, do_ida_intr,
36738 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36739 {
36740 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36741 add_timer(&hba[i]->timer);
36742
36743 /* Enable IRQ now that spinlock and rate limit timer are set up */
36744 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36745 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36746
36747 for(j=0; j<NWD; j++) {
36748 struct gendisk *disk = ida_gendisk[i][j];
36749 @@ -694,7 +694,7 @@ DBGINFO(
36750 for(i=0; i<NR_PRODUCTS; i++) {
36751 if (board_id == products[i].board_id) {
36752 c->product_name = products[i].product_name;
36753 - c->access = *(products[i].access);
36754 + c->access = products[i].access;
36755 break;
36756 }
36757 }
36758 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36759 hba[ctlr]->intr = intr;
36760 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36761 hba[ctlr]->product_name = products[j].product_name;
36762 - hba[ctlr]->access = *(products[j].access);
36763 + hba[ctlr]->access = products[j].access;
36764 hba[ctlr]->ctlr = ctlr;
36765 hba[ctlr]->board_id = board_id;
36766 hba[ctlr]->pci_dev = NULL; /* not PCI */
36767 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36768
36769 while((c = h->reqQ) != NULL) {
36770 /* Can't do anything if we're busy */
36771 - if (h->access.fifo_full(h) == 0)
36772 + if (h->access->fifo_full(h) == 0)
36773 return;
36774
36775 /* Get the first entry from the request Q */
36776 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36777 h->Qdepth--;
36778
36779 /* Tell the controller to do our bidding */
36780 - h->access.submit_command(h, c);
36781 + h->access->submit_command(h, c);
36782
36783 /* Get onto the completion Q */
36784 addQ(&h->cmpQ, c);
36785 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36786 unsigned long flags;
36787 __u32 a,a1;
36788
36789 - istat = h->access.intr_pending(h);
36790 + istat = h->access->intr_pending(h);
36791 /* Is this interrupt for us? */
36792 if (istat == 0)
36793 return IRQ_NONE;
36794 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36795 */
36796 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36797 if (istat & FIFO_NOT_EMPTY) {
36798 - while((a = h->access.command_completed(h))) {
36799 + while((a = h->access->command_completed(h))) {
36800 a1 = a; a &= ~3;
36801 if ((c = h->cmpQ) == NULL)
36802 {
36803 @@ -1448,11 +1448,11 @@ static int sendcmd(
36804 /*
36805 * Disable interrupt
36806 */
36807 - info_p->access.set_intr_mask(info_p, 0);
36808 + info_p->access->set_intr_mask(info_p, 0);
36809 /* Make sure there is room in the command FIFO */
36810 /* Actually it should be completely empty at this time. */
36811 for (i = 200000; i > 0; i--) {
36812 - temp = info_p->access.fifo_full(info_p);
36813 + temp = info_p->access->fifo_full(info_p);
36814 if (temp != 0) {
36815 break;
36816 }
36817 @@ -1465,7 +1465,7 @@ DBG(
36818 /*
36819 * Send the cmd
36820 */
36821 - info_p->access.submit_command(info_p, c);
36822 + info_p->access->submit_command(info_p, c);
36823 complete = pollcomplete(ctlr);
36824
36825 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36826 @@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36827 * we check the new geometry. Then turn interrupts back on when
36828 * we're done.
36829 */
36830 - host->access.set_intr_mask(host, 0);
36831 + host->access->set_intr_mask(host, 0);
36832 getgeometry(ctlr);
36833 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36834 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36835
36836 for(i=0; i<NWD; i++) {
36837 struct gendisk *disk = ida_gendisk[ctlr][i];
36838 @@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
36839 /* Wait (up to 2 seconds) for a command to complete */
36840
36841 for (i = 200000; i > 0; i--) {
36842 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36843 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36844 if (done == 0) {
36845 udelay(10); /* a short fixed delay */
36846 } else
36847 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36848 index be73e9d..7fbf140 100644
36849 --- a/drivers/block/cpqarray.h
36850 +++ b/drivers/block/cpqarray.h
36851 @@ -99,7 +99,7 @@ struct ctlr_info {
36852 drv_info_t drv[NWD];
36853 struct proc_dir_entry *proc;
36854
36855 - struct access_method access;
36856 + struct access_method *access;
36857
36858 cmdlist_t *reqQ;
36859 cmdlist_t *cmpQ;
36860 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36861 index 2d7f608..11245fe 100644
36862 --- a/drivers/block/drbd/drbd_int.h
36863 +++ b/drivers/block/drbd/drbd_int.h
36864 @@ -582,7 +582,7 @@ struct drbd_epoch {
36865 struct drbd_tconn *tconn;
36866 struct list_head list;
36867 unsigned int barrier_nr;
36868 - atomic_t epoch_size; /* increased on every request added. */
36869 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36870 atomic_t active; /* increased on every req. added, and dec on every finished. */
36871 unsigned long flags;
36872 };
36873 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36874 unsigned int al_tr_number;
36875 int al_tr_cycle;
36876 wait_queue_head_t seq_wait;
36877 - atomic_t packet_seq;
36878 + atomic_unchecked_t packet_seq;
36879 unsigned int peer_seq;
36880 spinlock_t peer_seq_lock;
36881 unsigned int minor;
36882 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36883 char __user *uoptval;
36884 int err;
36885
36886 - uoptval = (char __user __force *)optval;
36887 + uoptval = (char __force_user *)optval;
36888
36889 set_fs(KERNEL_DS);
36890 if (level == SOL_SOCKET)
36891 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36892 index 55635ed..40e837c 100644
36893 --- a/drivers/block/drbd/drbd_main.c
36894 +++ b/drivers/block/drbd/drbd_main.c
36895 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36896 p->sector = sector;
36897 p->block_id = block_id;
36898 p->blksize = blksize;
36899 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36900 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36901 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36902 }
36903
36904 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36905 return -EIO;
36906 p->sector = cpu_to_be64(req->i.sector);
36907 p->block_id = (unsigned long)req;
36908 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36909 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36910 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36911 if (mdev->state.conn >= C_SYNC_SOURCE &&
36912 mdev->state.conn <= C_PAUSED_SYNC_T)
36913 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36914 {
36915 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36916
36917 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36918 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36919 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36920 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36921 kfree(tconn->current_epoch);
36922
36923 idr_destroy(&tconn->volumes);
36924 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36925 index 8cc1e64..ba7ffa9 100644
36926 --- a/drivers/block/drbd/drbd_nl.c
36927 +++ b/drivers/block/drbd/drbd_nl.c
36928 @@ -3440,7 +3440,7 @@ out:
36929
36930 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36931 {
36932 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36933 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36934 struct sk_buff *msg;
36935 struct drbd_genlmsghdr *d_out;
36936 unsigned seq;
36937 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36938 return;
36939 }
36940
36941 - seq = atomic_inc_return(&drbd_genl_seq);
36942 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36943 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36944 if (!msg)
36945 goto failed;
36946 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36947 index cc29cd3..d4b058b 100644
36948 --- a/drivers/block/drbd/drbd_receiver.c
36949 +++ b/drivers/block/drbd/drbd_receiver.c
36950 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36951 {
36952 int err;
36953
36954 - atomic_set(&mdev->packet_seq, 0);
36955 + atomic_set_unchecked(&mdev->packet_seq, 0);
36956 mdev->peer_seq = 0;
36957
36958 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36959 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36960 do {
36961 next_epoch = NULL;
36962
36963 - epoch_size = atomic_read(&epoch->epoch_size);
36964 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36965
36966 switch (ev & ~EV_CLEANUP) {
36967 case EV_PUT:
36968 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36969 rv = FE_DESTROYED;
36970 } else {
36971 epoch->flags = 0;
36972 - atomic_set(&epoch->epoch_size, 0);
36973 + atomic_set_unchecked(&epoch->epoch_size, 0);
36974 /* atomic_set(&epoch->active, 0); is already zero */
36975 if (rv == FE_STILL_LIVE)
36976 rv = FE_RECYCLED;
36977 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36978 conn_wait_active_ee_empty(tconn);
36979 drbd_flush(tconn);
36980
36981 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36982 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36983 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36984 if (epoch)
36985 break;
36986 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36987 }
36988
36989 epoch->flags = 0;
36990 - atomic_set(&epoch->epoch_size, 0);
36991 + atomic_set_unchecked(&epoch->epoch_size, 0);
36992 atomic_set(&epoch->active, 0);
36993
36994 spin_lock(&tconn->epoch_lock);
36995 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36996 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36997 list_add(&epoch->list, &tconn->current_epoch->list);
36998 tconn->current_epoch = epoch;
36999 tconn->epochs++;
37000 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
37001
37002 err = wait_for_and_update_peer_seq(mdev, peer_seq);
37003 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
37004 - atomic_inc(&tconn->current_epoch->epoch_size);
37005 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
37006 err2 = drbd_drain_block(mdev, pi->size);
37007 if (!err)
37008 err = err2;
37009 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
37010
37011 spin_lock(&tconn->epoch_lock);
37012 peer_req->epoch = tconn->current_epoch;
37013 - atomic_inc(&peer_req->epoch->epoch_size);
37014 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
37015 atomic_inc(&peer_req->epoch->active);
37016 spin_unlock(&tconn->epoch_lock);
37017
37018 @@ -4347,7 +4347,7 @@ struct data_cmd {
37019 int expect_payload;
37020 size_t pkt_size;
37021 int (*fn)(struct drbd_tconn *, struct packet_info *);
37022 -};
37023 +} __do_const;
37024
37025 static struct data_cmd drbd_cmd_handler[] = {
37026 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
37027 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
37028 if (!list_empty(&tconn->current_epoch->list))
37029 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
37030 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
37031 - atomic_set(&tconn->current_epoch->epoch_size, 0);
37032 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
37033 tconn->send.seen_any_write_yet = false;
37034
37035 conn_info(tconn, "Connection closed\n");
37036 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
37037 struct asender_cmd {
37038 size_t pkt_size;
37039 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
37040 -};
37041 +} __do_const;
37042
37043 static struct asender_cmd asender_tbl[] = {
37044 [P_PING] = { 0, got_Ping },
37045 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
37046 index c8dac73..1800093 100644
37047 --- a/drivers/block/loop.c
37048 +++ b/drivers/block/loop.c
37049 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
37050
37051 file_start_write(file);
37052 set_fs(get_ds());
37053 - bw = file->f_op->write(file, buf, len, &pos);
37054 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
37055 set_fs(old_fs);
37056 file_end_write(file);
37057 if (likely(bw == len))
37058 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
37059 index 5618847..5a46f3b 100644
37060 --- a/drivers/block/pktcdvd.c
37061 +++ b/drivers/block/pktcdvd.c
37062 @@ -108,7 +108,7 @@ static int pkt_seq_show(struct seq_file *m, void *p);
37063
37064 static sector_t get_zone(sector_t sector, struct pktcdvd_device *pd)
37065 {
37066 - return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1);
37067 + return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1UL);
37068 }
37069
37070 /*
37071 @@ -1897,7 +1897,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
37072 return -EROFS;
37073 }
37074 pd->settings.fp = ti.fp;
37075 - pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
37076 + pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1UL);
37077
37078 if (ti.nwa_v) {
37079 pd->nwa = be32_to_cpu(ti.next_writable);
37080 diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
37081 index 60abf59..80789e1 100644
37082 --- a/drivers/bluetooth/btwilink.c
37083 +++ b/drivers/bluetooth/btwilink.c
37084 @@ -293,7 +293,7 @@ static int ti_st_send_frame(struct sk_buff *skb)
37085
37086 static int bt_ti_probe(struct platform_device *pdev)
37087 {
37088 - static struct ti_st *hst;
37089 + struct ti_st *hst;
37090 struct hci_dev *hdev;
37091 int err;
37092
37093 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
37094 index 2009266..7be9ca2 100644
37095 --- a/drivers/bus/arm-cci.c
37096 +++ b/drivers/bus/arm-cci.c
37097 @@ -405,7 +405,7 @@ static int __init cci_probe(void)
37098
37099 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
37100
37101 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
37102 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
37103 if (!ports)
37104 return -ENOMEM;
37105
37106 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
37107 index 8a3aff7..d7538c2 100644
37108 --- a/drivers/cdrom/cdrom.c
37109 +++ b/drivers/cdrom/cdrom.c
37110 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
37111 ENSURE(reset, CDC_RESET);
37112 ENSURE(generic_packet, CDC_GENERIC_PACKET);
37113 cdi->mc_flags = 0;
37114 - cdo->n_minors = 0;
37115 cdi->options = CDO_USE_FFLAGS;
37116
37117 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
37118 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
37119 else
37120 cdi->cdda_method = CDDA_OLD;
37121
37122 - if (!cdo->generic_packet)
37123 - cdo->generic_packet = cdrom_dummy_generic_packet;
37124 + if (!cdo->generic_packet) {
37125 + pax_open_kernel();
37126 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
37127 + pax_close_kernel();
37128 + }
37129
37130 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
37131 mutex_lock(&cdrom_mutex);
37132 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
37133 if (cdi->exit)
37134 cdi->exit(cdi);
37135
37136 - cdi->ops->n_minors--;
37137 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
37138 }
37139
37140 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
37141 */
37142 nr = nframes;
37143 do {
37144 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
37145 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
37146 if (cgc.buffer)
37147 break;
37148
37149 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
37150 struct cdrom_device_info *cdi;
37151 int ret;
37152
37153 - ret = scnprintf(info + *pos, max_size - *pos, header);
37154 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
37155 if (!ret)
37156 return 1;
37157
37158 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
37159 index 5980cb9..6d7bd7e 100644
37160 --- a/drivers/cdrom/gdrom.c
37161 +++ b/drivers/cdrom/gdrom.c
37162 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
37163 .audio_ioctl = gdrom_audio_ioctl,
37164 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
37165 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
37166 - .n_minors = 1,
37167 };
37168
37169 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
37170 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
37171 index 1421997..33f5d6d 100644
37172 --- a/drivers/char/Kconfig
37173 +++ b/drivers/char/Kconfig
37174 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
37175
37176 config DEVKMEM
37177 bool "/dev/kmem virtual device support"
37178 - default y
37179 + default n
37180 + depends on !GRKERNSEC_KMEM
37181 help
37182 Say Y here if you want to support the /dev/kmem device. The
37183 /dev/kmem device is rarely used, but can be used for certain
37184 @@ -570,6 +571,7 @@ config DEVPORT
37185 bool
37186 depends on !M68K
37187 depends on ISA || PCI
37188 + depends on !GRKERNSEC_KMEM
37189 default y
37190
37191 source "drivers/s390/char/Kconfig"
37192 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
37193 index a48e05b..6bac831 100644
37194 --- a/drivers/char/agp/compat_ioctl.c
37195 +++ b/drivers/char/agp/compat_ioctl.c
37196 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
37197 return -ENOMEM;
37198 }
37199
37200 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
37201 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
37202 sizeof(*usegment) * ureserve.seg_count)) {
37203 kfree(usegment);
37204 kfree(ksegment);
37205 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
37206 index 1b19239..b87b143 100644
37207 --- a/drivers/char/agp/frontend.c
37208 +++ b/drivers/char/agp/frontend.c
37209 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
37210 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
37211 return -EFAULT;
37212
37213 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
37214 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
37215 return -EFAULT;
37216
37217 client = agp_find_client_by_pid(reserve.pid);
37218 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
37219 if (segment == NULL)
37220 return -ENOMEM;
37221
37222 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
37223 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
37224 sizeof(struct agp_segment) * reserve.seg_count)) {
37225 kfree(segment);
37226 return -EFAULT;
37227 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
37228 index 4f94375..413694e 100644
37229 --- a/drivers/char/genrtc.c
37230 +++ b/drivers/char/genrtc.c
37231 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
37232 switch (cmd) {
37233
37234 case RTC_PLL_GET:
37235 + memset(&pll, 0, sizeof(pll));
37236 if (get_rtc_pll(&pll))
37237 return -EINVAL;
37238 else
37239 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
37240 index 448ce5e..3a76625 100644
37241 --- a/drivers/char/hpet.c
37242 +++ b/drivers/char/hpet.c
37243 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
37244 }
37245
37246 static int
37247 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
37248 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
37249 struct hpet_info *info)
37250 {
37251 struct hpet_timer __iomem *timer;
37252 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
37253 index 86fe45c..c0ea948 100644
37254 --- a/drivers/char/hw_random/intel-rng.c
37255 +++ b/drivers/char/hw_random/intel-rng.c
37256 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
37257
37258 if (no_fwh_detect)
37259 return -ENODEV;
37260 - printk(warning);
37261 + printk("%s", warning);
37262 return -EBUSY;
37263 }
37264
37265 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
37266 index ec4e10f..f2a763b 100644
37267 --- a/drivers/char/ipmi/ipmi_msghandler.c
37268 +++ b/drivers/char/ipmi/ipmi_msghandler.c
37269 @@ -420,7 +420,7 @@ struct ipmi_smi {
37270 struct proc_dir_entry *proc_dir;
37271 char proc_dir_name[10];
37272
37273 - atomic_t stats[IPMI_NUM_STATS];
37274 + atomic_unchecked_t stats[IPMI_NUM_STATS];
37275
37276 /*
37277 * run_to_completion duplicate of smb_info, smi_info
37278 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
37279
37280
37281 #define ipmi_inc_stat(intf, stat) \
37282 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
37283 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
37284 #define ipmi_get_stat(intf, stat) \
37285 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
37286 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
37287
37288 static int is_lan_addr(struct ipmi_addr *addr)
37289 {
37290 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
37291 INIT_LIST_HEAD(&intf->cmd_rcvrs);
37292 init_waitqueue_head(&intf->waitq);
37293 for (i = 0; i < IPMI_NUM_STATS; i++)
37294 - atomic_set(&intf->stats[i], 0);
37295 + atomic_set_unchecked(&intf->stats[i], 0);
37296
37297 intf->proc_dir = NULL;
37298
37299 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
37300 index 15e4a60..b046093 100644
37301 --- a/drivers/char/ipmi/ipmi_si_intf.c
37302 +++ b/drivers/char/ipmi/ipmi_si_intf.c
37303 @@ -280,7 +280,7 @@ struct smi_info {
37304 unsigned char slave_addr;
37305
37306 /* Counters and things for the proc filesystem. */
37307 - atomic_t stats[SI_NUM_STATS];
37308 + atomic_unchecked_t stats[SI_NUM_STATS];
37309
37310 struct task_struct *thread;
37311
37312 @@ -289,9 +289,9 @@ struct smi_info {
37313 };
37314
37315 #define smi_inc_stat(smi, stat) \
37316 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
37317 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
37318 #define smi_get_stat(smi, stat) \
37319 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
37320 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
37321
37322 #define SI_MAX_PARMS 4
37323
37324 @@ -3324,7 +3324,7 @@ static int try_smi_init(struct smi_info *new_smi)
37325 atomic_set(&new_smi->req_events, 0);
37326 new_smi->run_to_completion = 0;
37327 for (i = 0; i < SI_NUM_STATS; i++)
37328 - atomic_set(&new_smi->stats[i], 0);
37329 + atomic_set_unchecked(&new_smi->stats[i], 0);
37330
37331 new_smi->interrupt_disabled = 1;
37332 atomic_set(&new_smi->stop_operation, 0);
37333 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
37334 index f895a8c..2bc9147 100644
37335 --- a/drivers/char/mem.c
37336 +++ b/drivers/char/mem.c
37337 @@ -18,6 +18,7 @@
37338 #include <linux/raw.h>
37339 #include <linux/tty.h>
37340 #include <linux/capability.h>
37341 +#include <linux/security.h>
37342 #include <linux/ptrace.h>
37343 #include <linux/device.h>
37344 #include <linux/highmem.h>
37345 @@ -37,6 +38,10 @@
37346
37347 #define DEVPORT_MINOR 4
37348
37349 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
37350 +extern const struct file_operations grsec_fops;
37351 +#endif
37352 +
37353 static inline unsigned long size_inside_page(unsigned long start,
37354 unsigned long size)
37355 {
37356 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37357
37358 while (cursor < to) {
37359 if (!devmem_is_allowed(pfn)) {
37360 +#ifdef CONFIG_GRKERNSEC_KMEM
37361 + gr_handle_mem_readwrite(from, to);
37362 +#else
37363 printk(KERN_INFO
37364 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
37365 current->comm, from, to);
37366 +#endif
37367 return 0;
37368 }
37369 cursor += PAGE_SIZE;
37370 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37371 }
37372 return 1;
37373 }
37374 +#elif defined(CONFIG_GRKERNSEC_KMEM)
37375 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37376 +{
37377 + return 0;
37378 +}
37379 #else
37380 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37381 {
37382 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
37383
37384 while (count > 0) {
37385 unsigned long remaining;
37386 + char *temp;
37387
37388 sz = size_inside_page(p, count);
37389
37390 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
37391 if (!ptr)
37392 return -EFAULT;
37393
37394 - remaining = copy_to_user(buf, ptr, sz);
37395 +#ifdef CONFIG_PAX_USERCOPY
37396 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
37397 + if (!temp) {
37398 + unxlate_dev_mem_ptr(p, ptr);
37399 + return -ENOMEM;
37400 + }
37401 + memcpy(temp, ptr, sz);
37402 +#else
37403 + temp = ptr;
37404 +#endif
37405 +
37406 + remaining = copy_to_user(buf, temp, sz);
37407 +
37408 +#ifdef CONFIG_PAX_USERCOPY
37409 + kfree(temp);
37410 +#endif
37411 +
37412 unxlate_dev_mem_ptr(p, ptr);
37413 if (remaining)
37414 return -EFAULT;
37415 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
37416 size_t count, loff_t *ppos)
37417 {
37418 unsigned long p = *ppos;
37419 - ssize_t low_count, read, sz;
37420 + ssize_t low_count, read, sz, err = 0;
37421 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
37422 - int err = 0;
37423
37424 read = 0;
37425 if (p < (unsigned long) high_memory) {
37426 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
37427 }
37428 #endif
37429 while (low_count > 0) {
37430 + char *temp;
37431 +
37432 sz = size_inside_page(p, low_count);
37433
37434 /*
37435 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
37436 */
37437 kbuf = xlate_dev_kmem_ptr((char *)p);
37438
37439 - if (copy_to_user(buf, kbuf, sz))
37440 +#ifdef CONFIG_PAX_USERCOPY
37441 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
37442 + if (!temp)
37443 + return -ENOMEM;
37444 + memcpy(temp, kbuf, sz);
37445 +#else
37446 + temp = kbuf;
37447 +#endif
37448 +
37449 + err = copy_to_user(buf, temp, sz);
37450 +
37451 +#ifdef CONFIG_PAX_USERCOPY
37452 + kfree(temp);
37453 +#endif
37454 +
37455 + if (err)
37456 return -EFAULT;
37457 buf += sz;
37458 p += sz;
37459 @@ -822,6 +869,9 @@ static const struct memdev {
37460 #ifdef CONFIG_PRINTK
37461 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
37462 #endif
37463 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
37464 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
37465 +#endif
37466 };
37467
37468 static int memory_open(struct inode *inode, struct file *filp)
37469 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
37470 continue;
37471
37472 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
37473 - NULL, devlist[minor].name);
37474 + NULL, "%s", devlist[minor].name);
37475 }
37476
37477 return tty_init();
37478 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
37479 index 9df78e2..01ba9ae 100644
37480 --- a/drivers/char/nvram.c
37481 +++ b/drivers/char/nvram.c
37482 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
37483
37484 spin_unlock_irq(&rtc_lock);
37485
37486 - if (copy_to_user(buf, contents, tmp - contents))
37487 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
37488 return -EFAULT;
37489
37490 *ppos = i;
37491 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
37492 index d39cca6..8c1e269 100644
37493 --- a/drivers/char/pcmcia/synclink_cs.c
37494 +++ b/drivers/char/pcmcia/synclink_cs.c
37495 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
37496
37497 if (debug_level >= DEBUG_LEVEL_INFO)
37498 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
37499 - __FILE__, __LINE__, info->device_name, port->count);
37500 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
37501
37502 - WARN_ON(!port->count);
37503 + WARN_ON(!atomic_read(&port->count));
37504
37505 if (tty_port_close_start(port, tty, filp) == 0)
37506 goto cleanup;
37507 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
37508 cleanup:
37509 if (debug_level >= DEBUG_LEVEL_INFO)
37510 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
37511 - tty->driver->name, port->count);
37512 + tty->driver->name, atomic_read(&port->count));
37513 }
37514
37515 /* Wait until the transmitter is empty.
37516 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
37517
37518 if (debug_level >= DEBUG_LEVEL_INFO)
37519 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
37520 - __FILE__, __LINE__, tty->driver->name, port->count);
37521 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
37522
37523 /* If port is closing, signal caller to try again */
37524 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
37525 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
37526 goto cleanup;
37527 }
37528 spin_lock(&port->lock);
37529 - port->count++;
37530 + atomic_inc(&port->count);
37531 spin_unlock(&port->lock);
37532 spin_unlock_irqrestore(&info->netlock, flags);
37533
37534 - if (port->count == 1) {
37535 + if (atomic_read(&port->count) == 1) {
37536 /* 1st open on this device, init hardware */
37537 retval = startup(info, tty);
37538 if (retval < 0)
37539 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
37540 unsigned short new_crctype;
37541
37542 /* return error if TTY interface open */
37543 - if (info->port.count)
37544 + if (atomic_read(&info->port.count))
37545 return -EBUSY;
37546
37547 switch (encoding)
37548 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
37549
37550 /* arbitrate between network and tty opens */
37551 spin_lock_irqsave(&info->netlock, flags);
37552 - if (info->port.count != 0 || info->netcount != 0) {
37553 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
37554 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
37555 spin_unlock_irqrestore(&info->netlock, flags);
37556 return -EBUSY;
37557 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
37558 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
37559
37560 /* return error if TTY interface open */
37561 - if (info->port.count)
37562 + if (atomic_read(&info->port.count))
37563 return -EBUSY;
37564
37565 if (cmd != SIOCWANDEV)
37566 diff --git a/drivers/char/random.c b/drivers/char/random.c
37567 index 7a744d3..35a177ee 100644
37568 --- a/drivers/char/random.c
37569 +++ b/drivers/char/random.c
37570 @@ -269,8 +269,13 @@
37571 /*
37572 * Configuration information
37573 */
37574 +#ifdef CONFIG_GRKERNSEC_RANDNET
37575 +#define INPUT_POOL_WORDS 512
37576 +#define OUTPUT_POOL_WORDS 128
37577 +#else
37578 #define INPUT_POOL_WORDS 128
37579 #define OUTPUT_POOL_WORDS 32
37580 +#endif
37581 #define SEC_XFER_SIZE 512
37582 #define EXTRACT_SIZE 10
37583
37584 @@ -310,10 +315,17 @@ static struct poolinfo {
37585 int poolwords;
37586 int tap1, tap2, tap3, tap4, tap5;
37587 } poolinfo_table[] = {
37588 +#ifdef CONFIG_GRKERNSEC_RANDNET
37589 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
37590 + { 512, 411, 308, 208, 104, 1 },
37591 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
37592 + { 128, 103, 76, 51, 25, 1 },
37593 +#else
37594 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
37595 { 128, 103, 76, 51, 25, 1 },
37596 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
37597 { 32, 26, 20, 14, 7, 1 },
37598 +#endif
37599 #if 0
37600 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
37601 { 2048, 1638, 1231, 819, 411, 1 },
37602 @@ -521,8 +533,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
37603 input_rotate += i ? 7 : 14;
37604 }
37605
37606 - ACCESS_ONCE(r->input_rotate) = input_rotate;
37607 - ACCESS_ONCE(r->add_ptr) = i;
37608 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
37609 + ACCESS_ONCE_RW(r->add_ptr) = i;
37610 smp_wmb();
37611
37612 if (out)
37613 @@ -1029,7 +1041,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
37614
37615 extract_buf(r, tmp);
37616 i = min_t(int, nbytes, EXTRACT_SIZE);
37617 - if (copy_to_user(buf, tmp, i)) {
37618 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
37619 ret = -EFAULT;
37620 break;
37621 }
37622 @@ -1365,7 +1377,7 @@ EXPORT_SYMBOL(generate_random_uuid);
37623 #include <linux/sysctl.h>
37624
37625 static int min_read_thresh = 8, min_write_thresh;
37626 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
37627 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
37628 static int max_write_thresh = INPUT_POOL_WORDS * 32;
37629 static char sysctl_bootid[16];
37630
37631 @@ -1381,7 +1393,7 @@ static char sysctl_bootid[16];
37632 static int proc_do_uuid(struct ctl_table *table, int write,
37633 void __user *buffer, size_t *lenp, loff_t *ppos)
37634 {
37635 - struct ctl_table fake_table;
37636 + ctl_table_no_const fake_table;
37637 unsigned char buf[64], tmp_uuid[16], *uuid;
37638
37639 uuid = table->data;
37640 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
37641 index 7cc1fe22..b602d6b 100644
37642 --- a/drivers/char/sonypi.c
37643 +++ b/drivers/char/sonypi.c
37644 @@ -54,6 +54,7 @@
37645
37646 #include <asm/uaccess.h>
37647 #include <asm/io.h>
37648 +#include <asm/local.h>
37649
37650 #include <linux/sonypi.h>
37651
37652 @@ -490,7 +491,7 @@ static struct sonypi_device {
37653 spinlock_t fifo_lock;
37654 wait_queue_head_t fifo_proc_list;
37655 struct fasync_struct *fifo_async;
37656 - int open_count;
37657 + local_t open_count;
37658 int model;
37659 struct input_dev *input_jog_dev;
37660 struct input_dev *input_key_dev;
37661 @@ -892,7 +893,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
37662 static int sonypi_misc_release(struct inode *inode, struct file *file)
37663 {
37664 mutex_lock(&sonypi_device.lock);
37665 - sonypi_device.open_count--;
37666 + local_dec(&sonypi_device.open_count);
37667 mutex_unlock(&sonypi_device.lock);
37668 return 0;
37669 }
37670 @@ -901,9 +902,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
37671 {
37672 mutex_lock(&sonypi_device.lock);
37673 /* Flush input queue on first open */
37674 - if (!sonypi_device.open_count)
37675 + if (!local_read(&sonypi_device.open_count))
37676 kfifo_reset(&sonypi_device.fifo);
37677 - sonypi_device.open_count++;
37678 + local_inc(&sonypi_device.open_count);
37679 mutex_unlock(&sonypi_device.lock);
37680
37681 return 0;
37682 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37683 index 64420b3..5c40b56 100644
37684 --- a/drivers/char/tpm/tpm_acpi.c
37685 +++ b/drivers/char/tpm/tpm_acpi.c
37686 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37687 virt = acpi_os_map_memory(start, len);
37688 if (!virt) {
37689 kfree(log->bios_event_log);
37690 + log->bios_event_log = NULL;
37691 printk("%s: ERROR - Unable to map memory\n", __func__);
37692 return -EIO;
37693 }
37694
37695 - memcpy_fromio(log->bios_event_log, virt, len);
37696 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37697
37698 acpi_os_unmap_memory(virt, len);
37699 return 0;
37700 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37701 index 84ddc55..1d32f1e 100644
37702 --- a/drivers/char/tpm/tpm_eventlog.c
37703 +++ b/drivers/char/tpm/tpm_eventlog.c
37704 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37705 event = addr;
37706
37707 if ((event->event_type == 0 && event->event_size == 0) ||
37708 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37709 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37710 return NULL;
37711
37712 return addr;
37713 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37714 return NULL;
37715
37716 if ((event->event_type == 0 && event->event_size == 0) ||
37717 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37718 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37719 return NULL;
37720
37721 (*pos)++;
37722 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37723 int i;
37724
37725 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37726 - seq_putc(m, data[i]);
37727 + if (!seq_putc(m, data[i]))
37728 + return -EFAULT;
37729
37730 return 0;
37731 }
37732 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37733 index b79cf3e..de172d64f 100644
37734 --- a/drivers/char/virtio_console.c
37735 +++ b/drivers/char/virtio_console.c
37736 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37737 if (to_user) {
37738 ssize_t ret;
37739
37740 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37741 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37742 if (ret)
37743 return -EFAULT;
37744 } else {
37745 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37746 if (!port_has_data(port) && !port->host_connected)
37747 return 0;
37748
37749 - return fill_readbuf(port, ubuf, count, true);
37750 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37751 }
37752
37753 static int wait_port_writable(struct port *port, bool nonblock)
37754 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37755 index a33f46f..a720eed 100644
37756 --- a/drivers/clk/clk-composite.c
37757 +++ b/drivers/clk/clk-composite.c
37758 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37759 struct clk *clk;
37760 struct clk_init_data init;
37761 struct clk_composite *composite;
37762 - struct clk_ops *clk_composite_ops;
37763 + clk_ops_no_const *clk_composite_ops;
37764
37765 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37766 if (!composite) {
37767 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37768 index 81dd31a..ef5c542 100644
37769 --- a/drivers/clk/socfpga/clk.c
37770 +++ b/drivers/clk/socfpga/clk.c
37771 @@ -22,6 +22,7 @@
37772 #include <linux/clk-provider.h>
37773 #include <linux/io.h>
37774 #include <linux/of.h>
37775 +#include <asm/pgtable.h>
37776
37777 /* Clock Manager offsets */
37778 #define CLKMGR_CTRL 0x0
37779 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37780 streq(clk_name, "periph_pll") ||
37781 streq(clk_name, "sdram_pll")) {
37782 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37783 - clk_pll_ops.enable = clk_gate_ops.enable;
37784 - clk_pll_ops.disable = clk_gate_ops.disable;
37785 + pax_open_kernel();
37786 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37787 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37788 + pax_close_kernel();
37789 }
37790
37791 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37792 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37793 return parent_rate / div;
37794 }
37795
37796 -static struct clk_ops gateclk_ops = {
37797 +static clk_ops_no_const gateclk_ops __read_only = {
37798 .recalc_rate = socfpga_clk_recalc_rate,
37799 .get_parent = socfpga_clk_get_parent,
37800 .set_parent = socfpga_clk_set_parent,
37801 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37802 index 506fd23..01a593f 100644
37803 --- a/drivers/cpufreq/acpi-cpufreq.c
37804 +++ b/drivers/cpufreq/acpi-cpufreq.c
37805 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37806 return sprintf(buf, "%u\n", boost_enabled);
37807 }
37808
37809 -static struct global_attr global_boost = __ATTR(boost, 0644,
37810 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37811 show_global_boost,
37812 store_global_boost);
37813
37814 @@ -721,8 +721,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37815 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37816 per_cpu(acfreq_data, cpu) = data;
37817
37818 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37819 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37820 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37821 + pax_open_kernel();
37822 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37823 + pax_close_kernel();
37824 + }
37825
37826 result = acpi_processor_register_performance(data->acpi_data, cpu);
37827 if (result)
37828 @@ -850,7 +853,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37829 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37830 break;
37831 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37832 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37833 + pax_open_kernel();
37834 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37835 + pax_close_kernel();
37836 policy->cur = get_cur_freq_on_cpu(cpu);
37837 break;
37838 default:
37839 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37840 index 04548f7..457a342 100644
37841 --- a/drivers/cpufreq/cpufreq.c
37842 +++ b/drivers/cpufreq/cpufreq.c
37843 @@ -2069,7 +2069,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37844 return NOTIFY_OK;
37845 }
37846
37847 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37848 +static struct notifier_block cpufreq_cpu_notifier = {
37849 .notifier_call = cpufreq_cpu_callback,
37850 };
37851
37852 @@ -2101,8 +2101,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37853
37854 pr_debug("trying to register driver %s\n", driver_data->name);
37855
37856 - if (driver_data->setpolicy)
37857 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37858 + if (driver_data->setpolicy) {
37859 + pax_open_kernel();
37860 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37861 + pax_close_kernel();
37862 + }
37863
37864 write_lock_irqsave(&cpufreq_driver_lock, flags);
37865 if (cpufreq_driver) {
37866 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37867 index 0806c31..6a73276 100644
37868 --- a/drivers/cpufreq/cpufreq_governor.c
37869 +++ b/drivers/cpufreq/cpufreq_governor.c
37870 @@ -187,7 +187,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37871 struct dbs_data *dbs_data;
37872 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37873 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37874 - struct od_ops *od_ops = NULL;
37875 + const struct od_ops *od_ops = NULL;
37876 struct od_dbs_tuners *od_tuners = NULL;
37877 struct cs_dbs_tuners *cs_tuners = NULL;
37878 struct cpu_dbs_common_info *cpu_cdbs;
37879 @@ -253,7 +253,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37880
37881 if ((cdata->governor == GOV_CONSERVATIVE) &&
37882 (!policy->governor->initialized)) {
37883 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37884 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37885
37886 cpufreq_register_notifier(cs_ops->notifier_block,
37887 CPUFREQ_TRANSITION_NOTIFIER);
37888 @@ -273,7 +273,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37889
37890 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37891 (policy->governor->initialized == 1)) {
37892 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37893 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37894
37895 cpufreq_unregister_notifier(cs_ops->notifier_block,
37896 CPUFREQ_TRANSITION_NOTIFIER);
37897 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37898 index 88cd39f..87f0393 100644
37899 --- a/drivers/cpufreq/cpufreq_governor.h
37900 +++ b/drivers/cpufreq/cpufreq_governor.h
37901 @@ -202,7 +202,7 @@ struct common_dbs_data {
37902 void (*exit)(struct dbs_data *dbs_data);
37903
37904 /* Governor specific ops, see below */
37905 - void *gov_ops;
37906 + const void *gov_ops;
37907 };
37908
37909 /* Governor Per policy data */
37910 @@ -222,7 +222,7 @@ struct od_ops {
37911 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37912 unsigned int freq_next, unsigned int relation);
37913 void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq);
37914 -};
37915 +} __no_const;
37916
37917 struct cs_ops {
37918 struct notifier_block *notifier_block;
37919 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37920 index 32f26f6..feb657b 100644
37921 --- a/drivers/cpufreq/cpufreq_ondemand.c
37922 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37923 @@ -522,7 +522,7 @@ static void od_exit(struct dbs_data *dbs_data)
37924
37925 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37926
37927 -static struct od_ops od_ops = {
37928 +static struct od_ops od_ops __read_only = {
37929 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37930 .powersave_bias_target = generic_powersave_bias_target,
37931 .freq_increase = dbs_freq_increase,
37932 @@ -577,14 +577,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37933 (struct cpufreq_policy *, unsigned int, unsigned int),
37934 unsigned int powersave_bias)
37935 {
37936 - od_ops.powersave_bias_target = f;
37937 + pax_open_kernel();
37938 + *(void **)&od_ops.powersave_bias_target = f;
37939 + pax_close_kernel();
37940 od_set_powersave_bias(powersave_bias);
37941 }
37942 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37943
37944 void od_unregister_powersave_bias_handler(void)
37945 {
37946 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37947 + pax_open_kernel();
37948 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37949 + pax_close_kernel();
37950 od_set_powersave_bias(0);
37951 }
37952 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37953 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37954 index 4cf0d28..5830372 100644
37955 --- a/drivers/cpufreq/cpufreq_stats.c
37956 +++ b/drivers/cpufreq/cpufreq_stats.c
37957 @@ -352,7 +352,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37958 }
37959
37960 /* priority=1 so this will get called before cpufreq_remove_dev */
37961 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37962 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37963 .notifier_call = cpufreq_stat_cpu_callback,
37964 .priority = 1,
37965 };
37966 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37967 index 2f0a2a6..93d728e 100644
37968 --- a/drivers/cpufreq/p4-clockmod.c
37969 +++ b/drivers/cpufreq/p4-clockmod.c
37970 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37971 case 0x0F: /* Core Duo */
37972 case 0x16: /* Celeron Core */
37973 case 0x1C: /* Atom */
37974 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37975 + pax_open_kernel();
37976 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37977 + pax_close_kernel();
37978 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37979 case 0x0D: /* Pentium M (Dothan) */
37980 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37981 + pax_open_kernel();
37982 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37983 + pax_close_kernel();
37984 /* fall through */
37985 case 0x09: /* Pentium M (Banias) */
37986 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37987 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37988
37989 /* on P-4s, the TSC runs with constant frequency independent whether
37990 * throttling is active or not. */
37991 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37992 + pax_open_kernel();
37993 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37994 + pax_close_kernel();
37995
37996 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37997 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37998 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37999 index ac76b48..2445bc6 100644
38000 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
38001 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
38002 @@ -18,14 +18,12 @@
38003 #include <asm/head.h>
38004 #include <asm/timer.h>
38005
38006 -static struct cpufreq_driver *cpufreq_us3_driver;
38007 -
38008 struct us3_freq_percpu_info {
38009 struct cpufreq_frequency_table table[4];
38010 };
38011
38012 /* Indexed by cpu number. */
38013 -static struct us3_freq_percpu_info *us3_freq_table;
38014 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
38015
38016 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
38017 * in the Safari config register.
38018 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
38019
38020 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
38021 {
38022 - if (cpufreq_us3_driver)
38023 - us3_set_cpu_divider_index(policy, 0);
38024 + us3_set_cpu_divider_index(policy->cpu, 0);
38025
38026 return 0;
38027 }
38028
38029 +static int __init us3_freq_init(void);
38030 +static void __exit us3_freq_exit(void);
38031 +
38032 +static struct cpufreq_driver cpufreq_us3_driver = {
38033 + .init = us3_freq_cpu_init,
38034 + .verify = us3_freq_verify,
38035 + .target = us3_freq_target,
38036 + .get = us3_freq_get,
38037 + .exit = us3_freq_cpu_exit,
38038 + .owner = THIS_MODULE,
38039 + .name = "UltraSPARC-III",
38040 +
38041 +};
38042 +
38043 static int __init us3_freq_init(void)
38044 {
38045 unsigned long manuf, impl, ver;
38046 @@ -208,55 +219,15 @@ static int __init us3_freq_init(void)
38047 (impl == CHEETAH_IMPL ||
38048 impl == CHEETAH_PLUS_IMPL ||
38049 impl == JAGUAR_IMPL ||
38050 - impl == PANTHER_IMPL)) {
38051 - struct cpufreq_driver *driver;
38052 -
38053 - ret = -ENOMEM;
38054 - driver = kzalloc(sizeof(*driver), GFP_KERNEL);
38055 - if (!driver)
38056 - goto err_out;
38057 -
38058 - us3_freq_table = kzalloc((NR_CPUS * sizeof(*us3_freq_table)),
38059 - GFP_KERNEL);
38060 - if (!us3_freq_table)
38061 - goto err_out;
38062 -
38063 - driver->init = us3_freq_cpu_init;
38064 - driver->verify = us3_freq_verify;
38065 - driver->target = us3_freq_target;
38066 - driver->get = us3_freq_get;
38067 - driver->exit = us3_freq_cpu_exit;
38068 - strcpy(driver->name, "UltraSPARC-III");
38069 -
38070 - cpufreq_us3_driver = driver;
38071 - ret = cpufreq_register_driver(driver);
38072 - if (ret)
38073 - goto err_out;
38074 -
38075 - return 0;
38076 -
38077 -err_out:
38078 - if (driver) {
38079 - kfree(driver);
38080 - cpufreq_us3_driver = NULL;
38081 - }
38082 - kfree(us3_freq_table);
38083 - us3_freq_table = NULL;
38084 - return ret;
38085 - }
38086 + impl == PANTHER_IMPL))
38087 + return cpufreq_register_driver(&cpufreq_us3_driver);
38088
38089 return -ENODEV;
38090 }
38091
38092 static void __exit us3_freq_exit(void)
38093 {
38094 - if (cpufreq_us3_driver) {
38095 - cpufreq_unregister_driver(cpufreq_us3_driver);
38096 - kfree(cpufreq_us3_driver);
38097 - cpufreq_us3_driver = NULL;
38098 - kfree(us3_freq_table);
38099 - us3_freq_table = NULL;
38100 - }
38101 + cpufreq_unregister_driver(&cpufreq_us3_driver);
38102 }
38103
38104 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
38105 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
38106 index f897d51..15da295 100644
38107 --- a/drivers/cpufreq/speedstep-centrino.c
38108 +++ b/drivers/cpufreq/speedstep-centrino.c
38109 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
38110 !cpu_has(cpu, X86_FEATURE_EST))
38111 return -ENODEV;
38112
38113 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
38114 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
38115 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
38116 + pax_open_kernel();
38117 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
38118 + pax_close_kernel();
38119 + }
38120
38121 if (policy->cpu != 0)
38122 return -ENODEV;
38123 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
38124 index 22c07fb..9dff5ac 100644
38125 --- a/drivers/cpuidle/cpuidle.c
38126 +++ b/drivers/cpuidle/cpuidle.c
38127 @@ -252,7 +252,7 @@ static int poll_idle(struct cpuidle_device *dev,
38128
38129 static void poll_idle_init(struct cpuidle_driver *drv)
38130 {
38131 - struct cpuidle_state *state = &drv->states[0];
38132 + cpuidle_state_no_const *state = &drv->states[0];
38133
38134 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
38135 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
38136 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
38137 index ea2f8e7..70ac501 100644
38138 --- a/drivers/cpuidle/governor.c
38139 +++ b/drivers/cpuidle/governor.c
38140 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
38141 mutex_lock(&cpuidle_lock);
38142 if (__cpuidle_find_governor(gov->name) == NULL) {
38143 ret = 0;
38144 - list_add_tail(&gov->governor_list, &cpuidle_governors);
38145 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
38146 if (!cpuidle_curr_governor ||
38147 cpuidle_curr_governor->rating < gov->rating)
38148 cpuidle_switch_governor(gov);
38149 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
38150 new_gov = cpuidle_replace_governor(gov->rating);
38151 cpuidle_switch_governor(new_gov);
38152 }
38153 - list_del(&gov->governor_list);
38154 + pax_list_del((struct list_head *)&gov->governor_list);
38155 mutex_unlock(&cpuidle_lock);
38156 }
38157
38158 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
38159 index 8739cc0..dc859d0 100644
38160 --- a/drivers/cpuidle/sysfs.c
38161 +++ b/drivers/cpuidle/sysfs.c
38162 @@ -134,7 +134,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
38163 NULL
38164 };
38165
38166 -static struct attribute_group cpuidle_attr_group = {
38167 +static attribute_group_no_const cpuidle_attr_group = {
38168 .attrs = cpuidle_default_attrs,
38169 .name = "cpuidle",
38170 };
38171 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
38172 index 12fea3e..1e28f47 100644
38173 --- a/drivers/crypto/hifn_795x.c
38174 +++ b/drivers/crypto/hifn_795x.c
38175 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
38176 MODULE_PARM_DESC(hifn_pll_ref,
38177 "PLL reference clock (pci[freq] or ext[freq], default ext)");
38178
38179 -static atomic_t hifn_dev_number;
38180 +static atomic_unchecked_t hifn_dev_number;
38181
38182 #define ACRYPTO_OP_DECRYPT 0
38183 #define ACRYPTO_OP_ENCRYPT 1
38184 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
38185 goto err_out_disable_pci_device;
38186
38187 snprintf(name, sizeof(name), "hifn%d",
38188 - atomic_inc_return(&hifn_dev_number)-1);
38189 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
38190
38191 err = pci_request_regions(pdev, name);
38192 if (err)
38193 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
38194 index c99c00d..990a4b2 100644
38195 --- a/drivers/devfreq/devfreq.c
38196 +++ b/drivers/devfreq/devfreq.c
38197 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
38198 goto err_out;
38199 }
38200
38201 - list_add(&governor->node, &devfreq_governor_list);
38202 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
38203
38204 list_for_each_entry(devfreq, &devfreq_list, node) {
38205 int ret = 0;
38206 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
38207 }
38208 }
38209
38210 - list_del(&governor->node);
38211 + pax_list_del((struct list_head *)&governor->node);
38212 err_out:
38213 mutex_unlock(&devfreq_list_lock);
38214
38215 diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
38216 index 1069e88..dfcd642 100644
38217 --- a/drivers/dma/sh/shdmac.c
38218 +++ b/drivers/dma/sh/shdmac.c
38219 @@ -511,7 +511,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
38220 return ret;
38221 }
38222
38223 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
38224 +static struct notifier_block sh_dmae_nmi_notifier = {
38225 .notifier_call = sh_dmae_nmi_handler,
38226
38227 /* Run before NMI debug handler and KGDB */
38228 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
38229 index 211021d..201d47f 100644
38230 --- a/drivers/edac/edac_device.c
38231 +++ b/drivers/edac/edac_device.c
38232 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
38233 */
38234 int edac_device_alloc_index(void)
38235 {
38236 - static atomic_t device_indexes = ATOMIC_INIT(0);
38237 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
38238
38239 - return atomic_inc_return(&device_indexes) - 1;
38240 + return atomic_inc_return_unchecked(&device_indexes) - 1;
38241 }
38242 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
38243
38244 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
38245 index 9f7e0e60..348c875 100644
38246 --- a/drivers/edac/edac_mc_sysfs.c
38247 +++ b/drivers/edac/edac_mc_sysfs.c
38248 @@ -150,7 +150,7 @@ static const char * const edac_caps[] = {
38249 struct dev_ch_attribute {
38250 struct device_attribute attr;
38251 int channel;
38252 -};
38253 +} __do_const;
38254
38255 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
38256 struct dev_ch_attribute dev_attr_legacy_##_name = \
38257 @@ -1007,14 +1007,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
38258 }
38259
38260 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
38261 + pax_open_kernel();
38262 if (mci->get_sdram_scrub_rate) {
38263 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
38264 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
38265 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
38266 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
38267 }
38268 if (mci->set_sdram_scrub_rate) {
38269 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
38270 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
38271 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
38272 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
38273 }
38274 + pax_close_kernel();
38275 err = device_create_file(&mci->dev,
38276 &dev_attr_sdram_scrub_rate);
38277 if (err) {
38278 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
38279 index dd370f9..0281629 100644
38280 --- a/drivers/edac/edac_pci.c
38281 +++ b/drivers/edac/edac_pci.c
38282 @@ -29,7 +29,7 @@
38283
38284 static DEFINE_MUTEX(edac_pci_ctls_mutex);
38285 static LIST_HEAD(edac_pci_list);
38286 -static atomic_t pci_indexes = ATOMIC_INIT(0);
38287 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
38288
38289 /*
38290 * edac_pci_alloc_ctl_info
38291 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
38292 */
38293 int edac_pci_alloc_index(void)
38294 {
38295 - return atomic_inc_return(&pci_indexes) - 1;
38296 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
38297 }
38298 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
38299
38300 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
38301 index e8658e4..22746d6 100644
38302 --- a/drivers/edac/edac_pci_sysfs.c
38303 +++ b/drivers/edac/edac_pci_sysfs.c
38304 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
38305 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
38306 static int edac_pci_poll_msec = 1000; /* one second workq period */
38307
38308 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
38309 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
38310 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
38311 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
38312
38313 static struct kobject *edac_pci_top_main_kobj;
38314 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
38315 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
38316 void *value;
38317 ssize_t(*show) (void *, char *);
38318 ssize_t(*store) (void *, const char *, size_t);
38319 -};
38320 +} __do_const;
38321
38322 /* Set of show/store abstract level functions for PCI Parity object */
38323 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
38324 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38325 edac_printk(KERN_CRIT, EDAC_PCI,
38326 "Signaled System Error on %s\n",
38327 pci_name(dev));
38328 - atomic_inc(&pci_nonparity_count);
38329 + atomic_inc_unchecked(&pci_nonparity_count);
38330 }
38331
38332 if (status & (PCI_STATUS_PARITY)) {
38333 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38334 "Master Data Parity Error on %s\n",
38335 pci_name(dev));
38336
38337 - atomic_inc(&pci_parity_count);
38338 + atomic_inc_unchecked(&pci_parity_count);
38339 }
38340
38341 if (status & (PCI_STATUS_DETECTED_PARITY)) {
38342 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38343 "Detected Parity Error on %s\n",
38344 pci_name(dev));
38345
38346 - atomic_inc(&pci_parity_count);
38347 + atomic_inc_unchecked(&pci_parity_count);
38348 }
38349 }
38350
38351 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38352 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
38353 "Signaled System Error on %s\n",
38354 pci_name(dev));
38355 - atomic_inc(&pci_nonparity_count);
38356 + atomic_inc_unchecked(&pci_nonparity_count);
38357 }
38358
38359 if (status & (PCI_STATUS_PARITY)) {
38360 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38361 "Master Data Parity Error on "
38362 "%s\n", pci_name(dev));
38363
38364 - atomic_inc(&pci_parity_count);
38365 + atomic_inc_unchecked(&pci_parity_count);
38366 }
38367
38368 if (status & (PCI_STATUS_DETECTED_PARITY)) {
38369 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38370 "Detected Parity Error on %s\n",
38371 pci_name(dev));
38372
38373 - atomic_inc(&pci_parity_count);
38374 + atomic_inc_unchecked(&pci_parity_count);
38375 }
38376 }
38377 }
38378 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
38379 if (!check_pci_errors)
38380 return;
38381
38382 - before_count = atomic_read(&pci_parity_count);
38383 + before_count = atomic_read_unchecked(&pci_parity_count);
38384
38385 /* scan all PCI devices looking for a Parity Error on devices and
38386 * bridges.
38387 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
38388 /* Only if operator has selected panic on PCI Error */
38389 if (edac_pci_get_panic_on_pe()) {
38390 /* If the count is different 'after' from 'before' */
38391 - if (before_count != atomic_read(&pci_parity_count))
38392 + if (before_count != atomic_read_unchecked(&pci_parity_count))
38393 panic("EDAC: PCI Parity Error");
38394 }
38395 }
38396 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
38397 index 51b7e3a..aa8a3e8 100644
38398 --- a/drivers/edac/mce_amd.h
38399 +++ b/drivers/edac/mce_amd.h
38400 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
38401 bool (*mc0_mce)(u16, u8);
38402 bool (*mc1_mce)(u16, u8);
38403 bool (*mc2_mce)(u16, u8);
38404 -};
38405 +} __no_const;
38406
38407 void amd_report_gart_errors(bool);
38408 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
38409 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
38410 index 57ea7f4..af06b76 100644
38411 --- a/drivers/firewire/core-card.c
38412 +++ b/drivers/firewire/core-card.c
38413 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
38414 const struct fw_card_driver *driver,
38415 struct device *device)
38416 {
38417 - static atomic_t index = ATOMIC_INIT(-1);
38418 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
38419
38420 - card->index = atomic_inc_return(&index);
38421 + card->index = atomic_inc_return_unchecked(&index);
38422 card->driver = driver;
38423 card->device = device;
38424 card->current_tlabel = 0;
38425 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
38426
38427 void fw_core_remove_card(struct fw_card *card)
38428 {
38429 - struct fw_card_driver dummy_driver = dummy_driver_template;
38430 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
38431
38432 card->driver->update_phy_reg(card, 4,
38433 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
38434 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
38435 index de4aa40..49ab1f2 100644
38436 --- a/drivers/firewire/core-device.c
38437 +++ b/drivers/firewire/core-device.c
38438 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
38439 struct config_rom_attribute {
38440 struct device_attribute attr;
38441 u32 key;
38442 -};
38443 +} __do_const;
38444
38445 static ssize_t show_immediate(struct device *dev,
38446 struct device_attribute *dattr, char *buf)
38447 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
38448 index e5af0e3..d318058 100644
38449 --- a/drivers/firewire/core-transaction.c
38450 +++ b/drivers/firewire/core-transaction.c
38451 @@ -38,6 +38,7 @@
38452 #include <linux/timer.h>
38453 #include <linux/types.h>
38454 #include <linux/workqueue.h>
38455 +#include <linux/sched.h>
38456
38457 #include <asm/byteorder.h>
38458
38459 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
38460 index 515a42c..5ecf3ba 100644
38461 --- a/drivers/firewire/core.h
38462 +++ b/drivers/firewire/core.h
38463 @@ -111,6 +111,7 @@ struct fw_card_driver {
38464
38465 int (*stop_iso)(struct fw_iso_context *ctx);
38466 };
38467 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
38468
38469 void fw_card_initialize(struct fw_card *card,
38470 const struct fw_card_driver *driver, struct device *device);
38471 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
38472 index 94a58a0..f5eba42 100644
38473 --- a/drivers/firmware/dmi-id.c
38474 +++ b/drivers/firmware/dmi-id.c
38475 @@ -16,7 +16,7 @@
38476 struct dmi_device_attribute{
38477 struct device_attribute dev_attr;
38478 int field;
38479 -};
38480 +} __do_const;
38481 #define to_dmi_dev_attr(_dev_attr) \
38482 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
38483
38484 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
38485 index fa0affb..aa448eb 100644
38486 --- a/drivers/firmware/dmi_scan.c
38487 +++ b/drivers/firmware/dmi_scan.c
38488 @@ -791,7 +791,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
38489 if (buf == NULL)
38490 return -1;
38491
38492 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
38493 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
38494
38495 iounmap(buf);
38496 return 0;
38497 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
38498 index 5145fa3..0d3babd 100644
38499 --- a/drivers/firmware/efi/efi.c
38500 +++ b/drivers/firmware/efi/efi.c
38501 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
38502 };
38503
38504 static struct efivars generic_efivars;
38505 -static struct efivar_operations generic_ops;
38506 +static efivar_operations_no_const generic_ops __read_only;
38507
38508 static int generic_ops_register(void)
38509 {
38510 - generic_ops.get_variable = efi.get_variable;
38511 - generic_ops.set_variable = efi.set_variable;
38512 - generic_ops.get_next_variable = efi.get_next_variable;
38513 - generic_ops.query_variable_store = efi_query_variable_store;
38514 + pax_open_kernel();
38515 + *(void **)&generic_ops.get_variable = efi.get_variable;
38516 + *(void **)&generic_ops.set_variable = efi.set_variable;
38517 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
38518 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
38519 + pax_close_kernel();
38520
38521 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
38522 }
38523 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
38524 index 8c5a61a..cf07bd0 100644
38525 --- a/drivers/firmware/efi/efivars.c
38526 +++ b/drivers/firmware/efi/efivars.c
38527 @@ -456,7 +456,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
38528 static int
38529 create_efivars_bin_attributes(void)
38530 {
38531 - struct bin_attribute *attr;
38532 + bin_attribute_no_const *attr;
38533 int error;
38534
38535 /* new_var */
38536 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
38537 index 2a90ba6..07f3733 100644
38538 --- a/drivers/firmware/google/memconsole.c
38539 +++ b/drivers/firmware/google/memconsole.c
38540 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
38541 if (!found_memconsole())
38542 return -ENODEV;
38543
38544 - memconsole_bin_attr.size = memconsole_length;
38545 + pax_open_kernel();
38546 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
38547 + pax_close_kernel();
38548
38549 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
38550
38551 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
38552 index 814addb..0937d7f 100644
38553 --- a/drivers/gpio/gpio-ich.c
38554 +++ b/drivers/gpio/gpio-ich.c
38555 @@ -71,7 +71,7 @@ struct ichx_desc {
38556 /* Some chipsets have quirks, let these use their own request/get */
38557 int (*request)(struct gpio_chip *chip, unsigned offset);
38558 int (*get)(struct gpio_chip *chip, unsigned offset);
38559 -};
38560 +} __do_const;
38561
38562 static struct {
38563 spinlock_t lock;
38564 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
38565 index 9902732..64b62dd 100644
38566 --- a/drivers/gpio/gpio-vr41xx.c
38567 +++ b/drivers/gpio/gpio-vr41xx.c
38568 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
38569 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
38570 maskl, pendl, maskh, pendh);
38571
38572 - atomic_inc(&irq_err_count);
38573 + atomic_inc_unchecked(&irq_err_count);
38574
38575 return -EINVAL;
38576 }
38577 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
38578 index c722c3b..2ec6040 100644
38579 --- a/drivers/gpu/drm/drm_crtc_helper.c
38580 +++ b/drivers/gpu/drm/drm_crtc_helper.c
38581 @@ -328,7 +328,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
38582 struct drm_crtc *tmp;
38583 int crtc_mask = 1;
38584
38585 - WARN(!crtc, "checking null crtc?\n");
38586 + BUG_ON(!crtc);
38587
38588 dev = crtc->dev;
38589
38590 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
38591 index fe58d08..07bc38e 100644
38592 --- a/drivers/gpu/drm/drm_drv.c
38593 +++ b/drivers/gpu/drm/drm_drv.c
38594 @@ -186,7 +186,7 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
38595 atomic_set(&dev->vma_count, 0);
38596
38597 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
38598 - atomic_set(&dev->counts[i], 0);
38599 + atomic_set_unchecked(&dev->counts[i], 0);
38600
38601 dev->sigdata.lock = NULL;
38602
38603 @@ -302,7 +302,7 @@ module_exit(drm_core_exit);
38604 /**
38605 * Copy and IOCTL return string to user space
38606 */
38607 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
38608 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
38609 {
38610 int len;
38611
38612 @@ -372,7 +372,7 @@ long drm_ioctl(struct file *filp,
38613 struct drm_file *file_priv = filp->private_data;
38614 struct drm_device *dev;
38615 const struct drm_ioctl_desc *ioctl = NULL;
38616 - drm_ioctl_t *func;
38617 + drm_ioctl_no_const_t func;
38618 unsigned int nr = DRM_IOCTL_NR(cmd);
38619 int retcode = -EINVAL;
38620 char stack_kdata[128];
38621 @@ -385,7 +385,7 @@ long drm_ioctl(struct file *filp,
38622 return -ENODEV;
38623
38624 atomic_inc(&dev->ioctl_count);
38625 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
38626 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
38627 ++file_priv->ioctl_count;
38628
38629 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
38630 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
38631 index 3f84277..c627c54 100644
38632 --- a/drivers/gpu/drm/drm_fops.c
38633 +++ b/drivers/gpu/drm/drm_fops.c
38634 @@ -97,7 +97,7 @@ int drm_open(struct inode *inode, struct file *filp)
38635 if (drm_device_is_unplugged(dev))
38636 return -ENODEV;
38637
38638 - if (!dev->open_count++)
38639 + if (local_inc_return(&dev->open_count) == 1)
38640 need_setup = 1;
38641 mutex_lock(&dev->struct_mutex);
38642 old_imapping = inode->i_mapping;
38643 @@ -113,7 +113,7 @@ int drm_open(struct inode *inode, struct file *filp)
38644 retcode = drm_open_helper(inode, filp, dev);
38645 if (retcode)
38646 goto err_undo;
38647 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38648 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38649 if (need_setup) {
38650 retcode = drm_setup(dev);
38651 if (retcode)
38652 @@ -128,7 +128,7 @@ err_undo:
38653 iput(container_of(dev->dev_mapping, struct inode, i_data));
38654 dev->dev_mapping = old_mapping;
38655 mutex_unlock(&dev->struct_mutex);
38656 - dev->open_count--;
38657 + local_dec(&dev->open_count);
38658 return retcode;
38659 }
38660 EXPORT_SYMBOL(drm_open);
38661 @@ -405,7 +405,7 @@ int drm_release(struct inode *inode, struct file *filp)
38662
38663 mutex_lock(&drm_global_mutex);
38664
38665 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38666 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38667
38668 if (dev->driver->preclose)
38669 dev->driver->preclose(dev, file_priv);
38670 @@ -414,10 +414,10 @@ int drm_release(struct inode *inode, struct file *filp)
38671 * Begin inline drm_release
38672 */
38673
38674 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38675 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38676 task_pid_nr(current),
38677 (long)old_encode_dev(file_priv->minor->device),
38678 - dev->open_count);
38679 + local_read(&dev->open_count));
38680
38681 /* Release any auth tokens that might point to this file_priv,
38682 (do that under the drm_global_mutex) */
38683 @@ -516,8 +516,8 @@ int drm_release(struct inode *inode, struct file *filp)
38684 * End inline drm_release
38685 */
38686
38687 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38688 - if (!--dev->open_count) {
38689 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38690 + if (local_dec_and_test(&dev->open_count)) {
38691 if (atomic_read(&dev->ioctl_count)) {
38692 DRM_ERROR("Device busy: %d\n",
38693 atomic_read(&dev->ioctl_count));
38694 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38695 index f731116..629842c 100644
38696 --- a/drivers/gpu/drm/drm_global.c
38697 +++ b/drivers/gpu/drm/drm_global.c
38698 @@ -36,7 +36,7 @@
38699 struct drm_global_item {
38700 struct mutex mutex;
38701 void *object;
38702 - int refcount;
38703 + atomic_t refcount;
38704 };
38705
38706 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38707 @@ -49,7 +49,7 @@ void drm_global_init(void)
38708 struct drm_global_item *item = &glob[i];
38709 mutex_init(&item->mutex);
38710 item->object = NULL;
38711 - item->refcount = 0;
38712 + atomic_set(&item->refcount, 0);
38713 }
38714 }
38715
38716 @@ -59,7 +59,7 @@ void drm_global_release(void)
38717 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38718 struct drm_global_item *item = &glob[i];
38719 BUG_ON(item->object != NULL);
38720 - BUG_ON(item->refcount != 0);
38721 + BUG_ON(atomic_read(&item->refcount) != 0);
38722 }
38723 }
38724
38725 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38726 void *object;
38727
38728 mutex_lock(&item->mutex);
38729 - if (item->refcount == 0) {
38730 + if (atomic_read(&item->refcount) == 0) {
38731 item->object = kzalloc(ref->size, GFP_KERNEL);
38732 if (unlikely(item->object == NULL)) {
38733 ret = -ENOMEM;
38734 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38735 goto out_err;
38736
38737 }
38738 - ++item->refcount;
38739 + atomic_inc(&item->refcount);
38740 ref->object = item->object;
38741 object = item->object;
38742 mutex_unlock(&item->mutex);
38743 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38744 struct drm_global_item *item = &glob[ref->global_type];
38745
38746 mutex_lock(&item->mutex);
38747 - BUG_ON(item->refcount == 0);
38748 + BUG_ON(atomic_read(&item->refcount) == 0);
38749 BUG_ON(ref->object != item->object);
38750 - if (--item->refcount == 0) {
38751 + if (atomic_dec_and_test(&item->refcount)) {
38752 ref->release(ref);
38753 item->object = NULL;
38754 }
38755 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38756 index 5329832..b503f49 100644
38757 --- a/drivers/gpu/drm/drm_info.c
38758 +++ b/drivers/gpu/drm/drm_info.c
38759 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38760 struct drm_local_map *map;
38761 struct drm_map_list *r_list;
38762
38763 - /* Hardcoded from _DRM_FRAME_BUFFER,
38764 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38765 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38766 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38767 + static const char * const types[] = {
38768 + [_DRM_FRAME_BUFFER] = "FB",
38769 + [_DRM_REGISTERS] = "REG",
38770 + [_DRM_SHM] = "SHM",
38771 + [_DRM_AGP] = "AGP",
38772 + [_DRM_SCATTER_GATHER] = "SG",
38773 + [_DRM_CONSISTENT] = "PCI",
38774 + [_DRM_GEM] = "GEM" };
38775 const char *type;
38776 int i;
38777
38778 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38779 map = r_list->map;
38780 if (!map)
38781 continue;
38782 - if (map->type < 0 || map->type > 5)
38783 + if (map->type >= ARRAY_SIZE(types))
38784 type = "??";
38785 else
38786 type = types[map->type];
38787 @@ -257,7 +261,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38788 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38789 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38790 vma->vm_flags & VM_IO ? 'i' : '-',
38791 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38792 + 0);
38793 +#else
38794 vma->vm_pgoff);
38795 +#endif
38796
38797 #if defined(__i386__)
38798 pgprot = pgprot_val(vma->vm_page_prot);
38799 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38800 index 2f4c434..dd12cd2 100644
38801 --- a/drivers/gpu/drm/drm_ioc32.c
38802 +++ b/drivers/gpu/drm/drm_ioc32.c
38803 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38804 request = compat_alloc_user_space(nbytes);
38805 if (!access_ok(VERIFY_WRITE, request, nbytes))
38806 return -EFAULT;
38807 - list = (struct drm_buf_desc *) (request + 1);
38808 + list = (struct drm_buf_desc __user *) (request + 1);
38809
38810 if (__put_user(count, &request->count)
38811 || __put_user(list, &request->list))
38812 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38813 request = compat_alloc_user_space(nbytes);
38814 if (!access_ok(VERIFY_WRITE, request, nbytes))
38815 return -EFAULT;
38816 - list = (struct drm_buf_pub *) (request + 1);
38817 + list = (struct drm_buf_pub __user *) (request + 1);
38818
38819 if (__put_user(count, &request->count)
38820 || __put_user(list, &request->list))
38821 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38822 return 0;
38823 }
38824
38825 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38826 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38827 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38828 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38829 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38830 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38831 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38832 {
38833 unsigned int nr = DRM_IOCTL_NR(cmd);
38834 - drm_ioctl_compat_t *fn;
38835 int ret;
38836
38837 /* Assume that ioctls without an explicit compat routine will just
38838 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38839 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38840 return drm_ioctl(filp, cmd, arg);
38841
38842 - fn = drm_compat_ioctls[nr];
38843 -
38844 - if (fn != NULL)
38845 - ret = (*fn) (filp, cmd, arg);
38846 + if (drm_compat_ioctls[nr] != NULL)
38847 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38848 else
38849 ret = drm_ioctl(filp, cmd, arg);
38850
38851 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38852 index d752c96..fe08455 100644
38853 --- a/drivers/gpu/drm/drm_lock.c
38854 +++ b/drivers/gpu/drm/drm_lock.c
38855 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38856 if (drm_lock_take(&master->lock, lock->context)) {
38857 master->lock.file_priv = file_priv;
38858 master->lock.lock_time = jiffies;
38859 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38860 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38861 break; /* Got lock */
38862 }
38863
38864 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38865 return -EINVAL;
38866 }
38867
38868 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38869 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38870
38871 if (drm_lock_free(&master->lock, lock->context)) {
38872 /* FIXME: Should really bail out here. */
38873 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38874 index 39d8645..59e06fa 100644
38875 --- a/drivers/gpu/drm/drm_stub.c
38876 +++ b/drivers/gpu/drm/drm_stub.c
38877 @@ -484,7 +484,7 @@ void drm_unplug_dev(struct drm_device *dev)
38878
38879 drm_device_set_unplugged(dev);
38880
38881 - if (dev->open_count == 0) {
38882 + if (local_read(&dev->open_count) == 0) {
38883 drm_put_dev(dev);
38884 }
38885 mutex_unlock(&drm_global_mutex);
38886 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38887 index 2290b3b..22056a1 100644
38888 --- a/drivers/gpu/drm/drm_sysfs.c
38889 +++ b/drivers/gpu/drm/drm_sysfs.c
38890 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38891 int drm_sysfs_device_add(struct drm_minor *minor)
38892 {
38893 int err;
38894 - char *minor_str;
38895 + const char *minor_str;
38896
38897 minor->kdev.parent = minor->dev->dev;
38898
38899 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38900 index ab1892eb..d7009ca 100644
38901 --- a/drivers/gpu/drm/i810/i810_dma.c
38902 +++ b/drivers/gpu/drm/i810/i810_dma.c
38903 @@ -944,8 +944,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38904 dma->buflist[vertex->idx],
38905 vertex->discard, vertex->used);
38906
38907 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38908 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38909 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38910 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38911 sarea_priv->last_enqueue = dev_priv->counter - 1;
38912 sarea_priv->last_dispatch = (int)hw_status[5];
38913
38914 @@ -1105,8 +1105,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38915 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38916 mc->last_render);
38917
38918 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38919 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38920 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38921 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38922 sarea_priv->last_enqueue = dev_priv->counter - 1;
38923 sarea_priv->last_dispatch = (int)hw_status[5];
38924
38925 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38926 index d4d16ed..8fb0b51 100644
38927 --- a/drivers/gpu/drm/i810/i810_drv.h
38928 +++ b/drivers/gpu/drm/i810/i810_drv.h
38929 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38930 int page_flipping;
38931
38932 wait_queue_head_t irq_queue;
38933 - atomic_t irq_received;
38934 - atomic_t irq_emitted;
38935 + atomic_unchecked_t irq_received;
38936 + atomic_unchecked_t irq_emitted;
38937
38938 int front_offset;
38939 } drm_i810_private_t;
38940 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38941 index a6f4cb5..6b2beb2 100644
38942 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38943 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38944 @@ -624,7 +624,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38945 I915_READ(GTIMR));
38946 }
38947 seq_printf(m, "Interrupts received: %d\n",
38948 - atomic_read(&dev_priv->irq_received));
38949 + atomic_read_unchecked(&dev_priv->irq_received));
38950 for_each_ring(ring, dev_priv, i) {
38951 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38952 seq_printf(m,
38953 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38954 index 5a25f24..5af2004 100644
38955 --- a/drivers/gpu/drm/i915/i915_dma.c
38956 +++ b/drivers/gpu/drm/i915/i915_dma.c
38957 @@ -1271,7 +1271,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38958 bool can_switch;
38959
38960 spin_lock(&dev->count_lock);
38961 - can_switch = (dev->open_count == 0);
38962 + can_switch = (local_read(&dev->open_count) == 0);
38963 spin_unlock(&dev->count_lock);
38964 return can_switch;
38965 }
38966 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38967 index ab0f2c0..53c1bda 100644
38968 --- a/drivers/gpu/drm/i915/i915_drv.h
38969 +++ b/drivers/gpu/drm/i915/i915_drv.h
38970 @@ -1181,7 +1181,7 @@ typedef struct drm_i915_private {
38971 drm_dma_handle_t *status_page_dmah;
38972 struct resource mch_res;
38973
38974 - atomic_t irq_received;
38975 + atomic_unchecked_t irq_received;
38976
38977 /* protects the irq masks */
38978 spinlock_t irq_lock;
38979 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38980 index bf34577..3fd2ffa 100644
38981 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38982 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38983 @@ -768,9 +768,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38984
38985 static int
38986 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38987 - int count)
38988 + unsigned int count)
38989 {
38990 - int i;
38991 + unsigned int i;
38992 int relocs_total = 0;
38993 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38994
38995 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38996 index 3c59584..500f2e9 100644
38997 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38998 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38999 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
39000 (unsigned long)request);
39001 }
39002
39003 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
39004 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
39005 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
39006 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
39007 [DRM_I915_GETPARAM] = compat_i915_getparam,
39008 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
39009 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39010 {
39011 unsigned int nr = DRM_IOCTL_NR(cmd);
39012 - drm_ioctl_compat_t *fn = NULL;
39013 int ret;
39014
39015 if (nr < DRM_COMMAND_BASE)
39016 return drm_compat_ioctl(filp, cmd, arg);
39017
39018 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
39019 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
39020 -
39021 - if (fn != NULL)
39022 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
39023 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
39024 ret = (*fn) (filp, cmd, arg);
39025 - else
39026 + } else
39027 ret = drm_ioctl(filp, cmd, arg);
39028
39029 return ret;
39030 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
39031 index 4b91228..590c643 100644
39032 --- a/drivers/gpu/drm/i915/i915_irq.c
39033 +++ b/drivers/gpu/drm/i915/i915_irq.c
39034 @@ -1085,7 +1085,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
39035 int pipe;
39036 u32 pipe_stats[I915_MAX_PIPES];
39037
39038 - atomic_inc(&dev_priv->irq_received);
39039 + atomic_inc_unchecked(&dev_priv->irq_received);
39040
39041 while (true) {
39042 iir = I915_READ(VLV_IIR);
39043 @@ -1390,7 +1390,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
39044 irqreturn_t ret = IRQ_NONE;
39045 bool err_int_reenable = false;
39046
39047 - atomic_inc(&dev_priv->irq_received);
39048 + atomic_inc_unchecked(&dev_priv->irq_received);
39049
39050 /* We get interrupts on unclaimed registers, so check for this before we
39051 * do any I915_{READ,WRITE}. */
39052 @@ -2146,7 +2146,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
39053 {
39054 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39055
39056 - atomic_set(&dev_priv->irq_received, 0);
39057 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39058
39059 I915_WRITE(HWSTAM, 0xeffe);
39060
39061 @@ -2164,7 +2164,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
39062 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39063 int pipe;
39064
39065 - atomic_set(&dev_priv->irq_received, 0);
39066 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39067
39068 /* VLV magic */
39069 I915_WRITE(VLV_IMR, 0);
39070 @@ -2452,7 +2452,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
39071 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39072 int pipe;
39073
39074 - atomic_set(&dev_priv->irq_received, 0);
39075 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39076
39077 for_each_pipe(pipe)
39078 I915_WRITE(PIPESTAT(pipe), 0);
39079 @@ -2530,7 +2530,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
39080 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
39081 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
39082
39083 - atomic_inc(&dev_priv->irq_received);
39084 + atomic_inc_unchecked(&dev_priv->irq_received);
39085
39086 iir = I915_READ16(IIR);
39087 if (iir == 0)
39088 @@ -2604,7 +2604,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
39089 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39090 int pipe;
39091
39092 - atomic_set(&dev_priv->irq_received, 0);
39093 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39094
39095 if (I915_HAS_HOTPLUG(dev)) {
39096 I915_WRITE(PORT_HOTPLUG_EN, 0);
39097 @@ -2703,7 +2703,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
39098 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
39099 int pipe, ret = IRQ_NONE;
39100
39101 - atomic_inc(&dev_priv->irq_received);
39102 + atomic_inc_unchecked(&dev_priv->irq_received);
39103
39104 iir = I915_READ(IIR);
39105 do {
39106 @@ -2827,7 +2827,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
39107 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39108 int pipe;
39109
39110 - atomic_set(&dev_priv->irq_received, 0);
39111 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39112
39113 I915_WRITE(PORT_HOTPLUG_EN, 0);
39114 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
39115 @@ -2941,7 +2941,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
39116 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
39117 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
39118
39119 - atomic_inc(&dev_priv->irq_received);
39120 + atomic_inc_unchecked(&dev_priv->irq_received);
39121
39122 iir = I915_READ(IIR);
39123
39124 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
39125 index aad6f7b..dcc91447 100644
39126 --- a/drivers/gpu/drm/i915/intel_display.c
39127 +++ b/drivers/gpu/drm/i915/intel_display.c
39128 @@ -10019,13 +10019,13 @@ struct intel_quirk {
39129 int subsystem_vendor;
39130 int subsystem_device;
39131 void (*hook)(struct drm_device *dev);
39132 -};
39133 +} __do_const;
39134
39135 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
39136 struct intel_dmi_quirk {
39137 void (*hook)(struct drm_device *dev);
39138 const struct dmi_system_id (*dmi_id_list)[];
39139 -};
39140 +} __do_const;
39141
39142 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
39143 {
39144 @@ -10033,18 +10033,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
39145 return 1;
39146 }
39147
39148 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
39149 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
39150 {
39151 - .dmi_id_list = &(const struct dmi_system_id[]) {
39152 - {
39153 - .callback = intel_dmi_reverse_brightness,
39154 - .ident = "NCR Corporation",
39155 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
39156 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
39157 - },
39158 - },
39159 - { } /* terminating entry */
39160 + .callback = intel_dmi_reverse_brightness,
39161 + .ident = "NCR Corporation",
39162 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
39163 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
39164 },
39165 + },
39166 + { } /* terminating entry */
39167 +};
39168 +
39169 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
39170 + {
39171 + .dmi_id_list = &intel_dmi_quirks_table,
39172 .hook = quirk_invert_brightness,
39173 },
39174 };
39175 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
39176 index ca4bc54..ee598a2 100644
39177 --- a/drivers/gpu/drm/mga/mga_drv.h
39178 +++ b/drivers/gpu/drm/mga/mga_drv.h
39179 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
39180 u32 clear_cmd;
39181 u32 maccess;
39182
39183 - atomic_t vbl_received; /**< Number of vblanks received. */
39184 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
39185 wait_queue_head_t fence_queue;
39186 - atomic_t last_fence_retired;
39187 + atomic_unchecked_t last_fence_retired;
39188 u32 next_fence_to_post;
39189
39190 unsigned int fb_cpp;
39191 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
39192 index 709e90d..89a1c0d 100644
39193 --- a/drivers/gpu/drm/mga/mga_ioc32.c
39194 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
39195 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
39196 return 0;
39197 }
39198
39199 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
39200 +drm_ioctl_compat_t mga_compat_ioctls[] = {
39201 [DRM_MGA_INIT] = compat_mga_init,
39202 [DRM_MGA_GETPARAM] = compat_mga_getparam,
39203 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
39204 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
39205 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39206 {
39207 unsigned int nr = DRM_IOCTL_NR(cmd);
39208 - drm_ioctl_compat_t *fn = NULL;
39209 int ret;
39210
39211 if (nr < DRM_COMMAND_BASE)
39212 return drm_compat_ioctl(filp, cmd, arg);
39213
39214 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
39215 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
39216 -
39217 - if (fn != NULL)
39218 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
39219 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
39220 ret = (*fn) (filp, cmd, arg);
39221 - else
39222 + } else
39223 ret = drm_ioctl(filp, cmd, arg);
39224
39225 return ret;
39226 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
39227 index 598c281..60d590e 100644
39228 --- a/drivers/gpu/drm/mga/mga_irq.c
39229 +++ b/drivers/gpu/drm/mga/mga_irq.c
39230 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
39231 if (crtc != 0)
39232 return 0;
39233
39234 - return atomic_read(&dev_priv->vbl_received);
39235 + return atomic_read_unchecked(&dev_priv->vbl_received);
39236 }
39237
39238
39239 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
39240 /* VBLANK interrupt */
39241 if (status & MGA_VLINEPEN) {
39242 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
39243 - atomic_inc(&dev_priv->vbl_received);
39244 + atomic_inc_unchecked(&dev_priv->vbl_received);
39245 drm_handle_vblank(dev, 0);
39246 handled = 1;
39247 }
39248 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
39249 if ((prim_start & ~0x03) != (prim_end & ~0x03))
39250 MGA_WRITE(MGA_PRIMEND, prim_end);
39251
39252 - atomic_inc(&dev_priv->last_fence_retired);
39253 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
39254 DRM_WAKEUP(&dev_priv->fence_queue);
39255 handled = 1;
39256 }
39257 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
39258 * using fences.
39259 */
39260 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
39261 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
39262 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
39263 - *sequence) <= (1 << 23)));
39264
39265 *sequence = cur_fence;
39266 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
39267 index 3e72876..d1c15ad 100644
39268 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
39269 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
39270 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
39271 struct bit_table {
39272 const char id;
39273 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
39274 -};
39275 +} __no_const;
39276
39277 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
39278
39279 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
39280 index 994fd6e..6e12565 100644
39281 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
39282 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
39283 @@ -94,7 +94,6 @@ struct nouveau_drm {
39284 struct drm_global_reference mem_global_ref;
39285 struct ttm_bo_global_ref bo_global_ref;
39286 struct ttm_bo_device bdev;
39287 - atomic_t validate_sequence;
39288 int (*move)(struct nouveau_channel *,
39289 struct ttm_buffer_object *,
39290 struct ttm_mem_reg *, struct ttm_mem_reg *);
39291 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
39292 index c1a7e5a..38b8539 100644
39293 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
39294 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
39295 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
39296 unsigned long arg)
39297 {
39298 unsigned int nr = DRM_IOCTL_NR(cmd);
39299 - drm_ioctl_compat_t *fn = NULL;
39300 + drm_ioctl_compat_t fn = NULL;
39301 int ret;
39302
39303 if (nr < DRM_COMMAND_BASE)
39304 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
39305 index 81638d7..2e45854 100644
39306 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
39307 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
39308 @@ -65,7 +65,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
39309 bool can_switch;
39310
39311 spin_lock(&dev->count_lock);
39312 - can_switch = (dev->open_count == 0);
39313 + can_switch = (local_read(&dev->open_count) == 0);
39314 spin_unlock(&dev->count_lock);
39315 return can_switch;
39316 }
39317 diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
39318 index eb89653..613cf71 100644
39319 --- a/drivers/gpu/drm/qxl/qxl_cmd.c
39320 +++ b/drivers/gpu/drm/qxl/qxl_cmd.c
39321 @@ -285,27 +285,27 @@ static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port,
39322 int ret;
39323
39324 mutex_lock(&qdev->async_io_mutex);
39325 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
39326 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
39327 if (qdev->last_sent_io_cmd > irq_num) {
39328 if (intr)
39329 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
39330 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39331 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39332 else
39333 ret = wait_event_timeout(qdev->io_cmd_event,
39334 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39335 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39336 /* 0 is timeout, just bail the "hw" has gone away */
39337 if (ret <= 0)
39338 goto out;
39339 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
39340 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
39341 }
39342 outb(val, addr);
39343 qdev->last_sent_io_cmd = irq_num + 1;
39344 if (intr)
39345 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
39346 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39347 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39348 else
39349 ret = wait_event_timeout(qdev->io_cmd_event,
39350 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39351 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39352 out:
39353 if (ret > 0)
39354 ret = 0;
39355 diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
39356 index c3c2bbd..bc3c0fb 100644
39357 --- a/drivers/gpu/drm/qxl/qxl_debugfs.c
39358 +++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
39359 @@ -42,10 +42,10 @@ qxl_debugfs_irq_received(struct seq_file *m, void *data)
39360 struct drm_info_node *node = (struct drm_info_node *) m->private;
39361 struct qxl_device *qdev = node->minor->dev->dev_private;
39362
39363 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
39364 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
39365 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_cursor));
39366 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_io_cmd));
39367 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received));
39368 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_display));
39369 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_cursor));
39370 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_io_cmd));
39371 seq_printf(m, "%d\n", qdev->irq_received_error);
39372 return 0;
39373 }
39374 diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
39375 index f7c9add..fb971d2 100644
39376 --- a/drivers/gpu/drm/qxl/qxl_drv.h
39377 +++ b/drivers/gpu/drm/qxl/qxl_drv.h
39378 @@ -290,10 +290,10 @@ struct qxl_device {
39379 unsigned int last_sent_io_cmd;
39380
39381 /* interrupt handling */
39382 - atomic_t irq_received;
39383 - atomic_t irq_received_display;
39384 - atomic_t irq_received_cursor;
39385 - atomic_t irq_received_io_cmd;
39386 + atomic_unchecked_t irq_received;
39387 + atomic_unchecked_t irq_received_display;
39388 + atomic_unchecked_t irq_received_cursor;
39389 + atomic_unchecked_t irq_received_io_cmd;
39390 unsigned irq_received_error;
39391 wait_queue_head_t display_event;
39392 wait_queue_head_t cursor_event;
39393 diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
39394 index 21393dc..329f3a9 100644
39395 --- a/drivers/gpu/drm/qxl/qxl_irq.c
39396 +++ b/drivers/gpu/drm/qxl/qxl_irq.c
39397 @@ -33,19 +33,19 @@ irqreturn_t qxl_irq_handler(DRM_IRQ_ARGS)
39398
39399 pending = xchg(&qdev->ram_header->int_pending, 0);
39400
39401 - atomic_inc(&qdev->irq_received);
39402 + atomic_inc_unchecked(&qdev->irq_received);
39403
39404 if (pending & QXL_INTERRUPT_DISPLAY) {
39405 - atomic_inc(&qdev->irq_received_display);
39406 + atomic_inc_unchecked(&qdev->irq_received_display);
39407 wake_up_all(&qdev->display_event);
39408 qxl_queue_garbage_collect(qdev, false);
39409 }
39410 if (pending & QXL_INTERRUPT_CURSOR) {
39411 - atomic_inc(&qdev->irq_received_cursor);
39412 + atomic_inc_unchecked(&qdev->irq_received_cursor);
39413 wake_up_all(&qdev->cursor_event);
39414 }
39415 if (pending & QXL_INTERRUPT_IO_CMD) {
39416 - atomic_inc(&qdev->irq_received_io_cmd);
39417 + atomic_inc_unchecked(&qdev->irq_received_io_cmd);
39418 wake_up_all(&qdev->io_cmd_event);
39419 }
39420 if (pending & QXL_INTERRUPT_ERROR) {
39421 @@ -82,10 +82,10 @@ int qxl_irq_init(struct qxl_device *qdev)
39422 init_waitqueue_head(&qdev->io_cmd_event);
39423 INIT_WORK(&qdev->client_monitors_config_work,
39424 qxl_client_monitors_config_work_func);
39425 - atomic_set(&qdev->irq_received, 0);
39426 - atomic_set(&qdev->irq_received_display, 0);
39427 - atomic_set(&qdev->irq_received_cursor, 0);
39428 - atomic_set(&qdev->irq_received_io_cmd, 0);
39429 + atomic_set_unchecked(&qdev->irq_received, 0);
39430 + atomic_set_unchecked(&qdev->irq_received_display, 0);
39431 + atomic_set_unchecked(&qdev->irq_received_cursor, 0);
39432 + atomic_set_unchecked(&qdev->irq_received_io_cmd, 0);
39433 qdev->irq_received_error = 0;
39434 ret = drm_irq_install(qdev->ddev);
39435 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
39436 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
39437 index 037786d..2a95e33 100644
39438 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
39439 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
39440 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
39441 }
39442 }
39443
39444 -static struct vm_operations_struct qxl_ttm_vm_ops;
39445 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
39446 static const struct vm_operations_struct *ttm_vm_ops;
39447
39448 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39449 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
39450 return r;
39451 if (unlikely(ttm_vm_ops == NULL)) {
39452 ttm_vm_ops = vma->vm_ops;
39453 + pax_open_kernel();
39454 qxl_ttm_vm_ops = *ttm_vm_ops;
39455 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
39456 + pax_close_kernel();
39457 }
39458 vma->vm_ops = &qxl_ttm_vm_ops;
39459 return 0;
39460 @@ -558,25 +560,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
39461 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
39462 {
39463 #if defined(CONFIG_DEBUG_FS)
39464 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
39465 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
39466 - unsigned i;
39467 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
39468 + {
39469 + .name = "qxl_mem_mm",
39470 + .show = &qxl_mm_dump_table,
39471 + },
39472 + {
39473 + .name = "qxl_surf_mm",
39474 + .show = &qxl_mm_dump_table,
39475 + }
39476 + };
39477
39478 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
39479 - if (i == 0)
39480 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
39481 - else
39482 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
39483 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
39484 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
39485 - qxl_mem_types_list[i].driver_features = 0;
39486 - if (i == 0)
39487 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
39488 - else
39489 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
39490 + pax_open_kernel();
39491 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
39492 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
39493 + pax_close_kernel();
39494
39495 - }
39496 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
39497 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
39498 #else
39499 return 0;
39500 #endif
39501 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
39502 index c451257..0ad2134 100644
39503 --- a/drivers/gpu/drm/r128/r128_cce.c
39504 +++ b/drivers/gpu/drm/r128/r128_cce.c
39505 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
39506
39507 /* GH: Simple idle check.
39508 */
39509 - atomic_set(&dev_priv->idle_count, 0);
39510 + atomic_set_unchecked(&dev_priv->idle_count, 0);
39511
39512 /* We don't support anything other than bus-mastering ring mode,
39513 * but the ring can be in either AGP or PCI space for the ring
39514 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
39515 index 56eb5e3..c4ec43d 100644
39516 --- a/drivers/gpu/drm/r128/r128_drv.h
39517 +++ b/drivers/gpu/drm/r128/r128_drv.h
39518 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
39519 int is_pci;
39520 unsigned long cce_buffers_offset;
39521
39522 - atomic_t idle_count;
39523 + atomic_unchecked_t idle_count;
39524
39525 int page_flipping;
39526 int current_page;
39527 u32 crtc_offset;
39528 u32 crtc_offset_cntl;
39529
39530 - atomic_t vbl_received;
39531 + atomic_unchecked_t vbl_received;
39532
39533 u32 color_fmt;
39534 unsigned int front_offset;
39535 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
39536 index a954c54..9cc595c 100644
39537 --- a/drivers/gpu/drm/r128/r128_ioc32.c
39538 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
39539 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
39540 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
39541 }
39542
39543 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
39544 +drm_ioctl_compat_t r128_compat_ioctls[] = {
39545 [DRM_R128_INIT] = compat_r128_init,
39546 [DRM_R128_DEPTH] = compat_r128_depth,
39547 [DRM_R128_STIPPLE] = compat_r128_stipple,
39548 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
39549 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39550 {
39551 unsigned int nr = DRM_IOCTL_NR(cmd);
39552 - drm_ioctl_compat_t *fn = NULL;
39553 int ret;
39554
39555 if (nr < DRM_COMMAND_BASE)
39556 return drm_compat_ioctl(filp, cmd, arg);
39557
39558 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
39559 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39560 -
39561 - if (fn != NULL)
39562 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
39563 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39564 ret = (*fn) (filp, cmd, arg);
39565 - else
39566 + } else
39567 ret = drm_ioctl(filp, cmd, arg);
39568
39569 return ret;
39570 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
39571 index 2ea4f09..d391371 100644
39572 --- a/drivers/gpu/drm/r128/r128_irq.c
39573 +++ b/drivers/gpu/drm/r128/r128_irq.c
39574 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
39575 if (crtc != 0)
39576 return 0;
39577
39578 - return atomic_read(&dev_priv->vbl_received);
39579 + return atomic_read_unchecked(&dev_priv->vbl_received);
39580 }
39581
39582 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39583 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39584 /* VBLANK interrupt */
39585 if (status & R128_CRTC_VBLANK_INT) {
39586 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
39587 - atomic_inc(&dev_priv->vbl_received);
39588 + atomic_inc_unchecked(&dev_priv->vbl_received);
39589 drm_handle_vblank(dev, 0);
39590 return IRQ_HANDLED;
39591 }
39592 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
39593 index 01dd9ae..6352f04 100644
39594 --- a/drivers/gpu/drm/r128/r128_state.c
39595 +++ b/drivers/gpu/drm/r128/r128_state.c
39596 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
39597
39598 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
39599 {
39600 - if (atomic_read(&dev_priv->idle_count) == 0)
39601 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
39602 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
39603 else
39604 - atomic_set(&dev_priv->idle_count, 0);
39605 + atomic_set_unchecked(&dev_priv->idle_count, 0);
39606 }
39607
39608 #endif
39609 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
39610 index af85299..ed9ac8d 100644
39611 --- a/drivers/gpu/drm/radeon/mkregtable.c
39612 +++ b/drivers/gpu/drm/radeon/mkregtable.c
39613 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
39614 regex_t mask_rex;
39615 regmatch_t match[4];
39616 char buf[1024];
39617 - size_t end;
39618 + long end;
39619 int len;
39620 int done = 0;
39621 int r;
39622 unsigned o;
39623 struct offset *offset;
39624 char last_reg_s[10];
39625 - int last_reg;
39626 + unsigned long last_reg;
39627
39628 if (regcomp
39629 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
39630 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
39631 index 841d0e0..9eaa268 100644
39632 --- a/drivers/gpu/drm/radeon/radeon_device.c
39633 +++ b/drivers/gpu/drm/radeon/radeon_device.c
39634 @@ -1117,7 +1117,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
39635 bool can_switch;
39636
39637 spin_lock(&dev->count_lock);
39638 - can_switch = (dev->open_count == 0);
39639 + can_switch = (local_read(&dev->open_count) == 0);
39640 spin_unlock(&dev->count_lock);
39641 return can_switch;
39642 }
39643 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
39644 index b369d42..8dd04eb 100644
39645 --- a/drivers/gpu/drm/radeon/radeon_drv.h
39646 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
39647 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
39648
39649 /* SW interrupt */
39650 wait_queue_head_t swi_queue;
39651 - atomic_t swi_emitted;
39652 + atomic_unchecked_t swi_emitted;
39653 int vblank_crtc;
39654 uint32_t irq_enable_reg;
39655 uint32_t r500_disp_irq_reg;
39656 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
39657 index c180df8..5fd8186 100644
39658 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
39659 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
39660 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39661 request = compat_alloc_user_space(sizeof(*request));
39662 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
39663 || __put_user(req32.param, &request->param)
39664 - || __put_user((void __user *)(unsigned long)req32.value,
39665 + || __put_user((unsigned long)req32.value,
39666 &request->value))
39667 return -EFAULT;
39668
39669 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39670 #define compat_radeon_cp_setparam NULL
39671 #endif /* X86_64 || IA64 */
39672
39673 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39674 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
39675 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
39676 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
39677 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
39678 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39679 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39680 {
39681 unsigned int nr = DRM_IOCTL_NR(cmd);
39682 - drm_ioctl_compat_t *fn = NULL;
39683 int ret;
39684
39685 if (nr < DRM_COMMAND_BASE)
39686 return drm_compat_ioctl(filp, cmd, arg);
39687
39688 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
39689 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39690 -
39691 - if (fn != NULL)
39692 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
39693 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39694 ret = (*fn) (filp, cmd, arg);
39695 - else
39696 + } else
39697 ret = drm_ioctl(filp, cmd, arg);
39698
39699 return ret;
39700 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
39701 index 8d68e97..9dcfed8 100644
39702 --- a/drivers/gpu/drm/radeon/radeon_irq.c
39703 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
39704 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
39705 unsigned int ret;
39706 RING_LOCALS;
39707
39708 - atomic_inc(&dev_priv->swi_emitted);
39709 - ret = atomic_read(&dev_priv->swi_emitted);
39710 + atomic_inc_unchecked(&dev_priv->swi_emitted);
39711 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
39712
39713 BEGIN_RING(4);
39714 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
39715 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
39716 drm_radeon_private_t *dev_priv =
39717 (drm_radeon_private_t *) dev->dev_private;
39718
39719 - atomic_set(&dev_priv->swi_emitted, 0);
39720 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
39721 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
39722
39723 dev->max_vblank_count = 0x001fffff;
39724 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
39725 index 4d20910..6726b6d 100644
39726 --- a/drivers/gpu/drm/radeon/radeon_state.c
39727 +++ b/drivers/gpu/drm/radeon/radeon_state.c
39728 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
39729 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
39730 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
39731
39732 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39733 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39734 sarea_priv->nbox * sizeof(depth_boxes[0])))
39735 return -EFAULT;
39736
39737 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39738 {
39739 drm_radeon_private_t *dev_priv = dev->dev_private;
39740 drm_radeon_getparam_t *param = data;
39741 - int value;
39742 + int value = 0;
39743
39744 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39745
39746 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39747 index 71245d6..94c556d 100644
39748 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39749 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39750 @@ -784,7 +784,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39751 man->size = size >> PAGE_SHIFT;
39752 }
39753
39754 -static struct vm_operations_struct radeon_ttm_vm_ops;
39755 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39756 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39757
39758 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39759 @@ -825,8 +825,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39760 }
39761 if (unlikely(ttm_vm_ops == NULL)) {
39762 ttm_vm_ops = vma->vm_ops;
39763 + pax_open_kernel();
39764 radeon_ttm_vm_ops = *ttm_vm_ops;
39765 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39766 + pax_close_kernel();
39767 }
39768 vma->vm_ops = &radeon_ttm_vm_ops;
39769 return 0;
39770 @@ -855,38 +857,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39771 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39772 {
39773 #if defined(CONFIG_DEBUG_FS)
39774 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39775 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39776 - unsigned i;
39777 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39778 + {
39779 + .name = "radeon_vram_mm",
39780 + .show = &radeon_mm_dump_table,
39781 + },
39782 + {
39783 + .name = "radeon_gtt_mm",
39784 + .show = &radeon_mm_dump_table,
39785 + },
39786 + {
39787 + .name = "ttm_page_pool",
39788 + .show = &ttm_page_alloc_debugfs,
39789 + },
39790 + {
39791 + .name = "ttm_dma_page_pool",
39792 + .show = &ttm_dma_page_alloc_debugfs,
39793 + },
39794 + };
39795 + unsigned i = RADEON_DEBUGFS_MEM_TYPES + 1;
39796
39797 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39798 - if (i == 0)
39799 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39800 - else
39801 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39802 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39803 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39804 - radeon_mem_types_list[i].driver_features = 0;
39805 - if (i == 0)
39806 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39807 - else
39808 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39809 -
39810 - }
39811 - /* Add ttm page pool to debugfs */
39812 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39813 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39814 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39815 - radeon_mem_types_list[i].driver_features = 0;
39816 - radeon_mem_types_list[i++].data = NULL;
39817 + pax_open_kernel();
39818 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39819 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39820 + pax_close_kernel();
39821 #ifdef CONFIG_SWIOTLB
39822 - if (swiotlb_nr_tbl()) {
39823 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39824 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39825 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39826 - radeon_mem_types_list[i].driver_features = 0;
39827 - radeon_mem_types_list[i++].data = NULL;
39828 - }
39829 + if (swiotlb_nr_tbl())
39830 + i++;
39831 #endif
39832 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39833
39834 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39835 index 3c38f0a..13816e3 100644
39836 --- a/drivers/gpu/drm/radeon/rs690.c
39837 +++ b/drivers/gpu/drm/radeon/rs690.c
39838 @@ -355,9 +355,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39839 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39840 rdev->pm.sideport_bandwidth.full)
39841 max_bandwidth = rdev->pm.sideport_bandwidth;
39842 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39843 + read_delay_latency.full = dfixed_const(800 * 1000);
39844 read_delay_latency.full = dfixed_div(read_delay_latency,
39845 rdev->pm.igp_sideport_mclk);
39846 + a.full = dfixed_const(370);
39847 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39848 } else {
39849 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39850 rdev->pm.k8_bandwidth.full)
39851 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39852 index dbc2def..0a9f710 100644
39853 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39854 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39855 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39856 zone->glob = glob;
39857 glob->zone_kernel = zone;
39858 ret = kobject_init_and_add(
39859 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39860 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39861 if (unlikely(ret != 0)) {
39862 kobject_put(&zone->kobj);
39863 return ret;
39864 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39865 zone->glob = glob;
39866 glob->zone_dma32 = zone;
39867 ret = kobject_init_and_add(
39868 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39869 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39870 if (unlikely(ret != 0)) {
39871 kobject_put(&zone->kobj);
39872 return ret;
39873 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39874 index 863bef9..cba15cf 100644
39875 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39876 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39877 @@ -391,9 +391,9 @@ out:
39878 static unsigned long
39879 ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
39880 {
39881 - static atomic_t start_pool = ATOMIC_INIT(0);
39882 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39883 unsigned i;
39884 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39885 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39886 struct ttm_page_pool *pool;
39887 int shrink_pages = sc->nr_to_scan;
39888 unsigned long freed = 0;
39889 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39890 index 97e9d61..bf23c461 100644
39891 --- a/drivers/gpu/drm/udl/udl_fb.c
39892 +++ b/drivers/gpu/drm/udl/udl_fb.c
39893 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39894 fb_deferred_io_cleanup(info);
39895 kfree(info->fbdefio);
39896 info->fbdefio = NULL;
39897 - info->fbops->fb_mmap = udl_fb_mmap;
39898 }
39899
39900 pr_warn("released /dev/fb%d user=%d count=%d\n",
39901 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39902 index a811ef2..ff99b05 100644
39903 --- a/drivers/gpu/drm/via/via_drv.h
39904 +++ b/drivers/gpu/drm/via/via_drv.h
39905 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39906 typedef uint32_t maskarray_t[5];
39907
39908 typedef struct drm_via_irq {
39909 - atomic_t irq_received;
39910 + atomic_unchecked_t irq_received;
39911 uint32_t pending_mask;
39912 uint32_t enable_mask;
39913 wait_queue_head_t irq_queue;
39914 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39915 struct timeval last_vblank;
39916 int last_vblank_valid;
39917 unsigned usec_per_vblank;
39918 - atomic_t vbl_received;
39919 + atomic_unchecked_t vbl_received;
39920 drm_via_state_t hc_state;
39921 char pci_buf[VIA_PCI_BUF_SIZE];
39922 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39923 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39924 index ac98964..5dbf512 100644
39925 --- a/drivers/gpu/drm/via/via_irq.c
39926 +++ b/drivers/gpu/drm/via/via_irq.c
39927 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39928 if (crtc != 0)
39929 return 0;
39930
39931 - return atomic_read(&dev_priv->vbl_received);
39932 + return atomic_read_unchecked(&dev_priv->vbl_received);
39933 }
39934
39935 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39936 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39937
39938 status = VIA_READ(VIA_REG_INTERRUPT);
39939 if (status & VIA_IRQ_VBLANK_PENDING) {
39940 - atomic_inc(&dev_priv->vbl_received);
39941 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39942 + atomic_inc_unchecked(&dev_priv->vbl_received);
39943 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39944 do_gettimeofday(&cur_vblank);
39945 if (dev_priv->last_vblank_valid) {
39946 dev_priv->usec_per_vblank =
39947 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39948 dev_priv->last_vblank = cur_vblank;
39949 dev_priv->last_vblank_valid = 1;
39950 }
39951 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39952 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39953 DRM_DEBUG("US per vblank is: %u\n",
39954 dev_priv->usec_per_vblank);
39955 }
39956 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39957
39958 for (i = 0; i < dev_priv->num_irqs; ++i) {
39959 if (status & cur_irq->pending_mask) {
39960 - atomic_inc(&cur_irq->irq_received);
39961 + atomic_inc_unchecked(&cur_irq->irq_received);
39962 DRM_WAKEUP(&cur_irq->irq_queue);
39963 handled = 1;
39964 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39965 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39966 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39967 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39968 masks[irq][4]));
39969 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39970 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39971 } else {
39972 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39973 (((cur_irq_sequence =
39974 - atomic_read(&cur_irq->irq_received)) -
39975 + atomic_read_unchecked(&cur_irq->irq_received)) -
39976 *sequence) <= (1 << 23)));
39977 }
39978 *sequence = cur_irq_sequence;
39979 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39980 }
39981
39982 for (i = 0; i < dev_priv->num_irqs; ++i) {
39983 - atomic_set(&cur_irq->irq_received, 0);
39984 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39985 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39986 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39987 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39988 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39989 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39990 case VIA_IRQ_RELATIVE:
39991 irqwait->request.sequence +=
39992 - atomic_read(&cur_irq->irq_received);
39993 + atomic_read_unchecked(&cur_irq->irq_received);
39994 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39995 case VIA_IRQ_ABSOLUTE:
39996 break;
39997 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39998 index 150ec64..f5165f2 100644
39999 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
40000 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
40001 @@ -290,7 +290,7 @@ struct vmw_private {
40002 * Fencing and IRQs.
40003 */
40004
40005 - atomic_t marker_seq;
40006 + atomic_unchecked_t marker_seq;
40007 wait_queue_head_t fence_queue;
40008 wait_queue_head_t fifo_queue;
40009 int fence_queue_waiters; /* Protected by hw_mutex */
40010 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
40011 index 3eb1486..0a47ee9 100644
40012 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
40013 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
40014 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
40015 (unsigned int) min,
40016 (unsigned int) fifo->capabilities);
40017
40018 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
40019 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
40020 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
40021 vmw_marker_queue_init(&fifo->marker_queue);
40022 return vmw_fifo_send_fence(dev_priv, &dummy);
40023 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
40024 if (reserveable)
40025 iowrite32(bytes, fifo_mem +
40026 SVGA_FIFO_RESERVED);
40027 - return fifo_mem + (next_cmd >> 2);
40028 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
40029 } else {
40030 need_bounce = true;
40031 }
40032 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
40033
40034 fm = vmw_fifo_reserve(dev_priv, bytes);
40035 if (unlikely(fm == NULL)) {
40036 - *seqno = atomic_read(&dev_priv->marker_seq);
40037 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
40038 ret = -ENOMEM;
40039 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
40040 false, 3*HZ);
40041 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
40042 }
40043
40044 do {
40045 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
40046 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
40047 } while (*seqno == 0);
40048
40049 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
40050 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
40051 index c509d40..3b640c3 100644
40052 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
40053 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
40054 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
40055 int ret;
40056
40057 num_clips = arg->num_clips;
40058 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
40059 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
40060
40061 if (unlikely(num_clips == 0))
40062 return 0;
40063 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
40064 int ret;
40065
40066 num_clips = arg->num_clips;
40067 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
40068 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
40069
40070 if (unlikely(num_clips == 0))
40071 return 0;
40072 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
40073 index 4640adb..e1384ed 100644
40074 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
40075 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
40076 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
40077 * emitted. Then the fence is stale and signaled.
40078 */
40079
40080 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
40081 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
40082 > VMW_FENCE_WRAP);
40083
40084 return ret;
40085 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
40086
40087 if (fifo_idle)
40088 down_read(&fifo_state->rwsem);
40089 - signal_seq = atomic_read(&dev_priv->marker_seq);
40090 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
40091 ret = 0;
40092
40093 for (;;) {
40094 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
40095 index 8a8725c2..afed796 100644
40096 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
40097 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
40098 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
40099 while (!vmw_lag_lt(queue, us)) {
40100 spin_lock(&queue->lock);
40101 if (list_empty(&queue->head))
40102 - seqno = atomic_read(&dev_priv->marker_seq);
40103 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
40104 else {
40105 marker = list_first_entry(&queue->head,
40106 struct vmw_marker, head);
40107 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
40108 index b1a05ad..1c9d899 100644
40109 --- a/drivers/gpu/host1x/drm/dc.c
40110 +++ b/drivers/gpu/host1x/drm/dc.c
40111 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
40112 }
40113
40114 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
40115 - dc->debugfs_files[i].data = dc;
40116 + *(void **)&dc->debugfs_files[i].data = dc;
40117
40118 err = drm_debugfs_create_files(dc->debugfs_files,
40119 ARRAY_SIZE(debugfs_files),
40120 diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
40121 index ec0ae2d..dc0780b 100644
40122 --- a/drivers/gpu/vga/vga_switcheroo.c
40123 +++ b/drivers/gpu/vga/vga_switcheroo.c
40124 @@ -643,7 +643,7 @@ static int vga_switcheroo_runtime_resume(struct device *dev)
40125
40126 /* this version is for the case where the power switch is separate
40127 to the device being powered down. */
40128 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain)
40129 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain)
40130 {
40131 /* copy over all the bus versions */
40132 if (dev->bus && dev->bus->pm) {
40133 @@ -688,7 +688,7 @@ static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev)
40134 return ret;
40135 }
40136
40137 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain)
40138 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain)
40139 {
40140 /* copy over all the bus versions */
40141 if (dev->bus && dev->bus->pm) {
40142 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
40143 index aedfe50..1dc929b 100644
40144 --- a/drivers/hid/hid-core.c
40145 +++ b/drivers/hid/hid-core.c
40146 @@ -2416,7 +2416,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
40147
40148 int hid_add_device(struct hid_device *hdev)
40149 {
40150 - static atomic_t id = ATOMIC_INIT(0);
40151 + static atomic_unchecked_t id = ATOMIC_INIT(0);
40152 int ret;
40153
40154 if (WARN_ON(hdev->status & HID_STAT_ADDED))
40155 @@ -2450,7 +2450,7 @@ int hid_add_device(struct hid_device *hdev)
40156 /* XXX hack, any other cleaner solution after the driver core
40157 * is converted to allow more than 20 bytes as the device name? */
40158 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
40159 - hdev->vendor, hdev->product, atomic_inc_return(&id));
40160 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
40161
40162 hid_debug_register(hdev, dev_name(&hdev->dev));
40163 ret = device_add(&hdev->dev);
40164 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
40165 index c13fb5b..55a3802 100644
40166 --- a/drivers/hid/hid-wiimote-debug.c
40167 +++ b/drivers/hid/hid-wiimote-debug.c
40168 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
40169 else if (size == 0)
40170 return -EIO;
40171
40172 - if (copy_to_user(u, buf, size))
40173 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
40174 return -EFAULT;
40175
40176 *off += size;
40177 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
40178 index cedc6da..2c3da2a 100644
40179 --- a/drivers/hid/uhid.c
40180 +++ b/drivers/hid/uhid.c
40181 @@ -47,7 +47,7 @@ struct uhid_device {
40182 struct mutex report_lock;
40183 wait_queue_head_t report_wait;
40184 atomic_t report_done;
40185 - atomic_t report_id;
40186 + atomic_unchecked_t report_id;
40187 struct uhid_event report_buf;
40188 };
40189
40190 @@ -163,7 +163,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
40191
40192 spin_lock_irqsave(&uhid->qlock, flags);
40193 ev->type = UHID_FEATURE;
40194 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
40195 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
40196 ev->u.feature.rnum = rnum;
40197 ev->u.feature.rtype = report_type;
40198
40199 @@ -446,7 +446,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
40200 spin_lock_irqsave(&uhid->qlock, flags);
40201
40202 /* id for old report; drop it silently */
40203 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
40204 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
40205 goto unlock;
40206 if (atomic_read(&uhid->report_done))
40207 goto unlock;
40208 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
40209 index 6de6c98..18319e9 100644
40210 --- a/drivers/hv/channel.c
40211 +++ b/drivers/hv/channel.c
40212 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
40213 int ret = 0;
40214 int t;
40215
40216 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
40217 - atomic_inc(&vmbus_connection.next_gpadl_handle);
40218 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
40219 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
40220
40221 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
40222 if (ret)
40223 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
40224 index 88f4096..e50452e 100644
40225 --- a/drivers/hv/hv.c
40226 +++ b/drivers/hv/hv.c
40227 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
40228 u64 output_address = (output) ? virt_to_phys(output) : 0;
40229 u32 output_address_hi = output_address >> 32;
40230 u32 output_address_lo = output_address & 0xFFFFFFFF;
40231 - void *hypercall_page = hv_context.hypercall_page;
40232 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
40233
40234 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
40235 "=a"(hv_status_lo) : "d" (control_hi),
40236 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
40237 index 7e17a54..a50a33d 100644
40238 --- a/drivers/hv/hv_balloon.c
40239 +++ b/drivers/hv/hv_balloon.c
40240 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
40241
40242 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
40243 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
40244 -static atomic_t trans_id = ATOMIC_INIT(0);
40245 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
40246
40247 static int dm_ring_size = (5 * PAGE_SIZE);
40248
40249 @@ -886,7 +886,7 @@ static void hot_add_req(struct work_struct *dummy)
40250 pr_info("Memory hot add failed\n");
40251
40252 dm->state = DM_INITIALIZED;
40253 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
40254 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40255 vmbus_sendpacket(dm->dev->channel, &resp,
40256 sizeof(struct dm_hot_add_response),
40257 (unsigned long)NULL,
40258 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
40259 memset(&status, 0, sizeof(struct dm_status));
40260 status.hdr.type = DM_STATUS_REPORT;
40261 status.hdr.size = sizeof(struct dm_status);
40262 - status.hdr.trans_id = atomic_inc_return(&trans_id);
40263 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40264
40265 /*
40266 * The host expects the guest to report free memory.
40267 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
40268 * send the status. This can happen if we were interrupted
40269 * after we picked our transaction ID.
40270 */
40271 - if (status.hdr.trans_id != atomic_read(&trans_id))
40272 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
40273 return;
40274
40275 vmbus_sendpacket(dm->dev->channel, &status,
40276 @@ -1108,7 +1108,7 @@ static void balloon_up(struct work_struct *dummy)
40277 */
40278
40279 do {
40280 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
40281 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40282 ret = vmbus_sendpacket(dm_device.dev->channel,
40283 bl_resp,
40284 bl_resp->hdr.size,
40285 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
40286
40287 memset(&resp, 0, sizeof(struct dm_unballoon_response));
40288 resp.hdr.type = DM_UNBALLOON_RESPONSE;
40289 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
40290 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40291 resp.hdr.size = sizeof(struct dm_unballoon_response);
40292
40293 vmbus_sendpacket(dm_device.dev->channel, &resp,
40294 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
40295 memset(&version_req, 0, sizeof(struct dm_version_request));
40296 version_req.hdr.type = DM_VERSION_REQUEST;
40297 version_req.hdr.size = sizeof(struct dm_version_request);
40298 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
40299 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40300 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
40301 version_req.is_last_attempt = 1;
40302
40303 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
40304 memset(&version_req, 0, sizeof(struct dm_version_request));
40305 version_req.hdr.type = DM_VERSION_REQUEST;
40306 version_req.hdr.size = sizeof(struct dm_version_request);
40307 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
40308 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40309 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
40310 version_req.is_last_attempt = 0;
40311
40312 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
40313 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
40314 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
40315 cap_msg.hdr.size = sizeof(struct dm_capabilities);
40316 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
40317 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40318
40319 cap_msg.caps.cap_bits.balloon = 1;
40320 cap_msg.caps.cap_bits.hot_add = 1;
40321 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
40322 index d84918f..7f38f9f 100644
40323 --- a/drivers/hv/hyperv_vmbus.h
40324 +++ b/drivers/hv/hyperv_vmbus.h
40325 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
40326 struct vmbus_connection {
40327 enum vmbus_connect_state conn_state;
40328
40329 - atomic_t next_gpadl_handle;
40330 + atomic_unchecked_t next_gpadl_handle;
40331
40332 /*
40333 * Represents channel interrupts. Each bit position represents a
40334 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
40335 index f9fe46f..356b119 100644
40336 --- a/drivers/hv/vmbus_drv.c
40337 +++ b/drivers/hv/vmbus_drv.c
40338 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
40339 {
40340 int ret = 0;
40341
40342 - static atomic_t device_num = ATOMIC_INIT(0);
40343 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
40344
40345 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
40346 - atomic_inc_return(&device_num));
40347 + atomic_inc_return_unchecked(&device_num));
40348
40349 child_device_obj->device.bus = &hv_bus;
40350 child_device_obj->device.parent = &hv_acpi_dev->dev;
40351 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
40352 index a9e3d01..9dd246e 100644
40353 --- a/drivers/hwmon/acpi_power_meter.c
40354 +++ b/drivers/hwmon/acpi_power_meter.c
40355 @@ -117,7 +117,7 @@ struct sensor_template {
40356 struct device_attribute *devattr,
40357 const char *buf, size_t count);
40358 int index;
40359 -};
40360 +} __do_const;
40361
40362 /* Averaging interval */
40363 static int update_avg_interval(struct acpi_power_meter_resource *resource)
40364 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
40365 struct sensor_template *attrs)
40366 {
40367 struct device *dev = &resource->acpi_dev->dev;
40368 - struct sensor_device_attribute *sensors =
40369 + sensor_device_attribute_no_const *sensors =
40370 &resource->sensors[resource->num_sensors];
40371 int res = 0;
40372
40373 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
40374 index 3288f13..71cfb4e 100644
40375 --- a/drivers/hwmon/applesmc.c
40376 +++ b/drivers/hwmon/applesmc.c
40377 @@ -1106,7 +1106,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
40378 {
40379 struct applesmc_node_group *grp;
40380 struct applesmc_dev_attr *node;
40381 - struct attribute *attr;
40382 + attribute_no_const *attr;
40383 int ret, i;
40384
40385 for (grp = groups; grp->format; grp++) {
40386 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
40387 index b25c643..a13460d 100644
40388 --- a/drivers/hwmon/asus_atk0110.c
40389 +++ b/drivers/hwmon/asus_atk0110.c
40390 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
40391 struct atk_sensor_data {
40392 struct list_head list;
40393 struct atk_data *data;
40394 - struct device_attribute label_attr;
40395 - struct device_attribute input_attr;
40396 - struct device_attribute limit1_attr;
40397 - struct device_attribute limit2_attr;
40398 + device_attribute_no_const label_attr;
40399 + device_attribute_no_const input_attr;
40400 + device_attribute_no_const limit1_attr;
40401 + device_attribute_no_const limit2_attr;
40402 char label_attr_name[ATTR_NAME_SIZE];
40403 char input_attr_name[ATTR_NAME_SIZE];
40404 char limit1_attr_name[ATTR_NAME_SIZE];
40405 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
40406 static struct device_attribute atk_name_attr =
40407 __ATTR(name, 0444, atk_name_show, NULL);
40408
40409 -static void atk_init_attribute(struct device_attribute *attr, char *name,
40410 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
40411 sysfs_show_func show)
40412 {
40413 sysfs_attr_init(&attr->attr);
40414 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
40415 index 78be661..4dd032f 100644
40416 --- a/drivers/hwmon/coretemp.c
40417 +++ b/drivers/hwmon/coretemp.c
40418 @@ -797,7 +797,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
40419 return NOTIFY_OK;
40420 }
40421
40422 -static struct notifier_block coretemp_cpu_notifier __refdata = {
40423 +static struct notifier_block coretemp_cpu_notifier = {
40424 .notifier_call = coretemp_cpu_callback,
40425 };
40426
40427 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
40428 index 632f1dc..57e6a58 100644
40429 --- a/drivers/hwmon/ibmaem.c
40430 +++ b/drivers/hwmon/ibmaem.c
40431 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
40432 struct aem_rw_sensor_template *rw)
40433 {
40434 struct device *dev = &data->pdev->dev;
40435 - struct sensor_device_attribute *sensors = data->sensors;
40436 + sensor_device_attribute_no_const *sensors = data->sensors;
40437 int err;
40438
40439 /* Set up read-only sensors */
40440 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
40441 index 708081b..fe2d4ab 100644
40442 --- a/drivers/hwmon/iio_hwmon.c
40443 +++ b/drivers/hwmon/iio_hwmon.c
40444 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
40445 {
40446 struct device *dev = &pdev->dev;
40447 struct iio_hwmon_state *st;
40448 - struct sensor_device_attribute *a;
40449 + sensor_device_attribute_no_const *a;
40450 int ret, i;
40451 int in_i = 1, temp_i = 1, curr_i = 1;
40452 enum iio_chan_type type;
40453 diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
40454 index 6eb03ce..bea7e3e 100644
40455 --- a/drivers/hwmon/nct6775.c
40456 +++ b/drivers/hwmon/nct6775.c
40457 @@ -936,10 +936,10 @@ static struct attribute_group *
40458 nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
40459 int repeat)
40460 {
40461 - struct attribute_group *group;
40462 + attribute_group_no_const *group;
40463 struct sensor_device_attr_u *su;
40464 - struct sensor_device_attribute *a;
40465 - struct sensor_device_attribute_2 *a2;
40466 + sensor_device_attribute_no_const *a;
40467 + sensor_device_attribute_2_no_const *a2;
40468 struct attribute **attrs;
40469 struct sensor_device_template **t;
40470 int err, i, j, count;
40471 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
40472 index 9319fcf..189ff45 100644
40473 --- a/drivers/hwmon/pmbus/pmbus_core.c
40474 +++ b/drivers/hwmon/pmbus/pmbus_core.c
40475 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
40476 return 0;
40477 }
40478
40479 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
40480 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
40481 const char *name,
40482 umode_t mode,
40483 ssize_t (*show)(struct device *dev,
40484 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
40485 dev_attr->store = store;
40486 }
40487
40488 -static void pmbus_attr_init(struct sensor_device_attribute *a,
40489 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
40490 const char *name,
40491 umode_t mode,
40492 ssize_t (*show)(struct device *dev,
40493 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
40494 u16 reg, u8 mask)
40495 {
40496 struct pmbus_boolean *boolean;
40497 - struct sensor_device_attribute *a;
40498 + sensor_device_attribute_no_const *a;
40499
40500 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
40501 if (!boolean)
40502 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
40503 bool update, bool readonly)
40504 {
40505 struct pmbus_sensor *sensor;
40506 - struct device_attribute *a;
40507 + device_attribute_no_const *a;
40508
40509 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
40510 if (!sensor)
40511 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
40512 const char *lstring, int index)
40513 {
40514 struct pmbus_label *label;
40515 - struct device_attribute *a;
40516 + device_attribute_no_const *a;
40517
40518 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
40519 if (!label)
40520 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
40521 index 97cd45a..ac54d8b 100644
40522 --- a/drivers/hwmon/sht15.c
40523 +++ b/drivers/hwmon/sht15.c
40524 @@ -169,7 +169,7 @@ struct sht15_data {
40525 int supply_uv;
40526 bool supply_uv_valid;
40527 struct work_struct update_supply_work;
40528 - atomic_t interrupt_handled;
40529 + atomic_unchecked_t interrupt_handled;
40530 };
40531
40532 /**
40533 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
40534 ret = gpio_direction_input(data->pdata->gpio_data);
40535 if (ret)
40536 return ret;
40537 - atomic_set(&data->interrupt_handled, 0);
40538 + atomic_set_unchecked(&data->interrupt_handled, 0);
40539
40540 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40541 if (gpio_get_value(data->pdata->gpio_data) == 0) {
40542 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
40543 /* Only relevant if the interrupt hasn't occurred. */
40544 - if (!atomic_read(&data->interrupt_handled))
40545 + if (!atomic_read_unchecked(&data->interrupt_handled))
40546 schedule_work(&data->read_work);
40547 }
40548 ret = wait_event_timeout(data->wait_queue,
40549 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
40550
40551 /* First disable the interrupt */
40552 disable_irq_nosync(irq);
40553 - atomic_inc(&data->interrupt_handled);
40554 + atomic_inc_unchecked(&data->interrupt_handled);
40555 /* Then schedule a reading work struct */
40556 if (data->state != SHT15_READING_NOTHING)
40557 schedule_work(&data->read_work);
40558 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
40559 * If not, then start the interrupt again - care here as could
40560 * have gone low in meantime so verify it hasn't!
40561 */
40562 - atomic_set(&data->interrupt_handled, 0);
40563 + atomic_set_unchecked(&data->interrupt_handled, 0);
40564 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40565 /* If still not occurred or another handler was scheduled */
40566 if (gpio_get_value(data->pdata->gpio_data)
40567 - || atomic_read(&data->interrupt_handled))
40568 + || atomic_read_unchecked(&data->interrupt_handled))
40569 return;
40570 }
40571
40572 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
40573 index 38944e9..ae9e5ed 100644
40574 --- a/drivers/hwmon/via-cputemp.c
40575 +++ b/drivers/hwmon/via-cputemp.c
40576 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
40577 return NOTIFY_OK;
40578 }
40579
40580 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
40581 +static struct notifier_block via_cputemp_cpu_notifier = {
40582 .notifier_call = via_cputemp_cpu_callback,
40583 };
40584
40585 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
40586 index 07f01ac..d79ad3d 100644
40587 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
40588 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
40589 @@ -43,7 +43,7 @@
40590 extern struct i2c_adapter amd756_smbus;
40591
40592 static struct i2c_adapter *s4882_adapter;
40593 -static struct i2c_algorithm *s4882_algo;
40594 +static i2c_algorithm_no_const *s4882_algo;
40595
40596 /* Wrapper access functions for multiplexed SMBus */
40597 static DEFINE_MUTEX(amd756_lock);
40598 diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c
40599 index dae3ddf..26e21d1 100644
40600 --- a/drivers/i2c/busses/i2c-diolan-u2c.c
40601 +++ b/drivers/i2c/busses/i2c-diolan-u2c.c
40602 @@ -99,7 +99,7 @@ MODULE_PARM_DESC(frequency, "I2C clock frequency in hertz");
40603 /* usb layer */
40604
40605 /* Send command to device, and get response. */
40606 -static int diolan_usb_transfer(struct i2c_diolan_u2c *dev)
40607 +static int __intentional_overflow(-1) diolan_usb_transfer(struct i2c_diolan_u2c *dev)
40608 {
40609 int ret = 0;
40610 int actual;
40611 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
40612 index 2ca268d..c6acbdf 100644
40613 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
40614 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
40615 @@ -41,7 +41,7 @@
40616 extern struct i2c_adapter *nforce2_smbus;
40617
40618 static struct i2c_adapter *s4985_adapter;
40619 -static struct i2c_algorithm *s4985_algo;
40620 +static i2c_algorithm_no_const *s4985_algo;
40621
40622 /* Wrapper access functions for multiplexed SMBus */
40623 static DEFINE_MUTEX(nforce2_lock);
40624 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
40625 index c3ccdea..5b3dc1a 100644
40626 --- a/drivers/i2c/i2c-dev.c
40627 +++ b/drivers/i2c/i2c-dev.c
40628 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
40629 break;
40630 }
40631
40632 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
40633 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
40634 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
40635 if (IS_ERR(rdwr_pa[i].buf)) {
40636 res = PTR_ERR(rdwr_pa[i].buf);
40637 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
40638 index 0b510ba..4fbb5085 100644
40639 --- a/drivers/ide/ide-cd.c
40640 +++ b/drivers/ide/ide-cd.c
40641 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
40642 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
40643 if ((unsigned long)buf & alignment
40644 || blk_rq_bytes(rq) & q->dma_pad_mask
40645 - || object_is_on_stack(buf))
40646 + || object_starts_on_stack(buf))
40647 drive->dma = 0;
40648 }
40649 }
40650 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
40651 index f95c697..0a1b05c 100644
40652 --- a/drivers/iio/industrialio-core.c
40653 +++ b/drivers/iio/industrialio-core.c
40654 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
40655 }
40656
40657 static
40658 -int __iio_device_attr_init(struct device_attribute *dev_attr,
40659 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
40660 const char *postfix,
40661 struct iio_chan_spec const *chan,
40662 ssize_t (*readfunc)(struct device *dev,
40663 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
40664 index 784b97c..c9ceadf 100644
40665 --- a/drivers/infiniband/core/cm.c
40666 +++ b/drivers/infiniband/core/cm.c
40667 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
40668
40669 struct cm_counter_group {
40670 struct kobject obj;
40671 - atomic_long_t counter[CM_ATTR_COUNT];
40672 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
40673 };
40674
40675 struct cm_counter_attribute {
40676 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
40677 struct ib_mad_send_buf *msg = NULL;
40678 int ret;
40679
40680 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40681 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40682 counter[CM_REQ_COUNTER]);
40683
40684 /* Quick state check to discard duplicate REQs. */
40685 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
40686 if (!cm_id_priv)
40687 return;
40688
40689 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40690 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40691 counter[CM_REP_COUNTER]);
40692 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
40693 if (ret)
40694 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
40695 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
40696 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
40697 spin_unlock_irq(&cm_id_priv->lock);
40698 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40699 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40700 counter[CM_RTU_COUNTER]);
40701 goto out;
40702 }
40703 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
40704 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
40705 dreq_msg->local_comm_id);
40706 if (!cm_id_priv) {
40707 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40708 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40709 counter[CM_DREQ_COUNTER]);
40710 cm_issue_drep(work->port, work->mad_recv_wc);
40711 return -EINVAL;
40712 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
40713 case IB_CM_MRA_REP_RCVD:
40714 break;
40715 case IB_CM_TIMEWAIT:
40716 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40717 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40718 counter[CM_DREQ_COUNTER]);
40719 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40720 goto unlock;
40721 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
40722 cm_free_msg(msg);
40723 goto deref;
40724 case IB_CM_DREQ_RCVD:
40725 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40726 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40727 counter[CM_DREQ_COUNTER]);
40728 goto unlock;
40729 default:
40730 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
40731 ib_modify_mad(cm_id_priv->av.port->mad_agent,
40732 cm_id_priv->msg, timeout)) {
40733 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
40734 - atomic_long_inc(&work->port->
40735 + atomic_long_inc_unchecked(&work->port->
40736 counter_group[CM_RECV_DUPLICATES].
40737 counter[CM_MRA_COUNTER]);
40738 goto out;
40739 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
40740 break;
40741 case IB_CM_MRA_REQ_RCVD:
40742 case IB_CM_MRA_REP_RCVD:
40743 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40744 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40745 counter[CM_MRA_COUNTER]);
40746 /* fall through */
40747 default:
40748 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
40749 case IB_CM_LAP_IDLE:
40750 break;
40751 case IB_CM_MRA_LAP_SENT:
40752 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40753 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40754 counter[CM_LAP_COUNTER]);
40755 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40756 goto unlock;
40757 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
40758 cm_free_msg(msg);
40759 goto deref;
40760 case IB_CM_LAP_RCVD:
40761 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40762 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40763 counter[CM_LAP_COUNTER]);
40764 goto unlock;
40765 default:
40766 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
40767 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
40768 if (cur_cm_id_priv) {
40769 spin_unlock_irq(&cm.lock);
40770 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40771 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40772 counter[CM_SIDR_REQ_COUNTER]);
40773 goto out; /* Duplicate message. */
40774 }
40775 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
40776 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
40777 msg->retries = 1;
40778
40779 - atomic_long_add(1 + msg->retries,
40780 + atomic_long_add_unchecked(1 + msg->retries,
40781 &port->counter_group[CM_XMIT].counter[attr_index]);
40782 if (msg->retries)
40783 - atomic_long_add(msg->retries,
40784 + atomic_long_add_unchecked(msg->retries,
40785 &port->counter_group[CM_XMIT_RETRIES].
40786 counter[attr_index]);
40787
40788 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40789 }
40790
40791 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40792 - atomic_long_inc(&port->counter_group[CM_RECV].
40793 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40794 counter[attr_id - CM_ATTR_ID_OFFSET]);
40795
40796 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40797 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40798 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40799
40800 return sprintf(buf, "%ld\n",
40801 - atomic_long_read(&group->counter[cm_attr->index]));
40802 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40803 }
40804
40805 static const struct sysfs_ops cm_counter_ops = {
40806 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40807 index 9f5ad7c..588cd84 100644
40808 --- a/drivers/infiniband/core/fmr_pool.c
40809 +++ b/drivers/infiniband/core/fmr_pool.c
40810 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40811
40812 struct task_struct *thread;
40813
40814 - atomic_t req_ser;
40815 - atomic_t flush_ser;
40816 + atomic_unchecked_t req_ser;
40817 + atomic_unchecked_t flush_ser;
40818
40819 wait_queue_head_t force_wait;
40820 };
40821 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40822 struct ib_fmr_pool *pool = pool_ptr;
40823
40824 do {
40825 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40826 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40827 ib_fmr_batch_release(pool);
40828
40829 - atomic_inc(&pool->flush_ser);
40830 + atomic_inc_unchecked(&pool->flush_ser);
40831 wake_up_interruptible(&pool->force_wait);
40832
40833 if (pool->flush_function)
40834 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40835 }
40836
40837 set_current_state(TASK_INTERRUPTIBLE);
40838 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40839 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40840 !kthread_should_stop())
40841 schedule();
40842 __set_current_state(TASK_RUNNING);
40843 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40844 pool->dirty_watermark = params->dirty_watermark;
40845 pool->dirty_len = 0;
40846 spin_lock_init(&pool->pool_lock);
40847 - atomic_set(&pool->req_ser, 0);
40848 - atomic_set(&pool->flush_ser, 0);
40849 + atomic_set_unchecked(&pool->req_ser, 0);
40850 + atomic_set_unchecked(&pool->flush_ser, 0);
40851 init_waitqueue_head(&pool->force_wait);
40852
40853 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40854 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40855 }
40856 spin_unlock_irq(&pool->pool_lock);
40857
40858 - serial = atomic_inc_return(&pool->req_ser);
40859 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40860 wake_up_process(pool->thread);
40861
40862 if (wait_event_interruptible(pool->force_wait,
40863 - atomic_read(&pool->flush_ser) - serial >= 0))
40864 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40865 return -EINTR;
40866
40867 return 0;
40868 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40869 } else {
40870 list_add_tail(&fmr->list, &pool->dirty_list);
40871 if (++pool->dirty_len >= pool->dirty_watermark) {
40872 - atomic_inc(&pool->req_ser);
40873 + atomic_inc_unchecked(&pool->req_ser);
40874 wake_up_process(pool->thread);
40875 }
40876 }
40877 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40878 index 4cb8eb2..146bf60 100644
40879 --- a/drivers/infiniband/hw/cxgb4/mem.c
40880 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40881 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40882 int err;
40883 struct fw_ri_tpte tpt;
40884 u32 stag_idx;
40885 - static atomic_t key;
40886 + static atomic_unchecked_t key;
40887
40888 if (c4iw_fatal_error(rdev))
40889 return -EIO;
40890 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40891 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40892 rdev->stats.stag.max = rdev->stats.stag.cur;
40893 mutex_unlock(&rdev->stats.lock);
40894 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40895 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40896 }
40897 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40898 __func__, stag_state, type, pdid, stag_idx);
40899 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40900 index 79b3dbc..96e5fcc 100644
40901 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40902 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40903 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40904 struct ib_atomic_eth *ateth;
40905 struct ipath_ack_entry *e;
40906 u64 vaddr;
40907 - atomic64_t *maddr;
40908 + atomic64_unchecked_t *maddr;
40909 u64 sdata;
40910 u32 rkey;
40911 u8 next;
40912 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40913 IB_ACCESS_REMOTE_ATOMIC)))
40914 goto nack_acc_unlck;
40915 /* Perform atomic OP and save result. */
40916 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40917 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40918 sdata = be64_to_cpu(ateth->swap_data);
40919 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40920 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40921 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40922 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40923 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40924 be64_to_cpu(ateth->compare_data),
40925 sdata);
40926 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40927 index 1f95bba..9530f87 100644
40928 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40929 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40930 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40931 unsigned long flags;
40932 struct ib_wc wc;
40933 u64 sdata;
40934 - atomic64_t *maddr;
40935 + atomic64_unchecked_t *maddr;
40936 enum ib_wc_status send_status;
40937
40938 /*
40939 @@ -382,11 +382,11 @@ again:
40940 IB_ACCESS_REMOTE_ATOMIC)))
40941 goto acc_err;
40942 /* Perform atomic OP and save result. */
40943 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40944 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40945 sdata = wqe->wr.wr.atomic.compare_add;
40946 *(u64 *) sqp->s_sge.sge.vaddr =
40947 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40948 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40949 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40950 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40951 sdata, wqe->wr.wr.atomic.swap);
40952 goto send_comp;
40953 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40954 index f2a3f48..673ec79 100644
40955 --- a/drivers/infiniband/hw/mlx4/mad.c
40956 +++ b/drivers/infiniband/hw/mlx4/mad.c
40957 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40958
40959 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40960 {
40961 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40962 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40963 cpu_to_be64(0xff00000000000000LL);
40964 }
40965
40966 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40967 index 25b2cdf..099ff97 100644
40968 --- a/drivers/infiniband/hw/mlx4/mcg.c
40969 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40970 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40971 {
40972 char name[20];
40973
40974 - atomic_set(&ctx->tid, 0);
40975 + atomic_set_unchecked(&ctx->tid, 0);
40976 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40977 ctx->mcg_wq = create_singlethread_workqueue(name);
40978 if (!ctx->mcg_wq)
40979 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40980 index 036b663..c9a8c73 100644
40981 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40982 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40983 @@ -404,7 +404,7 @@ struct mlx4_ib_demux_ctx {
40984 struct list_head mcg_mgid0_list;
40985 struct workqueue_struct *mcg_wq;
40986 struct mlx4_ib_demux_pv_ctx **tun;
40987 - atomic_t tid;
40988 + atomic_unchecked_t tid;
40989 int flushing; /* flushing the work queue */
40990 };
40991
40992 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40993 index 9d3e5c1..6f166df 100644
40994 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40995 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40996 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40997 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40998 }
40999
41000 -int mthca_QUERY_FW(struct mthca_dev *dev)
41001 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
41002 {
41003 struct mthca_mailbox *mailbox;
41004 u32 *outbox;
41005 @@ -1612,7 +1612,7 @@ int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
41006 CMD_TIME_CLASS_B);
41007 }
41008
41009 -int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
41010 +int __intentional_overflow(-1) mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
41011 int num_mtt)
41012 {
41013 return mthca_cmd(dev, mailbox->dma, num_mtt, 0, CMD_WRITE_MTT,
41014 @@ -1634,7 +1634,7 @@ int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
41015 0, CMD_MAP_EQ, CMD_TIME_CLASS_B);
41016 }
41017
41018 -int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
41019 +int __intentional_overflow(-1) mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
41020 int eq_num)
41021 {
41022 return mthca_cmd(dev, mailbox->dma, eq_num, 0, CMD_SW2HW_EQ,
41023 @@ -1857,7 +1857,7 @@ int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn)
41024 CMD_TIME_CLASS_B);
41025 }
41026
41027 -int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
41028 +int __intentional_overflow(-1) mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
41029 int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
41030 void *in_mad, void *response_mad)
41031 {
41032 diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
41033 index 87897b9..7e79542 100644
41034 --- a/drivers/infiniband/hw/mthca/mthca_main.c
41035 +++ b/drivers/infiniband/hw/mthca/mthca_main.c
41036 @@ -692,7 +692,7 @@ err_close:
41037 return err;
41038 }
41039
41040 -static int mthca_setup_hca(struct mthca_dev *dev)
41041 +static int __intentional_overflow(-1) mthca_setup_hca(struct mthca_dev *dev)
41042 {
41043 int err;
41044
41045 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
41046 index ed9a989..6aa5dc2 100644
41047 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
41048 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
41049 @@ -81,7 +81,7 @@ struct mthca_mpt_entry {
41050 * through the bitmaps)
41051 */
41052
41053 -static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
41054 +static u32 __intentional_overflow(-1) mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
41055 {
41056 int o;
41057 int m;
41058 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
41059 return key;
41060 }
41061
41062 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
41063 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
41064 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
41065 {
41066 struct mthca_mailbox *mailbox;
41067 @@ -516,7 +516,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
41068 return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr);
41069 }
41070
41071 -int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
41072 +int __intentional_overflow(-1) mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
41073 u64 *buffer_list, int buffer_size_shift,
41074 int list_len, u64 iova, u64 total_size,
41075 u32 access, struct mthca_mr *mr)
41076 diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
41077 index 5b71d43..35a9e14 100644
41078 --- a/drivers/infiniband/hw/mthca/mthca_provider.c
41079 +++ b/drivers/infiniband/hw/mthca/mthca_provider.c
41080 @@ -763,7 +763,7 @@ unlock:
41081 return 0;
41082 }
41083
41084 -static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
41085 +static int __intentional_overflow(-1) mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
41086 {
41087 struct mthca_dev *dev = to_mdev(ibcq->device);
41088 struct mthca_cq *cq = to_mcq(ibcq);
41089 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
41090 index 4291410..d2ab1fb 100644
41091 --- a/drivers/infiniband/hw/nes/nes.c
41092 +++ b/drivers/infiniband/hw/nes/nes.c
41093 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
41094 LIST_HEAD(nes_adapter_list);
41095 static LIST_HEAD(nes_dev_list);
41096
41097 -atomic_t qps_destroyed;
41098 +atomic_unchecked_t qps_destroyed;
41099
41100 static unsigned int ee_flsh_adapter;
41101 static unsigned int sysfs_nonidx_addr;
41102 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
41103 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
41104 struct nes_adapter *nesadapter = nesdev->nesadapter;
41105
41106 - atomic_inc(&qps_destroyed);
41107 + atomic_inc_unchecked(&qps_destroyed);
41108
41109 /* Free the control structures */
41110
41111 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
41112 index 33cc589..3bd6538 100644
41113 --- a/drivers/infiniband/hw/nes/nes.h
41114 +++ b/drivers/infiniband/hw/nes/nes.h
41115 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
41116 extern unsigned int wqm_quanta;
41117 extern struct list_head nes_adapter_list;
41118
41119 -extern atomic_t cm_connects;
41120 -extern atomic_t cm_accepts;
41121 -extern atomic_t cm_disconnects;
41122 -extern atomic_t cm_closes;
41123 -extern atomic_t cm_connecteds;
41124 -extern atomic_t cm_connect_reqs;
41125 -extern atomic_t cm_rejects;
41126 -extern atomic_t mod_qp_timouts;
41127 -extern atomic_t qps_created;
41128 -extern atomic_t qps_destroyed;
41129 -extern atomic_t sw_qps_destroyed;
41130 +extern atomic_unchecked_t cm_connects;
41131 +extern atomic_unchecked_t cm_accepts;
41132 +extern atomic_unchecked_t cm_disconnects;
41133 +extern atomic_unchecked_t cm_closes;
41134 +extern atomic_unchecked_t cm_connecteds;
41135 +extern atomic_unchecked_t cm_connect_reqs;
41136 +extern atomic_unchecked_t cm_rejects;
41137 +extern atomic_unchecked_t mod_qp_timouts;
41138 +extern atomic_unchecked_t qps_created;
41139 +extern atomic_unchecked_t qps_destroyed;
41140 +extern atomic_unchecked_t sw_qps_destroyed;
41141 extern u32 mh_detected;
41142 extern u32 mh_pauses_sent;
41143 extern u32 cm_packets_sent;
41144 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
41145 extern u32 cm_packets_received;
41146 extern u32 cm_packets_dropped;
41147 extern u32 cm_packets_retrans;
41148 -extern atomic_t cm_listens_created;
41149 -extern atomic_t cm_listens_destroyed;
41150 +extern atomic_unchecked_t cm_listens_created;
41151 +extern atomic_unchecked_t cm_listens_destroyed;
41152 extern u32 cm_backlog_drops;
41153 -extern atomic_t cm_loopbacks;
41154 -extern atomic_t cm_nodes_created;
41155 -extern atomic_t cm_nodes_destroyed;
41156 -extern atomic_t cm_accel_dropped_pkts;
41157 -extern atomic_t cm_resets_recvd;
41158 -extern atomic_t pau_qps_created;
41159 -extern atomic_t pau_qps_destroyed;
41160 +extern atomic_unchecked_t cm_loopbacks;
41161 +extern atomic_unchecked_t cm_nodes_created;
41162 +extern atomic_unchecked_t cm_nodes_destroyed;
41163 +extern atomic_unchecked_t cm_accel_dropped_pkts;
41164 +extern atomic_unchecked_t cm_resets_recvd;
41165 +extern atomic_unchecked_t pau_qps_created;
41166 +extern atomic_unchecked_t pau_qps_destroyed;
41167
41168 extern u32 int_mod_timer_init;
41169 extern u32 int_mod_cq_depth_256;
41170 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
41171 index 6b29249..57081dd 100644
41172 --- a/drivers/infiniband/hw/nes/nes_cm.c
41173 +++ b/drivers/infiniband/hw/nes/nes_cm.c
41174 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
41175 u32 cm_packets_retrans;
41176 u32 cm_packets_created;
41177 u32 cm_packets_received;
41178 -atomic_t cm_listens_created;
41179 -atomic_t cm_listens_destroyed;
41180 +atomic_unchecked_t cm_listens_created;
41181 +atomic_unchecked_t cm_listens_destroyed;
41182 u32 cm_backlog_drops;
41183 -atomic_t cm_loopbacks;
41184 -atomic_t cm_nodes_created;
41185 -atomic_t cm_nodes_destroyed;
41186 -atomic_t cm_accel_dropped_pkts;
41187 -atomic_t cm_resets_recvd;
41188 +atomic_unchecked_t cm_loopbacks;
41189 +atomic_unchecked_t cm_nodes_created;
41190 +atomic_unchecked_t cm_nodes_destroyed;
41191 +atomic_unchecked_t cm_accel_dropped_pkts;
41192 +atomic_unchecked_t cm_resets_recvd;
41193
41194 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
41195 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
41196 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
41197
41198 static struct nes_cm_core *g_cm_core;
41199
41200 -atomic_t cm_connects;
41201 -atomic_t cm_accepts;
41202 -atomic_t cm_disconnects;
41203 -atomic_t cm_closes;
41204 -atomic_t cm_connecteds;
41205 -atomic_t cm_connect_reqs;
41206 -atomic_t cm_rejects;
41207 +atomic_unchecked_t cm_connects;
41208 +atomic_unchecked_t cm_accepts;
41209 +atomic_unchecked_t cm_disconnects;
41210 +atomic_unchecked_t cm_closes;
41211 +atomic_unchecked_t cm_connecteds;
41212 +atomic_unchecked_t cm_connect_reqs;
41213 +atomic_unchecked_t cm_rejects;
41214
41215 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
41216 {
41217 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
41218 kfree(listener);
41219 listener = NULL;
41220 ret = 0;
41221 - atomic_inc(&cm_listens_destroyed);
41222 + atomic_inc_unchecked(&cm_listens_destroyed);
41223 } else {
41224 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
41225 }
41226 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
41227 cm_node->rem_mac);
41228
41229 add_hte_node(cm_core, cm_node);
41230 - atomic_inc(&cm_nodes_created);
41231 + atomic_inc_unchecked(&cm_nodes_created);
41232
41233 return cm_node;
41234 }
41235 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
41236 }
41237
41238 atomic_dec(&cm_core->node_cnt);
41239 - atomic_inc(&cm_nodes_destroyed);
41240 + atomic_inc_unchecked(&cm_nodes_destroyed);
41241 nesqp = cm_node->nesqp;
41242 if (nesqp) {
41243 nesqp->cm_node = NULL;
41244 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
41245
41246 static void drop_packet(struct sk_buff *skb)
41247 {
41248 - atomic_inc(&cm_accel_dropped_pkts);
41249 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
41250 dev_kfree_skb_any(skb);
41251 }
41252
41253 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
41254 {
41255
41256 int reset = 0; /* whether to send reset in case of err.. */
41257 - atomic_inc(&cm_resets_recvd);
41258 + atomic_inc_unchecked(&cm_resets_recvd);
41259 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
41260 " refcnt=%d\n", cm_node, cm_node->state,
41261 atomic_read(&cm_node->ref_count));
41262 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
41263 rem_ref_cm_node(cm_node->cm_core, cm_node);
41264 return NULL;
41265 }
41266 - atomic_inc(&cm_loopbacks);
41267 + atomic_inc_unchecked(&cm_loopbacks);
41268 loopbackremotenode->loopbackpartner = cm_node;
41269 loopbackremotenode->tcp_cntxt.rcv_wscale =
41270 NES_CM_DEFAULT_RCV_WND_SCALE;
41271 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
41272 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
41273 else {
41274 rem_ref_cm_node(cm_core, cm_node);
41275 - atomic_inc(&cm_accel_dropped_pkts);
41276 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
41277 dev_kfree_skb_any(skb);
41278 }
41279 break;
41280 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
41281
41282 if ((cm_id) && (cm_id->event_handler)) {
41283 if (issue_disconn) {
41284 - atomic_inc(&cm_disconnects);
41285 + atomic_inc_unchecked(&cm_disconnects);
41286 cm_event.event = IW_CM_EVENT_DISCONNECT;
41287 cm_event.status = disconn_status;
41288 cm_event.local_addr = cm_id->local_addr;
41289 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
41290 }
41291
41292 if (issue_close) {
41293 - atomic_inc(&cm_closes);
41294 + atomic_inc_unchecked(&cm_closes);
41295 nes_disconnect(nesqp, 1);
41296
41297 cm_id->provider_data = nesqp;
41298 @@ -3035,7 +3035,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
41299
41300 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
41301 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
41302 - atomic_inc(&cm_accepts);
41303 + atomic_inc_unchecked(&cm_accepts);
41304
41305 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
41306 netdev_refcnt_read(nesvnic->netdev));
41307 @@ -3224,7 +3224,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
41308 struct nes_cm_core *cm_core;
41309 u8 *start_buff;
41310
41311 - atomic_inc(&cm_rejects);
41312 + atomic_inc_unchecked(&cm_rejects);
41313 cm_node = (struct nes_cm_node *)cm_id->provider_data;
41314 loopback = cm_node->loopbackpartner;
41315 cm_core = cm_node->cm_core;
41316 @@ -3286,7 +3286,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
41317 ntohs(raddr->sin_port), ntohl(laddr->sin_addr.s_addr),
41318 ntohs(laddr->sin_port));
41319
41320 - atomic_inc(&cm_connects);
41321 + atomic_inc_unchecked(&cm_connects);
41322 nesqp->active_conn = 1;
41323
41324 /* cache the cm_id in the qp */
41325 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
41326 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
41327 return err;
41328 }
41329 - atomic_inc(&cm_listens_created);
41330 + atomic_inc_unchecked(&cm_listens_created);
41331 }
41332
41333 cm_id->add_ref(cm_id);
41334 @@ -3505,7 +3505,7 @@ static void cm_event_connected(struct nes_cm_event *event)
41335
41336 if (nesqp->destroyed)
41337 return;
41338 - atomic_inc(&cm_connecteds);
41339 + atomic_inc_unchecked(&cm_connecteds);
41340 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
41341 " local port 0x%04X. jiffies = %lu.\n",
41342 nesqp->hwqp.qp_id, ntohl(raddr->sin_addr.s_addr),
41343 @@ -3686,7 +3686,7 @@ static void cm_event_reset(struct nes_cm_event *event)
41344
41345 cm_id->add_ref(cm_id);
41346 ret = cm_id->event_handler(cm_id, &cm_event);
41347 - atomic_inc(&cm_closes);
41348 + atomic_inc_unchecked(&cm_closes);
41349 cm_event.event = IW_CM_EVENT_CLOSE;
41350 cm_event.status = 0;
41351 cm_event.provider_data = cm_id->provider_data;
41352 @@ -3726,7 +3726,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
41353 return;
41354 cm_id = cm_node->cm_id;
41355
41356 - atomic_inc(&cm_connect_reqs);
41357 + atomic_inc_unchecked(&cm_connect_reqs);
41358 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
41359 cm_node, cm_id, jiffies);
41360
41361 @@ -3770,7 +3770,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
41362 return;
41363 cm_id = cm_node->cm_id;
41364
41365 - atomic_inc(&cm_connect_reqs);
41366 + atomic_inc_unchecked(&cm_connect_reqs);
41367 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
41368 cm_node, cm_id, jiffies);
41369
41370 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
41371 index 4166452..fc952c3 100644
41372 --- a/drivers/infiniband/hw/nes/nes_mgt.c
41373 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
41374 @@ -40,8 +40,8 @@
41375 #include "nes.h"
41376 #include "nes_mgt.h"
41377
41378 -atomic_t pau_qps_created;
41379 -atomic_t pau_qps_destroyed;
41380 +atomic_unchecked_t pau_qps_created;
41381 +atomic_unchecked_t pau_qps_destroyed;
41382
41383 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
41384 {
41385 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
41386 {
41387 struct sk_buff *skb;
41388 unsigned long flags;
41389 - atomic_inc(&pau_qps_destroyed);
41390 + atomic_inc_unchecked(&pau_qps_destroyed);
41391
41392 /* Free packets that have not yet been forwarded */
41393 /* Lock is acquired by skb_dequeue when removing the skb */
41394 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
41395 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
41396 skb_queue_head_init(&nesqp->pau_list);
41397 spin_lock_init(&nesqp->pau_lock);
41398 - atomic_inc(&pau_qps_created);
41399 + atomic_inc_unchecked(&pau_qps_created);
41400 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
41401 }
41402
41403 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
41404 index 49eb511..a774366 100644
41405 --- a/drivers/infiniband/hw/nes/nes_nic.c
41406 +++ b/drivers/infiniband/hw/nes/nes_nic.c
41407 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
41408 target_stat_values[++index] = mh_detected;
41409 target_stat_values[++index] = mh_pauses_sent;
41410 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
41411 - target_stat_values[++index] = atomic_read(&cm_connects);
41412 - target_stat_values[++index] = atomic_read(&cm_accepts);
41413 - target_stat_values[++index] = atomic_read(&cm_disconnects);
41414 - target_stat_values[++index] = atomic_read(&cm_connecteds);
41415 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
41416 - target_stat_values[++index] = atomic_read(&cm_rejects);
41417 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
41418 - target_stat_values[++index] = atomic_read(&qps_created);
41419 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
41420 - target_stat_values[++index] = atomic_read(&qps_destroyed);
41421 - target_stat_values[++index] = atomic_read(&cm_closes);
41422 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
41423 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
41424 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
41425 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
41426 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
41427 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
41428 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
41429 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
41430 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
41431 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
41432 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
41433 target_stat_values[++index] = cm_packets_sent;
41434 target_stat_values[++index] = cm_packets_bounced;
41435 target_stat_values[++index] = cm_packets_created;
41436 target_stat_values[++index] = cm_packets_received;
41437 target_stat_values[++index] = cm_packets_dropped;
41438 target_stat_values[++index] = cm_packets_retrans;
41439 - target_stat_values[++index] = atomic_read(&cm_listens_created);
41440 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
41441 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
41442 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
41443 target_stat_values[++index] = cm_backlog_drops;
41444 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
41445 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
41446 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
41447 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
41448 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
41449 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
41450 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
41451 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
41452 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
41453 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
41454 target_stat_values[++index] = nesadapter->free_4kpbl;
41455 target_stat_values[++index] = nesadapter->free_256pbl;
41456 target_stat_values[++index] = int_mod_timer_init;
41457 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
41458 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
41459 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
41460 - target_stat_values[++index] = atomic_read(&pau_qps_created);
41461 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
41462 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
41463 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
41464 }
41465
41466 /**
41467 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
41468 index 5b53ca5..443da3c 100644
41469 --- a/drivers/infiniband/hw/nes/nes_verbs.c
41470 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
41471 @@ -46,9 +46,9 @@
41472
41473 #include <rdma/ib_umem.h>
41474
41475 -atomic_t mod_qp_timouts;
41476 -atomic_t qps_created;
41477 -atomic_t sw_qps_destroyed;
41478 +atomic_unchecked_t mod_qp_timouts;
41479 +atomic_unchecked_t qps_created;
41480 +atomic_unchecked_t sw_qps_destroyed;
41481
41482 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
41483
41484 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
41485 if (init_attr->create_flags)
41486 return ERR_PTR(-EINVAL);
41487
41488 - atomic_inc(&qps_created);
41489 + atomic_inc_unchecked(&qps_created);
41490 switch (init_attr->qp_type) {
41491 case IB_QPT_RC:
41492 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
41493 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
41494 struct iw_cm_event cm_event;
41495 int ret = 0;
41496
41497 - atomic_inc(&sw_qps_destroyed);
41498 + atomic_inc_unchecked(&sw_qps_destroyed);
41499 nesqp->destroyed = 1;
41500
41501 /* Blow away the connection if it exists. */
41502 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
41503 index 1946101..09766d2 100644
41504 --- a/drivers/infiniband/hw/qib/qib.h
41505 +++ b/drivers/infiniband/hw/qib/qib.h
41506 @@ -52,6 +52,7 @@
41507 #include <linux/kref.h>
41508 #include <linux/sched.h>
41509 #include <linux/kthread.h>
41510 +#include <linux/slab.h>
41511
41512 #include "qib_common.h"
41513 #include "qib_verbs.h"
41514 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
41515 index 922a7fe..bb035db 100644
41516 --- a/drivers/input/gameport/gameport.c
41517 +++ b/drivers/input/gameport/gameport.c
41518 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
41519 */
41520 static void gameport_init_port(struct gameport *gameport)
41521 {
41522 - static atomic_t gameport_no = ATOMIC_INIT(0);
41523 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
41524
41525 __module_get(THIS_MODULE);
41526
41527 mutex_init(&gameport->drv_mutex);
41528 device_initialize(&gameport->dev);
41529 dev_set_name(&gameport->dev, "gameport%lu",
41530 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
41531 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
41532 gameport->dev.bus = &gameport_bus;
41533 gameport->dev.release = gameport_release_port;
41534 if (gameport->parent)
41535 diff --git a/drivers/input/input.c b/drivers/input/input.c
41536 index 74f4798..d9f7168 100644
41537 --- a/drivers/input/input.c
41538 +++ b/drivers/input/input.c
41539 @@ -1734,7 +1734,7 @@ EXPORT_SYMBOL_GPL(input_class);
41540 */
41541 struct input_dev *input_allocate_device(void)
41542 {
41543 - static atomic_t input_no = ATOMIC_INIT(0);
41544 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
41545 struct input_dev *dev;
41546
41547 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
41548 @@ -1749,7 +1749,7 @@ struct input_dev *input_allocate_device(void)
41549 INIT_LIST_HEAD(&dev->node);
41550
41551 dev_set_name(&dev->dev, "input%ld",
41552 - (unsigned long) atomic_inc_return(&input_no) - 1);
41553 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
41554
41555 __module_get(THIS_MODULE);
41556 }
41557 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
41558 index 04c69af..5f92d00 100644
41559 --- a/drivers/input/joystick/sidewinder.c
41560 +++ b/drivers/input/joystick/sidewinder.c
41561 @@ -30,6 +30,7 @@
41562 #include <linux/kernel.h>
41563 #include <linux/module.h>
41564 #include <linux/slab.h>
41565 +#include <linux/sched.h>
41566 #include <linux/init.h>
41567 #include <linux/input.h>
41568 #include <linux/gameport.h>
41569 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
41570 index 75e3b10..fb390fd 100644
41571 --- a/drivers/input/joystick/xpad.c
41572 +++ b/drivers/input/joystick/xpad.c
41573 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
41574
41575 static int xpad_led_probe(struct usb_xpad *xpad)
41576 {
41577 - static atomic_t led_seq = ATOMIC_INIT(0);
41578 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
41579 long led_no;
41580 struct xpad_led *led;
41581 struct led_classdev *led_cdev;
41582 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
41583 if (!led)
41584 return -ENOMEM;
41585
41586 - led_no = (long)atomic_inc_return(&led_seq) - 1;
41587 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
41588
41589 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
41590 led->xpad = xpad;
41591 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
41592 index e204f26..8459f15 100644
41593 --- a/drivers/input/misc/ims-pcu.c
41594 +++ b/drivers/input/misc/ims-pcu.c
41595 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
41596
41597 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41598 {
41599 - static atomic_t device_no = ATOMIC_INIT(0);
41600 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
41601
41602 const struct ims_pcu_device_info *info;
41603 u8 device_id;
41604 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41605 }
41606
41607 /* Device appears to be operable, complete initialization */
41608 - pcu->device_no = atomic_inc_return(&device_no) - 1;
41609 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
41610
41611 error = ims_pcu_setup_backlight(pcu);
41612 if (error)
41613 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
41614 index 2f0b39d..7370f13 100644
41615 --- a/drivers/input/mouse/psmouse.h
41616 +++ b/drivers/input/mouse/psmouse.h
41617 @@ -116,7 +116,7 @@ struct psmouse_attribute {
41618 ssize_t (*set)(struct psmouse *psmouse, void *data,
41619 const char *buf, size_t count);
41620 bool protect;
41621 -};
41622 +} __do_const;
41623 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
41624
41625 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
41626 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
41627 index 4c842c3..590b0bf 100644
41628 --- a/drivers/input/mousedev.c
41629 +++ b/drivers/input/mousedev.c
41630 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
41631
41632 spin_unlock_irq(&client->packet_lock);
41633
41634 - if (copy_to_user(buffer, data, count))
41635 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
41636 return -EFAULT;
41637
41638 return count;
41639 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
41640 index 2b56855..5a55837 100644
41641 --- a/drivers/input/serio/serio.c
41642 +++ b/drivers/input/serio/serio.c
41643 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
41644 */
41645 static void serio_init_port(struct serio *serio)
41646 {
41647 - static atomic_t serio_no = ATOMIC_INIT(0);
41648 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
41649
41650 __module_get(THIS_MODULE);
41651
41652 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
41653 mutex_init(&serio->drv_mutex);
41654 device_initialize(&serio->dev);
41655 dev_set_name(&serio->dev, "serio%ld",
41656 - (long)atomic_inc_return(&serio_no) - 1);
41657 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
41658 serio->dev.bus = &serio_bus;
41659 serio->dev.release = serio_release_port;
41660 serio->dev.groups = serio_device_attr_groups;
41661 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
41662 index 59df2e7..8f1cafb 100644
41663 --- a/drivers/input/serio/serio_raw.c
41664 +++ b/drivers/input/serio/serio_raw.c
41665 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
41666
41667 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41668 {
41669 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
41670 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
41671 struct serio_raw *serio_raw;
41672 int err;
41673
41674 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41675 }
41676
41677 snprintf(serio_raw->name, sizeof(serio_raw->name),
41678 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
41679 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
41680 kref_init(&serio_raw->kref);
41681 INIT_LIST_HEAD(&serio_raw->client_list);
41682 init_waitqueue_head(&serio_raw->wait);
41683 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
41684 index fbe9ca7..dbee61d 100644
41685 --- a/drivers/iommu/iommu.c
41686 +++ b/drivers/iommu/iommu.c
41687 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
41688 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
41689 {
41690 bus_register_notifier(bus, &iommu_bus_nb);
41691 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
41692 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
41693 }
41694
41695 /**
41696 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
41697 index 39f81ae..2660096 100644
41698 --- a/drivers/iommu/irq_remapping.c
41699 +++ b/drivers/iommu/irq_remapping.c
41700 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
41701 void panic_if_irq_remap(const char *msg)
41702 {
41703 if (irq_remapping_enabled)
41704 - panic(msg);
41705 + panic("%s", msg);
41706 }
41707
41708 static void ir_ack_apic_edge(struct irq_data *data)
41709 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
41710
41711 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
41712 {
41713 - chip->irq_print_chip = ir_print_prefix;
41714 - chip->irq_ack = ir_ack_apic_edge;
41715 - chip->irq_eoi = ir_ack_apic_level;
41716 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41717 + pax_open_kernel();
41718 + *(void **)&chip->irq_print_chip = ir_print_prefix;
41719 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
41720 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
41721 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41722 + pax_close_kernel();
41723 }
41724
41725 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
41726 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
41727 index d0e9480..d2b6340 100644
41728 --- a/drivers/irqchip/irq-gic.c
41729 +++ b/drivers/irqchip/irq-gic.c
41730 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
41731 * Supported arch specific GIC irq extension.
41732 * Default make them NULL.
41733 */
41734 -struct irq_chip gic_arch_extn = {
41735 +irq_chip_no_const gic_arch_extn = {
41736 .irq_eoi = NULL,
41737 .irq_mask = NULL,
41738 .irq_unmask = NULL,
41739 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
41740 chained_irq_exit(chip, desc);
41741 }
41742
41743 -static struct irq_chip gic_chip = {
41744 +static irq_chip_no_const gic_chip __read_only = {
41745 .name = "GIC",
41746 .irq_mask = gic_mask_irq,
41747 .irq_unmask = gic_unmask_irq,
41748 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
41749 index ac6f72b..81150f2 100644
41750 --- a/drivers/isdn/capi/capi.c
41751 +++ b/drivers/isdn/capi/capi.c
41752 @@ -81,8 +81,8 @@ struct capiminor {
41753
41754 struct capi20_appl *ap;
41755 u32 ncci;
41756 - atomic_t datahandle;
41757 - atomic_t msgid;
41758 + atomic_unchecked_t datahandle;
41759 + atomic_unchecked_t msgid;
41760
41761 struct tty_port port;
41762 int ttyinstop;
41763 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
41764 capimsg_setu16(s, 2, mp->ap->applid);
41765 capimsg_setu8 (s, 4, CAPI_DATA_B3);
41766 capimsg_setu8 (s, 5, CAPI_RESP);
41767 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
41768 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
41769 capimsg_setu32(s, 8, mp->ncci);
41770 capimsg_setu16(s, 12, datahandle);
41771 }
41772 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
41773 mp->outbytes -= len;
41774 spin_unlock_bh(&mp->outlock);
41775
41776 - datahandle = atomic_inc_return(&mp->datahandle);
41777 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
41778 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
41779 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41780 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41781 capimsg_setu16(skb->data, 2, mp->ap->applid);
41782 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
41783 capimsg_setu8 (skb->data, 5, CAPI_REQ);
41784 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
41785 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
41786 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
41787 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
41788 capimsg_setu16(skb->data, 16, len); /* Data length */
41789 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
41790 index 600c79b..3752bab 100644
41791 --- a/drivers/isdn/gigaset/interface.c
41792 +++ b/drivers/isdn/gigaset/interface.c
41793 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
41794 }
41795 tty->driver_data = cs;
41796
41797 - ++cs->port.count;
41798 + atomic_inc(&cs->port.count);
41799
41800 - if (cs->port.count == 1) {
41801 + if (atomic_read(&cs->port.count) == 1) {
41802 tty_port_tty_set(&cs->port, tty);
41803 cs->port.low_latency = 1;
41804 }
41805 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
41806
41807 if (!cs->connected)
41808 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
41809 - else if (!cs->port.count)
41810 + else if (!atomic_read(&cs->port.count))
41811 dev_warn(cs->dev, "%s: device not opened\n", __func__);
41812 - else if (!--cs->port.count)
41813 + else if (!atomic_dec_return(&cs->port.count))
41814 tty_port_tty_set(&cs->port, NULL);
41815
41816 mutex_unlock(&cs->mutex);
41817 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
41818 index d0a41cb..f0cdb8c 100644
41819 --- a/drivers/isdn/gigaset/usb-gigaset.c
41820 +++ b/drivers/isdn/gigaset/usb-gigaset.c
41821 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
41822 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
41823 memcpy(cs->hw.usb->bchars, buf, 6);
41824 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
41825 - 0, 0, &buf, 6, 2000);
41826 + 0, 0, buf, 6, 2000);
41827 }
41828
41829 static void gigaset_freebcshw(struct bc_state *bcs)
41830 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
41831 index 4d9b195..455075c 100644
41832 --- a/drivers/isdn/hardware/avm/b1.c
41833 +++ b/drivers/isdn/hardware/avm/b1.c
41834 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
41835 }
41836 if (left) {
41837 if (t4file->user) {
41838 - if (copy_from_user(buf, dp, left))
41839 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41840 return -EFAULT;
41841 } else {
41842 memcpy(buf, dp, left);
41843 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
41844 }
41845 if (left) {
41846 if (config->user) {
41847 - if (copy_from_user(buf, dp, left))
41848 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41849 return -EFAULT;
41850 } else {
41851 memcpy(buf, dp, left);
41852 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41853 index 9bb12ba..d4262f7 100644
41854 --- a/drivers/isdn/i4l/isdn_common.c
41855 +++ b/drivers/isdn/i4l/isdn_common.c
41856 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41857 } else
41858 return -EINVAL;
41859 case IIOCDBGVAR:
41860 + if (!capable(CAP_SYS_RAWIO))
41861 + return -EPERM;
41862 if (arg) {
41863 if (copy_to_user(argp, &dev, sizeof(ulong)))
41864 return -EFAULT;
41865 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41866 index 3c5f249..5fac4d0 100644
41867 --- a/drivers/isdn/i4l/isdn_tty.c
41868 +++ b/drivers/isdn/i4l/isdn_tty.c
41869 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41870
41871 #ifdef ISDN_DEBUG_MODEM_OPEN
41872 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41873 - port->count);
41874 + atomic_read(&port->count));
41875 #endif
41876 - port->count++;
41877 + atomic_inc(&port->count);
41878 port->tty = tty;
41879 /*
41880 * Start up serial port
41881 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41882 #endif
41883 return;
41884 }
41885 - if ((tty->count == 1) && (port->count != 1)) {
41886 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
41887 /*
41888 * Uh, oh. tty->count is 1, which means that the tty
41889 * structure will be freed. Info->count should always
41890 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41891 * serial port won't be shutdown.
41892 */
41893 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
41894 - "info->count is %d\n", port->count);
41895 - port->count = 1;
41896 + "info->count is %d\n", atomic_read(&port->count));
41897 + atomic_set(&port->count, 1);
41898 }
41899 - if (--port->count < 0) {
41900 + if (atomic_dec_return(&port->count) < 0) {
41901 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
41902 - info->line, port->count);
41903 - port->count = 0;
41904 + info->line, atomic_read(&port->count));
41905 + atomic_set(&port->count, 0);
41906 }
41907 - if (port->count) {
41908 + if (atomic_read(&port->count)) {
41909 #ifdef ISDN_DEBUG_MODEM_OPEN
41910 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
41911 #endif
41912 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
41913 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
41914 return;
41915 isdn_tty_shutdown(info);
41916 - port->count = 0;
41917 + atomic_set(&port->count, 0);
41918 port->flags &= ~ASYNC_NORMAL_ACTIVE;
41919 port->tty = NULL;
41920 wake_up_interruptible(&port->open_wait);
41921 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
41922 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
41923 modem_info *info = &dev->mdm.info[i];
41924
41925 - if (info->port.count == 0)
41926 + if (atomic_read(&info->port.count) == 0)
41927 continue;
41928 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
41929 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
41930 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
41931 index e74df7c..03a03ba 100644
41932 --- a/drivers/isdn/icn/icn.c
41933 +++ b/drivers/isdn/icn/icn.c
41934 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
41935 if (count > len)
41936 count = len;
41937 if (user) {
41938 - if (copy_from_user(msg, buf, count))
41939 + if (count > sizeof msg || copy_from_user(msg, buf, count))
41940 return -EFAULT;
41941 } else
41942 memcpy(msg, buf, count);
41943 diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
41944 index a4f05c5..1433bc5 100644
41945 --- a/drivers/isdn/mISDN/dsp_cmx.c
41946 +++ b/drivers/isdn/mISDN/dsp_cmx.c
41947 @@ -1628,7 +1628,7 @@ unsigned long dsp_spl_jiffies; /* calculate the next time to fire */
41948 static u16 dsp_count; /* last sample count */
41949 static int dsp_count_valid; /* if we have last sample count */
41950
41951 -void
41952 +void __intentional_overflow(-1)
41953 dsp_cmx_send(void *arg)
41954 {
41955 struct dsp_conf *conf;
41956 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
41957 index d93e245..e7ece6b 100644
41958 --- a/drivers/leds/leds-clevo-mail.c
41959 +++ b/drivers/leds/leds-clevo-mail.c
41960 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
41961 * detected as working, but in reality it is not) as low as
41962 * possible.
41963 */
41964 -static struct dmi_system_id clevo_mail_led_dmi_table[] __initdata = {
41965 +static struct dmi_system_id clevo_mail_led_dmi_table[] __initconst = {
41966 {
41967 .callback = clevo_mail_led_dmi_callback,
41968 .ident = "Clevo D410J",
41969 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
41970 index 5b8f938..b73d657 100644
41971 --- a/drivers/leds/leds-ss4200.c
41972 +++ b/drivers/leds/leds-ss4200.c
41973 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
41974 * detected as working, but in reality it is not) as low as
41975 * possible.
41976 */
41977 -static struct dmi_system_id nas_led_whitelist[] __initdata = {
41978 +static struct dmi_system_id nas_led_whitelist[] __initconst = {
41979 {
41980 .callback = ss4200_led_dmi_callback,
41981 .ident = "Intel SS4200-E",
41982 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
41983 index 0bf1e4e..b4bf44e 100644
41984 --- a/drivers/lguest/core.c
41985 +++ b/drivers/lguest/core.c
41986 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
41987 * The end address needs +1 because __get_vm_area allocates an
41988 * extra guard page, so we need space for that.
41989 */
41990 +
41991 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
41992 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41993 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
41994 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41995 +#else
41996 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41997 VM_ALLOC, switcher_addr, switcher_addr
41998 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41999 +#endif
42000 +
42001 if (!switcher_vma) {
42002 err = -ENOMEM;
42003 printk("lguest: could not map switcher pages high\n");
42004 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
42005 * Now the Switcher is mapped at the right address, we can't fail!
42006 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
42007 */
42008 - memcpy(switcher_vma->addr, start_switcher_text,
42009 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
42010 end_switcher_text - start_switcher_text);
42011
42012 printk(KERN_INFO "lguest: mapped switcher at %p\n",
42013 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
42014 index bfb39bb..08a603b 100644
42015 --- a/drivers/lguest/page_tables.c
42016 +++ b/drivers/lguest/page_tables.c
42017 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
42018 /*:*/
42019
42020 #ifdef CONFIG_X86_PAE
42021 -static void release_pmd(pmd_t *spmd)
42022 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
42023 {
42024 /* If the entry's not present, there's nothing to release. */
42025 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
42026 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
42027 index 5169239..47cb4db 100644
42028 --- a/drivers/lguest/x86/core.c
42029 +++ b/drivers/lguest/x86/core.c
42030 @@ -59,7 +59,7 @@ static struct {
42031 /* Offset from where switcher.S was compiled to where we've copied it */
42032 static unsigned long switcher_offset(void)
42033 {
42034 - return switcher_addr - (unsigned long)start_switcher_text;
42035 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
42036 }
42037
42038 /* This cpu's struct lguest_pages (after the Switcher text page) */
42039 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
42040 * These copies are pretty cheap, so we do them unconditionally: */
42041 /* Save the current Host top-level page directory.
42042 */
42043 +
42044 +#ifdef CONFIG_PAX_PER_CPU_PGD
42045 + pages->state.host_cr3 = read_cr3();
42046 +#else
42047 pages->state.host_cr3 = __pa(current->mm->pgd);
42048 +#endif
42049 +
42050 /*
42051 * Set up the Guest's page tables to see this CPU's pages (and no
42052 * other CPU's pages).
42053 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
42054 * compiled-in switcher code and the high-mapped copy we just made.
42055 */
42056 for (i = 0; i < IDT_ENTRIES; i++)
42057 - default_idt_entries[i] += switcher_offset();
42058 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
42059
42060 /*
42061 * Set up the Switcher's per-cpu areas.
42062 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
42063 * it will be undisturbed when we switch. To change %cs and jump we
42064 * need this structure to feed to Intel's "lcall" instruction.
42065 */
42066 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
42067 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
42068 lguest_entry.segment = LGUEST_CS;
42069
42070 /*
42071 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
42072 index 40634b0..4f5855e 100644
42073 --- a/drivers/lguest/x86/switcher_32.S
42074 +++ b/drivers/lguest/x86/switcher_32.S
42075 @@ -87,6 +87,7 @@
42076 #include <asm/page.h>
42077 #include <asm/segment.h>
42078 #include <asm/lguest.h>
42079 +#include <asm/processor-flags.h>
42080
42081 // We mark the start of the code to copy
42082 // It's placed in .text tho it's never run here
42083 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
42084 // Changes type when we load it: damn Intel!
42085 // For after we switch over our page tables
42086 // That entry will be read-only: we'd crash.
42087 +
42088 +#ifdef CONFIG_PAX_KERNEXEC
42089 + mov %cr0, %edx
42090 + xor $X86_CR0_WP, %edx
42091 + mov %edx, %cr0
42092 +#endif
42093 +
42094 movl $(GDT_ENTRY_TSS*8), %edx
42095 ltr %dx
42096
42097 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
42098 // Let's clear it again for our return.
42099 // The GDT descriptor of the Host
42100 // Points to the table after two "size" bytes
42101 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
42102 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
42103 // Clear "used" from type field (byte 5, bit 2)
42104 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
42105 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
42106 +
42107 +#ifdef CONFIG_PAX_KERNEXEC
42108 + mov %cr0, %eax
42109 + xor $X86_CR0_WP, %eax
42110 + mov %eax, %cr0
42111 +#endif
42112
42113 // Once our page table's switched, the Guest is live!
42114 // The Host fades as we run this final step.
42115 @@ -295,13 +309,12 @@ deliver_to_host:
42116 // I consulted gcc, and it gave
42117 // These instructions, which I gladly credit:
42118 leal (%edx,%ebx,8), %eax
42119 - movzwl (%eax),%edx
42120 - movl 4(%eax), %eax
42121 - xorw %ax, %ax
42122 - orl %eax, %edx
42123 + movl 4(%eax), %edx
42124 + movw (%eax), %dx
42125 // Now the address of the handler's in %edx
42126 // We call it now: its "iret" drops us home.
42127 - jmp *%edx
42128 + ljmp $__KERNEL_CS, $1f
42129 +1: jmp *%edx
42130
42131 // Every interrupt can come to us here
42132 // But we must truly tell each apart.
42133 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
42134 index 0003992..854bbce 100644
42135 --- a/drivers/md/bcache/closure.h
42136 +++ b/drivers/md/bcache/closure.h
42137 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
42138 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
42139 struct workqueue_struct *wq)
42140 {
42141 - BUG_ON(object_is_on_stack(cl));
42142 + BUG_ON(object_starts_on_stack(cl));
42143 closure_set_ip(cl);
42144 cl->fn = fn;
42145 cl->wq = wq;
42146 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
42147 index 547c4c5..5be1de4 100644
42148 --- a/drivers/md/bcache/super.c
42149 +++ b/drivers/md/bcache/super.c
42150 @@ -1644,7 +1644,7 @@ err_unlock_gc:
42151 err:
42152 closure_sync(&op.cl);
42153 /* XXX: test this, it's broken */
42154 - bch_cache_set_error(c, err);
42155 + bch_cache_set_error(c, "%s", err);
42156 }
42157
42158 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
42159 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
42160 index a7fd821..9dcf6c3 100644
42161 --- a/drivers/md/bitmap.c
42162 +++ b/drivers/md/bitmap.c
42163 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
42164 chunk_kb ? "KB" : "B");
42165 if (bitmap->storage.file) {
42166 seq_printf(seq, ", file: ");
42167 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
42168 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
42169 }
42170
42171 seq_printf(seq, "\n");
42172 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
42173 index afe0814..8cf3794 100644
42174 --- a/drivers/md/dm-ioctl.c
42175 +++ b/drivers/md/dm-ioctl.c
42176 @@ -1745,7 +1745,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
42177 cmd == DM_LIST_VERSIONS_CMD)
42178 return 0;
42179
42180 - if ((cmd == DM_DEV_CREATE_CMD)) {
42181 + if (cmd == DM_DEV_CREATE_CMD) {
42182 if (!*param->name) {
42183 DMWARN("name not supplied when creating device");
42184 return -EINVAL;
42185 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
42186 index 9584443..9fc9ac9 100644
42187 --- a/drivers/md/dm-raid1.c
42188 +++ b/drivers/md/dm-raid1.c
42189 @@ -40,7 +40,7 @@ enum dm_raid1_error {
42190
42191 struct mirror {
42192 struct mirror_set *ms;
42193 - atomic_t error_count;
42194 + atomic_unchecked_t error_count;
42195 unsigned long error_type;
42196 struct dm_dev *dev;
42197 sector_t offset;
42198 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
42199 struct mirror *m;
42200
42201 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
42202 - if (!atomic_read(&m->error_count))
42203 + if (!atomic_read_unchecked(&m->error_count))
42204 return m;
42205
42206 return NULL;
42207 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
42208 * simple way to tell if a device has encountered
42209 * errors.
42210 */
42211 - atomic_inc(&m->error_count);
42212 + atomic_inc_unchecked(&m->error_count);
42213
42214 if (test_and_set_bit(error_type, &m->error_type))
42215 return;
42216 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
42217 struct mirror *m = get_default_mirror(ms);
42218
42219 do {
42220 - if (likely(!atomic_read(&m->error_count)))
42221 + if (likely(!atomic_read_unchecked(&m->error_count)))
42222 return m;
42223
42224 if (m-- == ms->mirror)
42225 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
42226 {
42227 struct mirror *default_mirror = get_default_mirror(m->ms);
42228
42229 - return !atomic_read(&default_mirror->error_count);
42230 + return !atomic_read_unchecked(&default_mirror->error_count);
42231 }
42232
42233 static int mirror_available(struct mirror_set *ms, struct bio *bio)
42234 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
42235 */
42236 if (likely(region_in_sync(ms, region, 1)))
42237 m = choose_mirror(ms, bio->bi_sector);
42238 - else if (m && atomic_read(&m->error_count))
42239 + else if (m && atomic_read_unchecked(&m->error_count))
42240 m = NULL;
42241
42242 if (likely(m))
42243 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
42244 }
42245
42246 ms->mirror[mirror].ms = ms;
42247 - atomic_set(&(ms->mirror[mirror].error_count), 0);
42248 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
42249 ms->mirror[mirror].error_type = 0;
42250 ms->mirror[mirror].offset = offset;
42251
42252 @@ -1339,7 +1339,7 @@ static void mirror_resume(struct dm_target *ti)
42253 */
42254 static char device_status_char(struct mirror *m)
42255 {
42256 - if (!atomic_read(&(m->error_count)))
42257 + if (!atomic_read_unchecked(&(m->error_count)))
42258 return 'A';
42259
42260 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
42261 diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
42262 index 28a9012..9c0f6a5 100644
42263 --- a/drivers/md/dm-stats.c
42264 +++ b/drivers/md/dm-stats.c
42265 @@ -382,7 +382,7 @@ do_sync_free:
42266 synchronize_rcu_expedited();
42267 dm_stat_free(&s->rcu_head);
42268 } else {
42269 - ACCESS_ONCE(dm_stat_need_rcu_barrier) = 1;
42270 + ACCESS_ONCE_RW(dm_stat_need_rcu_barrier) = 1;
42271 call_rcu(&s->rcu_head, dm_stat_free);
42272 }
42273 return 0;
42274 @@ -554,8 +554,8 @@ void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
42275 ((bi_rw & (REQ_WRITE | REQ_DISCARD)) ==
42276 (ACCESS_ONCE(last->last_rw) & (REQ_WRITE | REQ_DISCARD)))
42277 ));
42278 - ACCESS_ONCE(last->last_sector) = end_sector;
42279 - ACCESS_ONCE(last->last_rw) = bi_rw;
42280 + ACCESS_ONCE_RW(last->last_sector) = end_sector;
42281 + ACCESS_ONCE_RW(last->last_rw) = bi_rw;
42282 }
42283
42284 rcu_read_lock();
42285 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
42286 index 73c1712..7347292 100644
42287 --- a/drivers/md/dm-stripe.c
42288 +++ b/drivers/md/dm-stripe.c
42289 @@ -21,7 +21,7 @@ struct stripe {
42290 struct dm_dev *dev;
42291 sector_t physical_start;
42292
42293 - atomic_t error_count;
42294 + atomic_unchecked_t error_count;
42295 };
42296
42297 struct stripe_c {
42298 @@ -186,7 +186,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
42299 kfree(sc);
42300 return r;
42301 }
42302 - atomic_set(&(sc->stripe[i].error_count), 0);
42303 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
42304 }
42305
42306 ti->private = sc;
42307 @@ -327,7 +327,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
42308 DMEMIT("%d ", sc->stripes);
42309 for (i = 0; i < sc->stripes; i++) {
42310 DMEMIT("%s ", sc->stripe[i].dev->name);
42311 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
42312 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
42313 'D' : 'A';
42314 }
42315 buffer[i] = '\0';
42316 @@ -372,8 +372,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
42317 */
42318 for (i = 0; i < sc->stripes; i++)
42319 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
42320 - atomic_inc(&(sc->stripe[i].error_count));
42321 - if (atomic_read(&(sc->stripe[i].error_count)) <
42322 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
42323 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
42324 DM_IO_ERROR_THRESHOLD)
42325 schedule_work(&sc->trigger_event);
42326 }
42327 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
42328 index 20a8cc0..5447b11 100644
42329 --- a/drivers/md/dm-table.c
42330 +++ b/drivers/md/dm-table.c
42331 @@ -291,7 +291,7 @@ static struct dm_dev_internal *find_device(struct list_head *l, dev_t dev)
42332 static int open_dev(struct dm_dev_internal *d, dev_t dev,
42333 struct mapped_device *md)
42334 {
42335 - static char *_claim_ptr = "I belong to device-mapper";
42336 + static char _claim_ptr[] = "I belong to device-mapper";
42337 struct block_device *bdev;
42338
42339 int r;
42340 @@ -359,7 +359,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
42341 if (!dev_size)
42342 return 0;
42343
42344 - if ((start >= dev_size) || (start + len > dev_size)) {
42345 + if ((start >= dev_size) || (len > dev_size - start)) {
42346 DMWARN("%s: %s too small for target: "
42347 "start=%llu, len=%llu, dev_size=%llu",
42348 dm_device_name(ti->table->md), bdevname(bdev, b),
42349 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
42350 index 8a30ad5..72792d3 100644
42351 --- a/drivers/md/dm-thin-metadata.c
42352 +++ b/drivers/md/dm-thin-metadata.c
42353 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42354 {
42355 pmd->info.tm = pmd->tm;
42356 pmd->info.levels = 2;
42357 - pmd->info.value_type.context = pmd->data_sm;
42358 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42359 pmd->info.value_type.size = sizeof(__le64);
42360 pmd->info.value_type.inc = data_block_inc;
42361 pmd->info.value_type.dec = data_block_dec;
42362 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42363
42364 pmd->bl_info.tm = pmd->tm;
42365 pmd->bl_info.levels = 1;
42366 - pmd->bl_info.value_type.context = pmd->data_sm;
42367 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42368 pmd->bl_info.value_type.size = sizeof(__le64);
42369 pmd->bl_info.value_type.inc = data_block_inc;
42370 pmd->bl_info.value_type.dec = data_block_dec;
42371 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
42372 index b3e26c7..1efca94 100644
42373 --- a/drivers/md/dm.c
42374 +++ b/drivers/md/dm.c
42375 @@ -179,9 +179,9 @@ struct mapped_device {
42376 /*
42377 * Event handling.
42378 */
42379 - atomic_t event_nr;
42380 + atomic_unchecked_t event_nr;
42381 wait_queue_head_t eventq;
42382 - atomic_t uevent_seq;
42383 + atomic_unchecked_t uevent_seq;
42384 struct list_head uevent_list;
42385 spinlock_t uevent_lock; /* Protect access to uevent_list */
42386
42387 @@ -1985,8 +1985,8 @@ static struct mapped_device *alloc_dev(int minor)
42388 spin_lock_init(&md->deferred_lock);
42389 atomic_set(&md->holders, 1);
42390 atomic_set(&md->open_count, 0);
42391 - atomic_set(&md->event_nr, 0);
42392 - atomic_set(&md->uevent_seq, 0);
42393 + atomic_set_unchecked(&md->event_nr, 0);
42394 + atomic_set_unchecked(&md->uevent_seq, 0);
42395 INIT_LIST_HEAD(&md->uevent_list);
42396 spin_lock_init(&md->uevent_lock);
42397
42398 @@ -2139,7 +2139,7 @@ static void event_callback(void *context)
42399
42400 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
42401
42402 - atomic_inc(&md->event_nr);
42403 + atomic_inc_unchecked(&md->event_nr);
42404 wake_up(&md->eventq);
42405 }
42406
42407 @@ -2832,18 +2832,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
42408
42409 uint32_t dm_next_uevent_seq(struct mapped_device *md)
42410 {
42411 - return atomic_add_return(1, &md->uevent_seq);
42412 + return atomic_add_return_unchecked(1, &md->uevent_seq);
42413 }
42414
42415 uint32_t dm_get_event_nr(struct mapped_device *md)
42416 {
42417 - return atomic_read(&md->event_nr);
42418 + return atomic_read_unchecked(&md->event_nr);
42419 }
42420
42421 int dm_wait_event(struct mapped_device *md, int event_nr)
42422 {
42423 return wait_event_interruptible(md->eventq,
42424 - (event_nr != atomic_read(&md->event_nr)));
42425 + (event_nr != atomic_read_unchecked(&md->event_nr)));
42426 }
42427
42428 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
42429 diff --git a/drivers/md/md.c b/drivers/md/md.c
42430 index ba46d97..f8f5019 100644
42431 --- a/drivers/md/md.c
42432 +++ b/drivers/md/md.c
42433 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
42434 * start build, activate spare
42435 */
42436 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
42437 -static atomic_t md_event_count;
42438 +static atomic_unchecked_t md_event_count;
42439 void md_new_event(struct mddev *mddev)
42440 {
42441 - atomic_inc(&md_event_count);
42442 + atomic_inc_unchecked(&md_event_count);
42443 wake_up(&md_event_waiters);
42444 }
42445 EXPORT_SYMBOL_GPL(md_new_event);
42446 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
42447 */
42448 static void md_new_event_inintr(struct mddev *mddev)
42449 {
42450 - atomic_inc(&md_event_count);
42451 + atomic_inc_unchecked(&md_event_count);
42452 wake_up(&md_event_waiters);
42453 }
42454
42455 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
42456 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
42457 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
42458 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
42459 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42460 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42461
42462 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
42463 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
42464 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
42465 else
42466 sb->resync_offset = cpu_to_le64(0);
42467
42468 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
42469 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
42470
42471 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
42472 sb->size = cpu_to_le64(mddev->dev_sectors);
42473 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
42474 static ssize_t
42475 errors_show(struct md_rdev *rdev, char *page)
42476 {
42477 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
42478 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
42479 }
42480
42481 static ssize_t
42482 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
42483 char *e;
42484 unsigned long n = simple_strtoul(buf, &e, 10);
42485 if (*buf && (*e == 0 || *e == '\n')) {
42486 - atomic_set(&rdev->corrected_errors, n);
42487 + atomic_set_unchecked(&rdev->corrected_errors, n);
42488 return len;
42489 }
42490 return -EINVAL;
42491 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
42492 rdev->sb_loaded = 0;
42493 rdev->bb_page = NULL;
42494 atomic_set(&rdev->nr_pending, 0);
42495 - atomic_set(&rdev->read_errors, 0);
42496 - atomic_set(&rdev->corrected_errors, 0);
42497 + atomic_set_unchecked(&rdev->read_errors, 0);
42498 + atomic_set_unchecked(&rdev->corrected_errors, 0);
42499
42500 INIT_LIST_HEAD(&rdev->same_set);
42501 init_waitqueue_head(&rdev->blocked_wait);
42502 @@ -7043,7 +7043,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
42503
42504 spin_unlock(&pers_lock);
42505 seq_printf(seq, "\n");
42506 - seq->poll_event = atomic_read(&md_event_count);
42507 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42508 return 0;
42509 }
42510 if (v == (void*)2) {
42511 @@ -7146,7 +7146,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
42512 return error;
42513
42514 seq = file->private_data;
42515 - seq->poll_event = atomic_read(&md_event_count);
42516 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42517 return error;
42518 }
42519
42520 @@ -7160,7 +7160,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
42521 /* always allow read */
42522 mask = POLLIN | POLLRDNORM;
42523
42524 - if (seq->poll_event != atomic_read(&md_event_count))
42525 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
42526 mask |= POLLERR | POLLPRI;
42527 return mask;
42528 }
42529 @@ -7204,7 +7204,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
42530 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
42531 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
42532 (int)part_stat_read(&disk->part0, sectors[1]) -
42533 - atomic_read(&disk->sync_io);
42534 + atomic_read_unchecked(&disk->sync_io);
42535 /* sync IO will cause sync_io to increase before the disk_stats
42536 * as sync_io is counted when a request starts, and
42537 * disk_stats is counted when it completes.
42538 diff --git a/drivers/md/md.h b/drivers/md/md.h
42539 index 608050c..6e77db5d 100644
42540 --- a/drivers/md/md.h
42541 +++ b/drivers/md/md.h
42542 @@ -94,13 +94,13 @@ struct md_rdev {
42543 * only maintained for arrays that
42544 * support hot removal
42545 */
42546 - atomic_t read_errors; /* number of consecutive read errors that
42547 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42548 * we have tried to ignore.
42549 */
42550 struct timespec last_read_error; /* monotonic time since our
42551 * last read error
42552 */
42553 - atomic_t corrected_errors; /* number of corrected read errors,
42554 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42555 * for reporting to userspace and storing
42556 * in superblock.
42557 */
42558 @@ -446,7 +446,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42559
42560 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42561 {
42562 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42563 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42564 }
42565
42566 struct md_personality
42567 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42568 index 3e6d115..ffecdeb 100644
42569 --- a/drivers/md/persistent-data/dm-space-map.h
42570 +++ b/drivers/md/persistent-data/dm-space-map.h
42571 @@ -71,6 +71,7 @@ struct dm_space_map {
42572 dm_sm_threshold_fn fn,
42573 void *context);
42574 };
42575 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42576
42577 /*----------------------------------------------------------------*/
42578
42579 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42580 index aacf6bf..67d63f2 100644
42581 --- a/drivers/md/raid1.c
42582 +++ b/drivers/md/raid1.c
42583 @@ -1824,7 +1824,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42584 if (r1_sync_page_io(rdev, sect, s,
42585 bio->bi_io_vec[idx].bv_page,
42586 READ) != 0)
42587 - atomic_add(s, &rdev->corrected_errors);
42588 + atomic_add_unchecked(s, &rdev->corrected_errors);
42589 }
42590 sectors -= s;
42591 sect += s;
42592 @@ -2051,7 +2051,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42593 test_bit(In_sync, &rdev->flags)) {
42594 if (r1_sync_page_io(rdev, sect, s,
42595 conf->tmppage, READ)) {
42596 - atomic_add(s, &rdev->corrected_errors);
42597 + atomic_add_unchecked(s, &rdev->corrected_errors);
42598 printk(KERN_INFO
42599 "md/raid1:%s: read error corrected "
42600 "(%d sectors at %llu on %s)\n",
42601 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42602 index 73dc8a3..bdd515a 100644
42603 --- a/drivers/md/raid10.c
42604 +++ b/drivers/md/raid10.c
42605 @@ -1963,7 +1963,7 @@ static void end_sync_read(struct bio *bio, int error)
42606 /* The write handler will notice the lack of
42607 * R10BIO_Uptodate and record any errors etc
42608 */
42609 - atomic_add(r10_bio->sectors,
42610 + atomic_add_unchecked(r10_bio->sectors,
42611 &conf->mirrors[d].rdev->corrected_errors);
42612
42613 /* for reconstruct, we always reschedule after a read.
42614 @@ -2321,7 +2321,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42615 {
42616 struct timespec cur_time_mon;
42617 unsigned long hours_since_last;
42618 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42619 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42620
42621 ktime_get_ts(&cur_time_mon);
42622
42623 @@ -2343,9 +2343,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42624 * overflowing the shift of read_errors by hours_since_last.
42625 */
42626 if (hours_since_last >= 8 * sizeof(read_errors))
42627 - atomic_set(&rdev->read_errors, 0);
42628 + atomic_set_unchecked(&rdev->read_errors, 0);
42629 else
42630 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42631 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42632 }
42633
42634 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42635 @@ -2399,8 +2399,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42636 return;
42637
42638 check_decay_read_errors(mddev, rdev);
42639 - atomic_inc(&rdev->read_errors);
42640 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42641 + atomic_inc_unchecked(&rdev->read_errors);
42642 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42643 char b[BDEVNAME_SIZE];
42644 bdevname(rdev->bdev, b);
42645
42646 @@ -2408,7 +2408,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42647 "md/raid10:%s: %s: Raid device exceeded "
42648 "read_error threshold [cur %d:max %d]\n",
42649 mdname(mddev), b,
42650 - atomic_read(&rdev->read_errors), max_read_errors);
42651 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42652 printk(KERN_NOTICE
42653 "md/raid10:%s: %s: Failing raid device\n",
42654 mdname(mddev), b);
42655 @@ -2563,7 +2563,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42656 sect +
42657 choose_data_offset(r10_bio, rdev)),
42658 bdevname(rdev->bdev, b));
42659 - atomic_add(s, &rdev->corrected_errors);
42660 + atomic_add_unchecked(s, &rdev->corrected_errors);
42661 }
42662
42663 rdev_dec_pending(rdev, mddev);
42664 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42665 index 8a0665d..984c46d 100644
42666 --- a/drivers/md/raid5.c
42667 +++ b/drivers/md/raid5.c
42668 @@ -1887,21 +1887,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42669 mdname(conf->mddev), STRIPE_SECTORS,
42670 (unsigned long long)s,
42671 bdevname(rdev->bdev, b));
42672 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42673 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42674 clear_bit(R5_ReadError, &sh->dev[i].flags);
42675 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42676 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42677 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42678
42679 - if (atomic_read(&rdev->read_errors))
42680 - atomic_set(&rdev->read_errors, 0);
42681 + if (atomic_read_unchecked(&rdev->read_errors))
42682 + atomic_set_unchecked(&rdev->read_errors, 0);
42683 } else {
42684 const char *bdn = bdevname(rdev->bdev, b);
42685 int retry = 0;
42686 int set_bad = 0;
42687
42688 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42689 - atomic_inc(&rdev->read_errors);
42690 + atomic_inc_unchecked(&rdev->read_errors);
42691 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42692 printk_ratelimited(
42693 KERN_WARNING
42694 @@ -1929,7 +1929,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42695 mdname(conf->mddev),
42696 (unsigned long long)s,
42697 bdn);
42698 - } else if (atomic_read(&rdev->read_errors)
42699 + } else if (atomic_read_unchecked(&rdev->read_errors)
42700 > conf->max_nr_stripes)
42701 printk(KERN_WARNING
42702 "md/raid:%s: Too many read errors, failing device %s.\n",
42703 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42704 index 401ef64..836e563 100644
42705 --- a/drivers/media/dvb-core/dvbdev.c
42706 +++ b/drivers/media/dvb-core/dvbdev.c
42707 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42708 const struct dvb_device *template, void *priv, int type)
42709 {
42710 struct dvb_device *dvbdev;
42711 - struct file_operations *dvbdevfops;
42712 + file_operations_no_const *dvbdevfops;
42713 struct device *clsdev;
42714 int minor;
42715 int id;
42716 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42717 index 9b6c3bb..baeb5c7 100644
42718 --- a/drivers/media/dvb-frontends/dib3000.h
42719 +++ b/drivers/media/dvb-frontends/dib3000.h
42720 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42721 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42722 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42723 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42724 -};
42725 +} __no_const;
42726
42727 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42728 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42729 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42730 index ecf21d9..b992428d 100644
42731 --- a/drivers/media/pci/cx88/cx88-video.c
42732 +++ b/drivers/media/pci/cx88/cx88-video.c
42733 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42734
42735 /* ------------------------------------------------------------------ */
42736
42737 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42738 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42739 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42740 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42741 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42742 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42743
42744 module_param_array(video_nr, int, NULL, 0444);
42745 module_param_array(vbi_nr, int, NULL, 0444);
42746 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42747 index c08ae3e..eb59af1 100644
42748 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42749 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42750 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42751 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42752
42753 /* ivtv instance counter */
42754 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42755 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42756
42757 /* Parameter declarations */
42758 static int cardtype[IVTV_MAX_CARDS];
42759 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42760 index dfd0a21..6bbb465 100644
42761 --- a/drivers/media/platform/omap/omap_vout.c
42762 +++ b/drivers/media/platform/omap/omap_vout.c
42763 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42764 OMAP_VIDEO2,
42765 };
42766
42767 -static struct videobuf_queue_ops video_vbq_ops;
42768 /* Variables configurable through module params*/
42769 static u32 video1_numbuffers = 3;
42770 static u32 video2_numbuffers = 3;
42771 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42772 {
42773 struct videobuf_queue *q;
42774 struct omap_vout_device *vout = NULL;
42775 + static struct videobuf_queue_ops video_vbq_ops = {
42776 + .buf_setup = omap_vout_buffer_setup,
42777 + .buf_prepare = omap_vout_buffer_prepare,
42778 + .buf_release = omap_vout_buffer_release,
42779 + .buf_queue = omap_vout_buffer_queue,
42780 + };
42781
42782 vout = video_drvdata(file);
42783 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42784 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42785 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42786
42787 q = &vout->vbq;
42788 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42789 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42790 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42791 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42792 spin_lock_init(&vout->vbq_lock);
42793
42794 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42795 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42796 index 04e6490..2df65bf 100644
42797 --- a/drivers/media/platform/s5p-tv/mixer.h
42798 +++ b/drivers/media/platform/s5p-tv/mixer.h
42799 @@ -156,7 +156,7 @@ struct mxr_layer {
42800 /** layer index (unique identifier) */
42801 int idx;
42802 /** callbacks for layer methods */
42803 - struct mxr_layer_ops ops;
42804 + struct mxr_layer_ops *ops;
42805 /** format array */
42806 const struct mxr_format **fmt_array;
42807 /** size of format array */
42808 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42809 index b93a21f..2535195 100644
42810 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42811 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42812 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42813 {
42814 struct mxr_layer *layer;
42815 int ret;
42816 - struct mxr_layer_ops ops = {
42817 + static struct mxr_layer_ops ops = {
42818 .release = mxr_graph_layer_release,
42819 .buffer_set = mxr_graph_buffer_set,
42820 .stream_set = mxr_graph_stream_set,
42821 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42822 index b713403..53cb5ad 100644
42823 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42824 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42825 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42826 layer->update_buf = next;
42827 }
42828
42829 - layer->ops.buffer_set(layer, layer->update_buf);
42830 + layer->ops->buffer_set(layer, layer->update_buf);
42831
42832 if (done && done != layer->shadow_buf)
42833 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42834 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42835 index 641b1f0..49cff30 100644
42836 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42837 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42838 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42839 layer->geo.src.height = layer->geo.src.full_height;
42840
42841 mxr_geometry_dump(mdev, &layer->geo);
42842 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42843 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42844 mxr_geometry_dump(mdev, &layer->geo);
42845 }
42846
42847 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42848 layer->geo.dst.full_width = mbus_fmt.width;
42849 layer->geo.dst.full_height = mbus_fmt.height;
42850 layer->geo.dst.field = mbus_fmt.field;
42851 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42852 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42853
42854 mxr_geometry_dump(mdev, &layer->geo);
42855 }
42856 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42857 /* set source size to highest accepted value */
42858 geo->src.full_width = max(geo->dst.full_width, pix->width);
42859 geo->src.full_height = max(geo->dst.full_height, pix->height);
42860 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42861 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42862 mxr_geometry_dump(mdev, &layer->geo);
42863 /* set cropping to total visible screen */
42864 geo->src.width = pix->width;
42865 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42866 geo->src.x_offset = 0;
42867 geo->src.y_offset = 0;
42868 /* assure consistency of geometry */
42869 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42870 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42871 mxr_geometry_dump(mdev, &layer->geo);
42872 /* set full size to lowest possible value */
42873 geo->src.full_width = 0;
42874 geo->src.full_height = 0;
42875 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42876 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42877 mxr_geometry_dump(mdev, &layer->geo);
42878
42879 /* returning results */
42880 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
42881 target->width = s->r.width;
42882 target->height = s->r.height;
42883
42884 - layer->ops.fix_geometry(layer, stage, s->flags);
42885 + layer->ops->fix_geometry(layer, stage, s->flags);
42886
42887 /* retrieve update selection rectangle */
42888 res.left = target->x_offset;
42889 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
42890 mxr_output_get(mdev);
42891
42892 mxr_layer_update_output(layer);
42893 - layer->ops.format_set(layer);
42894 + layer->ops->format_set(layer);
42895 /* enabling layer in hardware */
42896 spin_lock_irqsave(&layer->enq_slock, flags);
42897 layer->state = MXR_LAYER_STREAMING;
42898 spin_unlock_irqrestore(&layer->enq_slock, flags);
42899
42900 - layer->ops.stream_set(layer, MXR_ENABLE);
42901 + layer->ops->stream_set(layer, MXR_ENABLE);
42902 mxr_streamer_get(mdev);
42903
42904 return 0;
42905 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
42906 spin_unlock_irqrestore(&layer->enq_slock, flags);
42907
42908 /* disabling layer in hardware */
42909 - layer->ops.stream_set(layer, MXR_DISABLE);
42910 + layer->ops->stream_set(layer, MXR_DISABLE);
42911 /* remove one streamer */
42912 mxr_streamer_put(mdev);
42913 /* allow changes in output configuration */
42914 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
42915
42916 void mxr_layer_release(struct mxr_layer *layer)
42917 {
42918 - if (layer->ops.release)
42919 - layer->ops.release(layer);
42920 + if (layer->ops->release)
42921 + layer->ops->release(layer);
42922 }
42923
42924 void mxr_base_layer_release(struct mxr_layer *layer)
42925 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
42926
42927 layer->mdev = mdev;
42928 layer->idx = idx;
42929 - layer->ops = *ops;
42930 + layer->ops = ops;
42931
42932 spin_lock_init(&layer->enq_slock);
42933 INIT_LIST_HEAD(&layer->enq_list);
42934 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42935 index 3d13a63..da31bf1 100644
42936 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42937 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42938 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
42939 {
42940 struct mxr_layer *layer;
42941 int ret;
42942 - struct mxr_layer_ops ops = {
42943 + static struct mxr_layer_ops ops = {
42944 .release = mxr_vp_layer_release,
42945 .buffer_set = mxr_vp_buffer_set,
42946 .stream_set = mxr_vp_stream_set,
42947 diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
42948 index 1d3f119..75f40bb 100644
42949 --- a/drivers/media/platform/vivi.c
42950 +++ b/drivers/media/platform/vivi.c
42951 @@ -58,8 +58,8 @@ MODULE_AUTHOR("Mauro Carvalho Chehab, Ted Walther and John Sokol");
42952 MODULE_LICENSE("Dual BSD/GPL");
42953 MODULE_VERSION(VIVI_VERSION);
42954
42955 -static unsigned video_nr = -1;
42956 -module_param(video_nr, uint, 0644);
42957 +static int video_nr = -1;
42958 +module_param(video_nr, int, 0644);
42959 MODULE_PARM_DESC(video_nr, "videoX start number, -1 is autodetect");
42960
42961 static unsigned n_devs = 1;
42962 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
42963 index 545c04c..a14bded 100644
42964 --- a/drivers/media/radio/radio-cadet.c
42965 +++ b/drivers/media/radio/radio-cadet.c
42966 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42967 unsigned char readbuf[RDS_BUFFER];
42968 int i = 0;
42969
42970 + if (count > RDS_BUFFER)
42971 + return -EFAULT;
42972 mutex_lock(&dev->lock);
42973 if (dev->rdsstat == 0)
42974 cadet_start_rds(dev);
42975 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42976 while (i < count && dev->rdsin != dev->rdsout)
42977 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
42978
42979 - if (i && copy_to_user(data, readbuf, i))
42980 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
42981 i = -EFAULT;
42982 unlock:
42983 mutex_unlock(&dev->lock);
42984 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
42985 index 5236035..c622c74 100644
42986 --- a/drivers/media/radio/radio-maxiradio.c
42987 +++ b/drivers/media/radio/radio-maxiradio.c
42988 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
42989 /* TEA5757 pin mappings */
42990 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
42991
42992 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
42993 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
42994
42995 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
42996 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
42997 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
42998 index b914772..7ddbf9b 100644
42999 --- a/drivers/media/radio/radio-shark.c
43000 +++ b/drivers/media/radio/radio-shark.c
43001 @@ -79,7 +79,7 @@ struct shark_device {
43002 u32 last_val;
43003 };
43004
43005 -static atomic_t shark_instance = ATOMIC_INIT(0);
43006 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
43007
43008 static void shark_write_val(struct snd_tea575x *tea, u32 val)
43009 {
43010 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
43011 index 9fb6697..f167415 100644
43012 --- a/drivers/media/radio/radio-shark2.c
43013 +++ b/drivers/media/radio/radio-shark2.c
43014 @@ -74,7 +74,7 @@ struct shark_device {
43015 u8 *transfer_buffer;
43016 };
43017
43018 -static atomic_t shark_instance = ATOMIC_INIT(0);
43019 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
43020
43021 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
43022 {
43023 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
43024 index 9c9084c..a9e8dfb 100644
43025 --- a/drivers/media/radio/radio-si476x.c
43026 +++ b/drivers/media/radio/radio-si476x.c
43027 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
43028 struct si476x_radio *radio;
43029 struct v4l2_ctrl *ctrl;
43030
43031 - static atomic_t instance = ATOMIC_INIT(0);
43032 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
43033
43034 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
43035 if (!radio)
43036 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
43037 index 46da365..3ba4206 100644
43038 --- a/drivers/media/rc/rc-main.c
43039 +++ b/drivers/media/rc/rc-main.c
43040 @@ -1065,7 +1065,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
43041 int rc_register_device(struct rc_dev *dev)
43042 {
43043 static bool raw_init = false; /* raw decoders loaded? */
43044 - static atomic_t devno = ATOMIC_INIT(0);
43045 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
43046 struct rc_map *rc_map;
43047 const char *path;
43048 int rc;
43049 @@ -1096,7 +1096,7 @@ int rc_register_device(struct rc_dev *dev)
43050 */
43051 mutex_lock(&dev->lock);
43052
43053 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
43054 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
43055 dev_set_name(&dev->dev, "rc%ld", dev->devno);
43056 dev_set_drvdata(&dev->dev, dev);
43057 rc = device_add(&dev->dev);
43058 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
43059 index 20e345d..da56fe4 100644
43060 --- a/drivers/media/usb/dvb-usb/cxusb.c
43061 +++ b/drivers/media/usb/dvb-usb/cxusb.c
43062 @@ -1101,7 +1101,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
43063
43064 struct dib0700_adapter_state {
43065 int (*set_param_save) (struct dvb_frontend *);
43066 -};
43067 +} __no_const;
43068
43069 static int dib7070_set_param_override(struct dvb_frontend *fe)
43070 {
43071 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
43072 index 71b22f5..a63b33f 100644
43073 --- a/drivers/media/usb/dvb-usb/dw2102.c
43074 +++ b/drivers/media/usb/dvb-usb/dw2102.c
43075 @@ -121,7 +121,7 @@ struct su3000_state {
43076
43077 struct s6x0_state {
43078 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
43079 -};
43080 +} __no_const;
43081
43082 /* debug */
43083 static int dvb_usb_dw2102_debug;
43084 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43085 index 8f7a6a4..59502dd 100644
43086 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43087 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43088 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
43089 __u32 reserved;
43090 };
43091
43092 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43093 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43094 enum v4l2_memory memory)
43095 {
43096 void __user *up_pln;
43097 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43098 return 0;
43099 }
43100
43101 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43102 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43103 enum v4l2_memory memory)
43104 {
43105 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
43106 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
43107 put_user(kp->start_block, &up->start_block) ||
43108 put_user(kp->blocks, &up->blocks) ||
43109 put_user(tmp, &up->edid) ||
43110 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
43111 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
43112 return -EFAULT;
43113 return 0;
43114 }
43115 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
43116 index 02d1b63..5fd6b16 100644
43117 --- a/drivers/media/v4l2-core/v4l2-device.c
43118 +++ b/drivers/media/v4l2-core/v4l2-device.c
43119 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
43120 EXPORT_SYMBOL_GPL(v4l2_device_put);
43121
43122 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
43123 - atomic_t *instance)
43124 + atomic_unchecked_t *instance)
43125 {
43126 - int num = atomic_inc_return(instance) - 1;
43127 + int num = atomic_inc_return_unchecked(instance) - 1;
43128 int len = strlen(basename);
43129
43130 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
43131 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
43132 index 68e6b5e..d8b923e 100644
43133 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
43134 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
43135 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
43136 struct file *file, void *fh, void *p);
43137 } u;
43138 void (*debug)(const void *arg, bool write_only);
43139 -};
43140 +} __do_const;
43141 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
43142
43143 /* This control needs a priority check */
43144 #define INFO_FL_PRIO (1 << 0)
43145 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
43146 struct video_device *vfd = video_devdata(file);
43147 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
43148 bool write_only = false;
43149 - struct v4l2_ioctl_info default_info;
43150 + v4l2_ioctl_info_no_const default_info;
43151 const struct v4l2_ioctl_info *info;
43152 void *fh = file->private_data;
43153 struct v4l2_fh *vfh = NULL;
43154 @@ -2194,7 +2195,7 @@ done:
43155 }
43156
43157 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43158 - void * __user *user_ptr, void ***kernel_ptr)
43159 + void __user **user_ptr, void ***kernel_ptr)
43160 {
43161 int ret = 0;
43162
43163 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43164 ret = -EINVAL;
43165 break;
43166 }
43167 - *user_ptr = (void __user *)buf->m.planes;
43168 + *user_ptr = (void __force_user *)buf->m.planes;
43169 *kernel_ptr = (void *)&buf->m.planes;
43170 *array_size = sizeof(struct v4l2_plane) * buf->length;
43171 ret = 1;
43172 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43173 ret = -EINVAL;
43174 break;
43175 }
43176 - *user_ptr = (void __user *)ctrls->controls;
43177 + *user_ptr = (void __force_user *)ctrls->controls;
43178 *kernel_ptr = (void *)&ctrls->controls;
43179 *array_size = sizeof(struct v4l2_ext_control)
43180 * ctrls->count;
43181 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
43182 index 767ff4d..c69d259 100644
43183 --- a/drivers/message/fusion/mptbase.c
43184 +++ b/drivers/message/fusion/mptbase.c
43185 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43186 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
43187 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
43188
43189 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43190 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
43191 +#else
43192 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
43193 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
43194 +#endif
43195 +
43196 /*
43197 * Rounding UP to nearest 4-kB boundary here...
43198 */
43199 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43200 ioc->facts.GlobalCredits);
43201
43202 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
43203 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43204 + NULL, NULL);
43205 +#else
43206 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
43207 +#endif
43208 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
43209 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
43210 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
43211 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
43212 index dd239bd..689c4f7 100644
43213 --- a/drivers/message/fusion/mptsas.c
43214 +++ b/drivers/message/fusion/mptsas.c
43215 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
43216 return 0;
43217 }
43218
43219 +static inline void
43220 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43221 +{
43222 + if (phy_info->port_details) {
43223 + phy_info->port_details->rphy = rphy;
43224 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43225 + ioc->name, rphy));
43226 + }
43227 +
43228 + if (rphy) {
43229 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43230 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43231 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43232 + ioc->name, rphy, rphy->dev.release));
43233 + }
43234 +}
43235 +
43236 /* no mutex */
43237 static void
43238 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
43239 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
43240 return NULL;
43241 }
43242
43243 -static inline void
43244 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43245 -{
43246 - if (phy_info->port_details) {
43247 - phy_info->port_details->rphy = rphy;
43248 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43249 - ioc->name, rphy));
43250 - }
43251 -
43252 - if (rphy) {
43253 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43254 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43255 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43256 - ioc->name, rphy, rphy->dev.release));
43257 - }
43258 -}
43259 -
43260 static inline struct sas_port *
43261 mptsas_get_port(struct mptsas_phyinfo *phy_info)
43262 {
43263 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
43264 index 727819c..ad74694 100644
43265 --- a/drivers/message/fusion/mptscsih.c
43266 +++ b/drivers/message/fusion/mptscsih.c
43267 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
43268
43269 h = shost_priv(SChost);
43270
43271 - if (h) {
43272 - if (h->info_kbuf == NULL)
43273 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43274 - return h->info_kbuf;
43275 - h->info_kbuf[0] = '\0';
43276 + if (!h)
43277 + return NULL;
43278
43279 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43280 - h->info_kbuf[size-1] = '\0';
43281 - }
43282 + if (h->info_kbuf == NULL)
43283 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43284 + return h->info_kbuf;
43285 + h->info_kbuf[0] = '\0';
43286 +
43287 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43288 + h->info_kbuf[size-1] = '\0';
43289
43290 return h->info_kbuf;
43291 }
43292 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
43293 index b7d87cd..3fb36da 100644
43294 --- a/drivers/message/i2o/i2o_proc.c
43295 +++ b/drivers/message/i2o/i2o_proc.c
43296 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
43297 "Array Controller Device"
43298 };
43299
43300 -static char *chtostr(char *tmp, u8 *chars, int n)
43301 -{
43302 - tmp[0] = 0;
43303 - return strncat(tmp, (char *)chars, n);
43304 -}
43305 -
43306 static int i2o_report_query_status(struct seq_file *seq, int block_status,
43307 char *group)
43308 {
43309 @@ -707,9 +701,9 @@ static int i2o_seq_show_status(struct seq_file *seq, void *v)
43310 static int i2o_seq_show_hw(struct seq_file *seq, void *v)
43311 {
43312 struct i2o_controller *c = (struct i2o_controller *)seq->private;
43313 - static u32 work32[5];
43314 - static u8 *work8 = (u8 *) work32;
43315 - static u16 *work16 = (u16 *) work32;
43316 + u32 work32[5];
43317 + u8 *work8 = (u8 *) work32;
43318 + u16 *work16 = (u16 *) work32;
43319 int token;
43320 u32 hwcap;
43321
43322 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43323 } *result;
43324
43325 i2o_exec_execute_ddm_table ddm_table;
43326 - char tmp[28 + 1];
43327
43328 result = kmalloc(sizeof(*result), GFP_KERNEL);
43329 if (!result)
43330 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43331
43332 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
43333 seq_printf(seq, "%-#8x", ddm_table.module_id);
43334 - seq_printf(seq, "%-29s",
43335 - chtostr(tmp, ddm_table.module_name_version, 28));
43336 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
43337 seq_printf(seq, "%9d ", ddm_table.data_size);
43338 seq_printf(seq, "%8d", ddm_table.code_size);
43339
43340 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43341
43342 i2o_driver_result_table *result;
43343 i2o_driver_store_table *dst;
43344 - char tmp[28 + 1];
43345
43346 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
43347 if (result == NULL)
43348 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43349
43350 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
43351 seq_printf(seq, "%-#8x", dst->module_id);
43352 - seq_printf(seq, "%-29s",
43353 - chtostr(tmp, dst->module_name_version, 28));
43354 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
43355 + seq_printf(seq, "%-.28s", dst->module_name_version);
43356 + seq_printf(seq, "%-.8s", dst->date);
43357 seq_printf(seq, "%8d ", dst->module_size);
43358 seq_printf(seq, "%8d ", dst->mpb_size);
43359 seq_printf(seq, "0x%04x", dst->module_flags);
43360 @@ -1246,11 +1236,10 @@ static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
43361 static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43362 {
43363 struct i2o_device *d = (struct i2o_device *)seq->private;
43364 - static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
43365 + u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
43366 // == (allow) 512d bytes (max)
43367 - static u16 *work16 = (u16 *) work32;
43368 + u16 *work16 = (u16 *) work32;
43369 int token;
43370 - char tmp[16 + 1];
43371
43372 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
43373
43374 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43375 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
43376 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
43377 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
43378 - seq_printf(seq, "Vendor info : %s\n",
43379 - chtostr(tmp, (u8 *) (work32 + 2), 16));
43380 - seq_printf(seq, "Product info : %s\n",
43381 - chtostr(tmp, (u8 *) (work32 + 6), 16));
43382 - seq_printf(seq, "Description : %s\n",
43383 - chtostr(tmp, (u8 *) (work32 + 10), 16));
43384 - seq_printf(seq, "Product rev. : %s\n",
43385 - chtostr(tmp, (u8 *) (work32 + 14), 8));
43386 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
43387 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
43388 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
43389 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
43390
43391 seq_printf(seq, "Serial number : ");
43392 print_serial_number(seq, (u8 *) (work32 + 16),
43393 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43394 u8 pad[256]; // allow up to 256 byte (max) serial number
43395 } result;
43396
43397 - char tmp[24 + 1];
43398 -
43399 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
43400
43401 if (token < 0) {
43402 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43403 }
43404
43405 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
43406 - seq_printf(seq, "Module name : %s\n",
43407 - chtostr(tmp, result.module_name, 24));
43408 - seq_printf(seq, "Module revision : %s\n",
43409 - chtostr(tmp, result.module_rev, 8));
43410 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
43411 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
43412
43413 seq_printf(seq, "Serial number : ");
43414 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
43415 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43416 u8 instance_number[4];
43417 } result;
43418
43419 - char tmp[64 + 1];
43420 -
43421 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
43422
43423 if (token < 0) {
43424 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43425 return 0;
43426 }
43427
43428 - seq_printf(seq, "Device name : %s\n",
43429 - chtostr(tmp, result.device_name, 64));
43430 - seq_printf(seq, "Service name : %s\n",
43431 - chtostr(tmp, result.service_name, 64));
43432 - seq_printf(seq, "Physical name : %s\n",
43433 - chtostr(tmp, result.physical_location, 64));
43434 - seq_printf(seq, "Instance number : %s\n",
43435 - chtostr(tmp, result.instance_number, 4));
43436 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
43437 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
43438 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
43439 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
43440
43441 return 0;
43442 }
43443 @@ -1368,9 +1343,9 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43444 static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
43445 {
43446 struct i2o_device *d = (struct i2o_device *)seq->private;
43447 - static u32 work32[12];
43448 - static u16 *work16 = (u16 *) work32;
43449 - static u8 *work8 = (u8 *) work32;
43450 + u32 work32[12];
43451 + u16 *work16 = (u16 *) work32;
43452 + u8 *work8 = (u8 *) work32;
43453 int token;
43454
43455 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
43456 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
43457 index a8c08f3..155fe3d 100644
43458 --- a/drivers/message/i2o/iop.c
43459 +++ b/drivers/message/i2o/iop.c
43460 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
43461
43462 spin_lock_irqsave(&c->context_list_lock, flags);
43463
43464 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
43465 - atomic_inc(&c->context_list_counter);
43466 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
43467 + atomic_inc_unchecked(&c->context_list_counter);
43468
43469 - entry->context = atomic_read(&c->context_list_counter);
43470 + entry->context = atomic_read_unchecked(&c->context_list_counter);
43471
43472 list_add(&entry->list, &c->context_list);
43473
43474 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
43475
43476 #if BITS_PER_LONG == 64
43477 spin_lock_init(&c->context_list_lock);
43478 - atomic_set(&c->context_list_counter, 0);
43479 + atomic_set_unchecked(&c->context_list_counter, 0);
43480 INIT_LIST_HEAD(&c->context_list);
43481 #endif
43482
43483 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
43484 index fcbb2e9..2635e11 100644
43485 --- a/drivers/mfd/janz-cmodio.c
43486 +++ b/drivers/mfd/janz-cmodio.c
43487 @@ -13,6 +13,7 @@
43488
43489 #include <linux/kernel.h>
43490 #include <linux/module.h>
43491 +#include <linux/slab.h>
43492 #include <linux/init.h>
43493 #include <linux/pci.h>
43494 #include <linux/interrupt.h>
43495 diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
43496 index de7fb80..7c1b931 100644
43497 --- a/drivers/mfd/max8925-i2c.c
43498 +++ b/drivers/mfd/max8925-i2c.c
43499 @@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
43500 const struct i2c_device_id *id)
43501 {
43502 struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
43503 - static struct max8925_chip *chip;
43504 + struct max8925_chip *chip;
43505 struct device_node *node = client->dev.of_node;
43506
43507 if (node && !pdata) {
43508 diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
43509 index d792772..cd73ba3 100644
43510 --- a/drivers/mfd/tps65910.c
43511 +++ b/drivers/mfd/tps65910.c
43512 @@ -229,7 +229,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
43513 struct tps65910_platform_data *pdata)
43514 {
43515 int ret = 0;
43516 - static struct regmap_irq_chip *tps6591x_irqs_chip;
43517 + struct regmap_irq_chip *tps6591x_irqs_chip;
43518
43519 if (!irq) {
43520 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
43521 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
43522 index 9aa6d1e..1631bfc 100644
43523 --- a/drivers/mfd/twl4030-irq.c
43524 +++ b/drivers/mfd/twl4030-irq.c
43525 @@ -35,6 +35,7 @@
43526 #include <linux/of.h>
43527 #include <linux/irqdomain.h>
43528 #include <linux/i2c/twl.h>
43529 +#include <asm/pgtable.h>
43530
43531 #include "twl-core.h"
43532
43533 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
43534 * Install an irq handler for each of the SIH modules;
43535 * clone dummy irq_chip since PIH can't *do* anything
43536 */
43537 - twl4030_irq_chip = dummy_irq_chip;
43538 - twl4030_irq_chip.name = "twl4030";
43539 + pax_open_kernel();
43540 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
43541 + *(const char **)&twl4030_irq_chip.name = "twl4030";
43542
43543 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43544 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43545 + pax_close_kernel();
43546
43547 for (i = irq_base; i < irq_end; i++) {
43548 irq_set_chip_and_handler(i, &twl4030_irq_chip,
43549 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
43550 index 464419b..64bae8d 100644
43551 --- a/drivers/misc/c2port/core.c
43552 +++ b/drivers/misc/c2port/core.c
43553 @@ -922,7 +922,9 @@ struct c2port_device *c2port_device_register(char *name,
43554 goto error_idr_alloc;
43555 c2dev->id = ret;
43556
43557 - bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
43558 + pax_open_kernel();
43559 + *(size_t *)&bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
43560 + pax_close_kernel();
43561
43562 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
43563 "c2port%d", c2dev->id);
43564 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43565 index 36f5d52..32311c3 100644
43566 --- a/drivers/misc/kgdbts.c
43567 +++ b/drivers/misc/kgdbts.c
43568 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43569 char before[BREAK_INSTR_SIZE];
43570 char after[BREAK_INSTR_SIZE];
43571
43572 - probe_kernel_read(before, (char *)kgdbts_break_test,
43573 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43574 BREAK_INSTR_SIZE);
43575 init_simple_test();
43576 ts.tst = plant_and_detach_test;
43577 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43578 /* Activate test with initial breakpoint */
43579 if (!is_early)
43580 kgdb_breakpoint();
43581 - probe_kernel_read(after, (char *)kgdbts_break_test,
43582 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43583 BREAK_INSTR_SIZE);
43584 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43585 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43586 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43587 index 036effe..b3a6336 100644
43588 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43589 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43590 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43591 * the lid is closed. This leads to interrupts as soon as a little move
43592 * is done.
43593 */
43594 - atomic_inc(&lis3->count);
43595 + atomic_inc_unchecked(&lis3->count);
43596
43597 wake_up_interruptible(&lis3->misc_wait);
43598 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43599 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43600 if (lis3->pm_dev)
43601 pm_runtime_get_sync(lis3->pm_dev);
43602
43603 - atomic_set(&lis3->count, 0);
43604 + atomic_set_unchecked(&lis3->count, 0);
43605 return 0;
43606 }
43607
43608 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43609 add_wait_queue(&lis3->misc_wait, &wait);
43610 while (true) {
43611 set_current_state(TASK_INTERRUPTIBLE);
43612 - data = atomic_xchg(&lis3->count, 0);
43613 + data = atomic_xchg_unchecked(&lis3->count, 0);
43614 if (data)
43615 break;
43616
43617 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43618 struct lis3lv02d, miscdev);
43619
43620 poll_wait(file, &lis3->misc_wait, wait);
43621 - if (atomic_read(&lis3->count))
43622 + if (atomic_read_unchecked(&lis3->count))
43623 return POLLIN | POLLRDNORM;
43624 return 0;
43625 }
43626 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43627 index c439c82..1f20f57 100644
43628 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43629 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43630 @@ -297,7 +297,7 @@ struct lis3lv02d {
43631 struct input_polled_dev *idev; /* input device */
43632 struct platform_device *pdev; /* platform device */
43633 struct regulator_bulk_data regulators[2];
43634 - atomic_t count; /* interrupt count after last read */
43635 + atomic_unchecked_t count; /* interrupt count after last read */
43636 union axis_conversion ac; /* hw -> logical axis */
43637 int mapped_btns[3];
43638
43639 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43640 index 2f30bad..c4c13d0 100644
43641 --- a/drivers/misc/sgi-gru/gruhandles.c
43642 +++ b/drivers/misc/sgi-gru/gruhandles.c
43643 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43644 unsigned long nsec;
43645
43646 nsec = CLKS2NSEC(clks);
43647 - atomic_long_inc(&mcs_op_statistics[op].count);
43648 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43649 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43650 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43651 if (mcs_op_statistics[op].max < nsec)
43652 mcs_op_statistics[op].max = nsec;
43653 }
43654 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43655 index 4f76359..cdfcb2e 100644
43656 --- a/drivers/misc/sgi-gru/gruprocfs.c
43657 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43658 @@ -32,9 +32,9 @@
43659
43660 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43661
43662 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43663 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43664 {
43665 - unsigned long val = atomic_long_read(v);
43666 + unsigned long val = atomic_long_read_unchecked(v);
43667
43668 seq_printf(s, "%16lu %s\n", val, id);
43669 }
43670 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43671
43672 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43673 for (op = 0; op < mcsop_last; op++) {
43674 - count = atomic_long_read(&mcs_op_statistics[op].count);
43675 - total = atomic_long_read(&mcs_op_statistics[op].total);
43676 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43677 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43678 max = mcs_op_statistics[op].max;
43679 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43680 count ? total / count : 0, max);
43681 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43682 index 5c3ce24..4915ccb 100644
43683 --- a/drivers/misc/sgi-gru/grutables.h
43684 +++ b/drivers/misc/sgi-gru/grutables.h
43685 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43686 * GRU statistics.
43687 */
43688 struct gru_stats_s {
43689 - atomic_long_t vdata_alloc;
43690 - atomic_long_t vdata_free;
43691 - atomic_long_t gts_alloc;
43692 - atomic_long_t gts_free;
43693 - atomic_long_t gms_alloc;
43694 - atomic_long_t gms_free;
43695 - atomic_long_t gts_double_allocate;
43696 - atomic_long_t assign_context;
43697 - atomic_long_t assign_context_failed;
43698 - atomic_long_t free_context;
43699 - atomic_long_t load_user_context;
43700 - atomic_long_t load_kernel_context;
43701 - atomic_long_t lock_kernel_context;
43702 - atomic_long_t unlock_kernel_context;
43703 - atomic_long_t steal_user_context;
43704 - atomic_long_t steal_kernel_context;
43705 - atomic_long_t steal_context_failed;
43706 - atomic_long_t nopfn;
43707 - atomic_long_t asid_new;
43708 - atomic_long_t asid_next;
43709 - atomic_long_t asid_wrap;
43710 - atomic_long_t asid_reuse;
43711 - atomic_long_t intr;
43712 - atomic_long_t intr_cbr;
43713 - atomic_long_t intr_tfh;
43714 - atomic_long_t intr_spurious;
43715 - atomic_long_t intr_mm_lock_failed;
43716 - atomic_long_t call_os;
43717 - atomic_long_t call_os_wait_queue;
43718 - atomic_long_t user_flush_tlb;
43719 - atomic_long_t user_unload_context;
43720 - atomic_long_t user_exception;
43721 - atomic_long_t set_context_option;
43722 - atomic_long_t check_context_retarget_intr;
43723 - atomic_long_t check_context_unload;
43724 - atomic_long_t tlb_dropin;
43725 - atomic_long_t tlb_preload_page;
43726 - atomic_long_t tlb_dropin_fail_no_asid;
43727 - atomic_long_t tlb_dropin_fail_upm;
43728 - atomic_long_t tlb_dropin_fail_invalid;
43729 - atomic_long_t tlb_dropin_fail_range_active;
43730 - atomic_long_t tlb_dropin_fail_idle;
43731 - atomic_long_t tlb_dropin_fail_fmm;
43732 - atomic_long_t tlb_dropin_fail_no_exception;
43733 - atomic_long_t tfh_stale_on_fault;
43734 - atomic_long_t mmu_invalidate_range;
43735 - atomic_long_t mmu_invalidate_page;
43736 - atomic_long_t flush_tlb;
43737 - atomic_long_t flush_tlb_gru;
43738 - atomic_long_t flush_tlb_gru_tgh;
43739 - atomic_long_t flush_tlb_gru_zero_asid;
43740 + atomic_long_unchecked_t vdata_alloc;
43741 + atomic_long_unchecked_t vdata_free;
43742 + atomic_long_unchecked_t gts_alloc;
43743 + atomic_long_unchecked_t gts_free;
43744 + atomic_long_unchecked_t gms_alloc;
43745 + atomic_long_unchecked_t gms_free;
43746 + atomic_long_unchecked_t gts_double_allocate;
43747 + atomic_long_unchecked_t assign_context;
43748 + atomic_long_unchecked_t assign_context_failed;
43749 + atomic_long_unchecked_t free_context;
43750 + atomic_long_unchecked_t load_user_context;
43751 + atomic_long_unchecked_t load_kernel_context;
43752 + atomic_long_unchecked_t lock_kernel_context;
43753 + atomic_long_unchecked_t unlock_kernel_context;
43754 + atomic_long_unchecked_t steal_user_context;
43755 + atomic_long_unchecked_t steal_kernel_context;
43756 + atomic_long_unchecked_t steal_context_failed;
43757 + atomic_long_unchecked_t nopfn;
43758 + atomic_long_unchecked_t asid_new;
43759 + atomic_long_unchecked_t asid_next;
43760 + atomic_long_unchecked_t asid_wrap;
43761 + atomic_long_unchecked_t asid_reuse;
43762 + atomic_long_unchecked_t intr;
43763 + atomic_long_unchecked_t intr_cbr;
43764 + atomic_long_unchecked_t intr_tfh;
43765 + atomic_long_unchecked_t intr_spurious;
43766 + atomic_long_unchecked_t intr_mm_lock_failed;
43767 + atomic_long_unchecked_t call_os;
43768 + atomic_long_unchecked_t call_os_wait_queue;
43769 + atomic_long_unchecked_t user_flush_tlb;
43770 + atomic_long_unchecked_t user_unload_context;
43771 + atomic_long_unchecked_t user_exception;
43772 + atomic_long_unchecked_t set_context_option;
43773 + atomic_long_unchecked_t check_context_retarget_intr;
43774 + atomic_long_unchecked_t check_context_unload;
43775 + atomic_long_unchecked_t tlb_dropin;
43776 + atomic_long_unchecked_t tlb_preload_page;
43777 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43778 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43779 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43780 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43781 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43782 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43783 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43784 + atomic_long_unchecked_t tfh_stale_on_fault;
43785 + atomic_long_unchecked_t mmu_invalidate_range;
43786 + atomic_long_unchecked_t mmu_invalidate_page;
43787 + atomic_long_unchecked_t flush_tlb;
43788 + atomic_long_unchecked_t flush_tlb_gru;
43789 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43790 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43791
43792 - atomic_long_t copy_gpa;
43793 - atomic_long_t read_gpa;
43794 + atomic_long_unchecked_t copy_gpa;
43795 + atomic_long_unchecked_t read_gpa;
43796
43797 - atomic_long_t mesq_receive;
43798 - atomic_long_t mesq_receive_none;
43799 - atomic_long_t mesq_send;
43800 - atomic_long_t mesq_send_failed;
43801 - atomic_long_t mesq_noop;
43802 - atomic_long_t mesq_send_unexpected_error;
43803 - atomic_long_t mesq_send_lb_overflow;
43804 - atomic_long_t mesq_send_qlimit_reached;
43805 - atomic_long_t mesq_send_amo_nacked;
43806 - atomic_long_t mesq_send_put_nacked;
43807 - atomic_long_t mesq_page_overflow;
43808 - atomic_long_t mesq_qf_locked;
43809 - atomic_long_t mesq_qf_noop_not_full;
43810 - atomic_long_t mesq_qf_switch_head_failed;
43811 - atomic_long_t mesq_qf_unexpected_error;
43812 - atomic_long_t mesq_noop_unexpected_error;
43813 - atomic_long_t mesq_noop_lb_overflow;
43814 - atomic_long_t mesq_noop_qlimit_reached;
43815 - atomic_long_t mesq_noop_amo_nacked;
43816 - atomic_long_t mesq_noop_put_nacked;
43817 - atomic_long_t mesq_noop_page_overflow;
43818 + atomic_long_unchecked_t mesq_receive;
43819 + atomic_long_unchecked_t mesq_receive_none;
43820 + atomic_long_unchecked_t mesq_send;
43821 + atomic_long_unchecked_t mesq_send_failed;
43822 + atomic_long_unchecked_t mesq_noop;
43823 + atomic_long_unchecked_t mesq_send_unexpected_error;
43824 + atomic_long_unchecked_t mesq_send_lb_overflow;
43825 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43826 + atomic_long_unchecked_t mesq_send_amo_nacked;
43827 + atomic_long_unchecked_t mesq_send_put_nacked;
43828 + atomic_long_unchecked_t mesq_page_overflow;
43829 + atomic_long_unchecked_t mesq_qf_locked;
43830 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43831 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43832 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43833 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43834 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43835 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43836 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43837 + atomic_long_unchecked_t mesq_noop_put_nacked;
43838 + atomic_long_unchecked_t mesq_noop_page_overflow;
43839
43840 };
43841
43842 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43843 tghop_invalidate, mcsop_last};
43844
43845 struct mcs_op_statistic {
43846 - atomic_long_t count;
43847 - atomic_long_t total;
43848 + atomic_long_unchecked_t count;
43849 + atomic_long_unchecked_t total;
43850 unsigned long max;
43851 };
43852
43853 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43854
43855 #define STAT(id) do { \
43856 if (gru_options & OPT_STATS) \
43857 - atomic_long_inc(&gru_stats.id); \
43858 + atomic_long_inc_unchecked(&gru_stats.id); \
43859 } while (0)
43860
43861 #ifdef CONFIG_SGI_GRU_DEBUG
43862 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43863 index c862cd4..0d176fe 100644
43864 --- a/drivers/misc/sgi-xp/xp.h
43865 +++ b/drivers/misc/sgi-xp/xp.h
43866 @@ -288,7 +288,7 @@ struct xpc_interface {
43867 xpc_notify_func, void *);
43868 void (*received) (short, int, void *);
43869 enum xp_retval (*partid_to_nasids) (short, void *);
43870 -};
43871 +} __no_const;
43872
43873 extern struct xpc_interface xpc_interface;
43874
43875 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43876 index b94d5f7..7f494c5 100644
43877 --- a/drivers/misc/sgi-xp/xpc.h
43878 +++ b/drivers/misc/sgi-xp/xpc.h
43879 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43880 void (*received_payload) (struct xpc_channel *, void *);
43881 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43882 };
43883 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43884
43885 /* struct xpc_partition act_state values (for XPC HB) */
43886
43887 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43888 /* found in xpc_main.c */
43889 extern struct device *xpc_part;
43890 extern struct device *xpc_chan;
43891 -extern struct xpc_arch_operations xpc_arch_ops;
43892 +extern xpc_arch_operations_no_const xpc_arch_ops;
43893 extern int xpc_disengage_timelimit;
43894 extern int xpc_disengage_timedout;
43895 extern int xpc_activate_IRQ_rcvd;
43896 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43897 index 82dc574..8539ab2 100644
43898 --- a/drivers/misc/sgi-xp/xpc_main.c
43899 +++ b/drivers/misc/sgi-xp/xpc_main.c
43900 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43901 .notifier_call = xpc_system_die,
43902 };
43903
43904 -struct xpc_arch_operations xpc_arch_ops;
43905 +xpc_arch_operations_no_const xpc_arch_ops;
43906
43907 /*
43908 * Timer function to enforce the timelimit on the partition disengage.
43909 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43910
43911 if (((die_args->trapnr == X86_TRAP_MF) ||
43912 (die_args->trapnr == X86_TRAP_XF)) &&
43913 - !user_mode_vm(die_args->regs))
43914 + !user_mode(die_args->regs))
43915 xpc_die_deactivate();
43916
43917 break;
43918 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43919 index ef18348..1b53cf0 100644
43920 --- a/drivers/mmc/core/mmc_ops.c
43921 +++ b/drivers/mmc/core/mmc_ops.c
43922 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
43923 void *data_buf;
43924 int is_on_stack;
43925
43926 - is_on_stack = object_is_on_stack(buf);
43927 + is_on_stack = object_starts_on_stack(buf);
43928 if (is_on_stack) {
43929 /*
43930 * dma onto stack is unsafe/nonportable, but callers to this
43931 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
43932 index 81b2994..dce857e 100644
43933 --- a/drivers/mmc/host/dw_mmc.h
43934 +++ b/drivers/mmc/host/dw_mmc.h
43935 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
43936 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
43937 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
43938 int (*parse_dt)(struct dw_mci *host);
43939 -};
43940 +} __do_const;
43941 #endif /* _DW_MMC_H_ */
43942 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
43943 index c3785ed..1984c44 100644
43944 --- a/drivers/mmc/host/mmci.c
43945 +++ b/drivers/mmc/host/mmci.c
43946 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
43947 }
43948
43949 if (variant->busy_detect) {
43950 - mmci_ops.card_busy = mmci_card_busy;
43951 + pax_open_kernel();
43952 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
43953 + pax_close_kernel();
43954 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
43955 }
43956
43957 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
43958 index 6debda9..2ba7427 100644
43959 --- a/drivers/mmc/host/sdhci-s3c.c
43960 +++ b/drivers/mmc/host/sdhci-s3c.c
43961 @@ -668,9 +668,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
43962 * we can use overriding functions instead of default.
43963 */
43964 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
43965 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43966 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43967 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43968 + pax_open_kernel();
43969 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43970 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43971 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43972 + pax_close_kernel();
43973 }
43974
43975 /* It supports additional host capabilities if needed */
43976 diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
43977 index 096993f..f02c23b 100644
43978 --- a/drivers/mtd/chips/cfi_cmdset_0020.c
43979 +++ b/drivers/mtd/chips/cfi_cmdset_0020.c
43980 @@ -669,7 +669,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
43981 size_t totlen = 0, thislen;
43982 int ret = 0;
43983 size_t buflen = 0;
43984 - static char *buffer;
43985 + char *buffer;
43986
43987 if (!ECCBUF_SIZE) {
43988 /* We should fall back to a general writev implementation.
43989 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
43990 index 2ed2bb3..2d0b82e 100644
43991 --- a/drivers/mtd/nand/denali.c
43992 +++ b/drivers/mtd/nand/denali.c
43993 @@ -24,6 +24,7 @@
43994 #include <linux/slab.h>
43995 #include <linux/mtd/mtd.h>
43996 #include <linux/module.h>
43997 +#include <linux/slab.h>
43998
43999 #include "denali.h"
44000
44001 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
44002 index 51b9d6a..52af9a7 100644
44003 --- a/drivers/mtd/nftlmount.c
44004 +++ b/drivers/mtd/nftlmount.c
44005 @@ -24,6 +24,7 @@
44006 #include <asm/errno.h>
44007 #include <linux/delay.h>
44008 #include <linux/slab.h>
44009 +#include <linux/sched.h>
44010 #include <linux/mtd/mtd.h>
44011 #include <linux/mtd/nand.h>
44012 #include <linux/mtd/nftl.h>
44013 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
44014 index 4b8e895..6b3c498 100644
44015 --- a/drivers/mtd/sm_ftl.c
44016 +++ b/drivers/mtd/sm_ftl.c
44017 @@ -56,7 +56,7 @@ static ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
44018 #define SM_CIS_VENDOR_OFFSET 0x59
44019 static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
44020 {
44021 - struct attribute_group *attr_group;
44022 + attribute_group_no_const *attr_group;
44023 struct attribute **attributes;
44024 struct sm_sysfs_attribute *vendor_attribute;
44025
44026 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
44027 index dd8057d..22aaf36 100644
44028 --- a/drivers/net/bonding/bond_main.c
44029 +++ b/drivers/net/bonding/bond_main.c
44030 @@ -4511,7 +4511,7 @@ static unsigned int bond_get_num_tx_queues(void)
44031 return tx_queues;
44032 }
44033
44034 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
44035 +static struct rtnl_link_ops bond_link_ops = {
44036 .kind = "bond",
44037 .priv_size = sizeof(struct bonding),
44038 .setup = bond_setup,
44039 @@ -4636,8 +4636,8 @@ static void __exit bonding_exit(void)
44040
44041 bond_destroy_debugfs();
44042
44043 - rtnl_link_unregister(&bond_link_ops);
44044 unregister_pernet_subsys(&bond_net_ops);
44045 + rtnl_link_unregister(&bond_link_ops);
44046
44047 #ifdef CONFIG_NET_POLL_CONTROLLER
44048 /*
44049 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
44050 index f92f001..0b2f9bf 100644
44051 --- a/drivers/net/ethernet/8390/ax88796.c
44052 +++ b/drivers/net/ethernet/8390/ax88796.c
44053 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
44054 if (ax->plat->reg_offsets)
44055 ei_local->reg_offset = ax->plat->reg_offsets;
44056 else {
44057 + resource_size_t _mem_size = mem_size;
44058 + do_div(_mem_size, 0x18);
44059 ei_local->reg_offset = ax->reg_offsets;
44060 for (ret = 0; ret < 0x18; ret++)
44061 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
44062 + ax->reg_offsets[ret] = _mem_size * ret;
44063 }
44064
44065 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
44066 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44067 index da8fcaa..f4b5d3b 100644
44068 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44069 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44070 @@ -1138,7 +1138,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
44071 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
44072 {
44073 /* RX_MODE controlling object */
44074 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
44075 + bnx2x_init_rx_mode_obj(bp);
44076
44077 /* multicast configuration controlling object */
44078 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
44079 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44080 index 9fbeee5..5e3e37a 100644
44081 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44082 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44083 @@ -2590,15 +2590,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
44084 return rc;
44085 }
44086
44087 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
44088 - struct bnx2x_rx_mode_obj *o)
44089 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
44090 {
44091 if (CHIP_IS_E1x(bp)) {
44092 - o->wait_comp = bnx2x_empty_rx_mode_wait;
44093 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
44094 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
44095 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
44096 } else {
44097 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
44098 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
44099 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
44100 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
44101 }
44102 }
44103
44104 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44105 index 658f4e3..15074a6 100644
44106 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44107 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44108 @@ -1325,8 +1325,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
44109
44110 /********************* RX MODE ****************/
44111
44112 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
44113 - struct bnx2x_rx_mode_obj *o);
44114 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
44115
44116 /**
44117 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
44118 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
44119 index 7025780..e55a71c 100644
44120 --- a/drivers/net/ethernet/broadcom/tg3.h
44121 +++ b/drivers/net/ethernet/broadcom/tg3.h
44122 @@ -147,6 +147,7 @@
44123 #define CHIPREV_ID_5750_A0 0x4000
44124 #define CHIPREV_ID_5750_A1 0x4001
44125 #define CHIPREV_ID_5750_A3 0x4003
44126 +#define CHIPREV_ID_5750_C1 0x4201
44127 #define CHIPREV_ID_5750_C2 0x4202
44128 #define CHIPREV_ID_5752_A0_HW 0x5000
44129 #define CHIPREV_ID_5752_A0 0x6000
44130 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44131 index 8cffcdf..aadf043 100644
44132 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44133 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44134 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
44135 */
44136 struct l2t_skb_cb {
44137 arp_failure_handler_func arp_failure_handler;
44138 -};
44139 +} __no_const;
44140
44141 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
44142
44143 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
44144 index c73cabd..cd278b1 100644
44145 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
44146 +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
44147 @@ -2186,7 +2186,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
44148
44149 int i;
44150 struct adapter *ap = netdev2adap(dev);
44151 - static const unsigned int *reg_ranges;
44152 + const unsigned int *reg_ranges;
44153 int arr_size = 0, buf_size = 0;
44154
44155 if (is_t4(ap->chip)) {
44156 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
44157 index 263b92c..f05134b 100644
44158 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
44159 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
44160 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44161 for (i=0; i<ETH_ALEN; i++) {
44162 tmp.addr[i] = dev->dev_addr[i];
44163 }
44164 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44165 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44166 break;
44167
44168 case DE4X5_SET_HWADDR: /* Set the hardware address */
44169 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44170 spin_lock_irqsave(&lp->lock, flags);
44171 memcpy(&statbuf, &lp->pktStats, ioc->len);
44172 spin_unlock_irqrestore(&lp->lock, flags);
44173 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
44174 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
44175 return -EFAULT;
44176 break;
44177 }
44178 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
44179 index 2c38cc4..0323f6e 100644
44180 --- a/drivers/net/ethernet/emulex/benet/be_main.c
44181 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
44182 @@ -470,7 +470,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
44183
44184 if (wrapped)
44185 newacc += 65536;
44186 - ACCESS_ONCE(*acc) = newacc;
44187 + ACCESS_ONCE_RW(*acc) = newacc;
44188 }
44189
44190 static void populate_erx_stats(struct be_adapter *adapter,
44191 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
44192 index 212f44b..fb69959 100644
44193 --- a/drivers/net/ethernet/faraday/ftgmac100.c
44194 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
44195 @@ -31,6 +31,8 @@
44196 #include <linux/netdevice.h>
44197 #include <linux/phy.h>
44198 #include <linux/platform_device.h>
44199 +#include <linux/interrupt.h>
44200 +#include <linux/irqreturn.h>
44201 #include <net/ip.h>
44202
44203 #include "ftgmac100.h"
44204 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
44205 index 8be5b40..081bc1b 100644
44206 --- a/drivers/net/ethernet/faraday/ftmac100.c
44207 +++ b/drivers/net/ethernet/faraday/ftmac100.c
44208 @@ -31,6 +31,8 @@
44209 #include <linux/module.h>
44210 #include <linux/netdevice.h>
44211 #include <linux/platform_device.h>
44212 +#include <linux/interrupt.h>
44213 +#include <linux/irqreturn.h>
44214
44215 #include "ftmac100.h"
44216
44217 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44218 index 5184e2a..acb28c3 100644
44219 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44220 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44221 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
44222 }
44223
44224 /* update the base incval used to calculate frequency adjustment */
44225 - ACCESS_ONCE(adapter->base_incval) = incval;
44226 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
44227 smp_mb();
44228
44229 /* need lock to prevent incorrect read while modifying cyclecounter */
44230 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44231 index fbe5363..266b4e3 100644
44232 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
44233 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44234 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44235 struct __vxge_hw_fifo *fifo;
44236 struct vxge_hw_fifo_config *config;
44237 u32 txdl_size, txdl_per_memblock;
44238 - struct vxge_hw_mempool_cbs fifo_mp_callback;
44239 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
44240 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
44241 + };
44242 +
44243 struct __vxge_hw_virtualpath *vpath;
44244
44245 if ((vp == NULL) || (attr == NULL)) {
44246 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44247 goto exit;
44248 }
44249
44250 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
44251 -
44252 fifo->mempool =
44253 __vxge_hw_mempool_create(vpath->hldev,
44254 fifo->config->memblock_size,
44255 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44256 index f09e787..f3916a8 100644
44257 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44258 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44259 @@ -2055,7 +2055,9 @@ int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter)
44260
44261 } else if (ret == QLC_83XX_DEFAULT_OPMODE) {
44262 ahw->nic_mode = QLC_83XX_DEFAULT_MODE;
44263 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44264 + pax_open_kernel();
44265 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44266 + pax_close_kernel();
44267 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44268 } else {
44269 return -EIO;
44270 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44271 index 0248a4c..9648d96 100644
44272 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44273 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44274 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
44275 case QLCNIC_NON_PRIV_FUNC:
44276 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
44277 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44278 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44279 + pax_open_kernel();
44280 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44281 + pax_close_kernel();
44282 break;
44283 case QLCNIC_PRIV_FUNC:
44284 ahw->op_mode = QLCNIC_PRIV_FUNC;
44285 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
44286 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44287 + pax_open_kernel();
44288 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44289 + pax_close_kernel();
44290 break;
44291 case QLCNIC_MGMT_FUNC:
44292 ahw->op_mode = QLCNIC_MGMT_FUNC;
44293 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44294 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44295 + pax_open_kernel();
44296 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44297 + pax_close_kernel();
44298 break;
44299 default:
44300 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
44301 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44302 index 1551360..ed6510f 100644
44303 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44304 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44305 @@ -1108,7 +1108,7 @@ int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
44306 struct qlcnic_dump_entry *entry;
44307 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
44308 struct qlcnic_dump_template_hdr *tmpl_hdr = fw_dump->tmpl_hdr;
44309 - static const struct qlcnic_dump_operations *fw_dump_ops;
44310 + const struct qlcnic_dump_operations *fw_dump_ops;
44311 struct device *dev = &adapter->pdev->dev;
44312 struct qlcnic_hardware_context *ahw;
44313 void *temp_buffer;
44314 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
44315 index fb3f8dc..9d2ff38 100644
44316 --- a/drivers/net/ethernet/realtek/r8169.c
44317 +++ b/drivers/net/ethernet/realtek/r8169.c
44318 @@ -759,22 +759,22 @@ struct rtl8169_private {
44319 struct mdio_ops {
44320 void (*write)(struct rtl8169_private *, int, int);
44321 int (*read)(struct rtl8169_private *, int);
44322 - } mdio_ops;
44323 + } __no_const mdio_ops;
44324
44325 struct pll_power_ops {
44326 void (*down)(struct rtl8169_private *);
44327 void (*up)(struct rtl8169_private *);
44328 - } pll_power_ops;
44329 + } __no_const pll_power_ops;
44330
44331 struct jumbo_ops {
44332 void (*enable)(struct rtl8169_private *);
44333 void (*disable)(struct rtl8169_private *);
44334 - } jumbo_ops;
44335 + } __no_const jumbo_ops;
44336
44337 struct csi_ops {
44338 void (*write)(struct rtl8169_private *, int, int);
44339 u32 (*read)(struct rtl8169_private *, int);
44340 - } csi_ops;
44341 + } __no_const csi_ops;
44342
44343 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
44344 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
44345 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
44346 index 3dd39dc..85efa46 100644
44347 --- a/drivers/net/ethernet/sfc/ptp.c
44348 +++ b/drivers/net/ethernet/sfc/ptp.c
44349 @@ -541,7 +541,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
44350 ptp->start.dma_addr);
44351
44352 /* Clear flag that signals MC ready */
44353 - ACCESS_ONCE(*start) = 0;
44354 + ACCESS_ONCE_RW(*start) = 0;
44355 rc = efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
44356 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
44357 EFX_BUG_ON_PARANOID(rc);
44358 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44359 index 50617c5..b13724c 100644
44360 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44361 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44362 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
44363
44364 writel(value, ioaddr + MMC_CNTRL);
44365
44366 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44367 - MMC_CNTRL, value);
44368 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44369 +// MMC_CNTRL, value);
44370 }
44371
44372 /* To mask all all interrupts.*/
44373 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
44374 index e6fe0d8..2b7d752 100644
44375 --- a/drivers/net/hyperv/hyperv_net.h
44376 +++ b/drivers/net/hyperv/hyperv_net.h
44377 @@ -101,7 +101,7 @@ struct rndis_device {
44378
44379 enum rndis_device_state state;
44380 bool link_state;
44381 - atomic_t new_req_id;
44382 + atomic_unchecked_t new_req_id;
44383
44384 spinlock_t request_lock;
44385 struct list_head req_list;
44386 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
44387 index 0775f0a..d4fb316 100644
44388 --- a/drivers/net/hyperv/rndis_filter.c
44389 +++ b/drivers/net/hyperv/rndis_filter.c
44390 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
44391 * template
44392 */
44393 set = &rndis_msg->msg.set_req;
44394 - set->req_id = atomic_inc_return(&dev->new_req_id);
44395 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44396
44397 /* Add to the request list */
44398 spin_lock_irqsave(&dev->request_lock, flags);
44399 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
44400
44401 /* Setup the rndis set */
44402 halt = &request->request_msg.msg.halt_req;
44403 - halt->req_id = atomic_inc_return(&dev->new_req_id);
44404 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44405
44406 /* Ignore return since this msg is optional. */
44407 rndis_filter_send_request(dev, request);
44408 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
44409 index bf0d55e..82bcfbd1 100644
44410 --- a/drivers/net/ieee802154/fakehard.c
44411 +++ b/drivers/net/ieee802154/fakehard.c
44412 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
44413 phy->transmit_power = 0xbf;
44414
44415 dev->netdev_ops = &fake_ops;
44416 - dev->ml_priv = &fake_mlme;
44417 + dev->ml_priv = (void *)&fake_mlme;
44418
44419 priv = netdev_priv(dev);
44420 priv->phy = phy;
44421 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
44422 index 9bf46bd..bfdaa84 100644
44423 --- a/drivers/net/macvlan.c
44424 +++ b/drivers/net/macvlan.c
44425 @@ -939,13 +939,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
44426 int macvlan_link_register(struct rtnl_link_ops *ops)
44427 {
44428 /* common fields */
44429 - ops->priv_size = sizeof(struct macvlan_dev);
44430 - ops->validate = macvlan_validate;
44431 - ops->maxtype = IFLA_MACVLAN_MAX;
44432 - ops->policy = macvlan_policy;
44433 - ops->changelink = macvlan_changelink;
44434 - ops->get_size = macvlan_get_size;
44435 - ops->fill_info = macvlan_fill_info;
44436 + pax_open_kernel();
44437 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
44438 + *(void **)&ops->validate = macvlan_validate;
44439 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
44440 + *(const void **)&ops->policy = macvlan_policy;
44441 + *(void **)&ops->changelink = macvlan_changelink;
44442 + *(void **)&ops->get_size = macvlan_get_size;
44443 + *(void **)&ops->fill_info = macvlan_fill_info;
44444 + pax_close_kernel();
44445
44446 return rtnl_link_register(ops);
44447 };
44448 @@ -1001,7 +1003,7 @@ static int macvlan_device_event(struct notifier_block *unused,
44449 return NOTIFY_DONE;
44450 }
44451
44452 -static struct notifier_block macvlan_notifier_block __read_mostly = {
44453 +static struct notifier_block macvlan_notifier_block = {
44454 .notifier_call = macvlan_device_event,
44455 };
44456
44457 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
44458 index 5895e4d..0343d45 100644
44459 --- a/drivers/net/macvtap.c
44460 +++ b/drivers/net/macvtap.c
44461 @@ -1182,7 +1182,7 @@ static int macvtap_device_event(struct notifier_block *unused,
44462 return NOTIFY_DONE;
44463 }
44464
44465 -static struct notifier_block macvtap_notifier_block __read_mostly = {
44466 +static struct notifier_block macvtap_notifier_block = {
44467 .notifier_call = macvtap_device_event,
44468 };
44469
44470 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
44471 index daec9b0..6428fcb 100644
44472 --- a/drivers/net/phy/mdio-bitbang.c
44473 +++ b/drivers/net/phy/mdio-bitbang.c
44474 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
44475 struct mdiobb_ctrl *ctrl = bus->priv;
44476
44477 module_put(ctrl->ops->owner);
44478 + mdiobus_unregister(bus);
44479 mdiobus_free(bus);
44480 }
44481 EXPORT_SYMBOL(free_mdio_bitbang);
44482 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
44483 index 72ff14b..11d442d 100644
44484 --- a/drivers/net/ppp/ppp_generic.c
44485 +++ b/drivers/net/ppp/ppp_generic.c
44486 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44487 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
44488 struct ppp_stats stats;
44489 struct ppp_comp_stats cstats;
44490 - char *vers;
44491
44492 switch (cmd) {
44493 case SIOCGPPPSTATS:
44494 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44495 break;
44496
44497 case SIOCGPPPVER:
44498 - vers = PPP_VERSION;
44499 - if (copy_to_user(addr, vers, strlen(vers) + 1))
44500 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
44501 break;
44502 err = 0;
44503 break;
44504 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
44505 index 1252d9c..80e660b 100644
44506 --- a/drivers/net/slip/slhc.c
44507 +++ b/drivers/net/slip/slhc.c
44508 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
44509 register struct tcphdr *thp;
44510 register struct iphdr *ip;
44511 register struct cstate *cs;
44512 - int len, hdrlen;
44513 + long len, hdrlen;
44514 unsigned char *cp = icp;
44515
44516 /* We've got a compressed packet; read the change byte */
44517 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
44518 index 6327df2..e6e1ebe 100644
44519 --- a/drivers/net/team/team.c
44520 +++ b/drivers/net/team/team.c
44521 @@ -2873,7 +2873,7 @@ static int team_device_event(struct notifier_block *unused,
44522 return NOTIFY_DONE;
44523 }
44524
44525 -static struct notifier_block team_notifier_block __read_mostly = {
44526 +static struct notifier_block team_notifier_block = {
44527 .notifier_call = team_device_event,
44528 };
44529
44530 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
44531 index 7c8343a..80d1e69 100644
44532 --- a/drivers/net/tun.c
44533 +++ b/drivers/net/tun.c
44534 @@ -1838,7 +1838,7 @@ unlock:
44535 }
44536
44537 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44538 - unsigned long arg, int ifreq_len)
44539 + unsigned long arg, size_t ifreq_len)
44540 {
44541 struct tun_file *tfile = file->private_data;
44542 struct tun_struct *tun;
44543 @@ -1851,6 +1851,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44544 unsigned int ifindex;
44545 int ret;
44546
44547 + if (ifreq_len > sizeof ifr)
44548 + return -EFAULT;
44549 +
44550 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
44551 if (copy_from_user(&ifr, argp, ifreq_len))
44552 return -EFAULT;
44553 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
44554 index 86292e6..8d34433 100644
44555 --- a/drivers/net/usb/hso.c
44556 +++ b/drivers/net/usb/hso.c
44557 @@ -71,7 +71,7 @@
44558 #include <asm/byteorder.h>
44559 #include <linux/serial_core.h>
44560 #include <linux/serial.h>
44561 -
44562 +#include <asm/local.h>
44563
44564 #define MOD_AUTHOR "Option Wireless"
44565 #define MOD_DESCRIPTION "USB High Speed Option driver"
44566 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44567 struct urb *urb;
44568
44569 urb = serial->rx_urb[0];
44570 - if (serial->port.count > 0) {
44571 + if (atomic_read(&serial->port.count) > 0) {
44572 count = put_rxbuf_data(urb, serial);
44573 if (count == -1)
44574 return;
44575 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44576 DUMP1(urb->transfer_buffer, urb->actual_length);
44577
44578 /* Anyone listening? */
44579 - if (serial->port.count == 0)
44580 + if (atomic_read(&serial->port.count) == 0)
44581 return;
44582
44583 if (status == 0) {
44584 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44585 tty_port_tty_set(&serial->port, tty);
44586
44587 /* check for port already opened, if not set the termios */
44588 - serial->port.count++;
44589 - if (serial->port.count == 1) {
44590 + if (atomic_inc_return(&serial->port.count) == 1) {
44591 serial->rx_state = RX_IDLE;
44592 /* Force default termio settings */
44593 _hso_serial_set_termios(tty, NULL);
44594 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44595 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44596 if (result) {
44597 hso_stop_serial_device(serial->parent);
44598 - serial->port.count--;
44599 + atomic_dec(&serial->port.count);
44600 kref_put(&serial->parent->ref, hso_serial_ref_free);
44601 }
44602 } else {
44603 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44604
44605 /* reset the rts and dtr */
44606 /* do the actual close */
44607 - serial->port.count--;
44608 + atomic_dec(&serial->port.count);
44609
44610 - if (serial->port.count <= 0) {
44611 - serial->port.count = 0;
44612 + if (atomic_read(&serial->port.count) <= 0) {
44613 + atomic_set(&serial->port.count, 0);
44614 tty_port_tty_set(&serial->port, NULL);
44615 if (!usb_gone)
44616 hso_stop_serial_device(serial->parent);
44617 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44618
44619 /* the actual setup */
44620 spin_lock_irqsave(&serial->serial_lock, flags);
44621 - if (serial->port.count)
44622 + if (atomic_read(&serial->port.count))
44623 _hso_serial_set_termios(tty, old);
44624 else
44625 tty->termios = *old;
44626 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44627 D1("Pending read interrupt on port %d\n", i);
44628 spin_lock(&serial->serial_lock);
44629 if (serial->rx_state == RX_IDLE &&
44630 - serial->port.count > 0) {
44631 + atomic_read(&serial->port.count) > 0) {
44632 /* Setup and send a ctrl req read on
44633 * port i */
44634 if (!serial->rx_urb_filled[0]) {
44635 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44636 /* Start all serial ports */
44637 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44638 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44639 - if (dev2ser(serial_table[i])->port.count) {
44640 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44641 result =
44642 hso_start_serial_device(serial_table[i], GFP_NOIO);
44643 hso_kick_transmit(dev2ser(serial_table[i]));
44644 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44645 index a79e9d3..78cd4fa 100644
44646 --- a/drivers/net/usb/sierra_net.c
44647 +++ b/drivers/net/usb/sierra_net.c
44648 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44649 /* atomic counter partially included in MAC address to make sure 2 devices
44650 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44651 */
44652 -static atomic_t iface_counter = ATOMIC_INIT(0);
44653 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44654
44655 /*
44656 * SYNC Timer Delay definition used to set the expiry time
44657 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44658 dev->net->netdev_ops = &sierra_net_device_ops;
44659
44660 /* change MAC addr to include, ifacenum, and to be unique */
44661 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44662 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44663 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44664
44665 /* we will have to manufacture ethernet headers, prepare template */
44666 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44667 index 1462368..578941c 100644
44668 --- a/drivers/net/vxlan.c
44669 +++ b/drivers/net/vxlan.c
44670 @@ -2615,7 +2615,7 @@ nla_put_failure:
44671 return -EMSGSIZE;
44672 }
44673
44674 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44675 +static struct rtnl_link_ops vxlan_link_ops = {
44676 .kind = "vxlan",
44677 .maxtype = IFLA_VXLAN_MAX,
44678 .policy = vxlan_policy,
44679 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44680 index 0b60295..b8bfa5b 100644
44681 --- a/drivers/net/wimax/i2400m/rx.c
44682 +++ b/drivers/net/wimax/i2400m/rx.c
44683 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44684 if (i2400m->rx_roq == NULL)
44685 goto error_roq_alloc;
44686
44687 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44688 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44689 GFP_KERNEL);
44690 if (rd == NULL) {
44691 result = -ENOMEM;
44692 diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
44693 index 7fe1964..7016de0 100644
44694 --- a/drivers/net/wireless/airo.c
44695 +++ b/drivers/net/wireless/airo.c
44696 @@ -7844,7 +7844,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
44697 struct airo_info *ai = dev->ml_priv;
44698 int ridcode;
44699 int enabled;
44700 - static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44701 + int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44702 unsigned char *iobuf;
44703
44704 /* Only super-user can write RIDs */
44705 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44706 index 34c8a33..3261fdc 100644
44707 --- a/drivers/net/wireless/at76c50x-usb.c
44708 +++ b/drivers/net/wireless/at76c50x-usb.c
44709 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44710 }
44711
44712 /* Convert timeout from the DFU status to jiffies */
44713 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44714 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44715 {
44716 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44717 | (s->poll_timeout[1] << 8)
44718 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44719 index ef3329e..c28ff5d 100644
44720 --- a/drivers/net/wireless/ath/ath10k/htc.c
44721 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44722 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44723 /* registered target arrival callback from the HIF layer */
44724 int ath10k_htc_init(struct ath10k *ar)
44725 {
44726 - struct ath10k_hif_cb htc_callbacks;
44727 + static struct ath10k_hif_cb htc_callbacks = {
44728 + .rx_completion = ath10k_htc_rx_completion_handler,
44729 + .tx_completion = ath10k_htc_tx_completion_handler,
44730 + };
44731 struct ath10k_htc_ep *ep = NULL;
44732 struct ath10k_htc *htc = &ar->htc;
44733
44734 @@ -973,8 +976,6 @@ int ath10k_htc_init(struct ath10k *ar)
44735 ath10k_htc_reset_endpoint_states(htc);
44736
44737 /* setup HIF layer callbacks */
44738 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44739 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44740 htc->ar = ar;
44741
44742 /* Get HIF default pipe for HTC message exchange */
44743 diff --git a/drivers/net/wireless/ath/ath10k/htc.h b/drivers/net/wireless/ath/ath10k/htc.h
44744 index e1dd8c7..9f91b3f 100644
44745 --- a/drivers/net/wireless/ath/ath10k/htc.h
44746 +++ b/drivers/net/wireless/ath/ath10k/htc.h
44747 @@ -271,12 +271,12 @@ enum ath10k_htc_ep_id {
44748
44749 struct ath10k_htc_ops {
44750 void (*target_send_suspend_complete)(struct ath10k *ar);
44751 -};
44752 +} __no_const;
44753
44754 struct ath10k_htc_ep_ops {
44755 void (*ep_tx_complete)(struct ath10k *, struct sk_buff *);
44756 void (*ep_rx_complete)(struct ath10k *, struct sk_buff *);
44757 -};
44758 +} __no_const;
44759
44760 /* service connection information */
44761 struct ath10k_htc_svc_conn_req {
44762 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44763 index a366d6b..b6f28f8 100644
44764 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44765 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44766 @@ -218,8 +218,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44767 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44768 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44769
44770 - ACCESS_ONCE(ads->ds_link) = i->link;
44771 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44772 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44773 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44774
44775 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44776 ctl6 = SM(i->keytype, AR_EncrType);
44777 @@ -233,26 +233,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44778
44779 if ((i->is_first || i->is_last) &&
44780 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44781 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44782 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44783 | set11nTries(i->rates, 1)
44784 | set11nTries(i->rates, 2)
44785 | set11nTries(i->rates, 3)
44786 | (i->dur_update ? AR_DurUpdateEna : 0)
44787 | SM(0, AR_BurstDur);
44788
44789 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44790 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44791 | set11nRate(i->rates, 1)
44792 | set11nRate(i->rates, 2)
44793 | set11nRate(i->rates, 3);
44794 } else {
44795 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44796 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44797 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44798 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44799 }
44800
44801 if (!i->is_first) {
44802 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44803 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44804 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44805 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44806 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44807 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44808 return;
44809 }
44810
44811 @@ -277,7 +277,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44812 break;
44813 }
44814
44815 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44816 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44817 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44818 | SM(i->txpower, AR_XmitPower)
44819 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44820 @@ -287,19 +287,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44821 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44822 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44823
44824 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44825 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44826 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44827 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44828
44829 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44830 return;
44831
44832 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44833 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44834 | set11nPktDurRTSCTS(i->rates, 1);
44835
44836 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44837 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44838 | set11nPktDurRTSCTS(i->rates, 3);
44839
44840 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44841 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44842 | set11nRateFlags(i->rates, 1)
44843 | set11nRateFlags(i->rates, 2)
44844 | set11nRateFlags(i->rates, 3)
44845 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44846 index f6c5c1b..6058354 100644
44847 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44848 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44849 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44850 (i->qcu << AR_TxQcuNum_S) | desc_len;
44851
44852 checksum += val;
44853 - ACCESS_ONCE(ads->info) = val;
44854 + ACCESS_ONCE_RW(ads->info) = val;
44855
44856 checksum += i->link;
44857 - ACCESS_ONCE(ads->link) = i->link;
44858 + ACCESS_ONCE_RW(ads->link) = i->link;
44859
44860 checksum += i->buf_addr[0];
44861 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44862 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44863 checksum += i->buf_addr[1];
44864 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44865 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44866 checksum += i->buf_addr[2];
44867 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44868 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44869 checksum += i->buf_addr[3];
44870 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44871 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44872
44873 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44874 - ACCESS_ONCE(ads->ctl3) = val;
44875 + ACCESS_ONCE_RW(ads->ctl3) = val;
44876 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44877 - ACCESS_ONCE(ads->ctl5) = val;
44878 + ACCESS_ONCE_RW(ads->ctl5) = val;
44879 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44880 - ACCESS_ONCE(ads->ctl7) = val;
44881 + ACCESS_ONCE_RW(ads->ctl7) = val;
44882 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44883 - ACCESS_ONCE(ads->ctl9) = val;
44884 + ACCESS_ONCE_RW(ads->ctl9) = val;
44885
44886 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44887 - ACCESS_ONCE(ads->ctl10) = checksum;
44888 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44889
44890 if (i->is_first || i->is_last) {
44891 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44892 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44893 | set11nTries(i->rates, 1)
44894 | set11nTries(i->rates, 2)
44895 | set11nTries(i->rates, 3)
44896 | (i->dur_update ? AR_DurUpdateEna : 0)
44897 | SM(0, AR_BurstDur);
44898
44899 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44900 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44901 | set11nRate(i->rates, 1)
44902 | set11nRate(i->rates, 2)
44903 | set11nRate(i->rates, 3);
44904 } else {
44905 - ACCESS_ONCE(ads->ctl13) = 0;
44906 - ACCESS_ONCE(ads->ctl14) = 0;
44907 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44908 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44909 }
44910
44911 ads->ctl20 = 0;
44912 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44913
44914 ctl17 = SM(i->keytype, AR_EncrType);
44915 if (!i->is_first) {
44916 - ACCESS_ONCE(ads->ctl11) = 0;
44917 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44918 - ACCESS_ONCE(ads->ctl15) = 0;
44919 - ACCESS_ONCE(ads->ctl16) = 0;
44920 - ACCESS_ONCE(ads->ctl17) = ctl17;
44921 - ACCESS_ONCE(ads->ctl18) = 0;
44922 - ACCESS_ONCE(ads->ctl19) = 0;
44923 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44924 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44925 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44926 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44927 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44928 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44929 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44930 return;
44931 }
44932
44933 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44934 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44935 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44936 | SM(i->txpower, AR_XmitPower)
44937 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44938 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44939 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
44940 ctl12 |= SM(val, AR_PAPRDChainMask);
44941
44942 - ACCESS_ONCE(ads->ctl12) = ctl12;
44943 - ACCESS_ONCE(ads->ctl17) = ctl17;
44944 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
44945 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44946
44947 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44948 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44949 | set11nPktDurRTSCTS(i->rates, 1);
44950
44951 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44952 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44953 | set11nPktDurRTSCTS(i->rates, 3);
44954
44955 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
44956 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
44957 | set11nRateFlags(i->rates, 1)
44958 | set11nRateFlags(i->rates, 2)
44959 | set11nRateFlags(i->rates, 3)
44960 | SM(i->rtscts_rate, AR_RTSCTSRate);
44961
44962 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
44963 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
44964 }
44965
44966 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
44967 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
44968 index 69a907b..91e071c 100644
44969 --- a/drivers/net/wireless/ath/ath9k/hw.h
44970 +++ b/drivers/net/wireless/ath/ath9k/hw.h
44971 @@ -657,7 +657,7 @@ struct ath_hw_private_ops {
44972
44973 /* ANI */
44974 void (*ani_cache_ini_regs)(struct ath_hw *ah);
44975 -};
44976 +} __no_const;
44977
44978 /**
44979 * struct ath_spec_scan - parameters for Atheros spectral scan
44980 @@ -729,7 +729,7 @@ struct ath_hw_ops {
44981 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
44982 void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable);
44983 #endif
44984 -};
44985 +} __no_const;
44986
44987 struct ath_nf_limits {
44988 s16 max;
44989 diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
44990 index 92190da..f3a4c4c 100644
44991 --- a/drivers/net/wireless/b43/phy_lp.c
44992 +++ b/drivers/net/wireless/b43/phy_lp.c
44993 @@ -2514,7 +2514,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
44994 {
44995 struct ssb_bus *bus = dev->dev->sdev->bus;
44996
44997 - static const struct b206x_channel *chandata = NULL;
44998 + const struct b206x_channel *chandata = NULL;
44999 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
45000 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
45001 u16 old_comm15, scale;
45002 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
45003 index 9581d07..84f6a76 100644
45004 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
45005 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
45006 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
45007 */
45008 if (il3945_mod_params.disable_hw_scan) {
45009 D_INFO("Disabling hw_scan\n");
45010 - il3945_mac_ops.hw_scan = NULL;
45011 + pax_open_kernel();
45012 + *(void **)&il3945_mac_ops.hw_scan = NULL;
45013 + pax_close_kernel();
45014 }
45015
45016 D_INFO("*** LOAD DRIVER ***\n");
45017 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45018 index d94f8ab..5b568c8 100644
45019 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45020 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45021 @@ -188,7 +188,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
45022 {
45023 struct iwl_priv *priv = file->private_data;
45024 char buf[64];
45025 - int buf_size;
45026 + size_t buf_size;
45027 u32 offset, len;
45028
45029 memset(buf, 0, sizeof(buf));
45030 @@ -458,7 +458,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
45031 struct iwl_priv *priv = file->private_data;
45032
45033 char buf[8];
45034 - int buf_size;
45035 + size_t buf_size;
45036 u32 reset_flag;
45037
45038 memset(buf, 0, sizeof(buf));
45039 @@ -539,7 +539,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
45040 {
45041 struct iwl_priv *priv = file->private_data;
45042 char buf[8];
45043 - int buf_size;
45044 + size_t buf_size;
45045 int ht40;
45046
45047 memset(buf, 0, sizeof(buf));
45048 @@ -591,7 +591,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
45049 {
45050 struct iwl_priv *priv = file->private_data;
45051 char buf[8];
45052 - int buf_size;
45053 + size_t buf_size;
45054 int value;
45055
45056 memset(buf, 0, sizeof(buf));
45057 @@ -683,10 +683,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
45058 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
45059 DEBUGFS_READ_FILE_OPS(current_sleep_command);
45060
45061 -static const char *fmt_value = " %-30s %10u\n";
45062 -static const char *fmt_hex = " %-30s 0x%02X\n";
45063 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
45064 -static const char *fmt_header =
45065 +static const char fmt_value[] = " %-30s %10u\n";
45066 +static const char fmt_hex[] = " %-30s 0x%02X\n";
45067 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
45068 +static const char fmt_header[] =
45069 "%-32s current cumulative delta max\n";
45070
45071 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
45072 @@ -1856,7 +1856,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
45073 {
45074 struct iwl_priv *priv = file->private_data;
45075 char buf[8];
45076 - int buf_size;
45077 + size_t buf_size;
45078 int clear;
45079
45080 memset(buf, 0, sizeof(buf));
45081 @@ -1901,7 +1901,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
45082 {
45083 struct iwl_priv *priv = file->private_data;
45084 char buf[8];
45085 - int buf_size;
45086 + size_t buf_size;
45087 int trace;
45088
45089 memset(buf, 0, sizeof(buf));
45090 @@ -1972,7 +1972,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
45091 {
45092 struct iwl_priv *priv = file->private_data;
45093 char buf[8];
45094 - int buf_size;
45095 + size_t buf_size;
45096 int missed;
45097
45098 memset(buf, 0, sizeof(buf));
45099 @@ -2013,7 +2013,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
45100
45101 struct iwl_priv *priv = file->private_data;
45102 char buf[8];
45103 - int buf_size;
45104 + size_t buf_size;
45105 int plcp;
45106
45107 memset(buf, 0, sizeof(buf));
45108 @@ -2073,7 +2073,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
45109
45110 struct iwl_priv *priv = file->private_data;
45111 char buf[8];
45112 - int buf_size;
45113 + size_t buf_size;
45114 int flush;
45115
45116 memset(buf, 0, sizeof(buf));
45117 @@ -2163,7 +2163,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
45118
45119 struct iwl_priv *priv = file->private_data;
45120 char buf[8];
45121 - int buf_size;
45122 + size_t buf_size;
45123 int rts;
45124
45125 if (!priv->cfg->ht_params)
45126 @@ -2205,7 +2205,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
45127 {
45128 struct iwl_priv *priv = file->private_data;
45129 char buf[8];
45130 - int buf_size;
45131 + size_t buf_size;
45132
45133 memset(buf, 0, sizeof(buf));
45134 buf_size = min(count, sizeof(buf) - 1);
45135 @@ -2239,7 +2239,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
45136 struct iwl_priv *priv = file->private_data;
45137 u32 event_log_flag;
45138 char buf[8];
45139 - int buf_size;
45140 + size_t buf_size;
45141
45142 /* check that the interface is up */
45143 if (!iwl_is_ready(priv))
45144 @@ -2293,7 +2293,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
45145 struct iwl_priv *priv = file->private_data;
45146 char buf[8];
45147 u32 calib_disabled;
45148 - int buf_size;
45149 + size_t buf_size;
45150
45151 memset(buf, 0, sizeof(buf));
45152 buf_size = min(count, sizeof(buf) - 1);
45153 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
45154 index 7aad766..06addb4 100644
45155 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
45156 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
45157 @@ -1123,7 +1123,7 @@ static void iwl_option_config(struct iwl_priv *priv)
45158 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45159 {
45160 struct iwl_nvm_data *data = priv->nvm_data;
45161 - char *debug_msg;
45162 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45163
45164 if (data->sku_cap_11n_enable &&
45165 !priv->cfg->ht_params) {
45166 @@ -1137,7 +1137,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45167 return -EINVAL;
45168 }
45169
45170 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45171 IWL_DEBUG_INFO(priv, debug_msg,
45172 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
45173 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
45174 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
45175 index 6bc3100..dd1b80d 100644
45176 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
45177 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
45178 @@ -1249,7 +1249,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
45179 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
45180
45181 char buf[8];
45182 - int buf_size;
45183 + size_t buf_size;
45184 u32 reset_flag;
45185
45186 memset(buf, 0, sizeof(buf));
45187 @@ -1270,7 +1270,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
45188 {
45189 struct iwl_trans *trans = file->private_data;
45190 char buf[8];
45191 - int buf_size;
45192 + size_t buf_size;
45193 int csr;
45194
45195 memset(buf, 0, sizeof(buf));
45196 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
45197 index 2cd3f54..e936f90 100644
45198 --- a/drivers/net/wireless/mac80211_hwsim.c
45199 +++ b/drivers/net/wireless/mac80211_hwsim.c
45200 @@ -2196,25 +2196,19 @@ static int __init init_mac80211_hwsim(void)
45201
45202 if (channels > 1) {
45203 hwsim_if_comb.num_different_channels = channels;
45204 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45205 - mac80211_hwsim_ops.cancel_hw_scan =
45206 - mac80211_hwsim_cancel_hw_scan;
45207 - mac80211_hwsim_ops.sw_scan_start = NULL;
45208 - mac80211_hwsim_ops.sw_scan_complete = NULL;
45209 - mac80211_hwsim_ops.remain_on_channel =
45210 - mac80211_hwsim_roc;
45211 - mac80211_hwsim_ops.cancel_remain_on_channel =
45212 - mac80211_hwsim_croc;
45213 - mac80211_hwsim_ops.add_chanctx =
45214 - mac80211_hwsim_add_chanctx;
45215 - mac80211_hwsim_ops.remove_chanctx =
45216 - mac80211_hwsim_remove_chanctx;
45217 - mac80211_hwsim_ops.change_chanctx =
45218 - mac80211_hwsim_change_chanctx;
45219 - mac80211_hwsim_ops.assign_vif_chanctx =
45220 - mac80211_hwsim_assign_vif_chanctx;
45221 - mac80211_hwsim_ops.unassign_vif_chanctx =
45222 - mac80211_hwsim_unassign_vif_chanctx;
45223 + pax_open_kernel();
45224 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45225 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
45226 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
45227 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
45228 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
45229 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
45230 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
45231 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
45232 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
45233 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
45234 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
45235 + pax_close_kernel();
45236 }
45237
45238 spin_lock_init(&hwsim_radio_lock);
45239 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
45240 index 8169a85..7fa3b47 100644
45241 --- a/drivers/net/wireless/rndis_wlan.c
45242 +++ b/drivers/net/wireless/rndis_wlan.c
45243 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
45244
45245 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
45246
45247 - if (rts_threshold < 0 || rts_threshold > 2347)
45248 + if (rts_threshold > 2347)
45249 rts_threshold = 2347;
45250
45251 tmp = cpu_to_le32(rts_threshold);
45252 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
45253 index fe4c572..99dedfa 100644
45254 --- a/drivers/net/wireless/rt2x00/rt2x00.h
45255 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
45256 @@ -387,7 +387,7 @@ struct rt2x00_intf {
45257 * for hardware which doesn't support hardware
45258 * sequence counting.
45259 */
45260 - atomic_t seqno;
45261 + atomic_unchecked_t seqno;
45262 };
45263
45264 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
45265 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
45266 index 66a2db8..70cad04 100644
45267 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
45268 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
45269 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
45270 * sequence counter given by mac80211.
45271 */
45272 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
45273 - seqno = atomic_add_return(0x10, &intf->seqno);
45274 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
45275 else
45276 - seqno = atomic_read(&intf->seqno);
45277 + seqno = atomic_read_unchecked(&intf->seqno);
45278
45279 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
45280 hdr->seq_ctrl |= cpu_to_le16(seqno);
45281 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
45282 index e2b3d9c..67a5184 100644
45283 --- a/drivers/net/wireless/ti/wl1251/sdio.c
45284 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
45285 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
45286
45287 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
45288
45289 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45290 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45291 + pax_open_kernel();
45292 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45293 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45294 + pax_close_kernel();
45295
45296 wl1251_info("using dedicated interrupt line");
45297 } else {
45298 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45299 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45300 + pax_open_kernel();
45301 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45302 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45303 + pax_close_kernel();
45304
45305 wl1251_info("using SDIO interrupt");
45306 }
45307 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
45308 index 1c627da..69f7d17 100644
45309 --- a/drivers/net/wireless/ti/wl12xx/main.c
45310 +++ b/drivers/net/wireless/ti/wl12xx/main.c
45311 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45312 sizeof(wl->conf.mem));
45313
45314 /* read data preparation is only needed by wl127x */
45315 - wl->ops->prepare_read = wl127x_prepare_read;
45316 + pax_open_kernel();
45317 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45318 + pax_close_kernel();
45319
45320 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45321 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45322 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45323 sizeof(wl->conf.mem));
45324
45325 /* read data preparation is only needed by wl127x */
45326 - wl->ops->prepare_read = wl127x_prepare_read;
45327 + pax_open_kernel();
45328 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45329 + pax_close_kernel();
45330
45331 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45332 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45333 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
45334 index 7aa0eb8..5a9ef38 100644
45335 --- a/drivers/net/wireless/ti/wl18xx/main.c
45336 +++ b/drivers/net/wireless/ti/wl18xx/main.c
45337 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
45338 }
45339
45340 if (!checksum_param) {
45341 - wl18xx_ops.set_rx_csum = NULL;
45342 - wl18xx_ops.init_vif = NULL;
45343 + pax_open_kernel();
45344 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
45345 + *(void **)&wl18xx_ops.init_vif = NULL;
45346 + pax_close_kernel();
45347 }
45348
45349 /* Enable 11a Band only if we have 5G antennas */
45350 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
45351 index 7ef0b4a..ff65c28 100644
45352 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
45353 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
45354 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
45355 {
45356 struct zd_usb *usb = urb->context;
45357 struct zd_usb_interrupt *intr = &usb->intr;
45358 - int len;
45359 + unsigned int len;
45360 u16 int_num;
45361
45362 ZD_ASSERT(in_interrupt());
45363 diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
45364 index 59f95d8..53e0e7f 100644
45365 --- a/drivers/nfc/nfcwilink.c
45366 +++ b/drivers/nfc/nfcwilink.c
45367 @@ -513,7 +513,7 @@ static struct nci_ops nfcwilink_ops = {
45368
45369 static int nfcwilink_probe(struct platform_device *pdev)
45370 {
45371 - static struct nfcwilink *drv;
45372 + struct nfcwilink *drv;
45373 int rc;
45374 __u32 protocols;
45375
45376 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
45377 index d93b2b6..ae50401 100644
45378 --- a/drivers/oprofile/buffer_sync.c
45379 +++ b/drivers/oprofile/buffer_sync.c
45380 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
45381 if (cookie == NO_COOKIE)
45382 offset = pc;
45383 if (cookie == INVALID_COOKIE) {
45384 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45385 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45386 offset = pc;
45387 }
45388 if (cookie != last_cookie) {
45389 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
45390 /* add userspace sample */
45391
45392 if (!mm) {
45393 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
45394 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
45395 return 0;
45396 }
45397
45398 cookie = lookup_dcookie(mm, s->eip, &offset);
45399
45400 if (cookie == INVALID_COOKIE) {
45401 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45402 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45403 return 0;
45404 }
45405
45406 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
45407 /* ignore backtraces if failed to add a sample */
45408 if (state == sb_bt_start) {
45409 state = sb_bt_ignore;
45410 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
45411 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
45412 }
45413 }
45414 release_mm(mm);
45415 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
45416 index c0cc4e7..44d4e54 100644
45417 --- a/drivers/oprofile/event_buffer.c
45418 +++ b/drivers/oprofile/event_buffer.c
45419 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
45420 }
45421
45422 if (buffer_pos == buffer_size) {
45423 - atomic_inc(&oprofile_stats.event_lost_overflow);
45424 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
45425 return;
45426 }
45427
45428 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
45429 index ed2c3ec..deda85a 100644
45430 --- a/drivers/oprofile/oprof.c
45431 +++ b/drivers/oprofile/oprof.c
45432 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
45433 if (oprofile_ops.switch_events())
45434 return;
45435
45436 - atomic_inc(&oprofile_stats.multiplex_counter);
45437 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
45438 start_switch_worker();
45439 }
45440
45441 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
45442 index ee2cfce..7f8f699 100644
45443 --- a/drivers/oprofile/oprofile_files.c
45444 +++ b/drivers/oprofile/oprofile_files.c
45445 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
45446
45447 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
45448
45449 -static ssize_t timeout_read(struct file *file, char __user *buf,
45450 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
45451 size_t count, loff_t *offset)
45452 {
45453 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
45454 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
45455 index 59659ce..6c860a0 100644
45456 --- a/drivers/oprofile/oprofile_stats.c
45457 +++ b/drivers/oprofile/oprofile_stats.c
45458 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
45459 cpu_buf->sample_invalid_eip = 0;
45460 }
45461
45462 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
45463 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
45464 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
45465 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
45466 - atomic_set(&oprofile_stats.multiplex_counter, 0);
45467 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
45468 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
45469 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
45470 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
45471 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
45472 }
45473
45474
45475 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
45476 index 1fc622b..8c48fc3 100644
45477 --- a/drivers/oprofile/oprofile_stats.h
45478 +++ b/drivers/oprofile/oprofile_stats.h
45479 @@ -13,11 +13,11 @@
45480 #include <linux/atomic.h>
45481
45482 struct oprofile_stat_struct {
45483 - atomic_t sample_lost_no_mm;
45484 - atomic_t sample_lost_no_mapping;
45485 - atomic_t bt_lost_no_mapping;
45486 - atomic_t event_lost_overflow;
45487 - atomic_t multiplex_counter;
45488 + atomic_unchecked_t sample_lost_no_mm;
45489 + atomic_unchecked_t sample_lost_no_mapping;
45490 + atomic_unchecked_t bt_lost_no_mapping;
45491 + atomic_unchecked_t event_lost_overflow;
45492 + atomic_unchecked_t multiplex_counter;
45493 };
45494
45495 extern struct oprofile_stat_struct oprofile_stats;
45496 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
45497 index 3f49345..c750d0b 100644
45498 --- a/drivers/oprofile/oprofilefs.c
45499 +++ b/drivers/oprofile/oprofilefs.c
45500 @@ -176,8 +176,8 @@ int oprofilefs_create_ro_ulong(struct dentry *root,
45501
45502 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
45503 {
45504 - atomic_t *val = file->private_data;
45505 - return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
45506 + atomic_unchecked_t *val = file->private_data;
45507 + return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
45508 }
45509
45510
45511 @@ -189,7 +189,7 @@ static const struct file_operations atomic_ro_fops = {
45512
45513
45514 int oprofilefs_create_ro_atomic(struct dentry *root,
45515 - char const *name, atomic_t *val)
45516 + char const *name, atomic_unchecked_t *val)
45517 {
45518 return __oprofilefs_create_file(root, name,
45519 &atomic_ro_fops, 0444, val);
45520 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
45521 index 61be1d9..dec05d7 100644
45522 --- a/drivers/oprofile/timer_int.c
45523 +++ b/drivers/oprofile/timer_int.c
45524 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
45525 return NOTIFY_OK;
45526 }
45527
45528 -static struct notifier_block __refdata oprofile_cpu_notifier = {
45529 +static struct notifier_block oprofile_cpu_notifier = {
45530 .notifier_call = oprofile_cpu_notify,
45531 };
45532
45533 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
45534 index 92ed045..62d39bd7 100644
45535 --- a/drivers/parport/procfs.c
45536 +++ b/drivers/parport/procfs.c
45537 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
45538
45539 *ppos += len;
45540
45541 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
45542 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
45543 }
45544
45545 #ifdef CONFIG_PARPORT_1284
45546 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
45547
45548 *ppos += len;
45549
45550 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
45551 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
45552 }
45553 #endif /* IEEE1284.3 support. */
45554
45555 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45556 index 2f5786c..61ab4d1 100644
45557 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45558 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45559 @@ -463,7 +463,9 @@ static int __init ibm_acpiphp_init(void)
45560 goto init_cleanup;
45561 }
45562
45563 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45564 + pax_open_kernel();
45565 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45566 + pax_close_kernel();
45567 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45568
45569 return retval;
45570 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45571 index a6a71c4..c91097b 100644
45572 --- a/drivers/pci/hotplug/cpcihp_generic.c
45573 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45574 @@ -73,7 +73,6 @@ static u16 port;
45575 static unsigned int enum_bit;
45576 static u8 enum_mask;
45577
45578 -static struct cpci_hp_controller_ops generic_hpc_ops;
45579 static struct cpci_hp_controller generic_hpc;
45580
45581 static int __init validate_parameters(void)
45582 @@ -139,6 +138,10 @@ static int query_enum(void)
45583 return ((value & enum_mask) == enum_mask);
45584 }
45585
45586 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45587 + .query_enum = query_enum,
45588 +};
45589 +
45590 static int __init cpcihp_generic_init(void)
45591 {
45592 int status;
45593 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45594 pci_dev_put(dev);
45595
45596 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45597 - generic_hpc_ops.query_enum = query_enum;
45598 generic_hpc.ops = &generic_hpc_ops;
45599
45600 status = cpci_hp_register_controller(&generic_hpc);
45601 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45602 index 449b4bb..257e2e8 100644
45603 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45604 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45605 @@ -59,7 +59,6 @@
45606 /* local variables */
45607 static bool debug;
45608 static bool poll;
45609 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45610 static struct cpci_hp_controller zt5550_hpc;
45611
45612 /* Primary cPCI bus bridge device */
45613 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45614 return 0;
45615 }
45616
45617 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45618 + .query_enum = zt5550_hc_query_enum,
45619 +};
45620 +
45621 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45622 {
45623 int status;
45624 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45625 dbg("returned from zt5550_hc_config");
45626
45627 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45628 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45629 zt5550_hpc.ops = &zt5550_hpc_ops;
45630 if(!poll) {
45631 zt5550_hpc.irq = hc_dev->irq;
45632 zt5550_hpc.irq_flags = IRQF_SHARED;
45633 zt5550_hpc.dev_id = hc_dev;
45634
45635 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45636 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45637 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45638 + pax_open_kernel();
45639 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45640 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45641 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45642 + pax_open_kernel();
45643 } else {
45644 info("using ENUM# polling mode");
45645 }
45646 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45647 index 76ba8a1..20ca857 100644
45648 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45649 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45650 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45651
45652 void compaq_nvram_init (void __iomem *rom_start)
45653 {
45654 +
45655 +#ifndef CONFIG_PAX_KERNEXEC
45656 if (rom_start) {
45657 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45658 }
45659 +#endif
45660 +
45661 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45662
45663 /* initialize our int15 lock */
45664 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45665 index ec20f74..c1d961e 100644
45666 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45667 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45668 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45669 return -EINVAL;
45670 }
45671
45672 - slot->ops->owner = owner;
45673 - slot->ops->mod_name = mod_name;
45674 + pax_open_kernel();
45675 + *(struct module **)&slot->ops->owner = owner;
45676 + *(const char **)&slot->ops->mod_name = mod_name;
45677 + pax_close_kernel();
45678
45679 mutex_lock(&pci_hp_mutex);
45680 /*
45681 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45682 index f4a18f5..ff2463c 100644
45683 --- a/drivers/pci/hotplug/pciehp_core.c
45684 +++ b/drivers/pci/hotplug/pciehp_core.c
45685 @@ -92,7 +92,7 @@ static int init_slot(struct controller *ctrl)
45686 struct slot *slot = ctrl->slot;
45687 struct hotplug_slot *hotplug = NULL;
45688 struct hotplug_slot_info *info = NULL;
45689 - struct hotplug_slot_ops *ops = NULL;
45690 + hotplug_slot_ops_no_const *ops = NULL;
45691 char name[SLOT_NAME_SIZE];
45692 int retval = -ENOMEM;
45693
45694 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45695 index 7128cfd..a0640d6 100644
45696 --- a/drivers/pci/pci-sysfs.c
45697 +++ b/drivers/pci/pci-sysfs.c
45698 @@ -1083,7 +1083,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45699 {
45700 /* allocate attribute structure, piggyback attribute name */
45701 int name_len = write_combine ? 13 : 10;
45702 - struct bin_attribute *res_attr;
45703 + bin_attribute_no_const *res_attr;
45704 int retval;
45705
45706 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45707 @@ -1268,7 +1268,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45708 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45709 {
45710 int retval;
45711 - struct bin_attribute *attr;
45712 + bin_attribute_no_const *attr;
45713
45714 /* If the device has VPD, try to expose it in sysfs. */
45715 if (dev->vpd) {
45716 @@ -1315,7 +1315,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45717 {
45718 int retval;
45719 int rom_size = 0;
45720 - struct bin_attribute *attr;
45721 + bin_attribute_no_const *attr;
45722
45723 if (!sysfs_initialized)
45724 return -EACCES;
45725 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45726 index 8a00c06..18a9715 100644
45727 --- a/drivers/pci/pci.h
45728 +++ b/drivers/pci/pci.h
45729 @@ -95,7 +95,7 @@ struct pci_vpd_ops {
45730 struct pci_vpd {
45731 unsigned int len;
45732 const struct pci_vpd_ops *ops;
45733 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45734 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45735 };
45736
45737 int pci_vpd_pci22_init(struct pci_dev *dev);
45738 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45739 index 403a443..034e050 100644
45740 --- a/drivers/pci/pcie/aspm.c
45741 +++ b/drivers/pci/pcie/aspm.c
45742 @@ -27,9 +27,9 @@
45743 #define MODULE_PARAM_PREFIX "pcie_aspm."
45744
45745 /* Note: those are not register definitions */
45746 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45747 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45748 -#define ASPM_STATE_L1 (4) /* L1 state */
45749 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45750 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45751 +#define ASPM_STATE_L1 (4U) /* L1 state */
45752 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45753 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45754
45755 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45756 index 7ef0f86..17b710f 100644
45757 --- a/drivers/pci/probe.c
45758 +++ b/drivers/pci/probe.c
45759 @@ -175,7 +175,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45760 struct pci_bus_region region, inverted_region;
45761 bool bar_too_big = false, bar_disabled = false;
45762
45763 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45764 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45765
45766 /* No printks while decoding is disabled! */
45767 if (!dev->mmio_always_on) {
45768 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45769 index cdc7836..528635c 100644
45770 --- a/drivers/pci/proc.c
45771 +++ b/drivers/pci/proc.c
45772 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45773 static int __init pci_proc_init(void)
45774 {
45775 struct pci_dev *dev = NULL;
45776 +
45777 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45778 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45779 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45780 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45781 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45782 +#endif
45783 +#else
45784 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45785 +#endif
45786 proc_create("devices", 0, proc_bus_pci_dir,
45787 &proc_bus_pci_dev_operations);
45788 proc_initialized = 1;
45789 diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
45790 index 19c313b..ed28b38 100644
45791 --- a/drivers/platform/x86/asus-wmi.c
45792 +++ b/drivers/platform/x86/asus-wmi.c
45793 @@ -1618,6 +1618,10 @@ static int show_dsts(struct seq_file *m, void *data)
45794 int err;
45795 u32 retval = -1;
45796
45797 +#ifdef CONFIG_GRKERNSEC_KMEM
45798 + return -EPERM;
45799 +#endif
45800 +
45801 err = asus_wmi_get_devstate(asus, asus->debug.dev_id, &retval);
45802
45803 if (err < 0)
45804 @@ -1634,6 +1638,10 @@ static int show_devs(struct seq_file *m, void *data)
45805 int err;
45806 u32 retval = -1;
45807
45808 +#ifdef CONFIG_GRKERNSEC_KMEM
45809 + return -EPERM;
45810 +#endif
45811 +
45812 err = asus_wmi_set_devstate(asus->debug.dev_id, asus->debug.ctrl_param,
45813 &retval);
45814
45815 @@ -1658,6 +1666,10 @@ static int show_call(struct seq_file *m, void *data)
45816 union acpi_object *obj;
45817 acpi_status status;
45818
45819 +#ifdef CONFIG_GRKERNSEC_KMEM
45820 + return -EPERM;
45821 +#endif
45822 +
45823 status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID,
45824 1, asus->debug.method_id,
45825 &input, &output);
45826 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45827 index 3e5b4497..dcdfb70 100644
45828 --- a/drivers/platform/x86/chromeos_laptop.c
45829 +++ b/drivers/platform/x86/chromeos_laptop.c
45830 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45831 return 0;
45832 }
45833
45834 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45835 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45836 {
45837 .ident = "Samsung Series 5 550 - Touchpad",
45838 .matches = {
45839 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45840 index 62f8030..c7f2a45 100644
45841 --- a/drivers/platform/x86/msi-laptop.c
45842 +++ b/drivers/platform/x86/msi-laptop.c
45843 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45844
45845 if (!quirks->ec_read_only) {
45846 /* allow userland write sysfs file */
45847 - dev_attr_bluetooth.store = store_bluetooth;
45848 - dev_attr_wlan.store = store_wlan;
45849 - dev_attr_threeg.store = store_threeg;
45850 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45851 - dev_attr_wlan.attr.mode |= S_IWUSR;
45852 - dev_attr_threeg.attr.mode |= S_IWUSR;
45853 + pax_open_kernel();
45854 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45855 + *(void **)&dev_attr_wlan.store = store_wlan;
45856 + *(void **)&dev_attr_threeg.store = store_threeg;
45857 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45858 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45859 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45860 + pax_close_kernel();
45861 }
45862
45863 /* disable hardware control by fn key */
45864 diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
45865 index 70222f2..8c8ce66 100644
45866 --- a/drivers/platform/x86/msi-wmi.c
45867 +++ b/drivers/platform/x86/msi-wmi.c
45868 @@ -183,7 +183,7 @@ static const struct backlight_ops msi_backlight_ops = {
45869 static void msi_wmi_notify(u32 value, void *context)
45870 {
45871 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
45872 - static struct key_entry *key;
45873 + struct key_entry *key;
45874 union acpi_object *obj;
45875 acpi_status status;
45876
45877 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45878 index 3484dd2..13ee730 100644
45879 --- a/drivers/platform/x86/sony-laptop.c
45880 +++ b/drivers/platform/x86/sony-laptop.c
45881 @@ -2448,7 +2448,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45882 }
45883
45884 /* High speed charging function */
45885 -static struct device_attribute *hsc_handle;
45886 +static device_attribute_no_const *hsc_handle;
45887
45888 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45889 struct device_attribute *attr,
45890 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45891 index 4e86e97..04d50d1 100644
45892 --- a/drivers/platform/x86/thinkpad_acpi.c
45893 +++ b/drivers/platform/x86/thinkpad_acpi.c
45894 @@ -2091,7 +2091,7 @@ static int hotkey_mask_get(void)
45895 return 0;
45896 }
45897
45898 -void static hotkey_mask_warn_incomplete_mask(void)
45899 +static void hotkey_mask_warn_incomplete_mask(void)
45900 {
45901 /* log only what the user can fix... */
45902 const u32 wantedmask = hotkey_driver_mask &
45903 @@ -2318,11 +2318,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45904 }
45905 }
45906
45907 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45908 - struct tp_nvram_state *newn,
45909 - const u32 event_mask)
45910 -{
45911 -
45912 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45913 do { \
45914 if ((event_mask & (1 << __scancode)) && \
45915 @@ -2336,36 +2331,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45916 tpacpi_hotkey_send_key(__scancode); \
45917 } while (0)
45918
45919 - void issue_volchange(const unsigned int oldvol,
45920 - const unsigned int newvol)
45921 - {
45922 - unsigned int i = oldvol;
45923 +static void issue_volchange(const unsigned int oldvol,
45924 + const unsigned int newvol,
45925 + const u32 event_mask)
45926 +{
45927 + unsigned int i = oldvol;
45928
45929 - while (i > newvol) {
45930 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45931 - i--;
45932 - }
45933 - while (i < newvol) {
45934 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45935 - i++;
45936 - }
45937 + while (i > newvol) {
45938 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45939 + i--;
45940 }
45941 + while (i < newvol) {
45942 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45943 + i++;
45944 + }
45945 +}
45946
45947 - void issue_brightnesschange(const unsigned int oldbrt,
45948 - const unsigned int newbrt)
45949 - {
45950 - unsigned int i = oldbrt;
45951 +static void issue_brightnesschange(const unsigned int oldbrt,
45952 + const unsigned int newbrt,
45953 + const u32 event_mask)
45954 +{
45955 + unsigned int i = oldbrt;
45956
45957 - while (i > newbrt) {
45958 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45959 - i--;
45960 - }
45961 - while (i < newbrt) {
45962 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45963 - i++;
45964 - }
45965 + while (i > newbrt) {
45966 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45967 + i--;
45968 + }
45969 + while (i < newbrt) {
45970 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45971 + i++;
45972 }
45973 +}
45974
45975 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45976 + struct tp_nvram_state *newn,
45977 + const u32 event_mask)
45978 +{
45979 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45980 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45981 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45982 @@ -2399,7 +2400,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45983 oldn->volume_level != newn->volume_level) {
45984 /* recently muted, or repeated mute keypress, or
45985 * multiple presses ending in mute */
45986 - issue_volchange(oldn->volume_level, newn->volume_level);
45987 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45988 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45989 }
45990 } else {
45991 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45992 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45993 }
45994 if (oldn->volume_level != newn->volume_level) {
45995 - issue_volchange(oldn->volume_level, newn->volume_level);
45996 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45997 } else if (oldn->volume_toggle != newn->volume_toggle) {
45998 /* repeated vol up/down keypress at end of scale ? */
45999 if (newn->volume_level == 0)
46000 @@ -2422,7 +2423,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46001 /* handle brightness */
46002 if (oldn->brightness_level != newn->brightness_level) {
46003 issue_brightnesschange(oldn->brightness_level,
46004 - newn->brightness_level);
46005 + newn->brightness_level,
46006 + event_mask);
46007 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
46008 /* repeated key presses that didn't change state */
46009 if (newn->brightness_level == 0)
46010 @@ -2431,10 +2433,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46011 && !tp_features.bright_unkfw)
46012 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
46013 }
46014 +}
46015
46016 #undef TPACPI_COMPARE_KEY
46017 #undef TPACPI_MAY_SEND_KEY
46018 -}
46019
46020 /*
46021 * Polling driver
46022 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
46023 index 769d265..a3a05ca 100644
46024 --- a/drivers/pnp/pnpbios/bioscalls.c
46025 +++ b/drivers/pnp/pnpbios/bioscalls.c
46026 @@ -58,7 +58,7 @@ do { \
46027 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
46028 } while(0)
46029
46030 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
46031 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
46032 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
46033
46034 /*
46035 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
46036
46037 cpu = get_cpu();
46038 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
46039 +
46040 + pax_open_kernel();
46041 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
46042 + pax_close_kernel();
46043
46044 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
46045 spin_lock_irqsave(&pnp_bios_lock, flags);
46046 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
46047 :"memory");
46048 spin_unlock_irqrestore(&pnp_bios_lock, flags);
46049
46050 + pax_open_kernel();
46051 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
46052 + pax_close_kernel();
46053 +
46054 put_cpu();
46055
46056 /* If we get here and this is set then the PnP BIOS faulted on us. */
46057 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
46058 return status;
46059 }
46060
46061 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
46062 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
46063 {
46064 int i;
46065
46066 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
46067 pnp_bios_callpoint.offset = header->fields.pm16offset;
46068 pnp_bios_callpoint.segment = PNP_CS16;
46069
46070 + pax_open_kernel();
46071 +
46072 for_each_possible_cpu(i) {
46073 struct desc_struct *gdt = get_cpu_gdt_table(i);
46074 if (!gdt)
46075 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
46076 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
46077 (unsigned long)__va(header->fields.pm16dseg));
46078 }
46079 +
46080 + pax_close_kernel();
46081 }
46082 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
46083 index d95e101..67f0c3f 100644
46084 --- a/drivers/pnp/resource.c
46085 +++ b/drivers/pnp/resource.c
46086 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
46087 return 1;
46088
46089 /* check if the resource is valid */
46090 - if (*irq < 0 || *irq > 15)
46091 + if (*irq > 15)
46092 return 0;
46093
46094 /* check if the resource is reserved */
46095 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
46096 return 1;
46097
46098 /* check if the resource is valid */
46099 - if (*dma < 0 || *dma == 4 || *dma > 7)
46100 + if (*dma == 4 || *dma > 7)
46101 return 0;
46102
46103 /* check if the resource is reserved */
46104 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
46105 index 0c52e2a..3421ab7 100644
46106 --- a/drivers/power/pda_power.c
46107 +++ b/drivers/power/pda_power.c
46108 @@ -37,7 +37,11 @@ static int polling;
46109
46110 #if IS_ENABLED(CONFIG_USB_PHY)
46111 static struct usb_phy *transceiver;
46112 -static struct notifier_block otg_nb;
46113 +static int otg_handle_notification(struct notifier_block *nb,
46114 + unsigned long event, void *unused);
46115 +static struct notifier_block otg_nb = {
46116 + .notifier_call = otg_handle_notification
46117 +};
46118 #endif
46119
46120 static struct regulator *ac_draw;
46121 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
46122
46123 #if IS_ENABLED(CONFIG_USB_PHY)
46124 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
46125 - otg_nb.notifier_call = otg_handle_notification;
46126 ret = usb_register_notifier(transceiver, &otg_nb);
46127 if (ret) {
46128 dev_err(dev, "failure to register otg notifier\n");
46129 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
46130 index cc439fd..8fa30df 100644
46131 --- a/drivers/power/power_supply.h
46132 +++ b/drivers/power/power_supply.h
46133 @@ -16,12 +16,12 @@ struct power_supply;
46134
46135 #ifdef CONFIG_SYSFS
46136
46137 -extern void power_supply_init_attrs(struct device_type *dev_type);
46138 +extern void power_supply_init_attrs(void);
46139 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
46140
46141 #else
46142
46143 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
46144 +static inline void power_supply_init_attrs(void) {}
46145 #define power_supply_uevent NULL
46146
46147 #endif /* CONFIG_SYSFS */
46148 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
46149 index 557af94..84dc1fe 100644
46150 --- a/drivers/power/power_supply_core.c
46151 +++ b/drivers/power/power_supply_core.c
46152 @@ -24,7 +24,10 @@
46153 struct class *power_supply_class;
46154 EXPORT_SYMBOL_GPL(power_supply_class);
46155
46156 -static struct device_type power_supply_dev_type;
46157 +extern const struct attribute_group *power_supply_attr_groups[];
46158 +static struct device_type power_supply_dev_type = {
46159 + .groups = power_supply_attr_groups,
46160 +};
46161
46162 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
46163 struct power_supply *supply)
46164 @@ -584,7 +587,7 @@ static int __init power_supply_class_init(void)
46165 return PTR_ERR(power_supply_class);
46166
46167 power_supply_class->dev_uevent = power_supply_uevent;
46168 - power_supply_init_attrs(&power_supply_dev_type);
46169 + power_supply_init_attrs();
46170
46171 return 0;
46172 }
46173 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
46174 index 44420d1..967126e 100644
46175 --- a/drivers/power/power_supply_sysfs.c
46176 +++ b/drivers/power/power_supply_sysfs.c
46177 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
46178 .is_visible = power_supply_attr_is_visible,
46179 };
46180
46181 -static const struct attribute_group *power_supply_attr_groups[] = {
46182 +const struct attribute_group *power_supply_attr_groups[] = {
46183 &power_supply_attr_group,
46184 NULL,
46185 };
46186
46187 -void power_supply_init_attrs(struct device_type *dev_type)
46188 +void power_supply_init_attrs(void)
46189 {
46190 int i;
46191
46192 - dev_type->groups = power_supply_attr_groups;
46193 -
46194 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
46195 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
46196 }
46197 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
46198 index a01b8b3..37c2afe 100644
46199 --- a/drivers/regulator/core.c
46200 +++ b/drivers/regulator/core.c
46201 @@ -3307,7 +3307,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
46202 {
46203 const struct regulation_constraints *constraints = NULL;
46204 const struct regulator_init_data *init_data;
46205 - static atomic_t regulator_no = ATOMIC_INIT(0);
46206 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
46207 struct regulator_dev *rdev;
46208 struct device *dev;
46209 int ret, i;
46210 @@ -3377,7 +3377,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
46211 rdev->dev.of_node = config->of_node;
46212 rdev->dev.parent = dev;
46213 dev_set_name(&rdev->dev, "regulator.%d",
46214 - atomic_inc_return(&regulator_no) - 1);
46215 + atomic_inc_return_unchecked(&regulator_no) - 1);
46216 ret = device_register(&rdev->dev);
46217 if (ret != 0) {
46218 put_device(&rdev->dev);
46219 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
46220 index 144bcac..d20e7db 100644
46221 --- a/drivers/regulator/max8660.c
46222 +++ b/drivers/regulator/max8660.c
46223 @@ -420,8 +420,10 @@ static int max8660_probe(struct i2c_client *client,
46224 max8660->shadow_regs[MAX8660_OVER1] = 5;
46225 } else {
46226 /* Otherwise devices can be toggled via software */
46227 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
46228 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
46229 + pax_open_kernel();
46230 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
46231 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
46232 + pax_close_kernel();
46233 }
46234
46235 /*
46236 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
46237 index 5b77ab7..a62f061 100644
46238 --- a/drivers/regulator/max8973-regulator.c
46239 +++ b/drivers/regulator/max8973-regulator.c
46240 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
46241 if (!pdata || !pdata->enable_ext_control) {
46242 max->desc.enable_reg = MAX8973_VOUT;
46243 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
46244 - max->ops.enable = regulator_enable_regmap;
46245 - max->ops.disable = regulator_disable_regmap;
46246 - max->ops.is_enabled = regulator_is_enabled_regmap;
46247 + pax_open_kernel();
46248 + *(void **)&max->ops.enable = regulator_enable_regmap;
46249 + *(void **)&max->ops.disable = regulator_disable_regmap;
46250 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
46251 + pax_close_kernel();
46252 }
46253
46254 if (pdata) {
46255 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
46256 index 1037e07..e64dea1 100644
46257 --- a/drivers/regulator/mc13892-regulator.c
46258 +++ b/drivers/regulator/mc13892-regulator.c
46259 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
46260 }
46261 mc13xxx_unlock(mc13892);
46262
46263 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46264 + pax_open_kernel();
46265 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46266 = mc13892_vcam_set_mode;
46267 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46268 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46269 = mc13892_vcam_get_mode;
46270 + pax_close_kernel();
46271
46272 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
46273 ARRAY_SIZE(mc13892_regulators));
46274 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
46275 index 24e733c..bfbaa3e 100644
46276 --- a/drivers/rtc/rtc-cmos.c
46277 +++ b/drivers/rtc/rtc-cmos.c
46278 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
46279 hpet_rtc_timer_init();
46280
46281 /* export at least the first block of NVRAM */
46282 - nvram.size = address_space - NVRAM_OFFSET;
46283 + pax_open_kernel();
46284 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
46285 + pax_close_kernel();
46286 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
46287 if (retval < 0) {
46288 dev_dbg(dev, "can't create nvram file? %d\n", retval);
46289 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
46290 index d049393..bb20be0 100644
46291 --- a/drivers/rtc/rtc-dev.c
46292 +++ b/drivers/rtc/rtc-dev.c
46293 @@ -16,6 +16,7 @@
46294 #include <linux/module.h>
46295 #include <linux/rtc.h>
46296 #include <linux/sched.h>
46297 +#include <linux/grsecurity.h>
46298 #include "rtc-core.h"
46299
46300 static dev_t rtc_devt;
46301 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
46302 if (copy_from_user(&tm, uarg, sizeof(tm)))
46303 return -EFAULT;
46304
46305 + gr_log_timechange();
46306 +
46307 return rtc_set_time(rtc, &tm);
46308
46309 case RTC_PIE_ON:
46310 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
46311 index ca18fd1..055e42d 100644
46312 --- a/drivers/rtc/rtc-ds1307.c
46313 +++ b/drivers/rtc/rtc-ds1307.c
46314 @@ -107,7 +107,7 @@ struct ds1307 {
46315 u8 offset; /* register's offset */
46316 u8 regs[11];
46317 u16 nvram_offset;
46318 - struct bin_attribute *nvram;
46319 + bin_attribute_no_const *nvram;
46320 enum ds_type type;
46321 unsigned long flags;
46322 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
46323 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
46324 index fcb0329..d77b7f2 100644
46325 --- a/drivers/rtc/rtc-m48t59.c
46326 +++ b/drivers/rtc/rtc-m48t59.c
46327 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
46328 if (IS_ERR(m48t59->rtc))
46329 return PTR_ERR(m48t59->rtc);
46330
46331 - m48t59_nvram_attr.size = pdata->offset;
46332 + pax_open_kernel();
46333 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
46334 + pax_close_kernel();
46335
46336 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
46337 if (ret)
46338 diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
46339 index 14b5f8d..cc9bd26 100644
46340 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c
46341 +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
46342 @@ -827,7 +827,7 @@ ahd_pci_intr(struct ahd_softc *ahd)
46343 for (bit = 0; bit < 8; bit++) {
46344
46345 if ((pci_status[i] & (0x1 << bit)) != 0) {
46346 - static const char *s;
46347 + const char *s;
46348
46349 s = pci_status_strings[bit];
46350 if (i == 7/*TARG*/ && bit == 3)
46351 @@ -887,23 +887,15 @@ ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat)
46352
46353 for (bit = 0; bit < 8; bit++) {
46354
46355 - if ((split_status[i] & (0x1 << bit)) != 0) {
46356 - static const char *s;
46357 -
46358 - s = split_status_strings[bit];
46359 - printk(s, ahd_name(ahd),
46360 + if ((split_status[i] & (0x1 << bit)) != 0)
46361 + printk(split_status_strings[bit], ahd_name(ahd),
46362 split_status_source[i]);
46363 - }
46364
46365 if (i > 1)
46366 continue;
46367
46368 - if ((sg_split_status[i] & (0x1 << bit)) != 0) {
46369 - static const char *s;
46370 -
46371 - s = split_status_strings[bit];
46372 - printk(s, ahd_name(ahd), "SG");
46373 - }
46374 + if ((sg_split_status[i] & (0x1 << bit)) != 0)
46375 + printk(split_status_strings[bit], ahd_name(ahd), "SG");
46376 }
46377 }
46378 /*
46379 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
46380 index e693af6..2e525b6 100644
46381 --- a/drivers/scsi/bfa/bfa_fcpim.h
46382 +++ b/drivers/scsi/bfa/bfa_fcpim.h
46383 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
46384
46385 struct bfa_itn_s {
46386 bfa_isr_func_t isr;
46387 -};
46388 +} __no_const;
46389
46390 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
46391 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
46392 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
46393 index 90814fe..4384138 100644
46394 --- a/drivers/scsi/bfa/bfa_ioc.h
46395 +++ b/drivers/scsi/bfa/bfa_ioc.h
46396 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
46397 bfa_ioc_disable_cbfn_t disable_cbfn;
46398 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
46399 bfa_ioc_reset_cbfn_t reset_cbfn;
46400 -};
46401 +} __no_const;
46402
46403 /*
46404 * IOC event notification mechanism.
46405 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
46406 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
46407 enum bfi_ioc_state fwstate);
46408 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
46409 -};
46410 +} __no_const;
46411
46412 /*
46413 * Queue element to wait for room in request queue. FIFO order is
46414 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
46415 index c9382d6..6619864 100644
46416 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
46417 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
46418 @@ -33,8 +33,8 @@
46419 */
46420 #include "libfcoe.h"
46421
46422 -static atomic_t ctlr_num;
46423 -static atomic_t fcf_num;
46424 +static atomic_unchecked_t ctlr_num;
46425 +static atomic_unchecked_t fcf_num;
46426
46427 /*
46428 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
46429 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
46430 if (!ctlr)
46431 goto out;
46432
46433 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
46434 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
46435 ctlr->f = f;
46436 ctlr->mode = FIP_CONN_TYPE_FABRIC;
46437 INIT_LIST_HEAD(&ctlr->fcfs);
46438 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
46439 fcf->dev.parent = &ctlr->dev;
46440 fcf->dev.bus = &fcoe_bus_type;
46441 fcf->dev.type = &fcoe_fcf_device_type;
46442 - fcf->id = atomic_inc_return(&fcf_num) - 1;
46443 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
46444 fcf->state = FCOE_FCF_STATE_UNKNOWN;
46445
46446 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
46447 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
46448 {
46449 int error;
46450
46451 - atomic_set(&ctlr_num, 0);
46452 - atomic_set(&fcf_num, 0);
46453 + atomic_set_unchecked(&ctlr_num, 0);
46454 + atomic_set_unchecked(&fcf_num, 0);
46455
46456 error = bus_register(&fcoe_bus_type);
46457 if (error)
46458 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
46459 index 3cafe0d..f1e87f8 100644
46460 --- a/drivers/scsi/hosts.c
46461 +++ b/drivers/scsi/hosts.c
46462 @@ -42,7 +42,7 @@
46463 #include "scsi_logging.h"
46464
46465
46466 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46467 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46468
46469
46470 static void scsi_host_cls_release(struct device *dev)
46471 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
46472 * subtract one because we increment first then return, but we need to
46473 * know what the next host number was before increment
46474 */
46475 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
46476 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
46477 shost->dma_channel = 0xff;
46478
46479 /* These three are default values which can be overridden */
46480 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
46481 index 0eb0940..3ca9b79 100644
46482 --- a/drivers/scsi/hpsa.c
46483 +++ b/drivers/scsi/hpsa.c
46484 @@ -579,7 +579,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
46485 unsigned long flags;
46486
46487 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
46488 - return h->access.command_completed(h, q);
46489 + return h->access->command_completed(h, q);
46490
46491 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
46492 a = rq->head[rq->current_entry];
46493 @@ -3445,7 +3445,7 @@ static void start_io(struct ctlr_info *h)
46494 while (!list_empty(&h->reqQ)) {
46495 c = list_entry(h->reqQ.next, struct CommandList, list);
46496 /* can't do anything if fifo is full */
46497 - if ((h->access.fifo_full(h))) {
46498 + if ((h->access->fifo_full(h))) {
46499 dev_warn(&h->pdev->dev, "fifo full\n");
46500 break;
46501 }
46502 @@ -3467,7 +3467,7 @@ static void start_io(struct ctlr_info *h)
46503
46504 /* Tell the controller execute command */
46505 spin_unlock_irqrestore(&h->lock, flags);
46506 - h->access.submit_command(h, c);
46507 + h->access->submit_command(h, c);
46508 spin_lock_irqsave(&h->lock, flags);
46509 }
46510 spin_unlock_irqrestore(&h->lock, flags);
46511 @@ -3475,17 +3475,17 @@ static void start_io(struct ctlr_info *h)
46512
46513 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
46514 {
46515 - return h->access.command_completed(h, q);
46516 + return h->access->command_completed(h, q);
46517 }
46518
46519 static inline bool interrupt_pending(struct ctlr_info *h)
46520 {
46521 - return h->access.intr_pending(h);
46522 + return h->access->intr_pending(h);
46523 }
46524
46525 static inline long interrupt_not_for_us(struct ctlr_info *h)
46526 {
46527 - return (h->access.intr_pending(h) == 0) ||
46528 + return (h->access->intr_pending(h) == 0) ||
46529 (h->interrupts_enabled == 0);
46530 }
46531
46532 @@ -4387,7 +4387,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
46533 if (prod_index < 0)
46534 return -ENODEV;
46535 h->product_name = products[prod_index].product_name;
46536 - h->access = *(products[prod_index].access);
46537 + h->access = products[prod_index].access;
46538
46539 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
46540 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
46541 @@ -4669,7 +4669,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
46542
46543 assert_spin_locked(&lockup_detector_lock);
46544 remove_ctlr_from_lockup_detector_list(h);
46545 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46546 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46547 spin_lock_irqsave(&h->lock, flags);
46548 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
46549 spin_unlock_irqrestore(&h->lock, flags);
46550 @@ -4846,7 +4846,7 @@ reinit_after_soft_reset:
46551 }
46552
46553 /* make sure the board interrupts are off */
46554 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46555 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46556
46557 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
46558 goto clean2;
46559 @@ -4880,7 +4880,7 @@ reinit_after_soft_reset:
46560 * fake ones to scoop up any residual completions.
46561 */
46562 spin_lock_irqsave(&h->lock, flags);
46563 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46564 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46565 spin_unlock_irqrestore(&h->lock, flags);
46566 free_irqs(h);
46567 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
46568 @@ -4899,9 +4899,9 @@ reinit_after_soft_reset:
46569 dev_info(&h->pdev->dev, "Board READY.\n");
46570 dev_info(&h->pdev->dev,
46571 "Waiting for stale completions to drain.\n");
46572 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46573 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46574 msleep(10000);
46575 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46576 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46577
46578 rc = controller_reset_failed(h->cfgtable);
46579 if (rc)
46580 @@ -4922,7 +4922,7 @@ reinit_after_soft_reset:
46581 }
46582
46583 /* Turn the interrupts on so we can service requests */
46584 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46585 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46586
46587 hpsa_hba_inquiry(h);
46588 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
46589 @@ -4977,7 +4977,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
46590 * To write all data in the battery backed cache to disks
46591 */
46592 hpsa_flush_cache(h);
46593 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46594 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46595 hpsa_free_irqs_and_disable_msix(h);
46596 }
46597
46598 @@ -5145,7 +5145,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
46599 return;
46600 }
46601 /* Change the access methods to the performant access methods */
46602 - h->access = SA5_performant_access;
46603 + h->access = &SA5_performant_access;
46604 h->transMethod = CFGTBL_Trans_Performant;
46605 }
46606
46607 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
46608 index bc85e72..ae04a39 100644
46609 --- a/drivers/scsi/hpsa.h
46610 +++ b/drivers/scsi/hpsa.h
46611 @@ -79,7 +79,7 @@ struct ctlr_info {
46612 unsigned int msix_vector;
46613 unsigned int msi_vector;
46614 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
46615 - struct access_method access;
46616 + struct access_method *access;
46617
46618 /* queue and queue Info */
46619 struct list_head reqQ;
46620 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
46621 index 5879929..32b241d 100644
46622 --- a/drivers/scsi/libfc/fc_exch.c
46623 +++ b/drivers/scsi/libfc/fc_exch.c
46624 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
46625 u16 pool_max_index;
46626
46627 struct {
46628 - atomic_t no_free_exch;
46629 - atomic_t no_free_exch_xid;
46630 - atomic_t xid_not_found;
46631 - atomic_t xid_busy;
46632 - atomic_t seq_not_found;
46633 - atomic_t non_bls_resp;
46634 + atomic_unchecked_t no_free_exch;
46635 + atomic_unchecked_t no_free_exch_xid;
46636 + atomic_unchecked_t xid_not_found;
46637 + atomic_unchecked_t xid_busy;
46638 + atomic_unchecked_t seq_not_found;
46639 + atomic_unchecked_t non_bls_resp;
46640 } stats;
46641 };
46642
46643 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
46644 /* allocate memory for exchange */
46645 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
46646 if (!ep) {
46647 - atomic_inc(&mp->stats.no_free_exch);
46648 + atomic_inc_unchecked(&mp->stats.no_free_exch);
46649 goto out;
46650 }
46651 memset(ep, 0, sizeof(*ep));
46652 @@ -797,7 +797,7 @@ out:
46653 return ep;
46654 err:
46655 spin_unlock_bh(&pool->lock);
46656 - atomic_inc(&mp->stats.no_free_exch_xid);
46657 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
46658 mempool_free(ep, mp->ep_pool);
46659 return NULL;
46660 }
46661 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46662 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46663 ep = fc_exch_find(mp, xid);
46664 if (!ep) {
46665 - atomic_inc(&mp->stats.xid_not_found);
46666 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46667 reject = FC_RJT_OX_ID;
46668 goto out;
46669 }
46670 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46671 ep = fc_exch_find(mp, xid);
46672 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46673 if (ep) {
46674 - atomic_inc(&mp->stats.xid_busy);
46675 + atomic_inc_unchecked(&mp->stats.xid_busy);
46676 reject = FC_RJT_RX_ID;
46677 goto rel;
46678 }
46679 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46680 }
46681 xid = ep->xid; /* get our XID */
46682 } else if (!ep) {
46683 - atomic_inc(&mp->stats.xid_not_found);
46684 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46685 reject = FC_RJT_RX_ID; /* XID not found */
46686 goto out;
46687 }
46688 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46689 } else {
46690 sp = &ep->seq;
46691 if (sp->id != fh->fh_seq_id) {
46692 - atomic_inc(&mp->stats.seq_not_found);
46693 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46694 if (f_ctl & FC_FC_END_SEQ) {
46695 /*
46696 * Update sequence_id based on incoming last
46697 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46698
46699 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46700 if (!ep) {
46701 - atomic_inc(&mp->stats.xid_not_found);
46702 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46703 goto out;
46704 }
46705 if (ep->esb_stat & ESB_ST_COMPLETE) {
46706 - atomic_inc(&mp->stats.xid_not_found);
46707 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46708 goto rel;
46709 }
46710 if (ep->rxid == FC_XID_UNKNOWN)
46711 ep->rxid = ntohs(fh->fh_rx_id);
46712 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46713 - atomic_inc(&mp->stats.xid_not_found);
46714 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46715 goto rel;
46716 }
46717 if (ep->did != ntoh24(fh->fh_s_id) &&
46718 ep->did != FC_FID_FLOGI) {
46719 - atomic_inc(&mp->stats.xid_not_found);
46720 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46721 goto rel;
46722 }
46723 sof = fr_sof(fp);
46724 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46725 sp->ssb_stat |= SSB_ST_RESP;
46726 sp->id = fh->fh_seq_id;
46727 } else if (sp->id != fh->fh_seq_id) {
46728 - atomic_inc(&mp->stats.seq_not_found);
46729 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46730 goto rel;
46731 }
46732
46733 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46734 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46735
46736 if (!sp)
46737 - atomic_inc(&mp->stats.xid_not_found);
46738 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46739 else
46740 - atomic_inc(&mp->stats.non_bls_resp);
46741 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46742
46743 fc_frame_free(fp);
46744 }
46745 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46746
46747 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46748 mp = ema->mp;
46749 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46750 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46751 st->fc_no_free_exch_xid +=
46752 - atomic_read(&mp->stats.no_free_exch_xid);
46753 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46754 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46755 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46756 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46757 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46758 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46759 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46760 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46761 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46762 }
46763 }
46764 EXPORT_SYMBOL(fc_exch_update_stats);
46765 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46766 index d289583..b745eec 100644
46767 --- a/drivers/scsi/libsas/sas_ata.c
46768 +++ b/drivers/scsi/libsas/sas_ata.c
46769 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46770 .postreset = ata_std_postreset,
46771 .error_handler = ata_std_error_handler,
46772 .post_internal_cmd = sas_ata_post_internal,
46773 - .qc_defer = ata_std_qc_defer,
46774 + .qc_defer = ata_std_qc_defer,
46775 .qc_prep = ata_noop_qc_prep,
46776 .qc_issue = sas_ata_qc_issue,
46777 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46778 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46779 index 4e1b75c..0bbdfa9 100644
46780 --- a/drivers/scsi/lpfc/lpfc.h
46781 +++ b/drivers/scsi/lpfc/lpfc.h
46782 @@ -432,7 +432,7 @@ struct lpfc_vport {
46783 struct dentry *debug_nodelist;
46784 struct dentry *vport_debugfs_root;
46785 struct lpfc_debugfs_trc *disc_trc;
46786 - atomic_t disc_trc_cnt;
46787 + atomic_unchecked_t disc_trc_cnt;
46788 #endif
46789 uint8_t stat_data_enabled;
46790 uint8_t stat_data_blocked;
46791 @@ -865,8 +865,8 @@ struct lpfc_hba {
46792 struct timer_list fabric_block_timer;
46793 unsigned long bit_flags;
46794 #define FABRIC_COMANDS_BLOCKED 0
46795 - atomic_t num_rsrc_err;
46796 - atomic_t num_cmd_success;
46797 + atomic_unchecked_t num_rsrc_err;
46798 + atomic_unchecked_t num_cmd_success;
46799 unsigned long last_rsrc_error_time;
46800 unsigned long last_ramp_down_time;
46801 unsigned long last_ramp_up_time;
46802 @@ -902,7 +902,7 @@ struct lpfc_hba {
46803
46804 struct dentry *debug_slow_ring_trc;
46805 struct lpfc_debugfs_trc *slow_ring_trc;
46806 - atomic_t slow_ring_trc_cnt;
46807 + atomic_unchecked_t slow_ring_trc_cnt;
46808 /* iDiag debugfs sub-directory */
46809 struct dentry *idiag_root;
46810 struct dentry *idiag_pci_cfg;
46811 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46812 index 60084e6..0e2e700 100644
46813 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46814 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46815 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46816
46817 #include <linux/debugfs.h>
46818
46819 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46820 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46821 static unsigned long lpfc_debugfs_start_time = 0L;
46822
46823 /* iDiag */
46824 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46825 lpfc_debugfs_enable = 0;
46826
46827 len = 0;
46828 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46829 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46830 (lpfc_debugfs_max_disc_trc - 1);
46831 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46832 dtp = vport->disc_trc + i;
46833 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46834 lpfc_debugfs_enable = 0;
46835
46836 len = 0;
46837 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46838 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46839 (lpfc_debugfs_max_slow_ring_trc - 1);
46840 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46841 dtp = phba->slow_ring_trc + i;
46842 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46843 !vport || !vport->disc_trc)
46844 return;
46845
46846 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46847 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46848 (lpfc_debugfs_max_disc_trc - 1);
46849 dtp = vport->disc_trc + index;
46850 dtp->fmt = fmt;
46851 dtp->data1 = data1;
46852 dtp->data2 = data2;
46853 dtp->data3 = data3;
46854 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46855 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46856 dtp->jif = jiffies;
46857 #endif
46858 return;
46859 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46860 !phba || !phba->slow_ring_trc)
46861 return;
46862
46863 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46864 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46865 (lpfc_debugfs_max_slow_ring_trc - 1);
46866 dtp = phba->slow_ring_trc + index;
46867 dtp->fmt = fmt;
46868 dtp->data1 = data1;
46869 dtp->data2 = data2;
46870 dtp->data3 = data3;
46871 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46872 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46873 dtp->jif = jiffies;
46874 #endif
46875 return;
46876 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46877 "slow_ring buffer\n");
46878 goto debug_failed;
46879 }
46880 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46881 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46882 memset(phba->slow_ring_trc, 0,
46883 (sizeof(struct lpfc_debugfs_trc) *
46884 lpfc_debugfs_max_slow_ring_trc));
46885 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46886 "buffer\n");
46887 goto debug_failed;
46888 }
46889 - atomic_set(&vport->disc_trc_cnt, 0);
46890 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46891
46892 snprintf(name, sizeof(name), "discovery_trace");
46893 vport->debug_disc_trc =
46894 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46895 index 647f5bf..d0068b9 100644
46896 --- a/drivers/scsi/lpfc/lpfc_init.c
46897 +++ b/drivers/scsi/lpfc/lpfc_init.c
46898 @@ -10952,8 +10952,10 @@ lpfc_init(void)
46899 "misc_register returned with status %d", error);
46900
46901 if (lpfc_enable_npiv) {
46902 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46903 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46904 + pax_open_kernel();
46905 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46906 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46907 + pax_close_kernel();
46908 }
46909 lpfc_transport_template =
46910 fc_attach_transport(&lpfc_transport_functions);
46911 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46912 index c913e8c..d34a119 100644
46913 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46914 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46915 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46916 uint32_t evt_posted;
46917
46918 spin_lock_irqsave(&phba->hbalock, flags);
46919 - atomic_inc(&phba->num_rsrc_err);
46920 + atomic_inc_unchecked(&phba->num_rsrc_err);
46921 phba->last_rsrc_error_time = jiffies;
46922
46923 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46924 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46925 unsigned long flags;
46926 struct lpfc_hba *phba = vport->phba;
46927 uint32_t evt_posted;
46928 - atomic_inc(&phba->num_cmd_success);
46929 + atomic_inc_unchecked(&phba->num_cmd_success);
46930
46931 if (vport->cfg_lun_queue_depth <= queue_depth)
46932 return;
46933 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46934 unsigned long num_rsrc_err, num_cmd_success;
46935 int i;
46936
46937 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46938 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46939 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46940 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46941
46942 /*
46943 * The error and success command counters are global per
46944 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46945 }
46946 }
46947 lpfc_destroy_vport_work_array(phba, vports);
46948 - atomic_set(&phba->num_rsrc_err, 0);
46949 - atomic_set(&phba->num_cmd_success, 0);
46950 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46951 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46952 }
46953
46954 /**
46955 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46956 }
46957 }
46958 lpfc_destroy_vport_work_array(phba, vports);
46959 - atomic_set(&phba->num_rsrc_err, 0);
46960 - atomic_set(&phba->num_cmd_success, 0);
46961 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46962 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46963 }
46964
46965 /**
46966 diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46967 index 7f0af4f..193ac3e 100644
46968 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46969 +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46970 @@ -1557,7 +1557,7 @@ _scsih_get_resync(struct device *dev)
46971 {
46972 struct scsi_device *sdev = to_scsi_device(dev);
46973 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46974 - static struct _raid_device *raid_device;
46975 + struct _raid_device *raid_device;
46976 unsigned long flags;
46977 Mpi2RaidVolPage0_t vol_pg0;
46978 Mpi2ConfigReply_t mpi_reply;
46979 @@ -1609,7 +1609,7 @@ _scsih_get_state(struct device *dev)
46980 {
46981 struct scsi_device *sdev = to_scsi_device(dev);
46982 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46983 - static struct _raid_device *raid_device;
46984 + struct _raid_device *raid_device;
46985 unsigned long flags;
46986 Mpi2RaidVolPage0_t vol_pg0;
46987 Mpi2ConfigReply_t mpi_reply;
46988 @@ -6637,7 +6637,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
46989 struct fw_event_work *fw_event)
46990 {
46991 Mpi2EventDataIrOperationStatus_t *event_data = fw_event->event_data;
46992 - static struct _raid_device *raid_device;
46993 + struct _raid_device *raid_device;
46994 unsigned long flags;
46995 u16 handle;
46996
46997 @@ -7108,7 +7108,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
46998 u64 sas_address;
46999 struct _sas_device *sas_device;
47000 struct _sas_node *expander_device;
47001 - static struct _raid_device *raid_device;
47002 + struct _raid_device *raid_device;
47003 u8 retry_count;
47004 unsigned long flags;
47005
47006 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
47007 index a38f71b..f3bc572 100644
47008 --- a/drivers/scsi/pmcraid.c
47009 +++ b/drivers/scsi/pmcraid.c
47010 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
47011 res->scsi_dev = scsi_dev;
47012 scsi_dev->hostdata = res;
47013 res->change_detected = 0;
47014 - atomic_set(&res->read_failures, 0);
47015 - atomic_set(&res->write_failures, 0);
47016 + atomic_set_unchecked(&res->read_failures, 0);
47017 + atomic_set_unchecked(&res->write_failures, 0);
47018 rc = 0;
47019 }
47020 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
47021 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
47022
47023 /* If this was a SCSI read/write command keep count of errors */
47024 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
47025 - atomic_inc(&res->read_failures);
47026 + atomic_inc_unchecked(&res->read_failures);
47027 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
47028 - atomic_inc(&res->write_failures);
47029 + atomic_inc_unchecked(&res->write_failures);
47030
47031 if (!RES_IS_GSCSI(res->cfg_entry) &&
47032 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
47033 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
47034 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
47035 * hrrq_id assigned here in queuecommand
47036 */
47037 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
47038 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
47039 pinstance->num_hrrq;
47040 cmd->cmd_done = pmcraid_io_done;
47041
47042 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
47043 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
47044 * hrrq_id assigned here in queuecommand
47045 */
47046 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
47047 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
47048 pinstance->num_hrrq;
47049
47050 if (request_size) {
47051 @@ -4484,7 +4484,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
47052
47053 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
47054 /* add resources only after host is added into system */
47055 - if (!atomic_read(&pinstance->expose_resources))
47056 + if (!atomic_read_unchecked(&pinstance->expose_resources))
47057 return;
47058
47059 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
47060 @@ -5311,8 +5311,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
47061 init_waitqueue_head(&pinstance->reset_wait_q);
47062
47063 atomic_set(&pinstance->outstanding_cmds, 0);
47064 - atomic_set(&pinstance->last_message_id, 0);
47065 - atomic_set(&pinstance->expose_resources, 0);
47066 + atomic_set_unchecked(&pinstance->last_message_id, 0);
47067 + atomic_set_unchecked(&pinstance->expose_resources, 0);
47068
47069 INIT_LIST_HEAD(&pinstance->free_res_q);
47070 INIT_LIST_HEAD(&pinstance->used_res_q);
47071 @@ -6025,7 +6025,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
47072 /* Schedule worker thread to handle CCN and take care of adding and
47073 * removing devices to OS
47074 */
47075 - atomic_set(&pinstance->expose_resources, 1);
47076 + atomic_set_unchecked(&pinstance->expose_resources, 1);
47077 schedule_work(&pinstance->worker_q);
47078 return rc;
47079
47080 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
47081 index e1d150f..6c6df44 100644
47082 --- a/drivers/scsi/pmcraid.h
47083 +++ b/drivers/scsi/pmcraid.h
47084 @@ -748,7 +748,7 @@ struct pmcraid_instance {
47085 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
47086
47087 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
47088 - atomic_t last_message_id;
47089 + atomic_unchecked_t last_message_id;
47090
47091 /* configuration table */
47092 struct pmcraid_config_table *cfg_table;
47093 @@ -777,7 +777,7 @@ struct pmcraid_instance {
47094 atomic_t outstanding_cmds;
47095
47096 /* should add/delete resources to mid-layer now ?*/
47097 - atomic_t expose_resources;
47098 + atomic_unchecked_t expose_resources;
47099
47100
47101
47102 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
47103 struct pmcraid_config_table_entry_ext cfg_entry_ext;
47104 };
47105 struct scsi_device *scsi_dev; /* Link scsi_device structure */
47106 - atomic_t read_failures; /* count of failed READ commands */
47107 - atomic_t write_failures; /* count of failed WRITE commands */
47108 + atomic_unchecked_t read_failures; /* count of failed READ commands */
47109 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
47110
47111 /* To indicate add/delete/modify during CCN */
47112 u8 change_detected;
47113 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
47114 index 5f174b8..98d32b0 100644
47115 --- a/drivers/scsi/qla2xxx/qla_attr.c
47116 +++ b/drivers/scsi/qla2xxx/qla_attr.c
47117 @@ -2040,7 +2040,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
47118 return 0;
47119 }
47120
47121 -struct fc_function_template qla2xxx_transport_functions = {
47122 +fc_function_template_no_const qla2xxx_transport_functions = {
47123
47124 .show_host_node_name = 1,
47125 .show_host_port_name = 1,
47126 @@ -2088,7 +2088,7 @@ struct fc_function_template qla2xxx_transport_functions = {
47127 .bsg_timeout = qla24xx_bsg_timeout,
47128 };
47129
47130 -struct fc_function_template qla2xxx_transport_vport_functions = {
47131 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
47132
47133 .show_host_node_name = 1,
47134 .show_host_port_name = 1,
47135 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
47136 index 4446bf5..9a3574d 100644
47137 --- a/drivers/scsi/qla2xxx/qla_gbl.h
47138 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
47139 @@ -538,8 +538,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
47140 struct device_attribute;
47141 extern struct device_attribute *qla2x00_host_attrs[];
47142 struct fc_function_template;
47143 -extern struct fc_function_template qla2xxx_transport_functions;
47144 -extern struct fc_function_template qla2xxx_transport_vport_functions;
47145 +extern fc_function_template_no_const qla2xxx_transport_functions;
47146 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
47147 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
47148 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
47149 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
47150 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
47151 index 9f01bbb..5e1dcee 100644
47152 --- a/drivers/scsi/qla2xxx/qla_os.c
47153 +++ b/drivers/scsi/qla2xxx/qla_os.c
47154 @@ -1572,8 +1572,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
47155 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
47156 /* Ok, a 64bit DMA mask is applicable. */
47157 ha->flags.enable_64bit_addressing = 1;
47158 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
47159 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
47160 + pax_open_kernel();
47161 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
47162 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
47163 + pax_close_kernel();
47164 return;
47165 }
47166 }
47167 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
47168 index 41327d4..feb03d479 100644
47169 --- a/drivers/scsi/qla4xxx/ql4_def.h
47170 +++ b/drivers/scsi/qla4xxx/ql4_def.h
47171 @@ -296,7 +296,7 @@ struct ddb_entry {
47172 * (4000 only) */
47173 atomic_t relogin_timer; /* Max Time to wait for
47174 * relogin to complete */
47175 - atomic_t relogin_retry_count; /* Num of times relogin has been
47176 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
47177 * retried */
47178 uint32_t default_time2wait; /* Default Min time between
47179 * relogins (+aens) */
47180 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
47181 index f8a0a26..ec03cee 100644
47182 --- a/drivers/scsi/qla4xxx/ql4_os.c
47183 +++ b/drivers/scsi/qla4xxx/ql4_os.c
47184 @@ -3066,12 +3066,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
47185 */
47186 if (!iscsi_is_session_online(cls_sess)) {
47187 /* Reset retry relogin timer */
47188 - atomic_inc(&ddb_entry->relogin_retry_count);
47189 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
47190 DEBUG2(ql4_printk(KERN_INFO, ha,
47191 "%s: index[%d] relogin timed out-retrying"
47192 " relogin (%d), retry (%d)\n", __func__,
47193 ddb_entry->fw_ddb_index,
47194 - atomic_read(&ddb_entry->relogin_retry_count),
47195 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
47196 ddb_entry->default_time2wait + 4));
47197 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
47198 atomic_set(&ddb_entry->retry_relogin_timer,
47199 @@ -5209,7 +5209,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
47200
47201 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
47202 atomic_set(&ddb_entry->relogin_timer, 0);
47203 - atomic_set(&ddb_entry->relogin_retry_count, 0);
47204 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
47205 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
47206 ddb_entry->default_relogin_timeout =
47207 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
47208 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
47209 index eaa808e..95f8841 100644
47210 --- a/drivers/scsi/scsi.c
47211 +++ b/drivers/scsi/scsi.c
47212 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
47213 unsigned long timeout;
47214 int rtn = 0;
47215
47216 - atomic_inc(&cmd->device->iorequest_cnt);
47217 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
47218
47219 /* check if the device is still usable */
47220 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
47221 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
47222 index d1549b7..2f60767 100644
47223 --- a/drivers/scsi/scsi_lib.c
47224 +++ b/drivers/scsi/scsi_lib.c
47225 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
47226 shost = sdev->host;
47227 scsi_init_cmd_errh(cmd);
47228 cmd->result = DID_NO_CONNECT << 16;
47229 - atomic_inc(&cmd->device->iorequest_cnt);
47230 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
47231
47232 /*
47233 * SCSI request completion path will do scsi_device_unbusy(),
47234 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
47235
47236 INIT_LIST_HEAD(&cmd->eh_entry);
47237
47238 - atomic_inc(&cmd->device->iodone_cnt);
47239 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
47240 if (cmd->result)
47241 - atomic_inc(&cmd->device->ioerr_cnt);
47242 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
47243
47244 disposition = scsi_decide_disposition(cmd);
47245 if (disposition != SUCCESS &&
47246 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
47247 index 40c6394..62356c2 100644
47248 --- a/drivers/scsi/scsi_sysfs.c
47249 +++ b/drivers/scsi/scsi_sysfs.c
47250 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
47251 char *buf) \
47252 { \
47253 struct scsi_device *sdev = to_scsi_device(dev); \
47254 - unsigned long long count = atomic_read(&sdev->field); \
47255 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
47256 return snprintf(buf, 20, "0x%llx\n", count); \
47257 } \
47258 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
47259 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
47260 index 84a1fdf..693b0d6 100644
47261 --- a/drivers/scsi/scsi_tgt_lib.c
47262 +++ b/drivers/scsi/scsi_tgt_lib.c
47263 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
47264 int err;
47265
47266 dprintk("%lx %u\n", uaddr, len);
47267 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
47268 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
47269 if (err) {
47270 /*
47271 * TODO: need to fixup sg_tablesize, max_segment_size,
47272 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
47273 index 4628fd5..a94a1c2 100644
47274 --- a/drivers/scsi/scsi_transport_fc.c
47275 +++ b/drivers/scsi/scsi_transport_fc.c
47276 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
47277 * Netlink Infrastructure
47278 */
47279
47280 -static atomic_t fc_event_seq;
47281 +static atomic_unchecked_t fc_event_seq;
47282
47283 /**
47284 * fc_get_event_number - Obtain the next sequential FC event number
47285 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
47286 u32
47287 fc_get_event_number(void)
47288 {
47289 - return atomic_add_return(1, &fc_event_seq);
47290 + return atomic_add_return_unchecked(1, &fc_event_seq);
47291 }
47292 EXPORT_SYMBOL(fc_get_event_number);
47293
47294 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
47295 {
47296 int error;
47297
47298 - atomic_set(&fc_event_seq, 0);
47299 + atomic_set_unchecked(&fc_event_seq, 0);
47300
47301 error = transport_class_register(&fc_host_class);
47302 if (error)
47303 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
47304 char *cp;
47305
47306 *val = simple_strtoul(buf, &cp, 0);
47307 - if ((*cp && (*cp != '\n')) || (*val < 0))
47308 + if (*cp && (*cp != '\n'))
47309 return -EINVAL;
47310 /*
47311 * Check for overflow; dev_loss_tmo is u32
47312 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
47313 index e4a989f..293090c 100644
47314 --- a/drivers/scsi/scsi_transport_iscsi.c
47315 +++ b/drivers/scsi/scsi_transport_iscsi.c
47316 @@ -79,7 +79,7 @@ struct iscsi_internal {
47317 struct transport_container session_cont;
47318 };
47319
47320 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
47321 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
47322 static struct workqueue_struct *iscsi_eh_timer_workq;
47323
47324 static DEFINE_IDA(iscsi_sess_ida);
47325 @@ -1737,7 +1737,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
47326 int err;
47327
47328 ihost = shost->shost_data;
47329 - session->sid = atomic_add_return(1, &iscsi_session_nr);
47330 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
47331
47332 if (target_id == ISCSI_MAX_TARGET) {
47333 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
47334 @@ -4077,7 +4077,7 @@ static __init int iscsi_transport_init(void)
47335 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
47336 ISCSI_TRANSPORT_VERSION);
47337
47338 - atomic_set(&iscsi_session_nr, 0);
47339 + atomic_set_unchecked(&iscsi_session_nr, 0);
47340
47341 err = class_register(&iscsi_transport_class);
47342 if (err)
47343 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
47344 index f379c7f..e8fc69c 100644
47345 --- a/drivers/scsi/scsi_transport_srp.c
47346 +++ b/drivers/scsi/scsi_transport_srp.c
47347 @@ -33,7 +33,7 @@
47348 #include "scsi_transport_srp_internal.h"
47349
47350 struct srp_host_attrs {
47351 - atomic_t next_port_id;
47352 + atomic_unchecked_t next_port_id;
47353 };
47354 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
47355
47356 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
47357 struct Scsi_Host *shost = dev_to_shost(dev);
47358 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
47359
47360 - atomic_set(&srp_host->next_port_id, 0);
47361 + atomic_set_unchecked(&srp_host->next_port_id, 0);
47362 return 0;
47363 }
47364
47365 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
47366 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
47367 rport->roles = ids->roles;
47368
47369 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
47370 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
47371 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
47372
47373 transport_setup_device(&rport->dev);
47374 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
47375 index dbc024b..6e3b837 100644
47376 --- a/drivers/scsi/sd.c
47377 +++ b/drivers/scsi/sd.c
47378 @@ -2943,7 +2943,7 @@ static int sd_probe(struct device *dev)
47379 sdkp->disk = gd;
47380 sdkp->index = index;
47381 atomic_set(&sdkp->openers, 0);
47382 - atomic_set(&sdkp->device->ioerr_cnt, 0);
47383 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
47384
47385 if (!sdp->request_queue->rq_timeout) {
47386 if (sdp->type != TYPE_MOD)
47387 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
47388 index df5e961..df6b97f 100644
47389 --- a/drivers/scsi/sg.c
47390 +++ b/drivers/scsi/sg.c
47391 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
47392 sdp->disk->disk_name,
47393 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
47394 NULL,
47395 - (char *)arg);
47396 + (char __user *)arg);
47397 case BLKTRACESTART:
47398 return blk_trace_startstop(sdp->device->request_queue, 1);
47399 case BLKTRACESTOP:
47400 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
47401 index 9e039c6..ae9e800 100644
47402 --- a/drivers/spi/spi.c
47403 +++ b/drivers/spi/spi.c
47404 @@ -1762,7 +1762,7 @@ int spi_bus_unlock(struct spi_master *master)
47405 EXPORT_SYMBOL_GPL(spi_bus_unlock);
47406
47407 /* portable code must never pass more than 32 bytes */
47408 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
47409 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
47410
47411 static u8 *buf;
47412
47413 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
47414 index 2c61783..4d49e4e 100644
47415 --- a/drivers/staging/android/timed_output.c
47416 +++ b/drivers/staging/android/timed_output.c
47417 @@ -25,7 +25,7 @@
47418 #include "timed_output.h"
47419
47420 static struct class *timed_output_class;
47421 -static atomic_t device_count;
47422 +static atomic_unchecked_t device_count;
47423
47424 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
47425 char *buf)
47426 @@ -63,7 +63,7 @@ static int create_timed_output_class(void)
47427 timed_output_class = class_create(THIS_MODULE, "timed_output");
47428 if (IS_ERR(timed_output_class))
47429 return PTR_ERR(timed_output_class);
47430 - atomic_set(&device_count, 0);
47431 + atomic_set_unchecked(&device_count, 0);
47432 timed_output_class->dev_groups = timed_output_groups;
47433 }
47434
47435 @@ -81,7 +81,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
47436 if (ret < 0)
47437 return ret;
47438
47439 - tdev->index = atomic_inc_return(&device_count);
47440 + tdev->index = atomic_inc_return_unchecked(&device_count);
47441 tdev->dev = device_create(timed_output_class, NULL,
47442 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
47443 if (IS_ERR(tdev->dev))
47444 diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
47445 index 0247a20..cb9595c 100644
47446 --- a/drivers/staging/gdm724x/gdm_tty.c
47447 +++ b/drivers/staging/gdm724x/gdm_tty.c
47448 @@ -45,7 +45,7 @@
47449 #define gdm_tty_send_control(n, r, v, d, l) (\
47450 n->tty_dev->send_control(n->tty_dev->priv_dev, r, v, d, l))
47451
47452 -#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
47453 +#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && atomic_read(&gdm->port.count))
47454
47455 static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
47456 static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
47457 diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
47458 index ef5064e..fce01db 100644
47459 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c
47460 +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
47461 @@ -478,13 +478,11 @@ brw_server_handle(struct srpc_server_rpc *rpc)
47462 return 0;
47463 }
47464
47465 -sfw_test_client_ops_t brw_test_client;
47466 -void brw_init_test_client(void)
47467 -{
47468 - brw_test_client.tso_init = brw_client_init;
47469 - brw_test_client.tso_fini = brw_client_fini;
47470 - brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
47471 - brw_test_client.tso_done_rpc = brw_client_done_rpc;
47472 +sfw_test_client_ops_t brw_test_client = {
47473 + .tso_init = brw_client_init,
47474 + .tso_fini = brw_client_fini,
47475 + .tso_prep_rpc = brw_client_prep_rpc,
47476 + .tso_done_rpc = brw_client_done_rpc,
47477 };
47478
47479 srpc_service_t brw_test_service;
47480 diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
47481 index 483c785..e1a2a7b 100644
47482 --- a/drivers/staging/lustre/lnet/selftest/framework.c
47483 +++ b/drivers/staging/lustre/lnet/selftest/framework.c
47484 @@ -1635,12 +1635,10 @@ static srpc_service_t sfw_services[] =
47485
47486 extern sfw_test_client_ops_t ping_test_client;
47487 extern srpc_service_t ping_test_service;
47488 -extern void ping_init_test_client(void);
47489 extern void ping_init_test_service(void);
47490
47491 extern sfw_test_client_ops_t brw_test_client;
47492 extern srpc_service_t brw_test_service;
47493 -extern void brw_init_test_client(void);
47494 extern void brw_init_test_service(void);
47495
47496
47497 @@ -1684,12 +1682,10 @@ sfw_startup (void)
47498 INIT_LIST_HEAD(&sfw_data.fw_zombie_rpcs);
47499 INIT_LIST_HEAD(&sfw_data.fw_zombie_sessions);
47500
47501 - brw_init_test_client();
47502 brw_init_test_service();
47503 rc = sfw_register_test(&brw_test_service, &brw_test_client);
47504 LASSERT (rc == 0);
47505
47506 - ping_init_test_client();
47507 ping_init_test_service();
47508 rc = sfw_register_test(&ping_test_service, &ping_test_client);
47509 LASSERT (rc == 0);
47510 diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c
47511 index f0f9194..b589047 100644
47512 --- a/drivers/staging/lustre/lnet/selftest/ping_test.c
47513 +++ b/drivers/staging/lustre/lnet/selftest/ping_test.c
47514 @@ -210,14 +210,12 @@ ping_server_handle(struct srpc_server_rpc *rpc)
47515 return 0;
47516 }
47517
47518 -sfw_test_client_ops_t ping_test_client;
47519 -void ping_init_test_client(void)
47520 -{
47521 - ping_test_client.tso_init = ping_client_init;
47522 - ping_test_client.tso_fini = ping_client_fini;
47523 - ping_test_client.tso_prep_rpc = ping_client_prep_rpc;
47524 - ping_test_client.tso_done_rpc = ping_client_done_rpc;
47525 -}
47526 +sfw_test_client_ops_t ping_test_client = {
47527 + .tso_init = ping_client_init,
47528 + .tso_fini = ping_client_fini,
47529 + .tso_prep_rpc = ping_client_prep_rpc,
47530 + .tso_done_rpc = ping_client_done_rpc,
47531 +};
47532
47533 srpc_service_t ping_test_service;
47534 void ping_init_test_service(void)
47535 diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
47536 index 7020d9c..0d3b580 100644
47537 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
47538 +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
47539 @@ -1141,7 +1141,7 @@ struct ldlm_callback_suite {
47540 ldlm_completion_callback lcs_completion;
47541 ldlm_blocking_callback lcs_blocking;
47542 ldlm_glimpse_callback lcs_glimpse;
47543 -};
47544 +} __no_const;
47545
47546 /* ldlm_lockd.c */
47547 int ldlm_del_waiting_lock(struct ldlm_lock *lock);
47548 diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
47549 index a612255..9a9e2dd 100644
47550 --- a/drivers/staging/lustre/lustre/include/obd.h
47551 +++ b/drivers/staging/lustre/lustre/include/obd.h
47552 @@ -1417,7 +1417,7 @@ struct md_ops {
47553 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
47554 * wrapper function in include/linux/obd_class.h.
47555 */
47556 -};
47557 +} __no_const;
47558
47559 struct lsm_operations {
47560 void (*lsm_free)(struct lov_stripe_md *);
47561 diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
47562 index fc6c977..df1f956 100644
47563 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
47564 +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
47565 @@ -219,7 +219,7 @@ DECLARE_PROC_HANDLER(proc_debug_mb)
47566 int LL_PROC_PROTO(proc_console_max_delay_cs)
47567 {
47568 int rc, max_delay_cs;
47569 - ctl_table_t dummy = *table;
47570 + ctl_table_no_const dummy = *table;
47571 cfs_duration_t d;
47572
47573 dummy.data = &max_delay_cs;
47574 @@ -250,7 +250,7 @@ int LL_PROC_PROTO(proc_console_max_delay_cs)
47575 int LL_PROC_PROTO(proc_console_min_delay_cs)
47576 {
47577 int rc, min_delay_cs;
47578 - ctl_table_t dummy = *table;
47579 + ctl_table_no_const dummy = *table;
47580 cfs_duration_t d;
47581
47582 dummy.data = &min_delay_cs;
47583 @@ -281,7 +281,7 @@ int LL_PROC_PROTO(proc_console_min_delay_cs)
47584 int LL_PROC_PROTO(proc_console_backoff)
47585 {
47586 int rc, backoff;
47587 - ctl_table_t dummy = *table;
47588 + ctl_table_no_const dummy = *table;
47589
47590 dummy.data = &backoff;
47591 dummy.proc_handler = &proc_dointvec;
47592 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
47593 index 3675020..e80d92c 100644
47594 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
47595 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
47596 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
47597
47598 static int solo_sysfs_init(struct solo_dev *solo_dev)
47599 {
47600 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47601 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47602 struct device *dev = &solo_dev->dev;
47603 const char *driver;
47604 int i;
47605 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47606 index 3335941..2b26186 100644
47607 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
47608 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47609 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47610
47611 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47612 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47613 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47614 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47615 if (p2m_id < 0)
47616 p2m_id = -p2m_id;
47617 }
47618 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
47619 index 6f91d2e..3f011d2 100644
47620 --- a/drivers/staging/media/solo6x10/solo6x10.h
47621 +++ b/drivers/staging/media/solo6x10/solo6x10.h
47622 @@ -238,7 +238,7 @@ struct solo_dev {
47623
47624 /* P2M DMA Engine */
47625 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47626 - atomic_t p2m_count;
47627 + atomic_unchecked_t p2m_count;
47628 int p2m_jiffies;
47629 unsigned int p2m_timeouts;
47630
47631 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
47632 index e14a1bb..9cb9bbe 100644
47633 --- a/drivers/staging/octeon/ethernet-rx.c
47634 +++ b/drivers/staging/octeon/ethernet-rx.c
47635 @@ -419,11 +419,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47636 /* Increment RX stats for virtual ports */
47637 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
47638 #ifdef CONFIG_64BIT
47639 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
47640 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
47641 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
47642 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
47643 #else
47644 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
47645 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
47646 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
47647 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
47648 #endif
47649 }
47650 netif_receive_skb(skb);
47651 @@ -434,9 +434,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47652 dev->name);
47653 */
47654 #ifdef CONFIG_64BIT
47655 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47656 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47657 #else
47658 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47659 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47660 #endif
47661 dev_kfree_skb_irq(skb);
47662 }
47663 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47664 index c3a90e7..023619a 100644
47665 --- a/drivers/staging/octeon/ethernet.c
47666 +++ b/drivers/staging/octeon/ethernet.c
47667 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47668 * since the RX tasklet also increments it.
47669 */
47670 #ifdef CONFIG_64BIT
47671 - atomic64_add(rx_status.dropped_packets,
47672 - (atomic64_t *)&priv->stats.rx_dropped);
47673 + atomic64_add_unchecked(rx_status.dropped_packets,
47674 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47675 #else
47676 - atomic_add(rx_status.dropped_packets,
47677 - (atomic_t *)&priv->stats.rx_dropped);
47678 + atomic_add_unchecked(rx_status.dropped_packets,
47679 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47680 #endif
47681 }
47682
47683 diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h
47684 index 439c3c9..2d74293 100644
47685 --- a/drivers/staging/rtl8188eu/include/hal_intf.h
47686 +++ b/drivers/staging/rtl8188eu/include/hal_intf.h
47687 @@ -271,7 +271,7 @@ struct hal_ops {
47688 s32 (*c2h_handler)(struct adapter *padapter,
47689 struct c2h_evt_hdr *c2h_evt);
47690 c2h_id_filter c2h_id_filter_ccx;
47691 -};
47692 +} __no_const;
47693
47694 enum rt_eeprom_type {
47695 EEPROM_93C46,
47696 diff --git a/drivers/staging/rtl8188eu/include/rtw_io.h b/drivers/staging/rtl8188eu/include/rtw_io.h
47697 index eb6f0e5..e6a0958 100644
47698 --- a/drivers/staging/rtl8188eu/include/rtw_io.h
47699 +++ b/drivers/staging/rtl8188eu/include/rtw_io.h
47700 @@ -126,7 +126,7 @@ struct _io_ops {
47701 u32 (*_write_scsi)(struct intf_hdl *pintfhdl,u32 cnt, u8 *pmem);
47702 void (*_read_port_cancel)(struct intf_hdl *pintfhdl);
47703 void (*_write_port_cancel)(struct intf_hdl *pintfhdl);
47704 -};
47705 +} __no_const;
47706
47707 struct io_req {
47708 struct list_head list;
47709 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47710 index dc23395..cf7e9b1 100644
47711 --- a/drivers/staging/rtl8712/rtl871x_io.h
47712 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47713 @@ -108,7 +108,7 @@ struct _io_ops {
47714 u8 *pmem);
47715 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47716 u8 *pmem);
47717 -};
47718 +} __no_const;
47719
47720 struct io_req {
47721 struct list_head list;
47722 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47723 index 1f5088b..0e59820 100644
47724 --- a/drivers/staging/sbe-2t3e3/netdev.c
47725 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47726 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47727 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47728
47729 if (rlen)
47730 - if (copy_to_user(data, &resp, rlen))
47731 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47732 return -EFAULT;
47733
47734 return 0;
47735 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47736 index a863a98..d272795 100644
47737 --- a/drivers/staging/usbip/vhci.h
47738 +++ b/drivers/staging/usbip/vhci.h
47739 @@ -83,7 +83,7 @@ struct vhci_hcd {
47740 unsigned resuming:1;
47741 unsigned long re_timeout;
47742
47743 - atomic_t seqnum;
47744 + atomic_unchecked_t seqnum;
47745
47746 /*
47747 * NOTE:
47748 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47749 index d7974cb..d78076b 100644
47750 --- a/drivers/staging/usbip/vhci_hcd.c
47751 +++ b/drivers/staging/usbip/vhci_hcd.c
47752 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47753
47754 spin_lock(&vdev->priv_lock);
47755
47756 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47757 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47758 if (priv->seqnum == 0xffff)
47759 dev_info(&urb->dev->dev, "seqnum max\n");
47760
47761 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47762 return -ENOMEM;
47763 }
47764
47765 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47766 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47767 if (unlink->seqnum == 0xffff)
47768 pr_info("seqnum max\n");
47769
47770 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47771 vdev->rhport = rhport;
47772 }
47773
47774 - atomic_set(&vhci->seqnum, 0);
47775 + atomic_set_unchecked(&vhci->seqnum, 0);
47776 spin_lock_init(&vhci->lock);
47777
47778 hcd->power_budget = 0; /* no limit */
47779 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47780 index d07fcb5..358e1e1 100644
47781 --- a/drivers/staging/usbip/vhci_rx.c
47782 +++ b/drivers/staging/usbip/vhci_rx.c
47783 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47784 if (!urb) {
47785 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47786 pr_info("max seqnum %d\n",
47787 - atomic_read(&the_controller->seqnum));
47788 + atomic_read_unchecked(&the_controller->seqnum));
47789 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47790 return;
47791 }
47792 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47793 index 8acff44..bdb2fca 100644
47794 --- a/drivers/staging/vt6655/hostap.c
47795 +++ b/drivers/staging/vt6655/hostap.c
47796 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47797 *
47798 */
47799
47800 +static net_device_ops_no_const apdev_netdev_ops;
47801 +
47802 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47803 {
47804 PSDevice apdev_priv;
47805 struct net_device *dev = pDevice->dev;
47806 int ret;
47807 - const struct net_device_ops apdev_netdev_ops = {
47808 - .ndo_start_xmit = pDevice->tx_80211,
47809 - };
47810
47811 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47812
47813 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47814 *apdev_priv = *pDevice;
47815 eth_hw_addr_inherit(pDevice->apdev, dev);
47816
47817 + /* only half broken now */
47818 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47819 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47820
47821 pDevice->apdev->type = ARPHRD_IEEE80211;
47822 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47823 index c699a30..b90a5fd 100644
47824 --- a/drivers/staging/vt6656/hostap.c
47825 +++ b/drivers/staging/vt6656/hostap.c
47826 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47827 *
47828 */
47829
47830 +static net_device_ops_no_const apdev_netdev_ops;
47831 +
47832 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47833 {
47834 struct vnt_private *apdev_priv;
47835 struct net_device *dev = pDevice->dev;
47836 int ret;
47837 - const struct net_device_ops apdev_netdev_ops = {
47838 - .ndo_start_xmit = pDevice->tx_80211,
47839 - };
47840
47841 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47842
47843 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47844 *apdev_priv = *pDevice;
47845 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47846
47847 + /* only half broken now */
47848 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47849 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47850
47851 pDevice->apdev->type = ARPHRD_IEEE80211;
47852 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47853 index e51b09a..5ebac31 100644
47854 --- a/drivers/target/sbp/sbp_target.c
47855 +++ b/drivers/target/sbp/sbp_target.c
47856 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47857
47858 #define SESSION_MAINTENANCE_INTERVAL HZ
47859
47860 -static atomic_t login_id = ATOMIC_INIT(0);
47861 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47862
47863 static void session_maintenance_work(struct work_struct *);
47864 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47865 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47866 login->lun = se_lun;
47867 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47868 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47869 - login->login_id = atomic_inc_return(&login_id);
47870 + login->login_id = atomic_inc_return_unchecked(&login_id);
47871
47872 login->tgt_agt = sbp_target_agent_register(login);
47873 if (IS_ERR(login->tgt_agt)) {
47874 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47875 index e5e3965..a7b487c 100644
47876 --- a/drivers/target/target_core_device.c
47877 +++ b/drivers/target/target_core_device.c
47878 @@ -1436,7 +1436,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47879 spin_lock_init(&dev->se_tmr_lock);
47880 spin_lock_init(&dev->qf_cmd_lock);
47881 sema_init(&dev->caw_sem, 1);
47882 - atomic_set(&dev->dev_ordered_id, 0);
47883 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47884 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47885 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47886 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47887 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47888 index 0b0009b..215e88e 100644
47889 --- a/drivers/target/target_core_transport.c
47890 +++ b/drivers/target/target_core_transport.c
47891 @@ -1137,7 +1137,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47892 * Used to determine when ORDERED commands should go from
47893 * Dormant to Active status.
47894 */
47895 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47896 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47897 smp_mb__after_atomic_inc();
47898 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47899 cmd->se_ordered_id, cmd->sam_task_attr,
47900 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47901 index 33f83fe..d80f8e1 100644
47902 --- a/drivers/tty/cyclades.c
47903 +++ b/drivers/tty/cyclades.c
47904 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47905 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47906 info->port.count);
47907 #endif
47908 - info->port.count++;
47909 + atomic_inc(&info->port.count);
47910 #ifdef CY_DEBUG_COUNT
47911 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47912 - current->pid, info->port.count);
47913 + current->pid, atomic_read(&info->port.count));
47914 #endif
47915
47916 /*
47917 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47918 for (j = 0; j < cy_card[i].nports; j++) {
47919 info = &cy_card[i].ports[j];
47920
47921 - if (info->port.count) {
47922 + if (atomic_read(&info->port.count)) {
47923 /* XXX is the ldisc num worth this? */
47924 struct tty_struct *tty;
47925 struct tty_ldisc *ld;
47926 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47927 index 9eba119..5070303 100644
47928 --- a/drivers/tty/hvc/hvc_console.c
47929 +++ b/drivers/tty/hvc/hvc_console.c
47930 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47931
47932 spin_lock_irqsave(&hp->port.lock, flags);
47933 /* Check and then increment for fast path open. */
47934 - if (hp->port.count++ > 0) {
47935 + if (atomic_inc_return(&hp->port.count) > 1) {
47936 spin_unlock_irqrestore(&hp->port.lock, flags);
47937 hvc_kick();
47938 return 0;
47939 @@ -393,7 +393,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47940
47941 spin_lock_irqsave(&hp->port.lock, flags);
47942
47943 - if (--hp->port.count == 0) {
47944 + if (atomic_dec_return(&hp->port.count) == 0) {
47945 spin_unlock_irqrestore(&hp->port.lock, flags);
47946 /* We are done with the tty pointer now. */
47947 tty_port_tty_set(&hp->port, NULL);
47948 @@ -415,9 +415,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47949 */
47950 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47951 } else {
47952 - if (hp->port.count < 0)
47953 + if (atomic_read(&hp->port.count) < 0)
47954 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47955 - hp->vtermno, hp->port.count);
47956 + hp->vtermno, atomic_read(&hp->port.count));
47957 spin_unlock_irqrestore(&hp->port.lock, flags);
47958 }
47959 }
47960 @@ -447,12 +447,12 @@ static void hvc_hangup(struct tty_struct *tty)
47961 * open->hangup case this can be called after the final close so prevent
47962 * that from happening for now.
47963 */
47964 - if (hp->port.count <= 0) {
47965 + if (atomic_read(&hp->port.count) <= 0) {
47966 spin_unlock_irqrestore(&hp->port.lock, flags);
47967 return;
47968 }
47969
47970 - hp->port.count = 0;
47971 + atomic_set(&hp->port.count, 0);
47972 spin_unlock_irqrestore(&hp->port.lock, flags);
47973 tty_port_tty_set(&hp->port, NULL);
47974
47975 @@ -500,7 +500,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47976 return -EPIPE;
47977
47978 /* FIXME what's this (unprotected) check for? */
47979 - if (hp->port.count <= 0)
47980 + if (atomic_read(&hp->port.count) <= 0)
47981 return -EIO;
47982
47983 spin_lock_irqsave(&hp->lock, flags);
47984 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47985 index 81e939e..95ead10 100644
47986 --- a/drivers/tty/hvc/hvcs.c
47987 +++ b/drivers/tty/hvc/hvcs.c
47988 @@ -83,6 +83,7 @@
47989 #include <asm/hvcserver.h>
47990 #include <asm/uaccess.h>
47991 #include <asm/vio.h>
47992 +#include <asm/local.h>
47993
47994 /*
47995 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47996 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47997
47998 spin_lock_irqsave(&hvcsd->lock, flags);
47999
48000 - if (hvcsd->port.count > 0) {
48001 + if (atomic_read(&hvcsd->port.count) > 0) {
48002 spin_unlock_irqrestore(&hvcsd->lock, flags);
48003 printk(KERN_INFO "HVCS: vterm state unchanged. "
48004 "The hvcs device node is still in use.\n");
48005 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
48006 }
48007 }
48008
48009 - hvcsd->port.count = 0;
48010 + atomic_set(&hvcsd->port.count, 0);
48011 hvcsd->port.tty = tty;
48012 tty->driver_data = hvcsd;
48013
48014 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
48015 unsigned long flags;
48016
48017 spin_lock_irqsave(&hvcsd->lock, flags);
48018 - hvcsd->port.count++;
48019 + atomic_inc(&hvcsd->port.count);
48020 hvcsd->todo_mask |= HVCS_SCHED_READ;
48021 spin_unlock_irqrestore(&hvcsd->lock, flags);
48022
48023 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
48024 hvcsd = tty->driver_data;
48025
48026 spin_lock_irqsave(&hvcsd->lock, flags);
48027 - if (--hvcsd->port.count == 0) {
48028 + if (atomic_dec_and_test(&hvcsd->port.count)) {
48029
48030 vio_disable_interrupts(hvcsd->vdev);
48031
48032 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
48033
48034 free_irq(irq, hvcsd);
48035 return;
48036 - } else if (hvcsd->port.count < 0) {
48037 + } else if (atomic_read(&hvcsd->port.count) < 0) {
48038 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
48039 " is missmanaged.\n",
48040 - hvcsd->vdev->unit_address, hvcsd->port.count);
48041 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
48042 }
48043
48044 spin_unlock_irqrestore(&hvcsd->lock, flags);
48045 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
48046
48047 spin_lock_irqsave(&hvcsd->lock, flags);
48048 /* Preserve this so that we know how many kref refs to put */
48049 - temp_open_count = hvcsd->port.count;
48050 + temp_open_count = atomic_read(&hvcsd->port.count);
48051
48052 /*
48053 * Don't kref put inside the spinlock because the destruction
48054 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
48055 tty->driver_data = NULL;
48056 hvcsd->port.tty = NULL;
48057
48058 - hvcsd->port.count = 0;
48059 + atomic_set(&hvcsd->port.count, 0);
48060
48061 /* This will drop any buffered data on the floor which is OK in a hangup
48062 * scenario. */
48063 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
48064 * the middle of a write operation? This is a crummy place to do this
48065 * but we want to keep it all in the spinlock.
48066 */
48067 - if (hvcsd->port.count <= 0) {
48068 + if (atomic_read(&hvcsd->port.count) <= 0) {
48069 spin_unlock_irqrestore(&hvcsd->lock, flags);
48070 return -ENODEV;
48071 }
48072 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
48073 {
48074 struct hvcs_struct *hvcsd = tty->driver_data;
48075
48076 - if (!hvcsd || hvcsd->port.count <= 0)
48077 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
48078 return 0;
48079
48080 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
48081 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
48082 index 4190199..48f2920 100644
48083 --- a/drivers/tty/hvc/hvsi.c
48084 +++ b/drivers/tty/hvc/hvsi.c
48085 @@ -85,7 +85,7 @@ struct hvsi_struct {
48086 int n_outbuf;
48087 uint32_t vtermno;
48088 uint32_t virq;
48089 - atomic_t seqno; /* HVSI packet sequence number */
48090 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
48091 uint16_t mctrl;
48092 uint8_t state; /* HVSI protocol state */
48093 uint8_t flags;
48094 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
48095
48096 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
48097 packet.hdr.len = sizeof(struct hvsi_query_response);
48098 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48099 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48100 packet.verb = VSV_SEND_VERSION_NUMBER;
48101 packet.u.version = HVSI_VERSION;
48102 packet.query_seqno = query_seqno+1;
48103 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
48104
48105 packet.hdr.type = VS_QUERY_PACKET_HEADER;
48106 packet.hdr.len = sizeof(struct hvsi_query);
48107 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48108 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48109 packet.verb = verb;
48110
48111 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
48112 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
48113 int wrote;
48114
48115 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
48116 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48117 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48118 packet.hdr.len = sizeof(struct hvsi_control);
48119 packet.verb = VSV_SET_MODEM_CTL;
48120 packet.mask = HVSI_TSDTR;
48121 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
48122 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
48123
48124 packet.hdr.type = VS_DATA_PACKET_HEADER;
48125 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48126 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48127 packet.hdr.len = count + sizeof(struct hvsi_header);
48128 memcpy(&packet.data, buf, count);
48129
48130 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
48131 struct hvsi_control packet __ALIGNED__;
48132
48133 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
48134 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48135 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48136 packet.hdr.len = 6;
48137 packet.verb = VSV_CLOSE_PROTOCOL;
48138
48139 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
48140 index ac27671..0f627ee 100644
48141 --- a/drivers/tty/hvc/hvsi_lib.c
48142 +++ b/drivers/tty/hvc/hvsi_lib.c
48143 @@ -9,7 +9,7 @@
48144
48145 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
48146 {
48147 - packet->seqno = atomic_inc_return(&pv->seqno);
48148 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
48149
48150 /* Assumes that always succeeds, works in practice */
48151 return pv->put_chars(pv->termno, (char *)packet, packet->len);
48152 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
48153
48154 /* Reset state */
48155 pv->established = 0;
48156 - atomic_set(&pv->seqno, 0);
48157 + atomic_set_unchecked(&pv->seqno, 0);
48158
48159 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
48160
48161 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
48162 pv->mctrl_update = 0;
48163 q.hdr.type = VS_QUERY_PACKET_HEADER;
48164 q.hdr.len = sizeof(struct hvsi_query);
48165 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
48166 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
48167 q.verb = VSV_SEND_MODEM_CTL_STATUS;
48168 rc = hvsi_send_packet(pv, &q.hdr);
48169 if (rc <= 0) {
48170 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
48171 index 8fd72ff..34a0bed 100644
48172 --- a/drivers/tty/ipwireless/tty.c
48173 +++ b/drivers/tty/ipwireless/tty.c
48174 @@ -29,6 +29,7 @@
48175 #include <linux/tty_driver.h>
48176 #include <linux/tty_flip.h>
48177 #include <linux/uaccess.h>
48178 +#include <asm/local.h>
48179
48180 #include "tty.h"
48181 #include "network.h"
48182 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
48183 mutex_unlock(&tty->ipw_tty_mutex);
48184 return -ENODEV;
48185 }
48186 - if (tty->port.count == 0)
48187 + if (atomic_read(&tty->port.count) == 0)
48188 tty->tx_bytes_queued = 0;
48189
48190 - tty->port.count++;
48191 + atomic_inc(&tty->port.count);
48192
48193 tty->port.tty = linux_tty;
48194 linux_tty->driver_data = tty;
48195 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
48196
48197 static void do_ipw_close(struct ipw_tty *tty)
48198 {
48199 - tty->port.count--;
48200 -
48201 - if (tty->port.count == 0) {
48202 + if (atomic_dec_return(&tty->port.count) == 0) {
48203 struct tty_struct *linux_tty = tty->port.tty;
48204
48205 if (linux_tty != NULL) {
48206 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
48207 return;
48208
48209 mutex_lock(&tty->ipw_tty_mutex);
48210 - if (tty->port.count == 0) {
48211 + if (atomic_read(&tty->port.count) == 0) {
48212 mutex_unlock(&tty->ipw_tty_mutex);
48213 return;
48214 }
48215 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
48216
48217 mutex_lock(&tty->ipw_tty_mutex);
48218
48219 - if (!tty->port.count) {
48220 + if (!atomic_read(&tty->port.count)) {
48221 mutex_unlock(&tty->ipw_tty_mutex);
48222 return;
48223 }
48224 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
48225 return -ENODEV;
48226
48227 mutex_lock(&tty->ipw_tty_mutex);
48228 - if (!tty->port.count) {
48229 + if (!atomic_read(&tty->port.count)) {
48230 mutex_unlock(&tty->ipw_tty_mutex);
48231 return -EINVAL;
48232 }
48233 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
48234 if (!tty)
48235 return -ENODEV;
48236
48237 - if (!tty->port.count)
48238 + if (!atomic_read(&tty->port.count))
48239 return -EINVAL;
48240
48241 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
48242 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
48243 if (!tty)
48244 return 0;
48245
48246 - if (!tty->port.count)
48247 + if (!atomic_read(&tty->port.count))
48248 return 0;
48249
48250 return tty->tx_bytes_queued;
48251 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
48252 if (!tty)
48253 return -ENODEV;
48254
48255 - if (!tty->port.count)
48256 + if (!atomic_read(&tty->port.count))
48257 return -EINVAL;
48258
48259 return get_control_lines(tty);
48260 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
48261 if (!tty)
48262 return -ENODEV;
48263
48264 - if (!tty->port.count)
48265 + if (!atomic_read(&tty->port.count))
48266 return -EINVAL;
48267
48268 return set_control_lines(tty, set, clear);
48269 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
48270 if (!tty)
48271 return -ENODEV;
48272
48273 - if (!tty->port.count)
48274 + if (!atomic_read(&tty->port.count))
48275 return -EINVAL;
48276
48277 /* FIXME: Exactly how is the tty object locked here .. */
48278 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
48279 * are gone */
48280 mutex_lock(&ttyj->ipw_tty_mutex);
48281 }
48282 - while (ttyj->port.count)
48283 + while (atomic_read(&ttyj->port.count))
48284 do_ipw_close(ttyj);
48285 ipwireless_disassociate_network_ttys(network,
48286 ttyj->channel_idx);
48287 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
48288 index 1deaca4..c8582d4 100644
48289 --- a/drivers/tty/moxa.c
48290 +++ b/drivers/tty/moxa.c
48291 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
48292 }
48293
48294 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
48295 - ch->port.count++;
48296 + atomic_inc(&ch->port.count);
48297 tty->driver_data = ch;
48298 tty_port_tty_set(&ch->port, tty);
48299 mutex_lock(&ch->port.mutex);
48300 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
48301 index c0f76da..d974c32 100644
48302 --- a/drivers/tty/n_gsm.c
48303 +++ b/drivers/tty/n_gsm.c
48304 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
48305 spin_lock_init(&dlci->lock);
48306 mutex_init(&dlci->mutex);
48307 dlci->fifo = &dlci->_fifo;
48308 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
48309 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
48310 kfree(dlci);
48311 return NULL;
48312 }
48313 @@ -2935,7 +2935,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
48314 struct gsm_dlci *dlci = tty->driver_data;
48315 struct tty_port *port = &dlci->port;
48316
48317 - port->count++;
48318 + atomic_inc(&port->count);
48319 dlci_get(dlci);
48320 dlci_get(dlci->gsm->dlci[0]);
48321 mux_get(dlci->gsm);
48322 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
48323 index d4a89db..dbe8d8c 100644
48324 --- a/drivers/tty/n_tty.c
48325 +++ b/drivers/tty/n_tty.c
48326 @@ -114,7 +114,7 @@ struct n_tty_data {
48327 int minimum_to_wake;
48328
48329 /* consumer-published */
48330 - size_t read_tail;
48331 + size_t read_tail __intentional_overflow(-1);
48332 size_t line_start;
48333
48334 /* protected by output lock */
48335 @@ -2509,6 +2509,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
48336 {
48337 *ops = tty_ldisc_N_TTY;
48338 ops->owner = NULL;
48339 - ops->refcount = ops->flags = 0;
48340 + atomic_set(&ops->refcount, 0);
48341 + ops->flags = 0;
48342 }
48343 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
48344 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
48345 index 25c9bc7..24077b7 100644
48346 --- a/drivers/tty/pty.c
48347 +++ b/drivers/tty/pty.c
48348 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
48349 panic("Couldn't register Unix98 pts driver");
48350
48351 /* Now create the /dev/ptmx special device */
48352 + pax_open_kernel();
48353 tty_default_fops(&ptmx_fops);
48354 - ptmx_fops.open = ptmx_open;
48355 + *(void **)&ptmx_fops.open = ptmx_open;
48356 + pax_close_kernel();
48357
48358 cdev_init(&ptmx_cdev, &ptmx_fops);
48359 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
48360 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
48361 index 354564e..fe50d9a 100644
48362 --- a/drivers/tty/rocket.c
48363 +++ b/drivers/tty/rocket.c
48364 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
48365 tty->driver_data = info;
48366 tty_port_tty_set(port, tty);
48367
48368 - if (port->count++ == 0) {
48369 + if (atomic_inc_return(&port->count) == 1) {
48370 atomic_inc(&rp_num_ports_open);
48371
48372 #ifdef ROCKET_DEBUG_OPEN
48373 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
48374 #endif
48375 }
48376 #ifdef ROCKET_DEBUG_OPEN
48377 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
48378 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
48379 #endif
48380
48381 /*
48382 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
48383 spin_unlock_irqrestore(&info->port.lock, flags);
48384 return;
48385 }
48386 - if (info->port.count)
48387 + if (atomic_read(&info->port.count))
48388 atomic_dec(&rp_num_ports_open);
48389 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
48390 spin_unlock_irqrestore(&info->port.lock, flags);
48391 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
48392 index 1274499..f541382 100644
48393 --- a/drivers/tty/serial/ioc4_serial.c
48394 +++ b/drivers/tty/serial/ioc4_serial.c
48395 @@ -437,7 +437,7 @@ struct ioc4_soft {
48396 } is_intr_info[MAX_IOC4_INTR_ENTS];
48397
48398 /* Number of entries active in the above array */
48399 - atomic_t is_num_intrs;
48400 + atomic_unchecked_t is_num_intrs;
48401 } is_intr_type[IOC4_NUM_INTR_TYPES];
48402
48403 /* is_ir_lock must be held while
48404 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
48405 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
48406 || (type == IOC4_OTHER_INTR_TYPE)));
48407
48408 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
48409 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
48410 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
48411
48412 /* Save off the lower level interrupt handler */
48413 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
48414
48415 soft = arg;
48416 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
48417 - num_intrs = (int)atomic_read(
48418 + num_intrs = (int)atomic_read_unchecked(
48419 &soft->is_intr_type[intr_type].is_num_intrs);
48420
48421 this_mir = this_ir = pending_intrs(soft, intr_type);
48422 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
48423 index a260cde..6b2b5ce 100644
48424 --- a/drivers/tty/serial/kgdboc.c
48425 +++ b/drivers/tty/serial/kgdboc.c
48426 @@ -24,8 +24,9 @@
48427 #define MAX_CONFIG_LEN 40
48428
48429 static struct kgdb_io kgdboc_io_ops;
48430 +static struct kgdb_io kgdboc_io_ops_console;
48431
48432 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
48433 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
48434 static int configured = -1;
48435
48436 static char config[MAX_CONFIG_LEN];
48437 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
48438 kgdboc_unregister_kbd();
48439 if (configured == 1)
48440 kgdb_unregister_io_module(&kgdboc_io_ops);
48441 + else if (configured == 2)
48442 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
48443 }
48444
48445 static int configure_kgdboc(void)
48446 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
48447 int err;
48448 char *cptr = config;
48449 struct console *cons;
48450 + int is_console = 0;
48451
48452 err = kgdboc_option_setup(config);
48453 if (err || !strlen(config) || isspace(config[0]))
48454 goto noconfig;
48455
48456 err = -ENODEV;
48457 - kgdboc_io_ops.is_console = 0;
48458 kgdb_tty_driver = NULL;
48459
48460 kgdboc_use_kms = 0;
48461 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
48462 int idx;
48463 if (cons->device && cons->device(cons, &idx) == p &&
48464 idx == tty_line) {
48465 - kgdboc_io_ops.is_console = 1;
48466 + is_console = 1;
48467 break;
48468 }
48469 cons = cons->next;
48470 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
48471 kgdb_tty_line = tty_line;
48472
48473 do_register:
48474 - err = kgdb_register_io_module(&kgdboc_io_ops);
48475 + if (is_console) {
48476 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
48477 + configured = 2;
48478 + } else {
48479 + err = kgdb_register_io_module(&kgdboc_io_ops);
48480 + configured = 1;
48481 + }
48482 if (err)
48483 goto noconfig;
48484
48485 @@ -205,8 +214,6 @@ do_register:
48486 if (err)
48487 goto nmi_con_failed;
48488
48489 - configured = 1;
48490 -
48491 return 0;
48492
48493 nmi_con_failed:
48494 @@ -223,7 +230,7 @@ noconfig:
48495 static int __init init_kgdboc(void)
48496 {
48497 /* Already configured? */
48498 - if (configured == 1)
48499 + if (configured >= 1)
48500 return 0;
48501
48502 return configure_kgdboc();
48503 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
48504 if (config[len - 1] == '\n')
48505 config[len - 1] = '\0';
48506
48507 - if (configured == 1)
48508 + if (configured >= 1)
48509 cleanup_kgdboc();
48510
48511 /* Go and configure with the new params. */
48512 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
48513 .post_exception = kgdboc_post_exp_handler,
48514 };
48515
48516 +static struct kgdb_io kgdboc_io_ops_console = {
48517 + .name = "kgdboc",
48518 + .read_char = kgdboc_get_char,
48519 + .write_char = kgdboc_put_char,
48520 + .pre_exception = kgdboc_pre_exp_handler,
48521 + .post_exception = kgdboc_post_exp_handler,
48522 + .is_console = 1
48523 +};
48524 +
48525 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
48526 /* This is only available if kgdboc is a built in for early debugging */
48527 static int __init kgdboc_early_init(char *opt)
48528 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
48529 index b5d779c..3622cfe 100644
48530 --- a/drivers/tty/serial/msm_serial.c
48531 +++ b/drivers/tty/serial/msm_serial.c
48532 @@ -897,7 +897,7 @@ static struct uart_driver msm_uart_driver = {
48533 .cons = MSM_CONSOLE,
48534 };
48535
48536 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
48537 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
48538
48539 static const struct of_device_id msm_uartdm_table[] = {
48540 { .compatible = "qcom,msm-uartdm" },
48541 @@ -912,7 +912,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
48542 int irq;
48543
48544 if (pdev->id == -1)
48545 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
48546 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
48547
48548 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
48549 return -ENXIO;
48550 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
48551 index f3dfa19..342f2ff 100644
48552 --- a/drivers/tty/serial/samsung.c
48553 +++ b/drivers/tty/serial/samsung.c
48554 @@ -456,11 +456,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
48555 }
48556 }
48557
48558 +static int s3c64xx_serial_startup(struct uart_port *port);
48559 static int s3c24xx_serial_startup(struct uart_port *port)
48560 {
48561 struct s3c24xx_uart_port *ourport = to_ourport(port);
48562 int ret;
48563
48564 + /* Startup sequence is different for s3c64xx and higher SoC's */
48565 + if (s3c24xx_serial_has_interrupt_mask(port))
48566 + return s3c64xx_serial_startup(port);
48567 +
48568 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
48569 port->mapbase, port->membase);
48570
48571 @@ -1127,10 +1132,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
48572 /* setup info for port */
48573 port->dev = &platdev->dev;
48574
48575 - /* Startup sequence is different for s3c64xx and higher SoC's */
48576 - if (s3c24xx_serial_has_interrupt_mask(port))
48577 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
48578 -
48579 port->uartclk = 1;
48580
48581 if (cfg->uart_flags & UPF_CONS_FLOW) {
48582 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
48583 index 0f02351..07c59c5 100644
48584 --- a/drivers/tty/serial/serial_core.c
48585 +++ b/drivers/tty/serial/serial_core.c
48586 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
48587 uart_flush_buffer(tty);
48588 uart_shutdown(tty, state);
48589 spin_lock_irqsave(&port->lock, flags);
48590 - port->count = 0;
48591 + atomic_set(&port->count, 0);
48592 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
48593 spin_unlock_irqrestore(&port->lock, flags);
48594 tty_port_tty_set(port, NULL);
48595 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48596 goto end;
48597 }
48598
48599 - port->count++;
48600 + atomic_inc(&port->count);
48601 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
48602 retval = -ENXIO;
48603 goto err_dec_count;
48604 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48605 /*
48606 * Make sure the device is in D0 state.
48607 */
48608 - if (port->count == 1)
48609 + if (atomic_read(&port->count) == 1)
48610 uart_change_pm(state, UART_PM_STATE_ON);
48611
48612 /*
48613 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48614 end:
48615 return retval;
48616 err_dec_count:
48617 - port->count--;
48618 + atomic_inc(&port->count);
48619 mutex_unlock(&port->mutex);
48620 goto end;
48621 }
48622 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
48623 index e1ce141..6d4ed80 100644
48624 --- a/drivers/tty/synclink.c
48625 +++ b/drivers/tty/synclink.c
48626 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48627
48628 if (debug_level >= DEBUG_LEVEL_INFO)
48629 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
48630 - __FILE__,__LINE__, info->device_name, info->port.count);
48631 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48632
48633 if (tty_port_close_start(&info->port, tty, filp) == 0)
48634 goto cleanup;
48635 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48636 cleanup:
48637 if (debug_level >= DEBUG_LEVEL_INFO)
48638 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
48639 - tty->driver->name, info->port.count);
48640 + tty->driver->name, atomic_read(&info->port.count));
48641
48642 } /* end of mgsl_close() */
48643
48644 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
48645
48646 mgsl_flush_buffer(tty);
48647 shutdown(info);
48648 -
48649 - info->port.count = 0;
48650 +
48651 + atomic_set(&info->port.count, 0);
48652 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48653 info->port.tty = NULL;
48654
48655 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48656
48657 if (debug_level >= DEBUG_LEVEL_INFO)
48658 printk("%s(%d):block_til_ready before block on %s count=%d\n",
48659 - __FILE__,__LINE__, tty->driver->name, port->count );
48660 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48661
48662 spin_lock_irqsave(&info->irq_spinlock, flags);
48663 if (!tty_hung_up_p(filp)) {
48664 extra_count = true;
48665 - port->count--;
48666 + atomic_dec(&port->count);
48667 }
48668 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48669 port->blocked_open++;
48670 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48671
48672 if (debug_level >= DEBUG_LEVEL_INFO)
48673 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48674 - __FILE__,__LINE__, tty->driver->name, port->count );
48675 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48676
48677 tty_unlock(tty);
48678 schedule();
48679 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48680
48681 /* FIXME: Racy on hangup during close wait */
48682 if (extra_count)
48683 - port->count++;
48684 + atomic_inc(&port->count);
48685 port->blocked_open--;
48686
48687 if (debug_level >= DEBUG_LEVEL_INFO)
48688 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48689 - __FILE__,__LINE__, tty->driver->name, port->count );
48690 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48691
48692 if (!retval)
48693 port->flags |= ASYNC_NORMAL_ACTIVE;
48694 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48695
48696 if (debug_level >= DEBUG_LEVEL_INFO)
48697 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48698 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48699 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48700
48701 /* If port is closing, signal caller to try again */
48702 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48703 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48704 spin_unlock_irqrestore(&info->netlock, flags);
48705 goto cleanup;
48706 }
48707 - info->port.count++;
48708 + atomic_inc(&info->port.count);
48709 spin_unlock_irqrestore(&info->netlock, flags);
48710
48711 - if (info->port.count == 1) {
48712 + if (atomic_read(&info->port.count) == 1) {
48713 /* 1st open on this device, init hardware */
48714 retval = startup(info);
48715 if (retval < 0)
48716 @@ -3446,8 +3446,8 @@ cleanup:
48717 if (retval) {
48718 if (tty->count == 1)
48719 info->port.tty = NULL; /* tty layer will release tty struct */
48720 - if(info->port.count)
48721 - info->port.count--;
48722 + if (atomic_read(&info->port.count))
48723 + atomic_dec(&info->port.count);
48724 }
48725
48726 return retval;
48727 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48728 unsigned short new_crctype;
48729
48730 /* return error if TTY interface open */
48731 - if (info->port.count)
48732 + if (atomic_read(&info->port.count))
48733 return -EBUSY;
48734
48735 switch (encoding)
48736 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48737
48738 /* arbitrate between network and tty opens */
48739 spin_lock_irqsave(&info->netlock, flags);
48740 - if (info->port.count != 0 || info->netcount != 0) {
48741 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48742 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48743 spin_unlock_irqrestore(&info->netlock, flags);
48744 return -EBUSY;
48745 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48746 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48747
48748 /* return error if TTY interface open */
48749 - if (info->port.count)
48750 + if (atomic_read(&info->port.count))
48751 return -EBUSY;
48752
48753 if (cmd != SIOCWANDEV)
48754 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48755 index 1abf946..1ee34fc 100644
48756 --- a/drivers/tty/synclink_gt.c
48757 +++ b/drivers/tty/synclink_gt.c
48758 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48759 tty->driver_data = info;
48760 info->port.tty = tty;
48761
48762 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48763 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48764
48765 /* If port is closing, signal caller to try again */
48766 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48767 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48768 mutex_unlock(&info->port.mutex);
48769 goto cleanup;
48770 }
48771 - info->port.count++;
48772 + atomic_inc(&info->port.count);
48773 spin_unlock_irqrestore(&info->netlock, flags);
48774
48775 - if (info->port.count == 1) {
48776 + if (atomic_read(&info->port.count) == 1) {
48777 /* 1st open on this device, init hardware */
48778 retval = startup(info);
48779 if (retval < 0) {
48780 @@ -715,8 +715,8 @@ cleanup:
48781 if (retval) {
48782 if (tty->count == 1)
48783 info->port.tty = NULL; /* tty layer will release tty struct */
48784 - if(info->port.count)
48785 - info->port.count--;
48786 + if(atomic_read(&info->port.count))
48787 + atomic_dec(&info->port.count);
48788 }
48789
48790 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48791 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48792
48793 if (sanity_check(info, tty->name, "close"))
48794 return;
48795 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48796 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48797
48798 if (tty_port_close_start(&info->port, tty, filp) == 0)
48799 goto cleanup;
48800 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48801 tty_port_close_end(&info->port, tty);
48802 info->port.tty = NULL;
48803 cleanup:
48804 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48805 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48806 }
48807
48808 static void hangup(struct tty_struct *tty)
48809 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48810 shutdown(info);
48811
48812 spin_lock_irqsave(&info->port.lock, flags);
48813 - info->port.count = 0;
48814 + atomic_set(&info->port.count, 0);
48815 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48816 info->port.tty = NULL;
48817 spin_unlock_irqrestore(&info->port.lock, flags);
48818 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48819 unsigned short new_crctype;
48820
48821 /* return error if TTY interface open */
48822 - if (info->port.count)
48823 + if (atomic_read(&info->port.count))
48824 return -EBUSY;
48825
48826 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48827 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48828
48829 /* arbitrate between network and tty opens */
48830 spin_lock_irqsave(&info->netlock, flags);
48831 - if (info->port.count != 0 || info->netcount != 0) {
48832 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48833 DBGINFO(("%s hdlc_open busy\n", dev->name));
48834 spin_unlock_irqrestore(&info->netlock, flags);
48835 return -EBUSY;
48836 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48837 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48838
48839 /* return error if TTY interface open */
48840 - if (info->port.count)
48841 + if (atomic_read(&info->port.count))
48842 return -EBUSY;
48843
48844 if (cmd != SIOCWANDEV)
48845 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48846 if (port == NULL)
48847 continue;
48848 spin_lock(&port->lock);
48849 - if ((port->port.count || port->netcount) &&
48850 + if ((atomic_read(&port->port.count) || port->netcount) &&
48851 port->pending_bh && !port->bh_running &&
48852 !port->bh_requested) {
48853 DBGISR(("%s bh queued\n", port->device_name));
48854 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48855 spin_lock_irqsave(&info->lock, flags);
48856 if (!tty_hung_up_p(filp)) {
48857 extra_count = true;
48858 - port->count--;
48859 + atomic_dec(&port->count);
48860 }
48861 spin_unlock_irqrestore(&info->lock, flags);
48862 port->blocked_open++;
48863 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48864 remove_wait_queue(&port->open_wait, &wait);
48865
48866 if (extra_count)
48867 - port->count++;
48868 + atomic_inc(&port->count);
48869 port->blocked_open--;
48870
48871 if (!retval)
48872 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48873 index dc6e969..5dc8786 100644
48874 --- a/drivers/tty/synclinkmp.c
48875 +++ b/drivers/tty/synclinkmp.c
48876 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48877
48878 if (debug_level >= DEBUG_LEVEL_INFO)
48879 printk("%s(%d):%s open(), old ref count = %d\n",
48880 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48881 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48882
48883 /* If port is closing, signal caller to try again */
48884 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48885 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48886 spin_unlock_irqrestore(&info->netlock, flags);
48887 goto cleanup;
48888 }
48889 - info->port.count++;
48890 + atomic_inc(&info->port.count);
48891 spin_unlock_irqrestore(&info->netlock, flags);
48892
48893 - if (info->port.count == 1) {
48894 + if (atomic_read(&info->port.count) == 1) {
48895 /* 1st open on this device, init hardware */
48896 retval = startup(info);
48897 if (retval < 0)
48898 @@ -796,8 +796,8 @@ cleanup:
48899 if (retval) {
48900 if (tty->count == 1)
48901 info->port.tty = NULL; /* tty layer will release tty struct */
48902 - if(info->port.count)
48903 - info->port.count--;
48904 + if(atomic_read(&info->port.count))
48905 + atomic_dec(&info->port.count);
48906 }
48907
48908 return retval;
48909 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48910
48911 if (debug_level >= DEBUG_LEVEL_INFO)
48912 printk("%s(%d):%s close() entry, count=%d\n",
48913 - __FILE__,__LINE__, info->device_name, info->port.count);
48914 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48915
48916 if (tty_port_close_start(&info->port, tty, filp) == 0)
48917 goto cleanup;
48918 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48919 cleanup:
48920 if (debug_level >= DEBUG_LEVEL_INFO)
48921 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48922 - tty->driver->name, info->port.count);
48923 + tty->driver->name, atomic_read(&info->port.count));
48924 }
48925
48926 /* Called by tty_hangup() when a hangup is signaled.
48927 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48928 shutdown(info);
48929
48930 spin_lock_irqsave(&info->port.lock, flags);
48931 - info->port.count = 0;
48932 + atomic_set(&info->port.count, 0);
48933 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48934 info->port.tty = NULL;
48935 spin_unlock_irqrestore(&info->port.lock, flags);
48936 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48937 unsigned short new_crctype;
48938
48939 /* return error if TTY interface open */
48940 - if (info->port.count)
48941 + if (atomic_read(&info->port.count))
48942 return -EBUSY;
48943
48944 switch (encoding)
48945 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48946
48947 /* arbitrate between network and tty opens */
48948 spin_lock_irqsave(&info->netlock, flags);
48949 - if (info->port.count != 0 || info->netcount != 0) {
48950 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48951 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48952 spin_unlock_irqrestore(&info->netlock, flags);
48953 return -EBUSY;
48954 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48955 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48956
48957 /* return error if TTY interface open */
48958 - if (info->port.count)
48959 + if (atomic_read(&info->port.count))
48960 return -EBUSY;
48961
48962 if (cmd != SIOCWANDEV)
48963 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48964 * do not request bottom half processing if the
48965 * device is not open in a normal mode.
48966 */
48967 - if ( port && (port->port.count || port->netcount) &&
48968 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48969 port->pending_bh && !port->bh_running &&
48970 !port->bh_requested ) {
48971 if ( debug_level >= DEBUG_LEVEL_ISR )
48972 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48973
48974 if (debug_level >= DEBUG_LEVEL_INFO)
48975 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48976 - __FILE__,__LINE__, tty->driver->name, port->count );
48977 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48978
48979 spin_lock_irqsave(&info->lock, flags);
48980 if (!tty_hung_up_p(filp)) {
48981 extra_count = true;
48982 - port->count--;
48983 + atomic_dec(&port->count);
48984 }
48985 spin_unlock_irqrestore(&info->lock, flags);
48986 port->blocked_open++;
48987 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48988
48989 if (debug_level >= DEBUG_LEVEL_INFO)
48990 printk("%s(%d):%s block_til_ready() count=%d\n",
48991 - __FILE__,__LINE__, tty->driver->name, port->count );
48992 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48993
48994 tty_unlock(tty);
48995 schedule();
48996 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48997 remove_wait_queue(&port->open_wait, &wait);
48998
48999 if (extra_count)
49000 - port->count++;
49001 + atomic_inc(&port->count);
49002 port->blocked_open--;
49003
49004 if (debug_level >= DEBUG_LEVEL_INFO)
49005 printk("%s(%d):%s block_til_ready() after, count=%d\n",
49006 - __FILE__,__LINE__, tty->driver->name, port->count );
49007 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
49008
49009 if (!retval)
49010 port->flags |= ASYNC_NORMAL_ACTIVE;
49011 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
49012 index 40a9fe9..a3f10cc 100644
49013 --- a/drivers/tty/sysrq.c
49014 +++ b/drivers/tty/sysrq.c
49015 @@ -1075,7 +1075,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
49016 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
49017 size_t count, loff_t *ppos)
49018 {
49019 - if (count) {
49020 + if (count && capable(CAP_SYS_ADMIN)) {
49021 char c;
49022
49023 if (get_user(c, buf))
49024 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
49025 index c74a00a..02cf211a 100644
49026 --- a/drivers/tty/tty_io.c
49027 +++ b/drivers/tty/tty_io.c
49028 @@ -3474,7 +3474,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
49029
49030 void tty_default_fops(struct file_operations *fops)
49031 {
49032 - *fops = tty_fops;
49033 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
49034 }
49035
49036 /*
49037 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
49038 index 6458e11..6cfc218 100644
49039 --- a/drivers/tty/tty_ldisc.c
49040 +++ b/drivers/tty/tty_ldisc.c
49041 @@ -72,7 +72,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
49042 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
49043 tty_ldiscs[disc] = new_ldisc;
49044 new_ldisc->num = disc;
49045 - new_ldisc->refcount = 0;
49046 + atomic_set(&new_ldisc->refcount, 0);
49047 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
49048
49049 return ret;
49050 @@ -100,7 +100,7 @@ int tty_unregister_ldisc(int disc)
49051 return -EINVAL;
49052
49053 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
49054 - if (tty_ldiscs[disc]->refcount)
49055 + if (atomic_read(&tty_ldiscs[disc]->refcount))
49056 ret = -EBUSY;
49057 else
49058 tty_ldiscs[disc] = NULL;
49059 @@ -121,7 +121,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
49060 if (ldops) {
49061 ret = ERR_PTR(-EAGAIN);
49062 if (try_module_get(ldops->owner)) {
49063 - ldops->refcount++;
49064 + atomic_inc(&ldops->refcount);
49065 ret = ldops;
49066 }
49067 }
49068 @@ -134,7 +134,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
49069 unsigned long flags;
49070
49071 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
49072 - ldops->refcount--;
49073 + atomic_dec(&ldops->refcount);
49074 module_put(ldops->owner);
49075 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
49076 }
49077 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
49078 index f597e88..b7f68ed 100644
49079 --- a/drivers/tty/tty_port.c
49080 +++ b/drivers/tty/tty_port.c
49081 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
49082 unsigned long flags;
49083
49084 spin_lock_irqsave(&port->lock, flags);
49085 - port->count = 0;
49086 + atomic_set(&port->count, 0);
49087 port->flags &= ~ASYNC_NORMAL_ACTIVE;
49088 tty = port->tty;
49089 if (tty)
49090 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
49091 /* The port lock protects the port counts */
49092 spin_lock_irqsave(&port->lock, flags);
49093 if (!tty_hung_up_p(filp))
49094 - port->count--;
49095 + atomic_dec(&port->count);
49096 port->blocked_open++;
49097 spin_unlock_irqrestore(&port->lock, flags);
49098
49099 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
49100 we must not mess that up further */
49101 spin_lock_irqsave(&port->lock, flags);
49102 if (!tty_hung_up_p(filp))
49103 - port->count++;
49104 + atomic_inc(&port->count);
49105 port->blocked_open--;
49106 if (retval == 0)
49107 port->flags |= ASYNC_NORMAL_ACTIVE;
49108 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
49109 return 0;
49110 }
49111
49112 - if (tty->count == 1 && port->count != 1) {
49113 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
49114 printk(KERN_WARNING
49115 "tty_port_close_start: tty->count = 1 port count = %d.\n",
49116 - port->count);
49117 - port->count = 1;
49118 + atomic_read(&port->count));
49119 + atomic_set(&port->count, 1);
49120 }
49121 - if (--port->count < 0) {
49122 + if (atomic_dec_return(&port->count) < 0) {
49123 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
49124 - port->count);
49125 - port->count = 0;
49126 + atomic_read(&port->count));
49127 + atomic_set(&port->count, 0);
49128 }
49129
49130 - if (port->count) {
49131 + if (atomic_read(&port->count)) {
49132 spin_unlock_irqrestore(&port->lock, flags);
49133 if (port->ops->drop)
49134 port->ops->drop(port);
49135 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
49136 {
49137 spin_lock_irq(&port->lock);
49138 if (!tty_hung_up_p(filp))
49139 - ++port->count;
49140 + atomic_inc(&port->count);
49141 spin_unlock_irq(&port->lock);
49142 tty_port_tty_set(port, tty);
49143
49144 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
49145 index d0e3a44..5f8b754 100644
49146 --- a/drivers/tty/vt/keyboard.c
49147 +++ b/drivers/tty/vt/keyboard.c
49148 @@ -641,6 +641,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
49149 kbd->kbdmode == VC_OFF) &&
49150 value != KVAL(K_SAK))
49151 return; /* SAK is allowed even in raw mode */
49152 +
49153 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
49154 + {
49155 + void *func = fn_handler[value];
49156 + if (func == fn_show_state || func == fn_show_ptregs ||
49157 + func == fn_show_mem)
49158 + return;
49159 + }
49160 +#endif
49161 +
49162 fn_handler[value](vc);
49163 }
49164
49165 @@ -1776,9 +1786,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
49166 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
49167 return -EFAULT;
49168
49169 - if (!capable(CAP_SYS_TTY_CONFIG))
49170 - perm = 0;
49171 -
49172 switch (cmd) {
49173 case KDGKBENT:
49174 /* Ensure another thread doesn't free it under us */
49175 @@ -1793,6 +1800,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
49176 spin_unlock_irqrestore(&kbd_event_lock, flags);
49177 return put_user(val, &user_kbe->kb_value);
49178 case KDSKBENT:
49179 + if (!capable(CAP_SYS_TTY_CONFIG))
49180 + perm = 0;
49181 +
49182 if (!perm)
49183 return -EPERM;
49184 if (!i && v == K_NOSUCHMAP) {
49185 @@ -1883,9 +1893,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
49186 int i, j, k;
49187 int ret;
49188
49189 - if (!capable(CAP_SYS_TTY_CONFIG))
49190 - perm = 0;
49191 -
49192 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
49193 if (!kbs) {
49194 ret = -ENOMEM;
49195 @@ -1919,6 +1926,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
49196 kfree(kbs);
49197 return ((p && *p) ? -EOVERFLOW : 0);
49198 case KDSKBSENT:
49199 + if (!capable(CAP_SYS_TTY_CONFIG))
49200 + perm = 0;
49201 +
49202 if (!perm) {
49203 ret = -EPERM;
49204 goto reterr;
49205 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
49206 index 0e808cf..d7d274b 100644
49207 --- a/drivers/uio/uio.c
49208 +++ b/drivers/uio/uio.c
49209 @@ -25,6 +25,7 @@
49210 #include <linux/kobject.h>
49211 #include <linux/cdev.h>
49212 #include <linux/uio_driver.h>
49213 +#include <asm/local.h>
49214
49215 #define UIO_MAX_DEVICES (1U << MINORBITS)
49216
49217 @@ -32,7 +33,7 @@ struct uio_device {
49218 struct module *owner;
49219 struct device *dev;
49220 int minor;
49221 - atomic_t event;
49222 + atomic_unchecked_t event;
49223 struct fasync_struct *async_queue;
49224 wait_queue_head_t wait;
49225 struct uio_info *info;
49226 @@ -243,7 +244,7 @@ static ssize_t event_show(struct device *dev,
49227 struct device_attribute *attr, char *buf)
49228 {
49229 struct uio_device *idev = dev_get_drvdata(dev);
49230 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
49231 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
49232 }
49233 static DEVICE_ATTR_RO(event);
49234
49235 @@ -401,7 +402,7 @@ void uio_event_notify(struct uio_info *info)
49236 {
49237 struct uio_device *idev = info->uio_dev;
49238
49239 - atomic_inc(&idev->event);
49240 + atomic_inc_unchecked(&idev->event);
49241 wake_up_interruptible(&idev->wait);
49242 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
49243 }
49244 @@ -454,7 +455,7 @@ static int uio_open(struct inode *inode, struct file *filep)
49245 }
49246
49247 listener->dev = idev;
49248 - listener->event_count = atomic_read(&idev->event);
49249 + listener->event_count = atomic_read_unchecked(&idev->event);
49250 filep->private_data = listener;
49251
49252 if (idev->info->open) {
49253 @@ -505,7 +506,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
49254 return -EIO;
49255
49256 poll_wait(filep, &idev->wait, wait);
49257 - if (listener->event_count != atomic_read(&idev->event))
49258 + if (listener->event_count != atomic_read_unchecked(&idev->event))
49259 return POLLIN | POLLRDNORM;
49260 return 0;
49261 }
49262 @@ -530,7 +531,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
49263 do {
49264 set_current_state(TASK_INTERRUPTIBLE);
49265
49266 - event_count = atomic_read(&idev->event);
49267 + event_count = atomic_read_unchecked(&idev->event);
49268 if (event_count != listener->event_count) {
49269 if (copy_to_user(buf, &event_count, count))
49270 retval = -EFAULT;
49271 @@ -587,9 +588,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
49272 static int uio_find_mem_index(struct vm_area_struct *vma)
49273 {
49274 struct uio_device *idev = vma->vm_private_data;
49275 + unsigned long size;
49276
49277 if (vma->vm_pgoff < MAX_UIO_MAPS) {
49278 - if (idev->info->mem[vma->vm_pgoff].size == 0)
49279 + size = idev->info->mem[vma->vm_pgoff].size;
49280 + if (size == 0)
49281 + return -1;
49282 + if (vma->vm_end - vma->vm_start > size)
49283 return -1;
49284 return (int)vma->vm_pgoff;
49285 }
49286 @@ -647,6 +652,8 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
49287 return -EINVAL;
49288 mem = idev->info->mem + mi;
49289
49290 + if (mem->addr & ~PAGE_MASK)
49291 + return -ENODEV;
49292 if (vma->vm_end - vma->vm_start > mem->size)
49293 return -EINVAL;
49294
49295 @@ -818,7 +825,7 @@ int __uio_register_device(struct module *owner,
49296 idev->owner = owner;
49297 idev->info = info;
49298 init_waitqueue_head(&idev->wait);
49299 - atomic_set(&idev->event, 0);
49300 + atomic_set_unchecked(&idev->event, 0);
49301
49302 ret = uio_get_minor(idev);
49303 if (ret)
49304 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
49305 index 8a7eb77..c00402f 100644
49306 --- a/drivers/usb/atm/cxacru.c
49307 +++ b/drivers/usb/atm/cxacru.c
49308 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
49309 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
49310 if (ret < 2)
49311 return -EINVAL;
49312 - if (index < 0 || index > 0x7f)
49313 + if (index > 0x7f)
49314 return -EINVAL;
49315 pos += tmp;
49316
49317 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
49318 index 25a7bfc..57f3cf5 100644
49319 --- a/drivers/usb/atm/usbatm.c
49320 +++ b/drivers/usb/atm/usbatm.c
49321 @@ -331,7 +331,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49322 if (printk_ratelimit())
49323 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
49324 __func__, vpi, vci);
49325 - atomic_inc(&vcc->stats->rx_err);
49326 + atomic_inc_unchecked(&vcc->stats->rx_err);
49327 return;
49328 }
49329
49330 @@ -358,7 +358,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49331 if (length > ATM_MAX_AAL5_PDU) {
49332 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
49333 __func__, length, vcc);
49334 - atomic_inc(&vcc->stats->rx_err);
49335 + atomic_inc_unchecked(&vcc->stats->rx_err);
49336 goto out;
49337 }
49338
49339 @@ -367,14 +367,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49340 if (sarb->len < pdu_length) {
49341 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
49342 __func__, pdu_length, sarb->len, vcc);
49343 - atomic_inc(&vcc->stats->rx_err);
49344 + atomic_inc_unchecked(&vcc->stats->rx_err);
49345 goto out;
49346 }
49347
49348 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
49349 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
49350 __func__, vcc);
49351 - atomic_inc(&vcc->stats->rx_err);
49352 + atomic_inc_unchecked(&vcc->stats->rx_err);
49353 goto out;
49354 }
49355
49356 @@ -386,7 +386,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49357 if (printk_ratelimit())
49358 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
49359 __func__, length);
49360 - atomic_inc(&vcc->stats->rx_drop);
49361 + atomic_inc_unchecked(&vcc->stats->rx_drop);
49362 goto out;
49363 }
49364
49365 @@ -414,7 +414,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49366
49367 vcc->push(vcc, skb);
49368
49369 - atomic_inc(&vcc->stats->rx);
49370 + atomic_inc_unchecked(&vcc->stats->rx);
49371 out:
49372 skb_trim(sarb, 0);
49373 }
49374 @@ -612,7 +612,7 @@ static void usbatm_tx_process(unsigned long data)
49375 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
49376
49377 usbatm_pop(vcc, skb);
49378 - atomic_inc(&vcc->stats->tx);
49379 + atomic_inc_unchecked(&vcc->stats->tx);
49380
49381 skb = skb_dequeue(&instance->sndqueue);
49382 }
49383 @@ -756,11 +756,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
49384 if (!left--)
49385 return sprintf(page,
49386 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
49387 - atomic_read(&atm_dev->stats.aal5.tx),
49388 - atomic_read(&atm_dev->stats.aal5.tx_err),
49389 - atomic_read(&atm_dev->stats.aal5.rx),
49390 - atomic_read(&atm_dev->stats.aal5.rx_err),
49391 - atomic_read(&atm_dev->stats.aal5.rx_drop));
49392 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
49393 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
49394 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
49395 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
49396 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
49397
49398 if (!left--) {
49399 if (instance->disconnected)
49400 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
49401 index 2a3bbdf..91d72cf 100644
49402 --- a/drivers/usb/core/devices.c
49403 +++ b/drivers/usb/core/devices.c
49404 @@ -126,7 +126,7 @@ static const char format_endpt[] =
49405 * time it gets called.
49406 */
49407 static struct device_connect_event {
49408 - atomic_t count;
49409 + atomic_unchecked_t count;
49410 wait_queue_head_t wait;
49411 } device_event = {
49412 .count = ATOMIC_INIT(1),
49413 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
49414
49415 void usbfs_conn_disc_event(void)
49416 {
49417 - atomic_add(2, &device_event.count);
49418 + atomic_add_unchecked(2, &device_event.count);
49419 wake_up(&device_event.wait);
49420 }
49421
49422 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
49423
49424 poll_wait(file, &device_event.wait, wait);
49425
49426 - event_count = atomic_read(&device_event.count);
49427 + event_count = atomic_read_unchecked(&device_event.count);
49428 if (file->f_version != event_count) {
49429 file->f_version = event_count;
49430 return POLLIN | POLLRDNORM;
49431 diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
49432 index 71dc5d7..d4c488f 100644
49433 --- a/drivers/usb/core/devio.c
49434 +++ b/drivers/usb/core/devio.c
49435 @@ -187,7 +187,7 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
49436 struct dev_state *ps = file->private_data;
49437 struct usb_device *dev = ps->dev;
49438 ssize_t ret = 0;
49439 - unsigned len;
49440 + size_t len;
49441 loff_t pos;
49442 int i;
49443
49444 @@ -229,22 +229,22 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
49445 for (i = 0; nbytes && i < dev->descriptor.bNumConfigurations; i++) {
49446 struct usb_config_descriptor *config =
49447 (struct usb_config_descriptor *)dev->rawdescriptors[i];
49448 - unsigned int length = le16_to_cpu(config->wTotalLength);
49449 + size_t length = le16_to_cpu(config->wTotalLength);
49450
49451 if (*ppos < pos + length) {
49452
49453 /* The descriptor may claim to be longer than it
49454 * really is. Here is the actual allocated length. */
49455 - unsigned alloclen =
49456 + size_t alloclen =
49457 le16_to_cpu(dev->config[i].desc.wTotalLength);
49458
49459 - len = length - (*ppos - pos);
49460 + len = length + pos - *ppos;
49461 if (len > nbytes)
49462 len = nbytes;
49463
49464 /* Simply don't write (skip over) unallocated parts */
49465 if (alloclen > (*ppos - pos)) {
49466 - alloclen -= (*ppos - pos);
49467 + alloclen = alloclen + pos - *ppos;
49468 if (copy_to_user(buf,
49469 dev->rawdescriptors[i] + (*ppos - pos),
49470 min(len, alloclen))) {
49471 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
49472 index f20a044..d1059aa 100644
49473 --- a/drivers/usb/core/hcd.c
49474 +++ b/drivers/usb/core/hcd.c
49475 @@ -1552,7 +1552,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49476 */
49477 usb_get_urb(urb);
49478 atomic_inc(&urb->use_count);
49479 - atomic_inc(&urb->dev->urbnum);
49480 + atomic_inc_unchecked(&urb->dev->urbnum);
49481 usbmon_urb_submit(&hcd->self, urb);
49482
49483 /* NOTE requirements on root-hub callers (usbfs and the hub
49484 @@ -1579,7 +1579,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49485 urb->hcpriv = NULL;
49486 INIT_LIST_HEAD(&urb->urb_list);
49487 atomic_dec(&urb->use_count);
49488 - atomic_dec(&urb->dev->urbnum);
49489 + atomic_dec_unchecked(&urb->dev->urbnum);
49490 if (atomic_read(&urb->reject))
49491 wake_up(&usb_kill_urb_queue);
49492 usb_put_urb(urb);
49493 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
49494 index c5c3667..e54e5cd 100644
49495 --- a/drivers/usb/core/hub.c
49496 +++ b/drivers/usb/core/hub.c
49497 @@ -27,6 +27,7 @@
49498 #include <linux/freezer.h>
49499 #include <linux/random.h>
49500 #include <linux/pm_qos.h>
49501 +#include <linux/grsecurity.h>
49502
49503 #include <asm/uaccess.h>
49504 #include <asm/byteorder.h>
49505 @@ -4467,6 +4468,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
49506 goto done;
49507 return;
49508 }
49509 +
49510 + if (gr_handle_new_usb())
49511 + goto done;
49512 +
49513 if (hub_is_superspeed(hub->hdev))
49514 unit_load = 150;
49515 else
49516 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
49517 index 82927e1..4993dbf 100644
49518 --- a/drivers/usb/core/message.c
49519 +++ b/drivers/usb/core/message.c
49520 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
49521 * Return: If successful, the number of bytes transferred. Otherwise, a negative
49522 * error number.
49523 */
49524 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49525 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49526 __u8 requesttype, __u16 value, __u16 index, void *data,
49527 __u16 size, int timeout)
49528 {
49529 @@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg);
49530 * If successful, 0. Otherwise a negative error number. The number of actual
49531 * bytes transferred will be stored in the @actual_length paramater.
49532 */
49533 -int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
49534 +int __intentional_overflow(-1) usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
49535 void *data, int len, int *actual_length, int timeout)
49536 {
49537 return usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout);
49538 @@ -221,7 +221,7 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg);
49539 * bytes transferred will be stored in the @actual_length paramater.
49540 *
49541 */
49542 -int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
49543 +int __intentional_overflow(-1) usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
49544 void *data, int len, int *actual_length, int timeout)
49545 {
49546 struct urb *urb;
49547 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
49548 index ca516ac..6c36ee4 100644
49549 --- a/drivers/usb/core/sysfs.c
49550 +++ b/drivers/usb/core/sysfs.c
49551 @@ -236,7 +236,7 @@ static ssize_t urbnum_show(struct device *dev, struct device_attribute *attr,
49552 struct usb_device *udev;
49553
49554 udev = to_usb_device(dev);
49555 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
49556 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
49557 }
49558 static DEVICE_ATTR_RO(urbnum);
49559
49560 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
49561 index 0a6ee2e..6f8d7e8 100644
49562 --- a/drivers/usb/core/usb.c
49563 +++ b/drivers/usb/core/usb.c
49564 @@ -433,7 +433,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
49565 set_dev_node(&dev->dev, dev_to_node(bus->controller));
49566 dev->state = USB_STATE_ATTACHED;
49567 dev->lpm_disable_count = 1;
49568 - atomic_set(&dev->urbnum, 0);
49569 + atomic_set_unchecked(&dev->urbnum, 0);
49570
49571 INIT_LIST_HEAD(&dev->ep0.urb_list);
49572 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
49573 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
49574 index 02e44fc..3c4fe64 100644
49575 --- a/drivers/usb/dwc3/gadget.c
49576 +++ b/drivers/usb/dwc3/gadget.c
49577 @@ -532,8 +532,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
49578 if (!usb_endpoint_xfer_isoc(desc))
49579 return 0;
49580
49581 - memset(&trb_link, 0, sizeof(trb_link));
49582 -
49583 /* Link TRB for ISOC. The HWO bit is never reset */
49584 trb_st_hw = &dep->trb_pool[0];
49585
49586 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
49587 index 5e29dde..eca992f 100644
49588 --- a/drivers/usb/early/ehci-dbgp.c
49589 +++ b/drivers/usb/early/ehci-dbgp.c
49590 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
49591
49592 #ifdef CONFIG_KGDB
49593 static struct kgdb_io kgdbdbgp_io_ops;
49594 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
49595 +static struct kgdb_io kgdbdbgp_io_ops_console;
49596 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
49597 #else
49598 #define dbgp_kgdb_mode (0)
49599 #endif
49600 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
49601 .write_char = kgdbdbgp_write_char,
49602 };
49603
49604 +static struct kgdb_io kgdbdbgp_io_ops_console = {
49605 + .name = "kgdbdbgp",
49606 + .read_char = kgdbdbgp_read_char,
49607 + .write_char = kgdbdbgp_write_char,
49608 + .is_console = 1
49609 +};
49610 +
49611 static int kgdbdbgp_wait_time;
49612
49613 static int __init kgdbdbgp_parse_config(char *str)
49614 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
49615 ptr++;
49616 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
49617 }
49618 - kgdb_register_io_module(&kgdbdbgp_io_ops);
49619 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
49620 + if (early_dbgp_console.index != -1)
49621 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
49622 + else
49623 + kgdb_register_io_module(&kgdbdbgp_io_ops);
49624
49625 return 0;
49626 }
49627 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
49628 index b369292..9f3ba40 100644
49629 --- a/drivers/usb/gadget/u_serial.c
49630 +++ b/drivers/usb/gadget/u_serial.c
49631 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49632 spin_lock_irq(&port->port_lock);
49633
49634 /* already open? Great. */
49635 - if (port->port.count) {
49636 + if (atomic_read(&port->port.count)) {
49637 status = 0;
49638 - port->port.count++;
49639 + atomic_inc(&port->port.count);
49640
49641 /* currently opening/closing? wait ... */
49642 } else if (port->openclose) {
49643 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49644 tty->driver_data = port;
49645 port->port.tty = tty;
49646
49647 - port->port.count = 1;
49648 + atomic_set(&port->port.count, 1);
49649 port->openclose = false;
49650
49651 /* if connected, start the I/O stream */
49652 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49653
49654 spin_lock_irq(&port->port_lock);
49655
49656 - if (port->port.count != 1) {
49657 - if (port->port.count == 0)
49658 + if (atomic_read(&port->port.count) != 1) {
49659 + if (atomic_read(&port->port.count) == 0)
49660 WARN_ON(1);
49661 else
49662 - --port->port.count;
49663 + atomic_dec(&port->port.count);
49664 goto exit;
49665 }
49666
49667 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49668 * and sleep if necessary
49669 */
49670 port->openclose = true;
49671 - port->port.count = 0;
49672 + atomic_set(&port->port.count, 0);
49673
49674 gser = port->port_usb;
49675 if (gser && gser->disconnect)
49676 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
49677 int cond;
49678
49679 spin_lock_irq(&port->port_lock);
49680 - cond = (port->port.count == 0) && !port->openclose;
49681 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
49682 spin_unlock_irq(&port->port_lock);
49683 return cond;
49684 }
49685 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
49686 /* if it's already open, start I/O ... and notify the serial
49687 * protocol about open/close status (connect/disconnect).
49688 */
49689 - if (port->port.count) {
49690 + if (atomic_read(&port->port.count)) {
49691 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
49692 gs_start_io(port);
49693 if (gser->connect)
49694 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
49695
49696 port->port_usb = NULL;
49697 gser->ioport = NULL;
49698 - if (port->port.count > 0 || port->openclose) {
49699 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
49700 wake_up_interruptible(&port->drain_wait);
49701 if (port->port.tty)
49702 tty_hangup(port->port.tty);
49703 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
49704
49705 /* finally, free any unused/unusable I/O buffers */
49706 spin_lock_irqsave(&port->port_lock, flags);
49707 - if (port->port.count == 0 && !port->openclose)
49708 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
49709 gs_buf_free(&port->port_write_buf);
49710 gs_free_requests(gser->out, &port->read_pool, NULL);
49711 gs_free_requests(gser->out, &port->read_queue, NULL);
49712 diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
49713 index 835fc08..f8b22bf 100644
49714 --- a/drivers/usb/host/ehci-hub.c
49715 +++ b/drivers/usb/host/ehci-hub.c
49716 @@ -762,7 +762,7 @@ static struct urb *request_single_step_set_feature_urb(
49717 urb->transfer_flags = URB_DIR_IN;
49718 usb_get_urb(urb);
49719 atomic_inc(&urb->use_count);
49720 - atomic_inc(&urb->dev->urbnum);
49721 + atomic_inc_unchecked(&urb->dev->urbnum);
49722 urb->setup_dma = dma_map_single(
49723 hcd->self.controller,
49724 urb->setup_packet,
49725 @@ -829,7 +829,7 @@ static int ehset_single_step_set_feature(struct usb_hcd *hcd, int port)
49726 urb->status = -EINPROGRESS;
49727 usb_get_urb(urb);
49728 atomic_inc(&urb->use_count);
49729 - atomic_inc(&urb->dev->urbnum);
49730 + atomic_inc_unchecked(&urb->dev->urbnum);
49731 retval = submit_single_step_set_feature(hcd, urb, 0);
49732 if (!retval && !wait_for_completion_timeout(&done,
49733 msecs_to_jiffies(2000))) {
49734 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49735 index ba6a5d6..f88f7f3 100644
49736 --- a/drivers/usb/misc/appledisplay.c
49737 +++ b/drivers/usb/misc/appledisplay.c
49738 @@ -83,7 +83,7 @@ struct appledisplay {
49739 spinlock_t lock;
49740 };
49741
49742 -static atomic_t count_displays = ATOMIC_INIT(0);
49743 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49744 static struct workqueue_struct *wq;
49745
49746 static void appledisplay_complete(struct urb *urb)
49747 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49748
49749 /* Register backlight device */
49750 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49751 - atomic_inc_return(&count_displays) - 1);
49752 + atomic_inc_return_unchecked(&count_displays) - 1);
49753 memset(&props, 0, sizeof(struct backlight_properties));
49754 props.type = BACKLIGHT_RAW;
49755 props.max_brightness = 0xff;
49756 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49757 index c69bb50..215ef37 100644
49758 --- a/drivers/usb/serial/console.c
49759 +++ b/drivers/usb/serial/console.c
49760 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49761
49762 info->port = port;
49763
49764 - ++port->port.count;
49765 + atomic_inc(&port->port.count);
49766 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49767 if (serial->type->set_termios) {
49768 /*
49769 @@ -170,7 +170,7 @@ static int usb_console_setup(struct console *co, char *options)
49770 }
49771 /* Now that any required fake tty operations are completed restore
49772 * the tty port count */
49773 - --port->port.count;
49774 + atomic_dec(&port->port.count);
49775 /* The console is special in terms of closing the device so
49776 * indicate this port is now acting as a system console. */
49777 port->port.console = 1;
49778 @@ -183,7 +183,7 @@ static int usb_console_setup(struct console *co, char *options)
49779 free_tty:
49780 kfree(tty);
49781 reset_open_count:
49782 - port->port.count = 0;
49783 + atomic_set(&port->port.count, 0);
49784 usb_autopm_put_interface(serial->interface);
49785 error_get_interface:
49786 usb_serial_put(serial);
49787 @@ -194,7 +194,7 @@ static int usb_console_setup(struct console *co, char *options)
49788 static void usb_console_write(struct console *co,
49789 const char *buf, unsigned count)
49790 {
49791 - static struct usbcons_info *info = &usbcons_info;
49792 + struct usbcons_info *info = &usbcons_info;
49793 struct usb_serial_port *port = info->port;
49794 struct usb_serial *serial;
49795 int retval = -ENODEV;
49796 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49797 index 75f70f0..d467e1a 100644
49798 --- a/drivers/usb/storage/usb.h
49799 +++ b/drivers/usb/storage/usb.h
49800 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49801 __u8 useProtocol;
49802 __u8 useTransport;
49803 int (*initFunction)(struct us_data *);
49804 -};
49805 +} __do_const;
49806
49807
49808 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49809 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49810 index cf250c2..ad9d904 100644
49811 --- a/drivers/usb/wusbcore/wa-hc.h
49812 +++ b/drivers/usb/wusbcore/wa-hc.h
49813 @@ -199,7 +199,7 @@ struct wahc {
49814 spinlock_t xfer_list_lock;
49815 struct work_struct xfer_enqueue_work;
49816 struct work_struct xfer_error_work;
49817 - atomic_t xfer_id_count;
49818 + atomic_unchecked_t xfer_id_count;
49819 };
49820
49821
49822 @@ -255,7 +255,7 @@ static inline void wa_init(struct wahc *wa)
49823 spin_lock_init(&wa->xfer_list_lock);
49824 INIT_WORK(&wa->xfer_enqueue_work, wa_urb_enqueue_run);
49825 INIT_WORK(&wa->xfer_error_work, wa_process_errored_transfers_run);
49826 - atomic_set(&wa->xfer_id_count, 1);
49827 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49828 }
49829
49830 /**
49831 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49832 index 3dcf66f..8faaf6e 100644
49833 --- a/drivers/usb/wusbcore/wa-xfer.c
49834 +++ b/drivers/usb/wusbcore/wa-xfer.c
49835 @@ -300,7 +300,7 @@ out:
49836 */
49837 static void wa_xfer_id_init(struct wa_xfer *xfer)
49838 {
49839 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49840 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49841 }
49842
49843 /*
49844 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49845 index 1eab4ac..e21efc9 100644
49846 --- a/drivers/vfio/vfio.c
49847 +++ b/drivers/vfio/vfio.c
49848 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49849 return 0;
49850
49851 /* TODO Prevent device auto probing */
49852 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49853 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49854 iommu_group_id(group->iommu_group));
49855
49856 return 0;
49857 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49858 index 5174eba..86e764a 100644
49859 --- a/drivers/vhost/vringh.c
49860 +++ b/drivers/vhost/vringh.c
49861 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49862
49863 static inline int putu16_kern(u16 *p, u16 val)
49864 {
49865 - ACCESS_ONCE(*p) = val;
49866 + ACCESS_ONCE_RW(*p) = val;
49867 return 0;
49868 }
49869
49870 diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
49871 index e43401a..dd49b3f 100644
49872 --- a/drivers/video/arcfb.c
49873 +++ b/drivers/video/arcfb.c
49874 @@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
49875 return -ENOSPC;
49876
49877 err = 0;
49878 - if ((count + p) > fbmemlength) {
49879 + if (count > (fbmemlength - p)) {
49880 count = fbmemlength - p;
49881 err = -ENOSPC;
49882 }
49883 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49884 index a4dfe8c..297ddd9 100644
49885 --- a/drivers/video/aty/aty128fb.c
49886 +++ b/drivers/video/aty/aty128fb.c
49887 @@ -149,7 +149,7 @@ enum {
49888 };
49889
49890 /* Must match above enum */
49891 -static char * const r128_family[] = {
49892 +static const char * const r128_family[] = {
49893 "AGP",
49894 "PCI",
49895 "PRO AGP",
49896 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49897 index 9b0f12c..024673d 100644
49898 --- a/drivers/video/aty/atyfb_base.c
49899 +++ b/drivers/video/aty/atyfb_base.c
49900 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49901 par->accel_flags = var->accel_flags; /* hack */
49902
49903 if (var->accel_flags) {
49904 - info->fbops->fb_sync = atyfb_sync;
49905 + pax_open_kernel();
49906 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49907 + pax_close_kernel();
49908 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49909 } else {
49910 - info->fbops->fb_sync = NULL;
49911 + pax_open_kernel();
49912 + *(void **)&info->fbops->fb_sync = NULL;
49913 + pax_close_kernel();
49914 info->flags |= FBINFO_HWACCEL_DISABLED;
49915 }
49916
49917 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49918 index 95ec042..e6affdd 100644
49919 --- a/drivers/video/aty/mach64_cursor.c
49920 +++ b/drivers/video/aty/mach64_cursor.c
49921 @@ -7,6 +7,7 @@
49922 #include <linux/string.h>
49923
49924 #include <asm/io.h>
49925 +#include <asm/pgtable.h>
49926
49927 #ifdef __sparc__
49928 #include <asm/fbio.h>
49929 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49930 info->sprite.buf_align = 16; /* and 64 lines tall. */
49931 info->sprite.flags = FB_PIXMAP_IO;
49932
49933 - info->fbops->fb_cursor = atyfb_cursor;
49934 + pax_open_kernel();
49935 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49936 + pax_close_kernel();
49937
49938 return 0;
49939 }
49940 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49941 index bca6ccc..252107e 100644
49942 --- a/drivers/video/backlight/kb3886_bl.c
49943 +++ b/drivers/video/backlight/kb3886_bl.c
49944 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49945 static unsigned long kb3886bl_flags;
49946 #define KB3886BL_SUSPENDED 0x01
49947
49948 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49949 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49950 {
49951 .ident = "Sahara Touch-iT",
49952 .matches = {
49953 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49954 index 900aa4e..6d49418 100644
49955 --- a/drivers/video/fb_defio.c
49956 +++ b/drivers/video/fb_defio.c
49957 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49958
49959 BUG_ON(!fbdefio);
49960 mutex_init(&fbdefio->lock);
49961 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49962 + pax_open_kernel();
49963 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49964 + pax_close_kernel();
49965 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49966 INIT_LIST_HEAD(&fbdefio->pagelist);
49967 if (fbdefio->delay == 0) /* set a default of 1 s */
49968 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49969 page->mapping = NULL;
49970 }
49971
49972 - info->fbops->fb_mmap = NULL;
49973 + *(void **)&info->fbops->fb_mmap = NULL;
49974 mutex_destroy(&fbdefio->lock);
49975 }
49976 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49977 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49978 index dacaf74..8478a46 100644
49979 --- a/drivers/video/fbmem.c
49980 +++ b/drivers/video/fbmem.c
49981 @@ -433,7 +433,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49982 image->dx += image->width + 8;
49983 }
49984 } else if (rotate == FB_ROTATE_UD) {
49985 - for (x = 0; x < num && image->dx >= 0; x++) {
49986 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49987 info->fbops->fb_imageblit(info, image);
49988 image->dx -= image->width + 8;
49989 }
49990 @@ -445,7 +445,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49991 image->dy += image->height + 8;
49992 }
49993 } else if (rotate == FB_ROTATE_CCW) {
49994 - for (x = 0; x < num && image->dy >= 0; x++) {
49995 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49996 info->fbops->fb_imageblit(info, image);
49997 image->dy -= image->height + 8;
49998 }
49999 @@ -1175,7 +1175,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
50000 return -EFAULT;
50001 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
50002 return -EINVAL;
50003 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
50004 + if (con2fb.framebuffer >= FB_MAX)
50005 return -EINVAL;
50006 if (!registered_fb[con2fb.framebuffer])
50007 request_module("fb%d", con2fb.framebuffer);
50008 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
50009 index 8d456dc..b4fa44b 100644
50010 --- a/drivers/video/hyperv_fb.c
50011 +++ b/drivers/video/hyperv_fb.c
50012 @@ -233,7 +233,7 @@ static uint screen_fb_size;
50013 static inline int synthvid_send(struct hv_device *hdev,
50014 struct synthvid_msg *msg)
50015 {
50016 - static atomic64_t request_id = ATOMIC64_INIT(0);
50017 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
50018 int ret;
50019
50020 msg->pipe_hdr.type = PIPE_MSG_DATA;
50021 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
50022
50023 ret = vmbus_sendpacket(hdev->channel, msg,
50024 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
50025 - atomic64_inc_return(&request_id),
50026 + atomic64_inc_return_unchecked(&request_id),
50027 VM_PKT_DATA_INBAND, 0);
50028
50029 if (ret)
50030 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
50031 index 7672d2e..b56437f 100644
50032 --- a/drivers/video/i810/i810_accel.c
50033 +++ b/drivers/video/i810/i810_accel.c
50034 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
50035 }
50036 }
50037 printk("ringbuffer lockup!!!\n");
50038 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
50039 i810_report_error(mmio);
50040 par->dev_flags |= LOCKUP;
50041 info->pixmap.scan_align = 1;
50042 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
50043 index 3c14e43..2630570 100644
50044 --- a/drivers/video/logo/logo_linux_clut224.ppm
50045 +++ b/drivers/video/logo/logo_linux_clut224.ppm
50046 @@ -2,1603 +2,1123 @@ P3
50047 # Standard 224-color Linux logo
50048 80 80
50049 255
50050 - 0 0 0 0 0 0 0 0 0 0 0 0
50051 - 0 0 0 0 0 0 0 0 0 0 0 0
50052 - 0 0 0 0 0 0 0 0 0 0 0 0
50053 - 0 0 0 0 0 0 0 0 0 0 0 0
50054 - 0 0 0 0 0 0 0 0 0 0 0 0
50055 - 0 0 0 0 0 0 0 0 0 0 0 0
50056 - 0 0 0 0 0 0 0 0 0 0 0 0
50057 - 0 0 0 0 0 0 0 0 0 0 0 0
50058 - 0 0 0 0 0 0 0 0 0 0 0 0
50059 - 6 6 6 6 6 6 10 10 10 10 10 10
50060 - 10 10 10 6 6 6 6 6 6 6 6 6
50061 - 0 0 0 0 0 0 0 0 0 0 0 0
50062 - 0 0 0 0 0 0 0 0 0 0 0 0
50063 - 0 0 0 0 0 0 0 0 0 0 0 0
50064 - 0 0 0 0 0 0 0 0 0 0 0 0
50065 - 0 0 0 0 0 0 0 0 0 0 0 0
50066 - 0 0 0 0 0 0 0 0 0 0 0 0
50067 - 0 0 0 0 0 0 0 0 0 0 0 0
50068 - 0 0 0 0 0 0 0 0 0 0 0 0
50069 - 0 0 0 0 0 0 0 0 0 0 0 0
50070 - 0 0 0 0 0 0 0 0 0 0 0 0
50071 - 0 0 0 0 0 0 0 0 0 0 0 0
50072 - 0 0 0 0 0 0 0 0 0 0 0 0
50073 - 0 0 0 0 0 0 0 0 0 0 0 0
50074 - 0 0 0 0 0 0 0 0 0 0 0 0
50075 - 0 0 0 0 0 0 0 0 0 0 0 0
50076 - 0 0 0 0 0 0 0 0 0 0 0 0
50077 - 0 0 0 0 0 0 0 0 0 0 0 0
50078 - 0 0 0 6 6 6 10 10 10 14 14 14
50079 - 22 22 22 26 26 26 30 30 30 34 34 34
50080 - 30 30 30 30 30 30 26 26 26 18 18 18
50081 - 14 14 14 10 10 10 6 6 6 0 0 0
50082 - 0 0 0 0 0 0 0 0 0 0 0 0
50083 - 0 0 0 0 0 0 0 0 0 0 0 0
50084 - 0 0 0 0 0 0 0 0 0 0 0 0
50085 - 0 0 0 0 0 0 0 0 0 0 0 0
50086 - 0 0 0 0 0 0 0 0 0 0 0 0
50087 - 0 0 0 0 0 0 0 0 0 0 0 0
50088 - 0 0 0 0 0 0 0 0 0 0 0 0
50089 - 0 0 0 0 0 0 0 0 0 0 0 0
50090 - 0 0 0 0 0 0 0 0 0 0 0 0
50091 - 0 0 0 0 0 1 0 0 1 0 0 0
50092 - 0 0 0 0 0 0 0 0 0 0 0 0
50093 - 0 0 0 0 0 0 0 0 0 0 0 0
50094 - 0 0 0 0 0 0 0 0 0 0 0 0
50095 - 0 0 0 0 0 0 0 0 0 0 0 0
50096 - 0 0 0 0 0 0 0 0 0 0 0 0
50097 - 0 0 0 0 0 0 0 0 0 0 0 0
50098 - 6 6 6 14 14 14 26 26 26 42 42 42
50099 - 54 54 54 66 66 66 78 78 78 78 78 78
50100 - 78 78 78 74 74 74 66 66 66 54 54 54
50101 - 42 42 42 26 26 26 18 18 18 10 10 10
50102 - 6 6 6 0 0 0 0 0 0 0 0 0
50103 - 0 0 0 0 0 0 0 0 0 0 0 0
50104 - 0 0 0 0 0 0 0 0 0 0 0 0
50105 - 0 0 0 0 0 0 0 0 0 0 0 0
50106 - 0 0 0 0 0 0 0 0 0 0 0 0
50107 - 0 0 0 0 0 0 0 0 0 0 0 0
50108 - 0 0 0 0 0 0 0 0 0 0 0 0
50109 - 0 0 0 0 0 0 0 0 0 0 0 0
50110 - 0 0 0 0 0 0 0 0 0 0 0 0
50111 - 0 0 1 0 0 0 0 0 0 0 0 0
50112 - 0 0 0 0 0 0 0 0 0 0 0 0
50113 - 0 0 0 0 0 0 0 0 0 0 0 0
50114 - 0 0 0 0 0 0 0 0 0 0 0 0
50115 - 0 0 0 0 0 0 0 0 0 0 0 0
50116 - 0 0 0 0 0 0 0 0 0 0 0 0
50117 - 0 0 0 0 0 0 0 0 0 10 10 10
50118 - 22 22 22 42 42 42 66 66 66 86 86 86
50119 - 66 66 66 38 38 38 38 38 38 22 22 22
50120 - 26 26 26 34 34 34 54 54 54 66 66 66
50121 - 86 86 86 70 70 70 46 46 46 26 26 26
50122 - 14 14 14 6 6 6 0 0 0 0 0 0
50123 - 0 0 0 0 0 0 0 0 0 0 0 0
50124 - 0 0 0 0 0 0 0 0 0 0 0 0
50125 - 0 0 0 0 0 0 0 0 0 0 0 0
50126 - 0 0 0 0 0 0 0 0 0 0 0 0
50127 - 0 0 0 0 0 0 0 0 0 0 0 0
50128 - 0 0 0 0 0 0 0 0 0 0 0 0
50129 - 0 0 0 0 0 0 0 0 0 0 0 0
50130 - 0 0 0 0 0 0 0 0 0 0 0 0
50131 - 0 0 1 0 0 1 0 0 1 0 0 0
50132 - 0 0 0 0 0 0 0 0 0 0 0 0
50133 - 0 0 0 0 0 0 0 0 0 0 0 0
50134 - 0 0 0 0 0 0 0 0 0 0 0 0
50135 - 0 0 0 0 0 0 0 0 0 0 0 0
50136 - 0 0 0 0 0 0 0 0 0 0 0 0
50137 - 0 0 0 0 0 0 10 10 10 26 26 26
50138 - 50 50 50 82 82 82 58 58 58 6 6 6
50139 - 2 2 6 2 2 6 2 2 6 2 2 6
50140 - 2 2 6 2 2 6 2 2 6 2 2 6
50141 - 6 6 6 54 54 54 86 86 86 66 66 66
50142 - 38 38 38 18 18 18 6 6 6 0 0 0
50143 - 0 0 0 0 0 0 0 0 0 0 0 0
50144 - 0 0 0 0 0 0 0 0 0 0 0 0
50145 - 0 0 0 0 0 0 0 0 0 0 0 0
50146 - 0 0 0 0 0 0 0 0 0 0 0 0
50147 - 0 0 0 0 0 0 0 0 0 0 0 0
50148 - 0 0 0 0 0 0 0 0 0 0 0 0
50149 - 0 0 0 0 0 0 0 0 0 0 0 0
50150 - 0 0 0 0 0 0 0 0 0 0 0 0
50151 - 0 0 0 0 0 0 0 0 0 0 0 0
50152 - 0 0 0 0 0 0 0 0 0 0 0 0
50153 - 0 0 0 0 0 0 0 0 0 0 0 0
50154 - 0 0 0 0 0 0 0 0 0 0 0 0
50155 - 0 0 0 0 0 0 0 0 0 0 0 0
50156 - 0 0 0 0 0 0 0 0 0 0 0 0
50157 - 0 0 0 6 6 6 22 22 22 50 50 50
50158 - 78 78 78 34 34 34 2 2 6 2 2 6
50159 - 2 2 6 2 2 6 2 2 6 2 2 6
50160 - 2 2 6 2 2 6 2 2 6 2 2 6
50161 - 2 2 6 2 2 6 6 6 6 70 70 70
50162 - 78 78 78 46 46 46 22 22 22 6 6 6
50163 - 0 0 0 0 0 0 0 0 0 0 0 0
50164 - 0 0 0 0 0 0 0 0 0 0 0 0
50165 - 0 0 0 0 0 0 0 0 0 0 0 0
50166 - 0 0 0 0 0 0 0 0 0 0 0 0
50167 - 0 0 0 0 0 0 0 0 0 0 0 0
50168 - 0 0 0 0 0 0 0 0 0 0 0 0
50169 - 0 0 0 0 0 0 0 0 0 0 0 0
50170 - 0 0 0 0 0 0 0 0 0 0 0 0
50171 - 0 0 1 0 0 1 0 0 1 0 0 0
50172 - 0 0 0 0 0 0 0 0 0 0 0 0
50173 - 0 0 0 0 0 0 0 0 0 0 0 0
50174 - 0 0 0 0 0 0 0 0 0 0 0 0
50175 - 0 0 0 0 0 0 0 0 0 0 0 0
50176 - 0 0 0 0 0 0 0 0 0 0 0 0
50177 - 6 6 6 18 18 18 42 42 42 82 82 82
50178 - 26 26 26 2 2 6 2 2 6 2 2 6
50179 - 2 2 6 2 2 6 2 2 6 2 2 6
50180 - 2 2 6 2 2 6 2 2 6 14 14 14
50181 - 46 46 46 34 34 34 6 6 6 2 2 6
50182 - 42 42 42 78 78 78 42 42 42 18 18 18
50183 - 6 6 6 0 0 0 0 0 0 0 0 0
50184 - 0 0 0 0 0 0 0 0 0 0 0 0
50185 - 0 0 0 0 0 0 0 0 0 0 0 0
50186 - 0 0 0 0 0 0 0 0 0 0 0 0
50187 - 0 0 0 0 0 0 0 0 0 0 0 0
50188 - 0 0 0 0 0 0 0 0 0 0 0 0
50189 - 0 0 0 0 0 0 0 0 0 0 0 0
50190 - 0 0 0 0 0 0 0 0 0 0 0 0
50191 - 0 0 1 0 0 0 0 0 1 0 0 0
50192 - 0 0 0 0 0 0 0 0 0 0 0 0
50193 - 0 0 0 0 0 0 0 0 0 0 0 0
50194 - 0 0 0 0 0 0 0 0 0 0 0 0
50195 - 0 0 0 0 0 0 0 0 0 0 0 0
50196 - 0 0 0 0 0 0 0 0 0 0 0 0
50197 - 10 10 10 30 30 30 66 66 66 58 58 58
50198 - 2 2 6 2 2 6 2 2 6 2 2 6
50199 - 2 2 6 2 2 6 2 2 6 2 2 6
50200 - 2 2 6 2 2 6 2 2 6 26 26 26
50201 - 86 86 86 101 101 101 46 46 46 10 10 10
50202 - 2 2 6 58 58 58 70 70 70 34 34 34
50203 - 10 10 10 0 0 0 0 0 0 0 0 0
50204 - 0 0 0 0 0 0 0 0 0 0 0 0
50205 - 0 0 0 0 0 0 0 0 0 0 0 0
50206 - 0 0 0 0 0 0 0 0 0 0 0 0
50207 - 0 0 0 0 0 0 0 0 0 0 0 0
50208 - 0 0 0 0 0 0 0 0 0 0 0 0
50209 - 0 0 0 0 0 0 0 0 0 0 0 0
50210 - 0 0 0 0 0 0 0 0 0 0 0 0
50211 - 0 0 1 0 0 1 0 0 1 0 0 0
50212 - 0 0 0 0 0 0 0 0 0 0 0 0
50213 - 0 0 0 0 0 0 0 0 0 0 0 0
50214 - 0 0 0 0 0 0 0 0 0 0 0 0
50215 - 0 0 0 0 0 0 0 0 0 0 0 0
50216 - 0 0 0 0 0 0 0 0 0 0 0 0
50217 - 14 14 14 42 42 42 86 86 86 10 10 10
50218 - 2 2 6 2 2 6 2 2 6 2 2 6
50219 - 2 2 6 2 2 6 2 2 6 2 2 6
50220 - 2 2 6 2 2 6 2 2 6 30 30 30
50221 - 94 94 94 94 94 94 58 58 58 26 26 26
50222 - 2 2 6 6 6 6 78 78 78 54 54 54
50223 - 22 22 22 6 6 6 0 0 0 0 0 0
50224 - 0 0 0 0 0 0 0 0 0 0 0 0
50225 - 0 0 0 0 0 0 0 0 0 0 0 0
50226 - 0 0 0 0 0 0 0 0 0 0 0 0
50227 - 0 0 0 0 0 0 0 0 0 0 0 0
50228 - 0 0 0 0 0 0 0 0 0 0 0 0
50229 - 0 0 0 0 0 0 0 0 0 0 0 0
50230 - 0 0 0 0 0 0 0 0 0 0 0 0
50231 - 0 0 0 0 0 0 0 0 0 0 0 0
50232 - 0 0 0 0 0 0 0 0 0 0 0 0
50233 - 0 0 0 0 0 0 0 0 0 0 0 0
50234 - 0 0 0 0 0 0 0 0 0 0 0 0
50235 - 0 0 0 0 0 0 0 0 0 0 0 0
50236 - 0 0 0 0 0 0 0 0 0 6 6 6
50237 - 22 22 22 62 62 62 62 62 62 2 2 6
50238 - 2 2 6 2 2 6 2 2 6 2 2 6
50239 - 2 2 6 2 2 6 2 2 6 2 2 6
50240 - 2 2 6 2 2 6 2 2 6 26 26 26
50241 - 54 54 54 38 38 38 18 18 18 10 10 10
50242 - 2 2 6 2 2 6 34 34 34 82 82 82
50243 - 38 38 38 14 14 14 0 0 0 0 0 0
50244 - 0 0 0 0 0 0 0 0 0 0 0 0
50245 - 0 0 0 0 0 0 0 0 0 0 0 0
50246 - 0 0 0 0 0 0 0 0 0 0 0 0
50247 - 0 0 0 0 0 0 0 0 0 0 0 0
50248 - 0 0 0 0 0 0 0 0 0 0 0 0
50249 - 0 0 0 0 0 0 0 0 0 0 0 0
50250 - 0 0 0 0 0 0 0 0 0 0 0 0
50251 - 0 0 0 0 0 1 0 0 1 0 0 0
50252 - 0 0 0 0 0 0 0 0 0 0 0 0
50253 - 0 0 0 0 0 0 0 0 0 0 0 0
50254 - 0 0 0 0 0 0 0 0 0 0 0 0
50255 - 0 0 0 0 0 0 0 0 0 0 0 0
50256 - 0 0 0 0 0 0 0 0 0 6 6 6
50257 - 30 30 30 78 78 78 30 30 30 2 2 6
50258 - 2 2 6 2 2 6 2 2 6 2 2 6
50259 - 2 2 6 2 2 6 2 2 6 2 2 6
50260 - 2 2 6 2 2 6 2 2 6 10 10 10
50261 - 10 10 10 2 2 6 2 2 6 2 2 6
50262 - 2 2 6 2 2 6 2 2 6 78 78 78
50263 - 50 50 50 18 18 18 6 6 6 0 0 0
50264 - 0 0 0 0 0 0 0 0 0 0 0 0
50265 - 0 0 0 0 0 0 0 0 0 0 0 0
50266 - 0 0 0 0 0 0 0 0 0 0 0 0
50267 - 0 0 0 0 0 0 0 0 0 0 0 0
50268 - 0 0 0 0 0 0 0 0 0 0 0 0
50269 - 0 0 0 0 0 0 0 0 0 0 0 0
50270 - 0 0 0 0 0 0 0 0 0 0 0 0
50271 - 0 0 1 0 0 0 0 0 0 0 0 0
50272 - 0 0 0 0 0 0 0 0 0 0 0 0
50273 - 0 0 0 0 0 0 0 0 0 0 0 0
50274 - 0 0 0 0 0 0 0 0 0 0 0 0
50275 - 0 0 0 0 0 0 0 0 0 0 0 0
50276 - 0 0 0 0 0 0 0 0 0 10 10 10
50277 - 38 38 38 86 86 86 14 14 14 2 2 6
50278 - 2 2 6 2 2 6 2 2 6 2 2 6
50279 - 2 2 6 2 2 6 2 2 6 2 2 6
50280 - 2 2 6 2 2 6 2 2 6 2 2 6
50281 - 2 2 6 2 2 6 2 2 6 2 2 6
50282 - 2 2 6 2 2 6 2 2 6 54 54 54
50283 - 66 66 66 26 26 26 6 6 6 0 0 0
50284 - 0 0 0 0 0 0 0 0 0 0 0 0
50285 - 0 0 0 0 0 0 0 0 0 0 0 0
50286 - 0 0 0 0 0 0 0 0 0 0 0 0
50287 - 0 0 0 0 0 0 0 0 0 0 0 0
50288 - 0 0 0 0 0 0 0 0 0 0 0 0
50289 - 0 0 0 0 0 0 0 0 0 0 0 0
50290 - 0 0 0 0 0 0 0 0 0 0 0 0
50291 - 0 0 0 0 0 1 0 0 1 0 0 0
50292 - 0 0 0 0 0 0 0 0 0 0 0 0
50293 - 0 0 0 0 0 0 0 0 0 0 0 0
50294 - 0 0 0 0 0 0 0 0 0 0 0 0
50295 - 0 0 0 0 0 0 0 0 0 0 0 0
50296 - 0 0 0 0 0 0 0 0 0 14 14 14
50297 - 42 42 42 82 82 82 2 2 6 2 2 6
50298 - 2 2 6 6 6 6 10 10 10 2 2 6
50299 - 2 2 6 2 2 6 2 2 6 2 2 6
50300 - 2 2 6 2 2 6 2 2 6 6 6 6
50301 - 14 14 14 10 10 10 2 2 6 2 2 6
50302 - 2 2 6 2 2 6 2 2 6 18 18 18
50303 - 82 82 82 34 34 34 10 10 10 0 0 0
50304 - 0 0 0 0 0 0 0 0 0 0 0 0
50305 - 0 0 0 0 0 0 0 0 0 0 0 0
50306 - 0 0 0 0 0 0 0 0 0 0 0 0
50307 - 0 0 0 0 0 0 0 0 0 0 0 0
50308 - 0 0 0 0 0 0 0 0 0 0 0 0
50309 - 0 0 0 0 0 0 0 0 0 0 0 0
50310 - 0 0 0 0 0 0 0 0 0 0 0 0
50311 - 0 0 1 0 0 0 0 0 0 0 0 0
50312 - 0 0 0 0 0 0 0 0 0 0 0 0
50313 - 0 0 0 0 0 0 0 0 0 0 0 0
50314 - 0 0 0 0 0 0 0 0 0 0 0 0
50315 - 0 0 0 0 0 0 0 0 0 0 0 0
50316 - 0 0 0 0 0 0 0 0 0 14 14 14
50317 - 46 46 46 86 86 86 2 2 6 2 2 6
50318 - 6 6 6 6 6 6 22 22 22 34 34 34
50319 - 6 6 6 2 2 6 2 2 6 2 2 6
50320 - 2 2 6 2 2 6 18 18 18 34 34 34
50321 - 10 10 10 50 50 50 22 22 22 2 2 6
50322 - 2 2 6 2 2 6 2 2 6 10 10 10
50323 - 86 86 86 42 42 42 14 14 14 0 0 0
50324 - 0 0 0 0 0 0 0 0 0 0 0 0
50325 - 0 0 0 0 0 0 0 0 0 0 0 0
50326 - 0 0 0 0 0 0 0 0 0 0 0 0
50327 - 0 0 0 0 0 0 0 0 0 0 0 0
50328 - 0 0 0 0 0 0 0 0 0 0 0 0
50329 - 0 0 0 0 0 0 0 0 0 0 0 0
50330 - 0 0 0 0 0 0 0 0 0 0 0 0
50331 - 0 0 1 0 0 1 0 0 1 0 0 0
50332 - 0 0 0 0 0 0 0 0 0 0 0 0
50333 - 0 0 0 0 0 0 0 0 0 0 0 0
50334 - 0 0 0 0 0 0 0 0 0 0 0 0
50335 - 0 0 0 0 0 0 0 0 0 0 0 0
50336 - 0 0 0 0 0 0 0 0 0 14 14 14
50337 - 46 46 46 86 86 86 2 2 6 2 2 6
50338 - 38 38 38 116 116 116 94 94 94 22 22 22
50339 - 22 22 22 2 2 6 2 2 6 2 2 6
50340 - 14 14 14 86 86 86 138 138 138 162 162 162
50341 -154 154 154 38 38 38 26 26 26 6 6 6
50342 - 2 2 6 2 2 6 2 2 6 2 2 6
50343 - 86 86 86 46 46 46 14 14 14 0 0 0
50344 - 0 0 0 0 0 0 0 0 0 0 0 0
50345 - 0 0 0 0 0 0 0 0 0 0 0 0
50346 - 0 0 0 0 0 0 0 0 0 0 0 0
50347 - 0 0 0 0 0 0 0 0 0 0 0 0
50348 - 0 0 0 0 0 0 0 0 0 0 0 0
50349 - 0 0 0 0 0 0 0 0 0 0 0 0
50350 - 0 0 0 0 0 0 0 0 0 0 0 0
50351 - 0 0 0 0 0 0 0 0 0 0 0 0
50352 - 0 0 0 0 0 0 0 0 0 0 0 0
50353 - 0 0 0 0 0 0 0 0 0 0 0 0
50354 - 0 0 0 0 0 0 0 0 0 0 0 0
50355 - 0 0 0 0 0 0 0 0 0 0 0 0
50356 - 0 0 0 0 0 0 0 0 0 14 14 14
50357 - 46 46 46 86 86 86 2 2 6 14 14 14
50358 -134 134 134 198 198 198 195 195 195 116 116 116
50359 - 10 10 10 2 2 6 2 2 6 6 6 6
50360 -101 98 89 187 187 187 210 210 210 218 218 218
50361 -214 214 214 134 134 134 14 14 14 6 6 6
50362 - 2 2 6 2 2 6 2 2 6 2 2 6
50363 - 86 86 86 50 50 50 18 18 18 6 6 6
50364 - 0 0 0 0 0 0 0 0 0 0 0 0
50365 - 0 0 0 0 0 0 0 0 0 0 0 0
50366 - 0 0 0 0 0 0 0 0 0 0 0 0
50367 - 0 0 0 0 0 0 0 0 0 0 0 0
50368 - 0 0 0 0 0 0 0 0 0 0 0 0
50369 - 0 0 0 0 0 0 0 0 0 0 0 0
50370 - 0 0 0 0 0 0 0 0 1 0 0 0
50371 - 0 0 1 0 0 1 0 0 1 0 0 0
50372 - 0 0 0 0 0 0 0 0 0 0 0 0
50373 - 0 0 0 0 0 0 0 0 0 0 0 0
50374 - 0 0 0 0 0 0 0 0 0 0 0 0
50375 - 0 0 0 0 0 0 0 0 0 0 0 0
50376 - 0 0 0 0 0 0 0 0 0 14 14 14
50377 - 46 46 46 86 86 86 2 2 6 54 54 54
50378 -218 218 218 195 195 195 226 226 226 246 246 246
50379 - 58 58 58 2 2 6 2 2 6 30 30 30
50380 -210 210 210 253 253 253 174 174 174 123 123 123
50381 -221 221 221 234 234 234 74 74 74 2 2 6
50382 - 2 2 6 2 2 6 2 2 6 2 2 6
50383 - 70 70 70 58 58 58 22 22 22 6 6 6
50384 - 0 0 0 0 0 0 0 0 0 0 0 0
50385 - 0 0 0 0 0 0 0 0 0 0 0 0
50386 - 0 0 0 0 0 0 0 0 0 0 0 0
50387 - 0 0 0 0 0 0 0 0 0 0 0 0
50388 - 0 0 0 0 0 0 0 0 0 0 0 0
50389 - 0 0 0 0 0 0 0 0 0 0 0 0
50390 - 0 0 0 0 0 0 0 0 0 0 0 0
50391 - 0 0 0 0 0 0 0 0 0 0 0 0
50392 - 0 0 0 0 0 0 0 0 0 0 0 0
50393 - 0 0 0 0 0 0 0 0 0 0 0 0
50394 - 0 0 0 0 0 0 0 0 0 0 0 0
50395 - 0 0 0 0 0 0 0 0 0 0 0 0
50396 - 0 0 0 0 0 0 0 0 0 14 14 14
50397 - 46 46 46 82 82 82 2 2 6 106 106 106
50398 -170 170 170 26 26 26 86 86 86 226 226 226
50399 -123 123 123 10 10 10 14 14 14 46 46 46
50400 -231 231 231 190 190 190 6 6 6 70 70 70
50401 - 90 90 90 238 238 238 158 158 158 2 2 6
50402 - 2 2 6 2 2 6 2 2 6 2 2 6
50403 - 70 70 70 58 58 58 22 22 22 6 6 6
50404 - 0 0 0 0 0 0 0 0 0 0 0 0
50405 - 0 0 0 0 0 0 0 0 0 0 0 0
50406 - 0 0 0 0 0 0 0 0 0 0 0 0
50407 - 0 0 0 0 0 0 0 0 0 0 0 0
50408 - 0 0 0 0 0 0 0 0 0 0 0 0
50409 - 0 0 0 0 0 0 0 0 0 0 0 0
50410 - 0 0 0 0 0 0 0 0 1 0 0 0
50411 - 0 0 1 0 0 1 0 0 1 0 0 0
50412 - 0 0 0 0 0 0 0 0 0 0 0 0
50413 - 0 0 0 0 0 0 0 0 0 0 0 0
50414 - 0 0 0 0 0 0 0 0 0 0 0 0
50415 - 0 0 0 0 0 0 0 0 0 0 0 0
50416 - 0 0 0 0 0 0 0 0 0 14 14 14
50417 - 42 42 42 86 86 86 6 6 6 116 116 116
50418 -106 106 106 6 6 6 70 70 70 149 149 149
50419 -128 128 128 18 18 18 38 38 38 54 54 54
50420 -221 221 221 106 106 106 2 2 6 14 14 14
50421 - 46 46 46 190 190 190 198 198 198 2 2 6
50422 - 2 2 6 2 2 6 2 2 6 2 2 6
50423 - 74 74 74 62 62 62 22 22 22 6 6 6
50424 - 0 0 0 0 0 0 0 0 0 0 0 0
50425 - 0 0 0 0 0 0 0 0 0 0 0 0
50426 - 0 0 0 0 0 0 0 0 0 0 0 0
50427 - 0 0 0 0 0 0 0 0 0 0 0 0
50428 - 0 0 0 0 0 0 0 0 0 0 0 0
50429 - 0 0 0 0 0 0 0 0 0 0 0 0
50430 - 0 0 0 0 0 0 0 0 1 0 0 0
50431 - 0 0 1 0 0 0 0 0 1 0 0 0
50432 - 0 0 0 0 0 0 0 0 0 0 0 0
50433 - 0 0 0 0 0 0 0 0 0 0 0 0
50434 - 0 0 0 0 0 0 0 0 0 0 0 0
50435 - 0 0 0 0 0 0 0 0 0 0 0 0
50436 - 0 0 0 0 0 0 0 0 0 14 14 14
50437 - 42 42 42 94 94 94 14 14 14 101 101 101
50438 -128 128 128 2 2 6 18 18 18 116 116 116
50439 -118 98 46 121 92 8 121 92 8 98 78 10
50440 -162 162 162 106 106 106 2 2 6 2 2 6
50441 - 2 2 6 195 195 195 195 195 195 6 6 6
50442 - 2 2 6 2 2 6 2 2 6 2 2 6
50443 - 74 74 74 62 62 62 22 22 22 6 6 6
50444 - 0 0 0 0 0 0 0 0 0 0 0 0
50445 - 0 0 0 0 0 0 0 0 0 0 0 0
50446 - 0 0 0 0 0 0 0 0 0 0 0 0
50447 - 0 0 0 0 0 0 0 0 0 0 0 0
50448 - 0 0 0 0 0 0 0 0 0 0 0 0
50449 - 0 0 0 0 0 0 0 0 0 0 0 0
50450 - 0 0 0 0 0 0 0 0 1 0 0 1
50451 - 0 0 1 0 0 0 0 0 1 0 0 0
50452 - 0 0 0 0 0 0 0 0 0 0 0 0
50453 - 0 0 0 0 0 0 0 0 0 0 0 0
50454 - 0 0 0 0 0 0 0 0 0 0 0 0
50455 - 0 0 0 0 0 0 0 0 0 0 0 0
50456 - 0 0 0 0 0 0 0 0 0 10 10 10
50457 - 38 38 38 90 90 90 14 14 14 58 58 58
50458 -210 210 210 26 26 26 54 38 6 154 114 10
50459 -226 170 11 236 186 11 225 175 15 184 144 12
50460 -215 174 15 175 146 61 37 26 9 2 2 6
50461 - 70 70 70 246 246 246 138 138 138 2 2 6
50462 - 2 2 6 2 2 6 2 2 6 2 2 6
50463 - 70 70 70 66 66 66 26 26 26 6 6 6
50464 - 0 0 0 0 0 0 0 0 0 0 0 0
50465 - 0 0 0 0 0 0 0 0 0 0 0 0
50466 - 0 0 0 0 0 0 0 0 0 0 0 0
50467 - 0 0 0 0 0 0 0 0 0 0 0 0
50468 - 0 0 0 0 0 0 0 0 0 0 0 0
50469 - 0 0 0 0 0 0 0 0 0 0 0 0
50470 - 0 0 0 0 0 0 0 0 0 0 0 0
50471 - 0 0 0 0 0 0 0 0 0 0 0 0
50472 - 0 0 0 0 0 0 0 0 0 0 0 0
50473 - 0 0 0 0 0 0 0 0 0 0 0 0
50474 - 0 0 0 0 0 0 0 0 0 0 0 0
50475 - 0 0 0 0 0 0 0 0 0 0 0 0
50476 - 0 0 0 0 0 0 0 0 0 10 10 10
50477 - 38 38 38 86 86 86 14 14 14 10 10 10
50478 -195 195 195 188 164 115 192 133 9 225 175 15
50479 -239 182 13 234 190 10 232 195 16 232 200 30
50480 -245 207 45 241 208 19 232 195 16 184 144 12
50481 -218 194 134 211 206 186 42 42 42 2 2 6
50482 - 2 2 6 2 2 6 2 2 6 2 2 6
50483 - 50 50 50 74 74 74 30 30 30 6 6 6
50484 - 0 0 0 0 0 0 0 0 0 0 0 0
50485 - 0 0 0 0 0 0 0 0 0 0 0 0
50486 - 0 0 0 0 0 0 0 0 0 0 0 0
50487 - 0 0 0 0 0 0 0 0 0 0 0 0
50488 - 0 0 0 0 0 0 0 0 0 0 0 0
50489 - 0 0 0 0 0 0 0 0 0 0 0 0
50490 - 0 0 0 0 0 0 0 0 0 0 0 0
50491 - 0 0 0 0 0 0 0 0 0 0 0 0
50492 - 0 0 0 0 0 0 0 0 0 0 0 0
50493 - 0 0 0 0 0 0 0 0 0 0 0 0
50494 - 0 0 0 0 0 0 0 0 0 0 0 0
50495 - 0 0 0 0 0 0 0 0 0 0 0 0
50496 - 0 0 0 0 0 0 0 0 0 10 10 10
50497 - 34 34 34 86 86 86 14 14 14 2 2 6
50498 -121 87 25 192 133 9 219 162 10 239 182 13
50499 -236 186 11 232 195 16 241 208 19 244 214 54
50500 -246 218 60 246 218 38 246 215 20 241 208 19
50501 -241 208 19 226 184 13 121 87 25 2 2 6
50502 - 2 2 6 2 2 6 2 2 6 2 2 6
50503 - 50 50 50 82 82 82 34 34 34 10 10 10
50504 - 0 0 0 0 0 0 0 0 0 0 0 0
50505 - 0 0 0 0 0 0 0 0 0 0 0 0
50506 - 0 0 0 0 0 0 0 0 0 0 0 0
50507 - 0 0 0 0 0 0 0 0 0 0 0 0
50508 - 0 0 0 0 0 0 0 0 0 0 0 0
50509 - 0 0 0 0 0 0 0 0 0 0 0 0
50510 - 0 0 0 0 0 0 0 0 0 0 0 0
50511 - 0 0 0 0 0 0 0 0 0 0 0 0
50512 - 0 0 0 0 0 0 0 0 0 0 0 0
50513 - 0 0 0 0 0 0 0 0 0 0 0 0
50514 - 0 0 0 0 0 0 0 0 0 0 0 0
50515 - 0 0 0 0 0 0 0 0 0 0 0 0
50516 - 0 0 0 0 0 0 0 0 0 10 10 10
50517 - 34 34 34 82 82 82 30 30 30 61 42 6
50518 -180 123 7 206 145 10 230 174 11 239 182 13
50519 -234 190 10 238 202 15 241 208 19 246 218 74
50520 -246 218 38 246 215 20 246 215 20 246 215 20
50521 -226 184 13 215 174 15 184 144 12 6 6 6
50522 - 2 2 6 2 2 6 2 2 6 2 2 6
50523 - 26 26 26 94 94 94 42 42 42 14 14 14
50524 - 0 0 0 0 0 0 0 0 0 0 0 0
50525 - 0 0 0 0 0 0 0 0 0 0 0 0
50526 - 0 0 0 0 0 0 0 0 0 0 0 0
50527 - 0 0 0 0 0 0 0 0 0 0 0 0
50528 - 0 0 0 0 0 0 0 0 0 0 0 0
50529 - 0 0 0 0 0 0 0 0 0 0 0 0
50530 - 0 0 0 0 0 0 0 0 0 0 0 0
50531 - 0 0 0 0 0 0 0 0 0 0 0 0
50532 - 0 0 0 0 0 0 0 0 0 0 0 0
50533 - 0 0 0 0 0 0 0 0 0 0 0 0
50534 - 0 0 0 0 0 0 0 0 0 0 0 0
50535 - 0 0 0 0 0 0 0 0 0 0 0 0
50536 - 0 0 0 0 0 0 0 0 0 10 10 10
50537 - 30 30 30 78 78 78 50 50 50 104 69 6
50538 -192 133 9 216 158 10 236 178 12 236 186 11
50539 -232 195 16 241 208 19 244 214 54 245 215 43
50540 -246 215 20 246 215 20 241 208 19 198 155 10
50541 -200 144 11 216 158 10 156 118 10 2 2 6
50542 - 2 2 6 2 2 6 2 2 6 2 2 6
50543 - 6 6 6 90 90 90 54 54 54 18 18 18
50544 - 6 6 6 0 0 0 0 0 0 0 0 0
50545 - 0 0 0 0 0 0 0 0 0 0 0 0
50546 - 0 0 0 0 0 0 0 0 0 0 0 0
50547 - 0 0 0 0 0 0 0 0 0 0 0 0
50548 - 0 0 0 0 0 0 0 0 0 0 0 0
50549 - 0 0 0 0 0 0 0 0 0 0 0 0
50550 - 0 0 0 0 0 0 0 0 0 0 0 0
50551 - 0 0 0 0 0 0 0 0 0 0 0 0
50552 - 0 0 0 0 0 0 0 0 0 0 0 0
50553 - 0 0 0 0 0 0 0 0 0 0 0 0
50554 - 0 0 0 0 0 0 0 0 0 0 0 0
50555 - 0 0 0 0 0 0 0 0 0 0 0 0
50556 - 0 0 0 0 0 0 0 0 0 10 10 10
50557 - 30 30 30 78 78 78 46 46 46 22 22 22
50558 -137 92 6 210 162 10 239 182 13 238 190 10
50559 -238 202 15 241 208 19 246 215 20 246 215 20
50560 -241 208 19 203 166 17 185 133 11 210 150 10
50561 -216 158 10 210 150 10 102 78 10 2 2 6
50562 - 6 6 6 54 54 54 14 14 14 2 2 6
50563 - 2 2 6 62 62 62 74 74 74 30 30 30
50564 - 10 10 10 0 0 0 0 0 0 0 0 0
50565 - 0 0 0 0 0 0 0 0 0 0 0 0
50566 - 0 0 0 0 0 0 0 0 0 0 0 0
50567 - 0 0 0 0 0 0 0 0 0 0 0 0
50568 - 0 0 0 0 0 0 0 0 0 0 0 0
50569 - 0 0 0 0 0 0 0 0 0 0 0 0
50570 - 0 0 0 0 0 0 0 0 0 0 0 0
50571 - 0 0 0 0 0 0 0 0 0 0 0 0
50572 - 0 0 0 0 0 0 0 0 0 0 0 0
50573 - 0 0 0 0 0 0 0 0 0 0 0 0
50574 - 0 0 0 0 0 0 0 0 0 0 0 0
50575 - 0 0 0 0 0 0 0 0 0 0 0 0
50576 - 0 0 0 0 0 0 0 0 0 10 10 10
50577 - 34 34 34 78 78 78 50 50 50 6 6 6
50578 - 94 70 30 139 102 15 190 146 13 226 184 13
50579 -232 200 30 232 195 16 215 174 15 190 146 13
50580 -168 122 10 192 133 9 210 150 10 213 154 11
50581 -202 150 34 182 157 106 101 98 89 2 2 6
50582 - 2 2 6 78 78 78 116 116 116 58 58 58
50583 - 2 2 6 22 22 22 90 90 90 46 46 46
50584 - 18 18 18 6 6 6 0 0 0 0 0 0
50585 - 0 0 0 0 0 0 0 0 0 0 0 0
50586 - 0 0 0 0 0 0 0 0 0 0 0 0
50587 - 0 0 0 0 0 0 0 0 0 0 0 0
50588 - 0 0 0 0 0 0 0 0 0 0 0 0
50589 - 0 0 0 0 0 0 0 0 0 0 0 0
50590 - 0 0 0 0 0 0 0 0 0 0 0 0
50591 - 0 0 0 0 0 0 0 0 0 0 0 0
50592 - 0 0 0 0 0 0 0 0 0 0 0 0
50593 - 0 0 0 0 0 0 0 0 0 0 0 0
50594 - 0 0 0 0 0 0 0 0 0 0 0 0
50595 - 0 0 0 0 0 0 0 0 0 0 0 0
50596 - 0 0 0 0 0 0 0 0 0 10 10 10
50597 - 38 38 38 86 86 86 50 50 50 6 6 6
50598 -128 128 128 174 154 114 156 107 11 168 122 10
50599 -198 155 10 184 144 12 197 138 11 200 144 11
50600 -206 145 10 206 145 10 197 138 11 188 164 115
50601 -195 195 195 198 198 198 174 174 174 14 14 14
50602 - 2 2 6 22 22 22 116 116 116 116 116 116
50603 - 22 22 22 2 2 6 74 74 74 70 70 70
50604 - 30 30 30 10 10 10 0 0 0 0 0 0
50605 - 0 0 0 0 0 0 0 0 0 0 0 0
50606 - 0 0 0 0 0 0 0 0 0 0 0 0
50607 - 0 0 0 0 0 0 0 0 0 0 0 0
50608 - 0 0 0 0 0 0 0 0 0 0 0 0
50609 - 0 0 0 0 0 0 0 0 0 0 0 0
50610 - 0 0 0 0 0 0 0 0 0 0 0 0
50611 - 0 0 0 0 0 0 0 0 0 0 0 0
50612 - 0 0 0 0 0 0 0 0 0 0 0 0
50613 - 0 0 0 0 0 0 0 0 0 0 0 0
50614 - 0 0 0 0 0 0 0 0 0 0 0 0
50615 - 0 0 0 0 0 0 0 0 0 0 0 0
50616 - 0 0 0 0 0 0 6 6 6 18 18 18
50617 - 50 50 50 101 101 101 26 26 26 10 10 10
50618 -138 138 138 190 190 190 174 154 114 156 107 11
50619 -197 138 11 200 144 11 197 138 11 192 133 9
50620 -180 123 7 190 142 34 190 178 144 187 187 187
50621 -202 202 202 221 221 221 214 214 214 66 66 66
50622 - 2 2 6 2 2 6 50 50 50 62 62 62
50623 - 6 6 6 2 2 6 10 10 10 90 90 90
50624 - 50 50 50 18 18 18 6 6 6 0 0 0
50625 - 0 0 0 0 0 0 0 0 0 0 0 0
50626 - 0 0 0 0 0 0 0 0 0 0 0 0
50627 - 0 0 0 0 0 0 0 0 0 0 0 0
50628 - 0 0 0 0 0 0 0 0 0 0 0 0
50629 - 0 0 0 0 0 0 0 0 0 0 0 0
50630 - 0 0 0 0 0 0 0 0 0 0 0 0
50631 - 0 0 0 0 0 0 0 0 0 0 0 0
50632 - 0 0 0 0 0 0 0 0 0 0 0 0
50633 - 0 0 0 0 0 0 0 0 0 0 0 0
50634 - 0 0 0 0 0 0 0 0 0 0 0 0
50635 - 0 0 0 0 0 0 0 0 0 0 0 0
50636 - 0 0 0 0 0 0 10 10 10 34 34 34
50637 - 74 74 74 74 74 74 2 2 6 6 6 6
50638 -144 144 144 198 198 198 190 190 190 178 166 146
50639 -154 121 60 156 107 11 156 107 11 168 124 44
50640 -174 154 114 187 187 187 190 190 190 210 210 210
50641 -246 246 246 253 253 253 253 253 253 182 182 182
50642 - 6 6 6 2 2 6 2 2 6 2 2 6
50643 - 2 2 6 2 2 6 2 2 6 62 62 62
50644 - 74 74 74 34 34 34 14 14 14 0 0 0
50645 - 0 0 0 0 0 0 0 0 0 0 0 0
50646 - 0 0 0 0 0 0 0 0 0 0 0 0
50647 - 0 0 0 0 0 0 0 0 0 0 0 0
50648 - 0 0 0 0 0 0 0 0 0 0 0 0
50649 - 0 0 0 0 0 0 0 0 0 0 0 0
50650 - 0 0 0 0 0 0 0 0 0 0 0 0
50651 - 0 0 0 0 0 0 0 0 0 0 0 0
50652 - 0 0 0 0 0 0 0 0 0 0 0 0
50653 - 0 0 0 0 0 0 0 0 0 0 0 0
50654 - 0 0 0 0 0 0 0 0 0 0 0 0
50655 - 0 0 0 0 0 0 0 0 0 0 0 0
50656 - 0 0 0 10 10 10 22 22 22 54 54 54
50657 - 94 94 94 18 18 18 2 2 6 46 46 46
50658 -234 234 234 221 221 221 190 190 190 190 190 190
50659 -190 190 190 187 187 187 187 187 187 190 190 190
50660 -190 190 190 195 195 195 214 214 214 242 242 242
50661 -253 253 253 253 253 253 253 253 253 253 253 253
50662 - 82 82 82 2 2 6 2 2 6 2 2 6
50663 - 2 2 6 2 2 6 2 2 6 14 14 14
50664 - 86 86 86 54 54 54 22 22 22 6 6 6
50665 - 0 0 0 0 0 0 0 0 0 0 0 0
50666 - 0 0 0 0 0 0 0 0 0 0 0 0
50667 - 0 0 0 0 0 0 0 0 0 0 0 0
50668 - 0 0 0 0 0 0 0 0 0 0 0 0
50669 - 0 0 0 0 0 0 0 0 0 0 0 0
50670 - 0 0 0 0 0 0 0 0 0 0 0 0
50671 - 0 0 0 0 0 0 0 0 0 0 0 0
50672 - 0 0 0 0 0 0 0 0 0 0 0 0
50673 - 0 0 0 0 0 0 0 0 0 0 0 0
50674 - 0 0 0 0 0 0 0 0 0 0 0 0
50675 - 0 0 0 0 0 0 0 0 0 0 0 0
50676 - 6 6 6 18 18 18 46 46 46 90 90 90
50677 - 46 46 46 18 18 18 6 6 6 182 182 182
50678 -253 253 253 246 246 246 206 206 206 190 190 190
50679 -190 190 190 190 190 190 190 190 190 190 190 190
50680 -206 206 206 231 231 231 250 250 250 253 253 253
50681 -253 253 253 253 253 253 253 253 253 253 253 253
50682 -202 202 202 14 14 14 2 2 6 2 2 6
50683 - 2 2 6 2 2 6 2 2 6 2 2 6
50684 - 42 42 42 86 86 86 42 42 42 18 18 18
50685 - 6 6 6 0 0 0 0 0 0 0 0 0
50686 - 0 0 0 0 0 0 0 0 0 0 0 0
50687 - 0 0 0 0 0 0 0 0 0 0 0 0
50688 - 0 0 0 0 0 0 0 0 0 0 0 0
50689 - 0 0 0 0 0 0 0 0 0 0 0 0
50690 - 0 0 0 0 0 0 0 0 0 0 0 0
50691 - 0 0 0 0 0 0 0 0 0 0 0 0
50692 - 0 0 0 0 0 0 0 0 0 0 0 0
50693 - 0 0 0 0 0 0 0 0 0 0 0 0
50694 - 0 0 0 0 0 0 0 0 0 0 0 0
50695 - 0 0 0 0 0 0 0 0 0 6 6 6
50696 - 14 14 14 38 38 38 74 74 74 66 66 66
50697 - 2 2 6 6 6 6 90 90 90 250 250 250
50698 -253 253 253 253 253 253 238 238 238 198 198 198
50699 -190 190 190 190 190 190 195 195 195 221 221 221
50700 -246 246 246 253 253 253 253 253 253 253 253 253
50701 -253 253 253 253 253 253 253 253 253 253 253 253
50702 -253 253 253 82 82 82 2 2 6 2 2 6
50703 - 2 2 6 2 2 6 2 2 6 2 2 6
50704 - 2 2 6 78 78 78 70 70 70 34 34 34
50705 - 14 14 14 6 6 6 0 0 0 0 0 0
50706 - 0 0 0 0 0 0 0 0 0 0 0 0
50707 - 0 0 0 0 0 0 0 0 0 0 0 0
50708 - 0 0 0 0 0 0 0 0 0 0 0 0
50709 - 0 0 0 0 0 0 0 0 0 0 0 0
50710 - 0 0 0 0 0 0 0 0 0 0 0 0
50711 - 0 0 0 0 0 0 0 0 0 0 0 0
50712 - 0 0 0 0 0 0 0 0 0 0 0 0
50713 - 0 0 0 0 0 0 0 0 0 0 0 0
50714 - 0 0 0 0 0 0 0 0 0 0 0 0
50715 - 0 0 0 0 0 0 0 0 0 14 14 14
50716 - 34 34 34 66 66 66 78 78 78 6 6 6
50717 - 2 2 6 18 18 18 218 218 218 253 253 253
50718 -253 253 253 253 253 253 253 253 253 246 246 246
50719 -226 226 226 231 231 231 246 246 246 253 253 253
50720 -253 253 253 253 253 253 253 253 253 253 253 253
50721 -253 253 253 253 253 253 253 253 253 253 253 253
50722 -253 253 253 178 178 178 2 2 6 2 2 6
50723 - 2 2 6 2 2 6 2 2 6 2 2 6
50724 - 2 2 6 18 18 18 90 90 90 62 62 62
50725 - 30 30 30 10 10 10 0 0 0 0 0 0
50726 - 0 0 0 0 0 0 0 0 0 0 0 0
50727 - 0 0 0 0 0 0 0 0 0 0 0 0
50728 - 0 0 0 0 0 0 0 0 0 0 0 0
50729 - 0 0 0 0 0 0 0 0 0 0 0 0
50730 - 0 0 0 0 0 0 0 0 0 0 0 0
50731 - 0 0 0 0 0 0 0 0 0 0 0 0
50732 - 0 0 0 0 0 0 0 0 0 0 0 0
50733 - 0 0 0 0 0 0 0 0 0 0 0 0
50734 - 0 0 0 0 0 0 0 0 0 0 0 0
50735 - 0 0 0 0 0 0 10 10 10 26 26 26
50736 - 58 58 58 90 90 90 18 18 18 2 2 6
50737 - 2 2 6 110 110 110 253 253 253 253 253 253
50738 -253 253 253 253 253 253 253 253 253 253 253 253
50739 -250 250 250 253 253 253 253 253 253 253 253 253
50740 -253 253 253 253 253 253 253 253 253 253 253 253
50741 -253 253 253 253 253 253 253 253 253 253 253 253
50742 -253 253 253 231 231 231 18 18 18 2 2 6
50743 - 2 2 6 2 2 6 2 2 6 2 2 6
50744 - 2 2 6 2 2 6 18 18 18 94 94 94
50745 - 54 54 54 26 26 26 10 10 10 0 0 0
50746 - 0 0 0 0 0 0 0 0 0 0 0 0
50747 - 0 0 0 0 0 0 0 0 0 0 0 0
50748 - 0 0 0 0 0 0 0 0 0 0 0 0
50749 - 0 0 0 0 0 0 0 0 0 0 0 0
50750 - 0 0 0 0 0 0 0 0 0 0 0 0
50751 - 0 0 0 0 0 0 0 0 0 0 0 0
50752 - 0 0 0 0 0 0 0 0 0 0 0 0
50753 - 0 0 0 0 0 0 0 0 0 0 0 0
50754 - 0 0 0 0 0 0 0 0 0 0 0 0
50755 - 0 0 0 6 6 6 22 22 22 50 50 50
50756 - 90 90 90 26 26 26 2 2 6 2 2 6
50757 - 14 14 14 195 195 195 250 250 250 253 253 253
50758 -253 253 253 253 253 253 253 253 253 253 253 253
50759 -253 253 253 253 253 253 253 253 253 253 253 253
50760 -253 253 253 253 253 253 253 253 253 253 253 253
50761 -253 253 253 253 253 253 253 253 253 253 253 253
50762 -250 250 250 242 242 242 54 54 54 2 2 6
50763 - 2 2 6 2 2 6 2 2 6 2 2 6
50764 - 2 2 6 2 2 6 2 2 6 38 38 38
50765 - 86 86 86 50 50 50 22 22 22 6 6 6
50766 - 0 0 0 0 0 0 0 0 0 0 0 0
50767 - 0 0 0 0 0 0 0 0 0 0 0 0
50768 - 0 0 0 0 0 0 0 0 0 0 0 0
50769 - 0 0 0 0 0 0 0 0 0 0 0 0
50770 - 0 0 0 0 0 0 0 0 0 0 0 0
50771 - 0 0 0 0 0 0 0 0 0 0 0 0
50772 - 0 0 0 0 0 0 0 0 0 0 0 0
50773 - 0 0 0 0 0 0 0 0 0 0 0 0
50774 - 0 0 0 0 0 0 0 0 0 0 0 0
50775 - 6 6 6 14 14 14 38 38 38 82 82 82
50776 - 34 34 34 2 2 6 2 2 6 2 2 6
50777 - 42 42 42 195 195 195 246 246 246 253 253 253
50778 -253 253 253 253 253 253 253 253 253 250 250 250
50779 -242 242 242 242 242 242 250 250 250 253 253 253
50780 -253 253 253 253 253 253 253 253 253 253 253 253
50781 -253 253 253 250 250 250 246 246 246 238 238 238
50782 -226 226 226 231 231 231 101 101 101 6 6 6
50783 - 2 2 6 2 2 6 2 2 6 2 2 6
50784 - 2 2 6 2 2 6 2 2 6 2 2 6
50785 - 38 38 38 82 82 82 42 42 42 14 14 14
50786 - 6 6 6 0 0 0 0 0 0 0 0 0
50787 - 0 0 0 0 0 0 0 0 0 0 0 0
50788 - 0 0 0 0 0 0 0 0 0 0 0 0
50789 - 0 0 0 0 0 0 0 0 0 0 0 0
50790 - 0 0 0 0 0 0 0 0 0 0 0 0
50791 - 0 0 0 0 0 0 0 0 0 0 0 0
50792 - 0 0 0 0 0 0 0 0 0 0 0 0
50793 - 0 0 0 0 0 0 0 0 0 0 0 0
50794 - 0 0 0 0 0 0 0 0 0 0 0 0
50795 - 10 10 10 26 26 26 62 62 62 66 66 66
50796 - 2 2 6 2 2 6 2 2 6 6 6 6
50797 - 70 70 70 170 170 170 206 206 206 234 234 234
50798 -246 246 246 250 250 250 250 250 250 238 238 238
50799 -226 226 226 231 231 231 238 238 238 250 250 250
50800 -250 250 250 250 250 250 246 246 246 231 231 231
50801 -214 214 214 206 206 206 202 202 202 202 202 202
50802 -198 198 198 202 202 202 182 182 182 18 18 18
50803 - 2 2 6 2 2 6 2 2 6 2 2 6
50804 - 2 2 6 2 2 6 2 2 6 2 2 6
50805 - 2 2 6 62 62 62 66 66 66 30 30 30
50806 - 10 10 10 0 0 0 0 0 0 0 0 0
50807 - 0 0 0 0 0 0 0 0 0 0 0 0
50808 - 0 0 0 0 0 0 0 0 0 0 0 0
50809 - 0 0 0 0 0 0 0 0 0 0 0 0
50810 - 0 0 0 0 0 0 0 0 0 0 0 0
50811 - 0 0 0 0 0 0 0 0 0 0 0 0
50812 - 0 0 0 0 0 0 0 0 0 0 0 0
50813 - 0 0 0 0 0 0 0 0 0 0 0 0
50814 - 0 0 0 0 0 0 0 0 0 0 0 0
50815 - 14 14 14 42 42 42 82 82 82 18 18 18
50816 - 2 2 6 2 2 6 2 2 6 10 10 10
50817 - 94 94 94 182 182 182 218 218 218 242 242 242
50818 -250 250 250 253 253 253 253 253 253 250 250 250
50819 -234 234 234 253 253 253 253 253 253 253 253 253
50820 -253 253 253 253 253 253 253 253 253 246 246 246
50821 -238 238 238 226 226 226 210 210 210 202 202 202
50822 -195 195 195 195 195 195 210 210 210 158 158 158
50823 - 6 6 6 14 14 14 50 50 50 14 14 14
50824 - 2 2 6 2 2 6 2 2 6 2 2 6
50825 - 2 2 6 6 6 6 86 86 86 46 46 46
50826 - 18 18 18 6 6 6 0 0 0 0 0 0
50827 - 0 0 0 0 0 0 0 0 0 0 0 0
50828 - 0 0 0 0 0 0 0 0 0 0 0 0
50829 - 0 0 0 0 0 0 0 0 0 0 0 0
50830 - 0 0 0 0 0 0 0 0 0 0 0 0
50831 - 0 0 0 0 0 0 0 0 0 0 0 0
50832 - 0 0 0 0 0 0 0 0 0 0 0 0
50833 - 0 0 0 0 0 0 0 0 0 0 0 0
50834 - 0 0 0 0 0 0 0 0 0 6 6 6
50835 - 22 22 22 54 54 54 70 70 70 2 2 6
50836 - 2 2 6 10 10 10 2 2 6 22 22 22
50837 -166 166 166 231 231 231 250 250 250 253 253 253
50838 -253 253 253 253 253 253 253 253 253 250 250 250
50839 -242 242 242 253 253 253 253 253 253 253 253 253
50840 -253 253 253 253 253 253 253 253 253 253 253 253
50841 -253 253 253 253 253 253 253 253 253 246 246 246
50842 -231 231 231 206 206 206 198 198 198 226 226 226
50843 - 94 94 94 2 2 6 6 6 6 38 38 38
50844 - 30 30 30 2 2 6 2 2 6 2 2 6
50845 - 2 2 6 2 2 6 62 62 62 66 66 66
50846 - 26 26 26 10 10 10 0 0 0 0 0 0
50847 - 0 0 0 0 0 0 0 0 0 0 0 0
50848 - 0 0 0 0 0 0 0 0 0 0 0 0
50849 - 0 0 0 0 0 0 0 0 0 0 0 0
50850 - 0 0 0 0 0 0 0 0 0 0 0 0
50851 - 0 0 0 0 0 0 0 0 0 0 0 0
50852 - 0 0 0 0 0 0 0 0 0 0 0 0
50853 - 0 0 0 0 0 0 0 0 0 0 0 0
50854 - 0 0 0 0 0 0 0 0 0 10 10 10
50855 - 30 30 30 74 74 74 50 50 50 2 2 6
50856 - 26 26 26 26 26 26 2 2 6 106 106 106
50857 -238 238 238 253 253 253 253 253 253 253 253 253
50858 -253 253 253 253 253 253 253 253 253 253 253 253
50859 -253 253 253 253 253 253 253 253 253 253 253 253
50860 -253 253 253 253 253 253 253 253 253 253 253 253
50861 -253 253 253 253 253 253 253 253 253 253 253 253
50862 -253 253 253 246 246 246 218 218 218 202 202 202
50863 -210 210 210 14 14 14 2 2 6 2 2 6
50864 - 30 30 30 22 22 22 2 2 6 2 2 6
50865 - 2 2 6 2 2 6 18 18 18 86 86 86
50866 - 42 42 42 14 14 14 0 0 0 0 0 0
50867 - 0 0 0 0 0 0 0 0 0 0 0 0
50868 - 0 0 0 0 0 0 0 0 0 0 0 0
50869 - 0 0 0 0 0 0 0 0 0 0 0 0
50870 - 0 0 0 0 0 0 0 0 0 0 0 0
50871 - 0 0 0 0 0 0 0 0 0 0 0 0
50872 - 0 0 0 0 0 0 0 0 0 0 0 0
50873 - 0 0 0 0 0 0 0 0 0 0 0 0
50874 - 0 0 0 0 0 0 0 0 0 14 14 14
50875 - 42 42 42 90 90 90 22 22 22 2 2 6
50876 - 42 42 42 2 2 6 18 18 18 218 218 218
50877 -253 253 253 253 253 253 253 253 253 253 253 253
50878 -253 253 253 253 253 253 253 253 253 253 253 253
50879 -253 253 253 253 253 253 253 253 253 253 253 253
50880 -253 253 253 253 253 253 253 253 253 253 253 253
50881 -253 253 253 253 253 253 253 253 253 253 253 253
50882 -253 253 253 253 253 253 250 250 250 221 221 221
50883 -218 218 218 101 101 101 2 2 6 14 14 14
50884 - 18 18 18 38 38 38 10 10 10 2 2 6
50885 - 2 2 6 2 2 6 2 2 6 78 78 78
50886 - 58 58 58 22 22 22 6 6 6 0 0 0
50887 - 0 0 0 0 0 0 0 0 0 0 0 0
50888 - 0 0 0 0 0 0 0 0 0 0 0 0
50889 - 0 0 0 0 0 0 0 0 0 0 0 0
50890 - 0 0 0 0 0 0 0 0 0 0 0 0
50891 - 0 0 0 0 0 0 0 0 0 0 0 0
50892 - 0 0 0 0 0 0 0 0 0 0 0 0
50893 - 0 0 0 0 0 0 0 0 0 0 0 0
50894 - 0 0 0 0 0 0 6 6 6 18 18 18
50895 - 54 54 54 82 82 82 2 2 6 26 26 26
50896 - 22 22 22 2 2 6 123 123 123 253 253 253
50897 -253 253 253 253 253 253 253 253 253 253 253 253
50898 -253 253 253 253 253 253 253 253 253 253 253 253
50899 -253 253 253 253 253 253 253 253 253 253 253 253
50900 -253 253 253 253 253 253 253 253 253 253 253 253
50901 -253 253 253 253 253 253 253 253 253 253 253 253
50902 -253 253 253 253 253 253 253 253 253 250 250 250
50903 -238 238 238 198 198 198 6 6 6 38 38 38
50904 - 58 58 58 26 26 26 38 38 38 2 2 6
50905 - 2 2 6 2 2 6 2 2 6 46 46 46
50906 - 78 78 78 30 30 30 10 10 10 0 0 0
50907 - 0 0 0 0 0 0 0 0 0 0 0 0
50908 - 0 0 0 0 0 0 0 0 0 0 0 0
50909 - 0 0 0 0 0 0 0 0 0 0 0 0
50910 - 0 0 0 0 0 0 0 0 0 0 0 0
50911 - 0 0 0 0 0 0 0 0 0 0 0 0
50912 - 0 0 0 0 0 0 0 0 0 0 0 0
50913 - 0 0 0 0 0 0 0 0 0 0 0 0
50914 - 0 0 0 0 0 0 10 10 10 30 30 30
50915 - 74 74 74 58 58 58 2 2 6 42 42 42
50916 - 2 2 6 22 22 22 231 231 231 253 253 253
50917 -253 253 253 253 253 253 253 253 253 253 253 253
50918 -253 253 253 253 253 253 253 253 253 250 250 250
50919 -253 253 253 253 253 253 253 253 253 253 253 253
50920 -253 253 253 253 253 253 253 253 253 253 253 253
50921 -253 253 253 253 253 253 253 253 253 253 253 253
50922 -253 253 253 253 253 253 253 253 253 253 253 253
50923 -253 253 253 246 246 246 46 46 46 38 38 38
50924 - 42 42 42 14 14 14 38 38 38 14 14 14
50925 - 2 2 6 2 2 6 2 2 6 6 6 6
50926 - 86 86 86 46 46 46 14 14 14 0 0 0
50927 - 0 0 0 0 0 0 0 0 0 0 0 0
50928 - 0 0 0 0 0 0 0 0 0 0 0 0
50929 - 0 0 0 0 0 0 0 0 0 0 0 0
50930 - 0 0 0 0 0 0 0 0 0 0 0 0
50931 - 0 0 0 0 0 0 0 0 0 0 0 0
50932 - 0 0 0 0 0 0 0 0 0 0 0 0
50933 - 0 0 0 0 0 0 0 0 0 0 0 0
50934 - 0 0 0 6 6 6 14 14 14 42 42 42
50935 - 90 90 90 18 18 18 18 18 18 26 26 26
50936 - 2 2 6 116 116 116 253 253 253 253 253 253
50937 -253 253 253 253 253 253 253 253 253 253 253 253
50938 -253 253 253 253 253 253 250 250 250 238 238 238
50939 -253 253 253 253 253 253 253 253 253 253 253 253
50940 -253 253 253 253 253 253 253 253 253 253 253 253
50941 -253 253 253 253 253 253 253 253 253 253 253 253
50942 -253 253 253 253 253 253 253 253 253 253 253 253
50943 -253 253 253 253 253 253 94 94 94 6 6 6
50944 - 2 2 6 2 2 6 10 10 10 34 34 34
50945 - 2 2 6 2 2 6 2 2 6 2 2 6
50946 - 74 74 74 58 58 58 22 22 22 6 6 6
50947 - 0 0 0 0 0 0 0 0 0 0 0 0
50948 - 0 0 0 0 0 0 0 0 0 0 0 0
50949 - 0 0 0 0 0 0 0 0 0 0 0 0
50950 - 0 0 0 0 0 0 0 0 0 0 0 0
50951 - 0 0 0 0 0 0 0 0 0 0 0 0
50952 - 0 0 0 0 0 0 0 0 0 0 0 0
50953 - 0 0 0 0 0 0 0 0 0 0 0 0
50954 - 0 0 0 10 10 10 26 26 26 66 66 66
50955 - 82 82 82 2 2 6 38 38 38 6 6 6
50956 - 14 14 14 210 210 210 253 253 253 253 253 253
50957 -253 253 253 253 253 253 253 253 253 253 253 253
50958 -253 253 253 253 253 253 246 246 246 242 242 242
50959 -253 253 253 253 253 253 253 253 253 253 253 253
50960 -253 253 253 253 253 253 253 253 253 253 253 253
50961 -253 253 253 253 253 253 253 253 253 253 253 253
50962 -253 253 253 253 253 253 253 253 253 253 253 253
50963 -253 253 253 253 253 253 144 144 144 2 2 6
50964 - 2 2 6 2 2 6 2 2 6 46 46 46
50965 - 2 2 6 2 2 6 2 2 6 2 2 6
50966 - 42 42 42 74 74 74 30 30 30 10 10 10
50967 - 0 0 0 0 0 0 0 0 0 0 0 0
50968 - 0 0 0 0 0 0 0 0 0 0 0 0
50969 - 0 0 0 0 0 0 0 0 0 0 0 0
50970 - 0 0 0 0 0 0 0 0 0 0 0 0
50971 - 0 0 0 0 0 0 0 0 0 0 0 0
50972 - 0 0 0 0 0 0 0 0 0 0 0 0
50973 - 0 0 0 0 0 0 0 0 0 0 0 0
50974 - 6 6 6 14 14 14 42 42 42 90 90 90
50975 - 26 26 26 6 6 6 42 42 42 2 2 6
50976 - 74 74 74 250 250 250 253 253 253 253 253 253
50977 -253 253 253 253 253 253 253 253 253 253 253 253
50978 -253 253 253 253 253 253 242 242 242 242 242 242
50979 -253 253 253 253 253 253 253 253 253 253 253 253
50980 -253 253 253 253 253 253 253 253 253 253 253 253
50981 -253 253 253 253 253 253 253 253 253 253 253 253
50982 -253 253 253 253 253 253 253 253 253 253 253 253
50983 -253 253 253 253 253 253 182 182 182 2 2 6
50984 - 2 2 6 2 2 6 2 2 6 46 46 46
50985 - 2 2 6 2 2 6 2 2 6 2 2 6
50986 - 10 10 10 86 86 86 38 38 38 10 10 10
50987 - 0 0 0 0 0 0 0 0 0 0 0 0
50988 - 0 0 0 0 0 0 0 0 0 0 0 0
50989 - 0 0 0 0 0 0 0 0 0 0 0 0
50990 - 0 0 0 0 0 0 0 0 0 0 0 0
50991 - 0 0 0 0 0 0 0 0 0 0 0 0
50992 - 0 0 0 0 0 0 0 0 0 0 0 0
50993 - 0 0 0 0 0 0 0 0 0 0 0 0
50994 - 10 10 10 26 26 26 66 66 66 82 82 82
50995 - 2 2 6 22 22 22 18 18 18 2 2 6
50996 -149 149 149 253 253 253 253 253 253 253 253 253
50997 -253 253 253 253 253 253 253 253 253 253 253 253
50998 -253 253 253 253 253 253 234 234 234 242 242 242
50999 -253 253 253 253 253 253 253 253 253 253 253 253
51000 -253 253 253 253 253 253 253 253 253 253 253 253
51001 -253 253 253 253 253 253 253 253 253 253 253 253
51002 -253 253 253 253 253 253 253 253 253 253 253 253
51003 -253 253 253 253 253 253 206 206 206 2 2 6
51004 - 2 2 6 2 2 6 2 2 6 38 38 38
51005 - 2 2 6 2 2 6 2 2 6 2 2 6
51006 - 6 6 6 86 86 86 46 46 46 14 14 14
51007 - 0 0 0 0 0 0 0 0 0 0 0 0
51008 - 0 0 0 0 0 0 0 0 0 0 0 0
51009 - 0 0 0 0 0 0 0 0 0 0 0 0
51010 - 0 0 0 0 0 0 0 0 0 0 0 0
51011 - 0 0 0 0 0 0 0 0 0 0 0 0
51012 - 0 0 0 0 0 0 0 0 0 0 0 0
51013 - 0 0 0 0 0 0 0 0 0 6 6 6
51014 - 18 18 18 46 46 46 86 86 86 18 18 18
51015 - 2 2 6 34 34 34 10 10 10 6 6 6
51016 -210 210 210 253 253 253 253 253 253 253 253 253
51017 -253 253 253 253 253 253 253 253 253 253 253 253
51018 -253 253 253 253 253 253 234 234 234 242 242 242
51019 -253 253 253 253 253 253 253 253 253 253 253 253
51020 -253 253 253 253 253 253 253 253 253 253 253 253
51021 -253 253 253 253 253 253 253 253 253 253 253 253
51022 -253 253 253 253 253 253 253 253 253 253 253 253
51023 -253 253 253 253 253 253 221 221 221 6 6 6
51024 - 2 2 6 2 2 6 6 6 6 30 30 30
51025 - 2 2 6 2 2 6 2 2 6 2 2 6
51026 - 2 2 6 82 82 82 54 54 54 18 18 18
51027 - 6 6 6 0 0 0 0 0 0 0 0 0
51028 - 0 0 0 0 0 0 0 0 0 0 0 0
51029 - 0 0 0 0 0 0 0 0 0 0 0 0
51030 - 0 0 0 0 0 0 0 0 0 0 0 0
51031 - 0 0 0 0 0 0 0 0 0 0 0 0
51032 - 0 0 0 0 0 0 0 0 0 0 0 0
51033 - 0 0 0 0 0 0 0 0 0 10 10 10
51034 - 26 26 26 66 66 66 62 62 62 2 2 6
51035 - 2 2 6 38 38 38 10 10 10 26 26 26
51036 -238 238 238 253 253 253 253 253 253 253 253 253
51037 -253 253 253 253 253 253 253 253 253 253 253 253
51038 -253 253 253 253 253 253 231 231 231 238 238 238
51039 -253 253 253 253 253 253 253 253 253 253 253 253
51040 -253 253 253 253 253 253 253 253 253 253 253 253
51041 -253 253 253 253 253 253 253 253 253 253 253 253
51042 -253 253 253 253 253 253 253 253 253 253 253 253
51043 -253 253 253 253 253 253 231 231 231 6 6 6
51044 - 2 2 6 2 2 6 10 10 10 30 30 30
51045 - 2 2 6 2 2 6 2 2 6 2 2 6
51046 - 2 2 6 66 66 66 58 58 58 22 22 22
51047 - 6 6 6 0 0 0 0 0 0 0 0 0
51048 - 0 0 0 0 0 0 0 0 0 0 0 0
51049 - 0 0 0 0 0 0 0 0 0 0 0 0
51050 - 0 0 0 0 0 0 0 0 0 0 0 0
51051 - 0 0 0 0 0 0 0 0 0 0 0 0
51052 - 0 0 0 0 0 0 0 0 0 0 0 0
51053 - 0 0 0 0 0 0 0 0 0 10 10 10
51054 - 38 38 38 78 78 78 6 6 6 2 2 6
51055 - 2 2 6 46 46 46 14 14 14 42 42 42
51056 -246 246 246 253 253 253 253 253 253 253 253 253
51057 -253 253 253 253 253 253 253 253 253 253 253 253
51058 -253 253 253 253 253 253 231 231 231 242 242 242
51059 -253 253 253 253 253 253 253 253 253 253 253 253
51060 -253 253 253 253 253 253 253 253 253 253 253 253
51061 -253 253 253 253 253 253 253 253 253 253 253 253
51062 -253 253 253 253 253 253 253 253 253 253 253 253
51063 -253 253 253 253 253 253 234 234 234 10 10 10
51064 - 2 2 6 2 2 6 22 22 22 14 14 14
51065 - 2 2 6 2 2 6 2 2 6 2 2 6
51066 - 2 2 6 66 66 66 62 62 62 22 22 22
51067 - 6 6 6 0 0 0 0 0 0 0 0 0
51068 - 0 0 0 0 0 0 0 0 0 0 0 0
51069 - 0 0 0 0 0 0 0 0 0 0 0 0
51070 - 0 0 0 0 0 0 0 0 0 0 0 0
51071 - 0 0 0 0 0 0 0 0 0 0 0 0
51072 - 0 0 0 0 0 0 0 0 0 0 0 0
51073 - 0 0 0 0 0 0 6 6 6 18 18 18
51074 - 50 50 50 74 74 74 2 2 6 2 2 6
51075 - 14 14 14 70 70 70 34 34 34 62 62 62
51076 -250 250 250 253 253 253 253 253 253 253 253 253
51077 -253 253 253 253 253 253 253 253 253 253 253 253
51078 -253 253 253 253 253 253 231 231 231 246 246 246
51079 -253 253 253 253 253 253 253 253 253 253 253 253
51080 -253 253 253 253 253 253 253 253 253 253 253 253
51081 -253 253 253 253 253 253 253 253 253 253 253 253
51082 -253 253 253 253 253 253 253 253 253 253 253 253
51083 -253 253 253 253 253 253 234 234 234 14 14 14
51084 - 2 2 6 2 2 6 30 30 30 2 2 6
51085 - 2 2 6 2 2 6 2 2 6 2 2 6
51086 - 2 2 6 66 66 66 62 62 62 22 22 22
51087 - 6 6 6 0 0 0 0 0 0 0 0 0
51088 - 0 0 0 0 0 0 0 0 0 0 0 0
51089 - 0 0 0 0 0 0 0 0 0 0 0 0
51090 - 0 0 0 0 0 0 0 0 0 0 0 0
51091 - 0 0 0 0 0 0 0 0 0 0 0 0
51092 - 0 0 0 0 0 0 0 0 0 0 0 0
51093 - 0 0 0 0 0 0 6 6 6 18 18 18
51094 - 54 54 54 62 62 62 2 2 6 2 2 6
51095 - 2 2 6 30 30 30 46 46 46 70 70 70
51096 -250 250 250 253 253 253 253 253 253 253 253 253
51097 -253 253 253 253 253 253 253 253 253 253 253 253
51098 -253 253 253 253 253 253 231 231 231 246 246 246
51099 -253 253 253 253 253 253 253 253 253 253 253 253
51100 -253 253 253 253 253 253 253 253 253 253 253 253
51101 -253 253 253 253 253 253 253 253 253 253 253 253
51102 -253 253 253 253 253 253 253 253 253 253 253 253
51103 -253 253 253 253 253 253 226 226 226 10 10 10
51104 - 2 2 6 6 6 6 30 30 30 2 2 6
51105 - 2 2 6 2 2 6 2 2 6 2 2 6
51106 - 2 2 6 66 66 66 58 58 58 22 22 22
51107 - 6 6 6 0 0 0 0 0 0 0 0 0
51108 - 0 0 0 0 0 0 0 0 0 0 0 0
51109 - 0 0 0 0 0 0 0 0 0 0 0 0
51110 - 0 0 0 0 0 0 0 0 0 0 0 0
51111 - 0 0 0 0 0 0 0 0 0 0 0 0
51112 - 0 0 0 0 0 0 0 0 0 0 0 0
51113 - 0 0 0 0 0 0 6 6 6 22 22 22
51114 - 58 58 58 62 62 62 2 2 6 2 2 6
51115 - 2 2 6 2 2 6 30 30 30 78 78 78
51116 -250 250 250 253 253 253 253 253 253 253 253 253
51117 -253 253 253 253 253 253 253 253 253 253 253 253
51118 -253 253 253 253 253 253 231 231 231 246 246 246
51119 -253 253 253 253 253 253 253 253 253 253 253 253
51120 -253 253 253 253 253 253 253 253 253 253 253 253
51121 -253 253 253 253 253 253 253 253 253 253 253 253
51122 -253 253 253 253 253 253 253 253 253 253 253 253
51123 -253 253 253 253 253 253 206 206 206 2 2 6
51124 - 22 22 22 34 34 34 18 14 6 22 22 22
51125 - 26 26 26 18 18 18 6 6 6 2 2 6
51126 - 2 2 6 82 82 82 54 54 54 18 18 18
51127 - 6 6 6 0 0 0 0 0 0 0 0 0
51128 - 0 0 0 0 0 0 0 0 0 0 0 0
51129 - 0 0 0 0 0 0 0 0 0 0 0 0
51130 - 0 0 0 0 0 0 0 0 0 0 0 0
51131 - 0 0 0 0 0 0 0 0 0 0 0 0
51132 - 0 0 0 0 0 0 0 0 0 0 0 0
51133 - 0 0 0 0 0 0 6 6 6 26 26 26
51134 - 62 62 62 106 106 106 74 54 14 185 133 11
51135 -210 162 10 121 92 8 6 6 6 62 62 62
51136 -238 238 238 253 253 253 253 253 253 253 253 253
51137 -253 253 253 253 253 253 253 253 253 253 253 253
51138 -253 253 253 253 253 253 231 231 231 246 246 246
51139 -253 253 253 253 253 253 253 253 253 253 253 253
51140 -253 253 253 253 253 253 253 253 253 253 253 253
51141 -253 253 253 253 253 253 253 253 253 253 253 253
51142 -253 253 253 253 253 253 253 253 253 253 253 253
51143 -253 253 253 253 253 253 158 158 158 18 18 18
51144 - 14 14 14 2 2 6 2 2 6 2 2 6
51145 - 6 6 6 18 18 18 66 66 66 38 38 38
51146 - 6 6 6 94 94 94 50 50 50 18 18 18
51147 - 6 6 6 0 0 0 0 0 0 0 0 0
51148 - 0 0 0 0 0 0 0 0 0 0 0 0
51149 - 0 0 0 0 0 0 0 0 0 0 0 0
51150 - 0 0 0 0 0 0 0 0 0 0 0 0
51151 - 0 0 0 0 0 0 0 0 0 0 0 0
51152 - 0 0 0 0 0 0 0 0 0 6 6 6
51153 - 10 10 10 10 10 10 18 18 18 38 38 38
51154 - 78 78 78 142 134 106 216 158 10 242 186 14
51155 -246 190 14 246 190 14 156 118 10 10 10 10
51156 - 90 90 90 238 238 238 253 253 253 253 253 253
51157 -253 253 253 253 253 253 253 253 253 253 253 253
51158 -253 253 253 253 253 253 231 231 231 250 250 250
51159 -253 253 253 253 253 253 253 253 253 253 253 253
51160 -253 253 253 253 253 253 253 253 253 253 253 253
51161 -253 253 253 253 253 253 253 253 253 253 253 253
51162 -253 253 253 253 253 253 253 253 253 246 230 190
51163 -238 204 91 238 204 91 181 142 44 37 26 9
51164 - 2 2 6 2 2 6 2 2 6 2 2 6
51165 - 2 2 6 2 2 6 38 38 38 46 46 46
51166 - 26 26 26 106 106 106 54 54 54 18 18 18
51167 - 6 6 6 0 0 0 0 0 0 0 0 0
51168 - 0 0 0 0 0 0 0 0 0 0 0 0
51169 - 0 0 0 0 0 0 0 0 0 0 0 0
51170 - 0 0 0 0 0 0 0 0 0 0 0 0
51171 - 0 0 0 0 0 0 0 0 0 0 0 0
51172 - 0 0 0 6 6 6 14 14 14 22 22 22
51173 - 30 30 30 38 38 38 50 50 50 70 70 70
51174 -106 106 106 190 142 34 226 170 11 242 186 14
51175 -246 190 14 246 190 14 246 190 14 154 114 10
51176 - 6 6 6 74 74 74 226 226 226 253 253 253
51177 -253 253 253 253 253 253 253 253 253 253 253 253
51178 -253 253 253 253 253 253 231 231 231 250 250 250
51179 -253 253 253 253 253 253 253 253 253 253 253 253
51180 -253 253 253 253 253 253 253 253 253 253 253 253
51181 -253 253 253 253 253 253 253 253 253 253 253 253
51182 -253 253 253 253 253 253 253 253 253 228 184 62
51183 -241 196 14 241 208 19 232 195 16 38 30 10
51184 - 2 2 6 2 2 6 2 2 6 2 2 6
51185 - 2 2 6 6 6 6 30 30 30 26 26 26
51186 -203 166 17 154 142 90 66 66 66 26 26 26
51187 - 6 6 6 0 0 0 0 0 0 0 0 0
51188 - 0 0 0 0 0 0 0 0 0 0 0 0
51189 - 0 0 0 0 0 0 0 0 0 0 0 0
51190 - 0 0 0 0 0 0 0 0 0 0 0 0
51191 - 0 0 0 0 0 0 0 0 0 0 0 0
51192 - 6 6 6 18 18 18 38 38 38 58 58 58
51193 - 78 78 78 86 86 86 101 101 101 123 123 123
51194 -175 146 61 210 150 10 234 174 13 246 186 14
51195 -246 190 14 246 190 14 246 190 14 238 190 10
51196 -102 78 10 2 2 6 46 46 46 198 198 198
51197 -253 253 253 253 253 253 253 253 253 253 253 253
51198 -253 253 253 253 253 253 234 234 234 242 242 242
51199 -253 253 253 253 253 253 253 253 253 253 253 253
51200 -253 253 253 253 253 253 253 253 253 253 253 253
51201 -253 253 253 253 253 253 253 253 253 253 253 253
51202 -253 253 253 253 253 253 253 253 253 224 178 62
51203 -242 186 14 241 196 14 210 166 10 22 18 6
51204 - 2 2 6 2 2 6 2 2 6 2 2 6
51205 - 2 2 6 2 2 6 6 6 6 121 92 8
51206 -238 202 15 232 195 16 82 82 82 34 34 34
51207 - 10 10 10 0 0 0 0 0 0 0 0 0
51208 - 0 0 0 0 0 0 0 0 0 0 0 0
51209 - 0 0 0 0 0 0 0 0 0 0 0 0
51210 - 0 0 0 0 0 0 0 0 0 0 0 0
51211 - 0 0 0 0 0 0 0 0 0 0 0 0
51212 - 14 14 14 38 38 38 70 70 70 154 122 46
51213 -190 142 34 200 144 11 197 138 11 197 138 11
51214 -213 154 11 226 170 11 242 186 14 246 190 14
51215 -246 190 14 246 190 14 246 190 14 246 190 14
51216 -225 175 15 46 32 6 2 2 6 22 22 22
51217 -158 158 158 250 250 250 253 253 253 253 253 253
51218 -253 253 253 253 253 253 253 253 253 253 253 253
51219 -253 253 253 253 253 253 253 253 253 253 253 253
51220 -253 253 253 253 253 253 253 253 253 253 253 253
51221 -253 253 253 253 253 253 253 253 253 253 253 253
51222 -253 253 253 250 250 250 242 242 242 224 178 62
51223 -239 182 13 236 186 11 213 154 11 46 32 6
51224 - 2 2 6 2 2 6 2 2 6 2 2 6
51225 - 2 2 6 2 2 6 61 42 6 225 175 15
51226 -238 190 10 236 186 11 112 100 78 42 42 42
51227 - 14 14 14 0 0 0 0 0 0 0 0 0
51228 - 0 0 0 0 0 0 0 0 0 0 0 0
51229 - 0 0 0 0 0 0 0 0 0 0 0 0
51230 - 0 0 0 0 0 0 0 0 0 0 0 0
51231 - 0 0 0 0 0 0 0 0 0 6 6 6
51232 - 22 22 22 54 54 54 154 122 46 213 154 11
51233 -226 170 11 230 174 11 226 170 11 226 170 11
51234 -236 178 12 242 186 14 246 190 14 246 190 14
51235 -246 190 14 246 190 14 246 190 14 246 190 14
51236 -241 196 14 184 144 12 10 10 10 2 2 6
51237 - 6 6 6 116 116 116 242 242 242 253 253 253
51238 -253 253 253 253 253 253 253 253 253 253 253 253
51239 -253 253 253 253 253 253 253 253 253 253 253 253
51240 -253 253 253 253 253 253 253 253 253 253 253 253
51241 -253 253 253 253 253 253 253 253 253 253 253 253
51242 -253 253 253 231 231 231 198 198 198 214 170 54
51243 -236 178 12 236 178 12 210 150 10 137 92 6
51244 - 18 14 6 2 2 6 2 2 6 2 2 6
51245 - 6 6 6 70 47 6 200 144 11 236 178 12
51246 -239 182 13 239 182 13 124 112 88 58 58 58
51247 - 22 22 22 6 6 6 0 0 0 0 0 0
51248 - 0 0 0 0 0 0 0 0 0 0 0 0
51249 - 0 0 0 0 0 0 0 0 0 0 0 0
51250 - 0 0 0 0 0 0 0 0 0 0 0 0
51251 - 0 0 0 0 0 0 0 0 0 10 10 10
51252 - 30 30 30 70 70 70 180 133 36 226 170 11
51253 -239 182 13 242 186 14 242 186 14 246 186 14
51254 -246 190 14 246 190 14 246 190 14 246 190 14
51255 -246 190 14 246 190 14 246 190 14 246 190 14
51256 -246 190 14 232 195 16 98 70 6 2 2 6
51257 - 2 2 6 2 2 6 66 66 66 221 221 221
51258 -253 253 253 253 253 253 253 253 253 253 253 253
51259 -253 253 253 253 253 253 253 253 253 253 253 253
51260 -253 253 253 253 253 253 253 253 253 253 253 253
51261 -253 253 253 253 253 253 253 253 253 253 253 253
51262 -253 253 253 206 206 206 198 198 198 214 166 58
51263 -230 174 11 230 174 11 216 158 10 192 133 9
51264 -163 110 8 116 81 8 102 78 10 116 81 8
51265 -167 114 7 197 138 11 226 170 11 239 182 13
51266 -242 186 14 242 186 14 162 146 94 78 78 78
51267 - 34 34 34 14 14 14 6 6 6 0 0 0
51268 - 0 0 0 0 0 0 0 0 0 0 0 0
51269 - 0 0 0 0 0 0 0 0 0 0 0 0
51270 - 0 0 0 0 0 0 0 0 0 0 0 0
51271 - 0 0 0 0 0 0 0 0 0 6 6 6
51272 - 30 30 30 78 78 78 190 142 34 226 170 11
51273 -239 182 13 246 190 14 246 190 14 246 190 14
51274 -246 190 14 246 190 14 246 190 14 246 190 14
51275 -246 190 14 246 190 14 246 190 14 246 190 14
51276 -246 190 14 241 196 14 203 166 17 22 18 6
51277 - 2 2 6 2 2 6 2 2 6 38 38 38
51278 -218 218 218 253 253 253 253 253 253 253 253 253
51279 -253 253 253 253 253 253 253 253 253 253 253 253
51280 -253 253 253 253 253 253 253 253 253 253 253 253
51281 -253 253 253 253 253 253 253 253 253 253 253 253
51282 -250 250 250 206 206 206 198 198 198 202 162 69
51283 -226 170 11 236 178 12 224 166 10 210 150 10
51284 -200 144 11 197 138 11 192 133 9 197 138 11
51285 -210 150 10 226 170 11 242 186 14 246 190 14
51286 -246 190 14 246 186 14 225 175 15 124 112 88
51287 - 62 62 62 30 30 30 14 14 14 6 6 6
51288 - 0 0 0 0 0 0 0 0 0 0 0 0
51289 - 0 0 0 0 0 0 0 0 0 0 0 0
51290 - 0 0 0 0 0 0 0 0 0 0 0 0
51291 - 0 0 0 0 0 0 0 0 0 10 10 10
51292 - 30 30 30 78 78 78 174 135 50 224 166 10
51293 -239 182 13 246 190 14 246 190 14 246 190 14
51294 -246 190 14 246 190 14 246 190 14 246 190 14
51295 -246 190 14 246 190 14 246 190 14 246 190 14
51296 -246 190 14 246 190 14 241 196 14 139 102 15
51297 - 2 2 6 2 2 6 2 2 6 2 2 6
51298 - 78 78 78 250 250 250 253 253 253 253 253 253
51299 -253 253 253 253 253 253 253 253 253 253 253 253
51300 -253 253 253 253 253 253 253 253 253 253 253 253
51301 -253 253 253 253 253 253 253 253 253 253 253 253
51302 -250 250 250 214 214 214 198 198 198 190 150 46
51303 -219 162 10 236 178 12 234 174 13 224 166 10
51304 -216 158 10 213 154 11 213 154 11 216 158 10
51305 -226 170 11 239 182 13 246 190 14 246 190 14
51306 -246 190 14 246 190 14 242 186 14 206 162 42
51307 -101 101 101 58 58 58 30 30 30 14 14 14
51308 - 6 6 6 0 0 0 0 0 0 0 0 0
51309 - 0 0 0 0 0 0 0 0 0 0 0 0
51310 - 0 0 0 0 0 0 0 0 0 0 0 0
51311 - 0 0 0 0 0 0 0 0 0 10 10 10
51312 - 30 30 30 74 74 74 174 135 50 216 158 10
51313 -236 178 12 246 190 14 246 190 14 246 190 14
51314 -246 190 14 246 190 14 246 190 14 246 190 14
51315 -246 190 14 246 190 14 246 190 14 246 190 14
51316 -246 190 14 246 190 14 241 196 14 226 184 13
51317 - 61 42 6 2 2 6 2 2 6 2 2 6
51318 - 22 22 22 238 238 238 253 253 253 253 253 253
51319 -253 253 253 253 253 253 253 253 253 253 253 253
51320 -253 253 253 253 253 253 253 253 253 253 253 253
51321 -253 253 253 253 253 253 253 253 253 253 253 253
51322 -253 253 253 226 226 226 187 187 187 180 133 36
51323 -216 158 10 236 178 12 239 182 13 236 178 12
51324 -230 174 11 226 170 11 226 170 11 230 174 11
51325 -236 178 12 242 186 14 246 190 14 246 190 14
51326 -246 190 14 246 190 14 246 186 14 239 182 13
51327 -206 162 42 106 106 106 66 66 66 34 34 34
51328 - 14 14 14 6 6 6 0 0 0 0 0 0
51329 - 0 0 0 0 0 0 0 0 0 0 0 0
51330 - 0 0 0 0 0 0 0 0 0 0 0 0
51331 - 0 0 0 0 0 0 0 0 0 6 6 6
51332 - 26 26 26 70 70 70 163 133 67 213 154 11
51333 -236 178 12 246 190 14 246 190 14 246 190 14
51334 -246 190 14 246 190 14 246 190 14 246 190 14
51335 -246 190 14 246 190 14 246 190 14 246 190 14
51336 -246 190 14 246 190 14 246 190 14 241 196 14
51337 -190 146 13 18 14 6 2 2 6 2 2 6
51338 - 46 46 46 246 246 246 253 253 253 253 253 253
51339 -253 253 253 253 253 253 253 253 253 253 253 253
51340 -253 253 253 253 253 253 253 253 253 253 253 253
51341 -253 253 253 253 253 253 253 253 253 253 253 253
51342 -253 253 253 221 221 221 86 86 86 156 107 11
51343 -216 158 10 236 178 12 242 186 14 246 186 14
51344 -242 186 14 239 182 13 239 182 13 242 186 14
51345 -242 186 14 246 186 14 246 190 14 246 190 14
51346 -246 190 14 246 190 14 246 190 14 246 190 14
51347 -242 186 14 225 175 15 142 122 72 66 66 66
51348 - 30 30 30 10 10 10 0 0 0 0 0 0
51349 - 0 0 0 0 0 0 0 0 0 0 0 0
51350 - 0 0 0 0 0 0 0 0 0 0 0 0
51351 - 0 0 0 0 0 0 0 0 0 6 6 6
51352 - 26 26 26 70 70 70 163 133 67 210 150 10
51353 -236 178 12 246 190 14 246 190 14 246 190 14
51354 -246 190 14 246 190 14 246 190 14 246 190 14
51355 -246 190 14 246 190 14 246 190 14 246 190 14
51356 -246 190 14 246 190 14 246 190 14 246 190 14
51357 -232 195 16 121 92 8 34 34 34 106 106 106
51358 -221 221 221 253 253 253 253 253 253 253 253 253
51359 -253 253 253 253 253 253 253 253 253 253 253 253
51360 -253 253 253 253 253 253 253 253 253 253 253 253
51361 -253 253 253 253 253 253 253 253 253 253 253 253
51362 -242 242 242 82 82 82 18 14 6 163 110 8
51363 -216 158 10 236 178 12 242 186 14 246 190 14
51364 -246 190 14 246 190 14 246 190 14 246 190 14
51365 -246 190 14 246 190 14 246 190 14 246 190 14
51366 -246 190 14 246 190 14 246 190 14 246 190 14
51367 -246 190 14 246 190 14 242 186 14 163 133 67
51368 - 46 46 46 18 18 18 6 6 6 0 0 0
51369 - 0 0 0 0 0 0 0 0 0 0 0 0
51370 - 0 0 0 0 0 0 0 0 0 0 0 0
51371 - 0 0 0 0 0 0 0 0 0 10 10 10
51372 - 30 30 30 78 78 78 163 133 67 210 150 10
51373 -236 178 12 246 186 14 246 190 14 246 190 14
51374 -246 190 14 246 190 14 246 190 14 246 190 14
51375 -246 190 14 246 190 14 246 190 14 246 190 14
51376 -246 190 14 246 190 14 246 190 14 246 190 14
51377 -241 196 14 215 174 15 190 178 144 253 253 253
51378 -253 253 253 253 253 253 253 253 253 253 253 253
51379 -253 253 253 253 253 253 253 253 253 253 253 253
51380 -253 253 253 253 253 253 253 253 253 253 253 253
51381 -253 253 253 253 253 253 253 253 253 218 218 218
51382 - 58 58 58 2 2 6 22 18 6 167 114 7
51383 -216 158 10 236 178 12 246 186 14 246 190 14
51384 -246 190 14 246 190 14 246 190 14 246 190 14
51385 -246 190 14 246 190 14 246 190 14 246 190 14
51386 -246 190 14 246 190 14 246 190 14 246 190 14
51387 -246 190 14 246 186 14 242 186 14 190 150 46
51388 - 54 54 54 22 22 22 6 6 6 0 0 0
51389 - 0 0 0 0 0 0 0 0 0 0 0 0
51390 - 0 0 0 0 0 0 0 0 0 0 0 0
51391 - 0 0 0 0 0 0 0 0 0 14 14 14
51392 - 38 38 38 86 86 86 180 133 36 213 154 11
51393 -236 178 12 246 186 14 246 190 14 246 190 14
51394 -246 190 14 246 190 14 246 190 14 246 190 14
51395 -246 190 14 246 190 14 246 190 14 246 190 14
51396 -246 190 14 246 190 14 246 190 14 246 190 14
51397 -246 190 14 232 195 16 190 146 13 214 214 214
51398 -253 253 253 253 253 253 253 253 253 253 253 253
51399 -253 253 253 253 253 253 253 253 253 253 253 253
51400 -253 253 253 253 253 253 253 253 253 253 253 253
51401 -253 253 253 250 250 250 170 170 170 26 26 26
51402 - 2 2 6 2 2 6 37 26 9 163 110 8
51403 -219 162 10 239 182 13 246 186 14 246 190 14
51404 -246 190 14 246 190 14 246 190 14 246 190 14
51405 -246 190 14 246 190 14 246 190 14 246 190 14
51406 -246 190 14 246 190 14 246 190 14 246 190 14
51407 -246 186 14 236 178 12 224 166 10 142 122 72
51408 - 46 46 46 18 18 18 6 6 6 0 0 0
51409 - 0 0 0 0 0 0 0 0 0 0 0 0
51410 - 0 0 0 0 0 0 0 0 0 0 0 0
51411 - 0 0 0 0 0 0 6 6 6 18 18 18
51412 - 50 50 50 109 106 95 192 133 9 224 166 10
51413 -242 186 14 246 190 14 246 190 14 246 190 14
51414 -246 190 14 246 190 14 246 190 14 246 190 14
51415 -246 190 14 246 190 14 246 190 14 246 190 14
51416 -246 190 14 246 190 14 246 190 14 246 190 14
51417 -242 186 14 226 184 13 210 162 10 142 110 46
51418 -226 226 226 253 253 253 253 253 253 253 253 253
51419 -253 253 253 253 253 253 253 253 253 253 253 253
51420 -253 253 253 253 253 253 253 253 253 253 253 253
51421 -198 198 198 66 66 66 2 2 6 2 2 6
51422 - 2 2 6 2 2 6 50 34 6 156 107 11
51423 -219 162 10 239 182 13 246 186 14 246 190 14
51424 -246 190 14 246 190 14 246 190 14 246 190 14
51425 -246 190 14 246 190 14 246 190 14 246 190 14
51426 -246 190 14 246 190 14 246 190 14 242 186 14
51427 -234 174 13 213 154 11 154 122 46 66 66 66
51428 - 30 30 30 10 10 10 0 0 0 0 0 0
51429 - 0 0 0 0 0 0 0 0 0 0 0 0
51430 - 0 0 0 0 0 0 0 0 0 0 0 0
51431 - 0 0 0 0 0 0 6 6 6 22 22 22
51432 - 58 58 58 154 121 60 206 145 10 234 174 13
51433 -242 186 14 246 186 14 246 190 14 246 190 14
51434 -246 190 14 246 190 14 246 190 14 246 190 14
51435 -246 190 14 246 190 14 246 190 14 246 190 14
51436 -246 190 14 246 190 14 246 190 14 246 190 14
51437 -246 186 14 236 178 12 210 162 10 163 110 8
51438 - 61 42 6 138 138 138 218 218 218 250 250 250
51439 -253 253 253 253 253 253 253 253 253 250 250 250
51440 -242 242 242 210 210 210 144 144 144 66 66 66
51441 - 6 6 6 2 2 6 2 2 6 2 2 6
51442 - 2 2 6 2 2 6 61 42 6 163 110 8
51443 -216 158 10 236 178 12 246 190 14 246 190 14
51444 -246 190 14 246 190 14 246 190 14 246 190 14
51445 -246 190 14 246 190 14 246 190 14 246 190 14
51446 -246 190 14 239 182 13 230 174 11 216 158 10
51447 -190 142 34 124 112 88 70 70 70 38 38 38
51448 - 18 18 18 6 6 6 0 0 0 0 0 0
51449 - 0 0 0 0 0 0 0 0 0 0 0 0
51450 - 0 0 0 0 0 0 0 0 0 0 0 0
51451 - 0 0 0 0 0 0 6 6 6 22 22 22
51452 - 62 62 62 168 124 44 206 145 10 224 166 10
51453 -236 178 12 239 182 13 242 186 14 242 186 14
51454 -246 186 14 246 190 14 246 190 14 246 190 14
51455 -246 190 14 246 190 14 246 190 14 246 190 14
51456 -246 190 14 246 190 14 246 190 14 246 190 14
51457 -246 190 14 236 178 12 216 158 10 175 118 6
51458 - 80 54 7 2 2 6 6 6 6 30 30 30
51459 - 54 54 54 62 62 62 50 50 50 38 38 38
51460 - 14 14 14 2 2 6 2 2 6 2 2 6
51461 - 2 2 6 2 2 6 2 2 6 2 2 6
51462 - 2 2 6 6 6 6 80 54 7 167 114 7
51463 -213 154 11 236 178 12 246 190 14 246 190 14
51464 -246 190 14 246 190 14 246 190 14 246 190 14
51465 -246 190 14 242 186 14 239 182 13 239 182 13
51466 -230 174 11 210 150 10 174 135 50 124 112 88
51467 - 82 82 82 54 54 54 34 34 34 18 18 18
51468 - 6 6 6 0 0 0 0 0 0 0 0 0
51469 - 0 0 0 0 0 0 0 0 0 0 0 0
51470 - 0 0 0 0 0 0 0 0 0 0 0 0
51471 - 0 0 0 0 0 0 6 6 6 18 18 18
51472 - 50 50 50 158 118 36 192 133 9 200 144 11
51473 -216 158 10 219 162 10 224 166 10 226 170 11
51474 -230 174 11 236 178 12 239 182 13 239 182 13
51475 -242 186 14 246 186 14 246 190 14 246 190 14
51476 -246 190 14 246 190 14 246 190 14 246 190 14
51477 -246 186 14 230 174 11 210 150 10 163 110 8
51478 -104 69 6 10 10 10 2 2 6 2 2 6
51479 - 2 2 6 2 2 6 2 2 6 2 2 6
51480 - 2 2 6 2 2 6 2 2 6 2 2 6
51481 - 2 2 6 2 2 6 2 2 6 2 2 6
51482 - 2 2 6 6 6 6 91 60 6 167 114 7
51483 -206 145 10 230 174 11 242 186 14 246 190 14
51484 -246 190 14 246 190 14 246 186 14 242 186 14
51485 -239 182 13 230 174 11 224 166 10 213 154 11
51486 -180 133 36 124 112 88 86 86 86 58 58 58
51487 - 38 38 38 22 22 22 10 10 10 6 6 6
51488 - 0 0 0 0 0 0 0 0 0 0 0 0
51489 - 0 0 0 0 0 0 0 0 0 0 0 0
51490 - 0 0 0 0 0 0 0 0 0 0 0 0
51491 - 0 0 0 0 0 0 0 0 0 14 14 14
51492 - 34 34 34 70 70 70 138 110 50 158 118 36
51493 -167 114 7 180 123 7 192 133 9 197 138 11
51494 -200 144 11 206 145 10 213 154 11 219 162 10
51495 -224 166 10 230 174 11 239 182 13 242 186 14
51496 -246 186 14 246 186 14 246 186 14 246 186 14
51497 -239 182 13 216 158 10 185 133 11 152 99 6
51498 -104 69 6 18 14 6 2 2 6 2 2 6
51499 - 2 2 6 2 2 6 2 2 6 2 2 6
51500 - 2 2 6 2 2 6 2 2 6 2 2 6
51501 - 2 2 6 2 2 6 2 2 6 2 2 6
51502 - 2 2 6 6 6 6 80 54 7 152 99 6
51503 -192 133 9 219 162 10 236 178 12 239 182 13
51504 -246 186 14 242 186 14 239 182 13 236 178 12
51505 -224 166 10 206 145 10 192 133 9 154 121 60
51506 - 94 94 94 62 62 62 42 42 42 22 22 22
51507 - 14 14 14 6 6 6 0 0 0 0 0 0
51508 - 0 0 0 0 0 0 0 0 0 0 0 0
51509 - 0 0 0 0 0 0 0 0 0 0 0 0
51510 - 0 0 0 0 0 0 0 0 0 0 0 0
51511 - 0 0 0 0 0 0 0 0 0 6 6 6
51512 - 18 18 18 34 34 34 58 58 58 78 78 78
51513 -101 98 89 124 112 88 142 110 46 156 107 11
51514 -163 110 8 167 114 7 175 118 6 180 123 7
51515 -185 133 11 197 138 11 210 150 10 219 162 10
51516 -226 170 11 236 178 12 236 178 12 234 174 13
51517 -219 162 10 197 138 11 163 110 8 130 83 6
51518 - 91 60 6 10 10 10 2 2 6 2 2 6
51519 - 18 18 18 38 38 38 38 38 38 38 38 38
51520 - 38 38 38 38 38 38 38 38 38 38 38 38
51521 - 38 38 38 38 38 38 26 26 26 2 2 6
51522 - 2 2 6 6 6 6 70 47 6 137 92 6
51523 -175 118 6 200 144 11 219 162 10 230 174 11
51524 -234 174 13 230 174 11 219 162 10 210 150 10
51525 -192 133 9 163 110 8 124 112 88 82 82 82
51526 - 50 50 50 30 30 30 14 14 14 6 6 6
51527 - 0 0 0 0 0 0 0 0 0 0 0 0
51528 - 0 0 0 0 0 0 0 0 0 0 0 0
51529 - 0 0 0 0 0 0 0 0 0 0 0 0
51530 - 0 0 0 0 0 0 0 0 0 0 0 0
51531 - 0 0 0 0 0 0 0 0 0 0 0 0
51532 - 6 6 6 14 14 14 22 22 22 34 34 34
51533 - 42 42 42 58 58 58 74 74 74 86 86 86
51534 -101 98 89 122 102 70 130 98 46 121 87 25
51535 -137 92 6 152 99 6 163 110 8 180 123 7
51536 -185 133 11 197 138 11 206 145 10 200 144 11
51537 -180 123 7 156 107 11 130 83 6 104 69 6
51538 - 50 34 6 54 54 54 110 110 110 101 98 89
51539 - 86 86 86 82 82 82 78 78 78 78 78 78
51540 - 78 78 78 78 78 78 78 78 78 78 78 78
51541 - 78 78 78 82 82 82 86 86 86 94 94 94
51542 -106 106 106 101 101 101 86 66 34 124 80 6
51543 -156 107 11 180 123 7 192 133 9 200 144 11
51544 -206 145 10 200 144 11 192 133 9 175 118 6
51545 -139 102 15 109 106 95 70 70 70 42 42 42
51546 - 22 22 22 10 10 10 0 0 0 0 0 0
51547 - 0 0 0 0 0 0 0 0 0 0 0 0
51548 - 0 0 0 0 0 0 0 0 0 0 0 0
51549 - 0 0 0 0 0 0 0 0 0 0 0 0
51550 - 0 0 0 0 0 0 0 0 0 0 0 0
51551 - 0 0 0 0 0 0 0 0 0 0 0 0
51552 - 0 0 0 0 0 0 6 6 6 10 10 10
51553 - 14 14 14 22 22 22 30 30 30 38 38 38
51554 - 50 50 50 62 62 62 74 74 74 90 90 90
51555 -101 98 89 112 100 78 121 87 25 124 80 6
51556 -137 92 6 152 99 6 152 99 6 152 99 6
51557 -138 86 6 124 80 6 98 70 6 86 66 30
51558 -101 98 89 82 82 82 58 58 58 46 46 46
51559 - 38 38 38 34 34 34 34 34 34 34 34 34
51560 - 34 34 34 34 34 34 34 34 34 34 34 34
51561 - 34 34 34 34 34 34 38 38 38 42 42 42
51562 - 54 54 54 82 82 82 94 86 76 91 60 6
51563 -134 86 6 156 107 11 167 114 7 175 118 6
51564 -175 118 6 167 114 7 152 99 6 121 87 25
51565 -101 98 89 62 62 62 34 34 34 18 18 18
51566 - 6 6 6 0 0 0 0 0 0 0 0 0
51567 - 0 0 0 0 0 0 0 0 0 0 0 0
51568 - 0 0 0 0 0 0 0 0 0 0 0 0
51569 - 0 0 0 0 0 0 0 0 0 0 0 0
51570 - 0 0 0 0 0 0 0 0 0 0 0 0
51571 - 0 0 0 0 0 0 0 0 0 0 0 0
51572 - 0 0 0 0 0 0 0 0 0 0 0 0
51573 - 0 0 0 6 6 6 6 6 6 10 10 10
51574 - 18 18 18 22 22 22 30 30 30 42 42 42
51575 - 50 50 50 66 66 66 86 86 86 101 98 89
51576 -106 86 58 98 70 6 104 69 6 104 69 6
51577 -104 69 6 91 60 6 82 62 34 90 90 90
51578 - 62 62 62 38 38 38 22 22 22 14 14 14
51579 - 10 10 10 10 10 10 10 10 10 10 10 10
51580 - 10 10 10 10 10 10 6 6 6 10 10 10
51581 - 10 10 10 10 10 10 10 10 10 14 14 14
51582 - 22 22 22 42 42 42 70 70 70 89 81 66
51583 - 80 54 7 104 69 6 124 80 6 137 92 6
51584 -134 86 6 116 81 8 100 82 52 86 86 86
51585 - 58 58 58 30 30 30 14 14 14 6 6 6
51586 - 0 0 0 0 0 0 0 0 0 0 0 0
51587 - 0 0 0 0 0 0 0 0 0 0 0 0
51588 - 0 0 0 0 0 0 0 0 0 0 0 0
51589 - 0 0 0 0 0 0 0 0 0 0 0 0
51590 - 0 0 0 0 0 0 0 0 0 0 0 0
51591 - 0 0 0 0 0 0 0 0 0 0 0 0
51592 - 0 0 0 0 0 0 0 0 0 0 0 0
51593 - 0 0 0 0 0 0 0 0 0 0 0 0
51594 - 0 0 0 6 6 6 10 10 10 14 14 14
51595 - 18 18 18 26 26 26 38 38 38 54 54 54
51596 - 70 70 70 86 86 86 94 86 76 89 81 66
51597 - 89 81 66 86 86 86 74 74 74 50 50 50
51598 - 30 30 30 14 14 14 6 6 6 0 0 0
51599 - 0 0 0 0 0 0 0 0 0 0 0 0
51600 - 0 0 0 0 0 0 0 0 0 0 0 0
51601 - 0 0 0 0 0 0 0 0 0 0 0 0
51602 - 6 6 6 18 18 18 34 34 34 58 58 58
51603 - 82 82 82 89 81 66 89 81 66 89 81 66
51604 - 94 86 66 94 86 76 74 74 74 50 50 50
51605 - 26 26 26 14 14 14 6 6 6 0 0 0
51606 - 0 0 0 0 0 0 0 0 0 0 0 0
51607 - 0 0 0 0 0 0 0 0 0 0 0 0
51608 - 0 0 0 0 0 0 0 0 0 0 0 0
51609 - 0 0 0 0 0 0 0 0 0 0 0 0
51610 - 0 0 0 0 0 0 0 0 0 0 0 0
51611 - 0 0 0 0 0 0 0 0 0 0 0 0
51612 - 0 0 0 0 0 0 0 0 0 0 0 0
51613 - 0 0 0 0 0 0 0 0 0 0 0 0
51614 - 0 0 0 0 0 0 0 0 0 0 0 0
51615 - 6 6 6 6 6 6 14 14 14 18 18 18
51616 - 30 30 30 38 38 38 46 46 46 54 54 54
51617 - 50 50 50 42 42 42 30 30 30 18 18 18
51618 - 10 10 10 0 0 0 0 0 0 0 0 0
51619 - 0 0 0 0 0 0 0 0 0 0 0 0
51620 - 0 0 0 0 0 0 0 0 0 0 0 0
51621 - 0 0 0 0 0 0 0 0 0 0 0 0
51622 - 0 0 0 6 6 6 14 14 14 26 26 26
51623 - 38 38 38 50 50 50 58 58 58 58 58 58
51624 - 54 54 54 42 42 42 30 30 30 18 18 18
51625 - 10 10 10 0 0 0 0 0 0 0 0 0
51626 - 0 0 0 0 0 0 0 0 0 0 0 0
51627 - 0 0 0 0 0 0 0 0 0 0 0 0
51628 - 0 0 0 0 0 0 0 0 0 0 0 0
51629 - 0 0 0 0 0 0 0 0 0 0 0 0
51630 - 0 0 0 0 0 0 0 0 0 0 0 0
51631 - 0 0 0 0 0 0 0 0 0 0 0 0
51632 - 0 0 0 0 0 0 0 0 0 0 0 0
51633 - 0 0 0 0 0 0 0 0 0 0 0 0
51634 - 0 0 0 0 0 0 0 0 0 0 0 0
51635 - 0 0 0 0 0 0 0 0 0 6 6 6
51636 - 6 6 6 10 10 10 14 14 14 18 18 18
51637 - 18 18 18 14 14 14 10 10 10 6 6 6
51638 - 0 0 0 0 0 0 0 0 0 0 0 0
51639 - 0 0 0 0 0 0 0 0 0 0 0 0
51640 - 0 0 0 0 0 0 0 0 0 0 0 0
51641 - 0 0 0 0 0 0 0 0 0 0 0 0
51642 - 0 0 0 0 0 0 0 0 0 6 6 6
51643 - 14 14 14 18 18 18 22 22 22 22 22 22
51644 - 18 18 18 14 14 14 10 10 10 6 6 6
51645 - 0 0 0 0 0 0 0 0 0 0 0 0
51646 - 0 0 0 0 0 0 0 0 0 0 0 0
51647 - 0 0 0 0 0 0 0 0 0 0 0 0
51648 - 0 0 0 0 0 0 0 0 0 0 0 0
51649 - 0 0 0 0 0 0 0 0 0 0 0 0
51650 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51651 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51652 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51655 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51656 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51659 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51660 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51661 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51662 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51663 +4 4 4 4 4 4
51664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51666 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51670 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51672 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51675 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51676 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51677 +4 4 4 4 4 4
51678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51680 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51686 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51688 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51689 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51690 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51691 +4 4 4 4 4 4
51692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51694 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51696 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51699 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51700 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51704 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51705 +4 4 4 4 4 4
51706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51707 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51710 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51712 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51713 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51714 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51715 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51716 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51718 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51719 +4 4 4 4 4 4
51720 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51724 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51727 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51728 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51732 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51733 +4 4 4 4 4 4
51734 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51738 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
51739 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
51740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51742 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51743 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
51744 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51745 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
51746 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51747 +4 4 4 4 4 4
51748 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51752 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
51753 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
51754 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51756 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51757 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
51758 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
51759 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
51760 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51761 +4 4 4 4 4 4
51762 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51766 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
51767 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
51768 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51771 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
51772 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
51773 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
51774 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
51775 +4 4 4 4 4 4
51776 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51779 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
51780 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
51781 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
51782 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
51783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51784 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51785 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
51786 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
51787 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
51788 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
51789 +4 4 4 4 4 4
51790 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51792 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51793 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
51794 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
51795 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
51796 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
51797 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51798 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
51799 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
51800 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
51801 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
51802 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
51803 +4 4 4 4 4 4
51804 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51807 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
51808 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
51809 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
51810 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
51811 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51812 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
51813 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
51814 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
51815 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
51816 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
51817 +4 4 4 4 4 4
51818 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51820 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
51821 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
51822 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
51823 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
51824 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
51825 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
51826 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
51827 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
51828 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
51829 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
51830 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
51831 +4 4 4 4 4 4
51832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51834 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
51835 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
51836 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
51837 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
51838 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
51839 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
51840 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
51841 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
51842 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
51843 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
51844 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
51845 +4 4 4 4 4 4
51846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51848 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
51849 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
51850 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
51851 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
51852 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
51853 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
51854 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
51855 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
51856 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
51857 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
51858 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51859 +4 4 4 4 4 4
51860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51862 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
51863 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
51864 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
51865 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
51866 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
51867 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
51868 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
51869 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
51870 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
51871 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
51872 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
51873 +4 4 4 4 4 4
51874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51875 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
51876 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
51877 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
51878 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
51879 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
51880 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
51881 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
51882 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
51883 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
51884 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
51885 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
51886 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
51887 +4 4 4 4 4 4
51888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51889 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
51890 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
51891 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
51892 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51893 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
51894 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
51895 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
51896 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
51897 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
51898 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
51899 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
51900 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
51901 +0 0 0 4 4 4
51902 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51903 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
51904 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
51905 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
51906 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
51907 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
51908 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
51909 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
51910 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
51911 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
51912 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
51913 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
51914 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
51915 +2 0 0 0 0 0
51916 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
51917 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
51918 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
51919 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
51920 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
51921 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
51922 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
51923 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
51924 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
51925 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
51926 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
51927 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
51928 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
51929 +37 38 37 0 0 0
51930 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
51931 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
51932 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
51933 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
51934 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
51935 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
51936 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
51937 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
51938 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
51939 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
51940 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
51941 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
51942 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
51943 +85 115 134 4 0 0
51944 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
51945 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
51946 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
51947 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
51948 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
51949 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
51950 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
51951 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
51952 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
51953 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
51954 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
51955 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
51956 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
51957 +60 73 81 4 0 0
51958 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
51959 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
51960 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
51961 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
51962 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
51963 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
51964 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
51965 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
51966 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
51967 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
51968 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
51969 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
51970 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
51971 +16 19 21 4 0 0
51972 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
51973 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
51974 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
51975 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
51976 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
51977 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
51978 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
51979 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
51980 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
51981 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
51982 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
51983 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
51984 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
51985 +4 0 0 4 3 3
51986 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
51987 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
51988 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
51989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
51990 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
51991 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
51992 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
51993 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
51994 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
51995 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
51996 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
51997 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
51998 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
51999 +3 2 2 4 4 4
52000 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
52001 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
52002 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
52003 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
52004 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
52005 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
52006 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
52007 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
52008 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
52009 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
52010 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
52011 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
52012 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
52013 +4 4 4 4 4 4
52014 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
52015 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
52016 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
52017 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
52018 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
52019 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
52020 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
52021 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
52022 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
52023 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
52024 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
52025 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
52026 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
52027 +4 4 4 4 4 4
52028 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
52029 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
52030 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
52031 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
52032 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
52033 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
52034 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
52035 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
52036 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
52037 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
52038 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
52039 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
52040 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
52041 +5 5 5 5 5 5
52042 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
52043 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
52044 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
52045 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
52046 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
52047 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52048 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
52049 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
52050 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
52051 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
52052 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
52053 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
52054 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
52055 +5 5 5 4 4 4
52056 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
52057 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
52058 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
52059 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
52060 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
52061 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
52062 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
52063 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
52064 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
52065 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
52066 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
52067 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
52068 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52069 +4 4 4 4 4 4
52070 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
52071 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
52072 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
52073 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
52074 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
52075 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52076 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52077 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
52078 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
52079 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
52080 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
52081 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
52082 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52083 +4 4 4 4 4 4
52084 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
52085 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
52086 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
52087 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
52088 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
52089 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
52090 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
52091 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
52092 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
52093 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
52094 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
52095 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52096 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52097 +4 4 4 4 4 4
52098 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
52099 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
52100 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
52101 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
52102 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
52103 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52104 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52105 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
52106 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
52107 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
52108 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
52109 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52110 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52111 +4 4 4 4 4 4
52112 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
52113 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
52114 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
52115 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
52116 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
52117 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
52118 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
52119 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
52120 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
52121 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
52122 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52123 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52124 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52125 +4 4 4 4 4 4
52126 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
52127 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
52128 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
52129 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
52130 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
52131 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
52132 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
52133 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
52134 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
52135 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
52136 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
52137 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52138 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52139 +4 4 4 4 4 4
52140 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
52141 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
52142 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
52143 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
52144 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
52145 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
52146 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
52147 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
52148 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
52149 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
52150 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
52151 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52152 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52153 +4 4 4 4 4 4
52154 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
52155 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
52156 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
52157 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
52158 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
52159 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
52160 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
52161 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
52162 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
52163 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
52164 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52165 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52166 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52167 +4 4 4 4 4 4
52168 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
52169 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
52170 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
52171 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
52172 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52173 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
52174 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
52175 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
52176 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
52177 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
52178 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52179 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52180 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52181 +4 4 4 4 4 4
52182 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
52183 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
52184 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
52185 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
52186 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52187 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
52188 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
52189 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
52190 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
52191 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
52192 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52193 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52194 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52195 +4 4 4 4 4 4
52196 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
52197 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
52198 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
52199 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
52200 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52201 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
52202 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
52203 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
52204 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
52205 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52206 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52207 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52208 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52209 +4 4 4 4 4 4
52210 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
52211 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
52212 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
52213 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
52214 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
52215 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
52216 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
52217 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
52218 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52219 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52220 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52221 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52222 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52223 +4 4 4 4 4 4
52224 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
52225 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
52226 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
52227 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
52228 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52229 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
52230 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
52231 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
52232 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52233 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52234 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52235 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52236 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52237 +4 4 4 4 4 4
52238 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
52239 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
52240 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
52241 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
52242 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
52243 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
52244 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
52245 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
52246 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52247 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52248 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52249 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52250 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52251 +4 4 4 4 4 4
52252 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
52253 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
52254 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52255 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
52256 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
52257 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
52258 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
52259 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
52260 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
52261 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52262 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52263 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52264 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52265 +4 4 4 4 4 4
52266 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
52267 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
52268 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
52269 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
52270 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
52271 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
52272 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
52273 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
52274 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52275 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52276 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52277 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52278 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52279 +4 4 4 4 4 4
52280 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
52281 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
52282 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52283 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
52284 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
52285 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
52286 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
52287 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
52288 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
52289 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52290 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52291 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52292 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52293 +4 4 4 4 4 4
52294 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
52295 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
52296 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
52297 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
52298 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
52299 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
52300 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
52301 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
52302 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52303 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52304 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52305 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52306 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52307 +4 4 4 4 4 4
52308 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52309 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
52310 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52311 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
52312 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
52313 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
52314 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
52315 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
52316 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52317 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52318 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52319 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52320 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52321 +4 4 4 4 4 4
52322 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
52323 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
52324 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
52325 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
52326 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
52327 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
52328 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52329 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
52330 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52331 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52332 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52333 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52334 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52335 +4 4 4 4 4 4
52336 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52337 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
52338 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
52339 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
52340 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
52341 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
52342 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52343 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
52344 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52345 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52346 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52347 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52348 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52349 +4 4 4 4 4 4
52350 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
52351 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
52352 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
52353 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
52354 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
52355 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
52356 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
52357 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
52358 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
52359 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52360 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52361 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52362 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52363 +4 4 4 4 4 4
52364 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52365 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
52366 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
52367 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
52368 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
52369 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
52370 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
52371 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
52372 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
52373 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52374 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52375 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52376 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52377 +4 4 4 4 4 4
52378 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
52379 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
52380 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
52381 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
52382 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
52383 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
52384 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
52385 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
52386 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
52387 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52388 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52389 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52390 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52391 +4 4 4 4 4 4
52392 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52393 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
52394 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
52395 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
52396 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
52397 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
52398 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
52399 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
52400 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
52401 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52402 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52403 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52404 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52405 +4 4 4 4 4 4
52406 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
52407 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
52408 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
52409 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
52410 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
52411 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
52412 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
52413 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
52414 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
52415 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
52416 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52417 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52418 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52419 +4 4 4 4 4 4
52420 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
52421 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
52422 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
52423 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
52424 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
52425 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
52426 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
52427 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
52428 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
52429 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
52430 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52432 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52433 +4 4 4 4 4 4
52434 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
52435 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
52436 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
52437 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
52438 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
52439 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
52440 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52441 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
52442 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
52443 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
52444 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52445 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52446 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52447 +4 4 4 4 4 4
52448 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
52449 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
52450 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
52451 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
52452 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
52453 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
52454 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
52455 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
52456 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
52457 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
52458 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52460 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52461 +4 4 4 4 4 4
52462 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
52463 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
52464 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
52465 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
52466 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
52467 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
52468 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
52469 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
52470 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
52471 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
52472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52474 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52475 +4 4 4 4 4 4
52476 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52477 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
52478 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
52479 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
52480 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
52481 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
52482 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
52483 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
52484 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
52485 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
52486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52488 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52489 +4 4 4 4 4 4
52490 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
52491 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
52492 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
52493 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
52494 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
52495 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
52496 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
52497 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
52498 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
52499 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
52500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52502 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52503 +4 4 4 4 4 4
52504 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
52505 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
52506 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
52507 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
52508 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
52509 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
52510 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
52511 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
52512 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
52513 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52516 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52517 +4 4 4 4 4 4
52518 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
52519 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52520 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
52521 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
52522 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
52523 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
52524 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
52525 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
52526 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
52527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52530 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52531 +4 4 4 4 4 4
52532 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
52533 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
52534 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
52535 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
52536 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
52537 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
52538 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
52539 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
52540 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
52541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52544 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52545 +4 4 4 4 4 4
52546 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
52547 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
52548 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
52549 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
52550 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
52551 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
52552 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
52553 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
52554 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52559 +4 4 4 4 4 4
52560 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
52561 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
52562 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
52563 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
52564 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
52565 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
52566 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
52567 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
52568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52572 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52573 +4 4 4 4 4 4
52574 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
52575 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
52576 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
52577 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
52578 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
52579 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
52580 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
52581 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
52582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52586 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52587 +4 4 4 4 4 4
52588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52589 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
52590 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52591 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
52592 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
52593 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
52594 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
52595 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
52596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52599 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52600 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52601 +4 4 4 4 4 4
52602 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52603 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
52604 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
52605 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
52606 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
52607 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
52608 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
52609 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
52610 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52613 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52614 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52615 +4 4 4 4 4 4
52616 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52617 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
52618 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
52619 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
52620 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
52621 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
52622 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
52623 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52624 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52625 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52627 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52628 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52629 +4 4 4 4 4 4
52630 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52631 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52632 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
52633 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
52634 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
52635 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
52636 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
52637 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52638 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52641 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52642 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52643 +4 4 4 4 4 4
52644 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52645 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52646 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52647 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52648 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
52649 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
52650 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
52651 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52652 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52655 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52656 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52657 +4 4 4 4 4 4
52658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52659 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52660 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52661 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
52662 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
52663 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
52664 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
52665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52666 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52670 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52671 +4 4 4 4 4 4
52672 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52675 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
52676 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52677 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
52678 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
52679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52680 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52685 +4 4 4 4 4 4
52686 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52688 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52689 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
52690 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
52691 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
52692 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
52693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52694 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52696 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52699 +4 4 4 4 4 4
52700 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52704 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
52705 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52706 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52707 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52710 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52712 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52713 +4 4 4 4 4 4
52714 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52715 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52716 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52718 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
52719 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
52720 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
52721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52724 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52727 +4 4 4 4 4 4
52728 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52732 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
52733 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
52734 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52738 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52741 +4 4 4 4 4 4
52742 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52743 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52744 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52746 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
52747 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
52748 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52752 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52755 +4 4 4 4 4 4
52756 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52757 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52758 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52760 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
52761 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
52762 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52766 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52769 +4 4 4 4 4 4
52770 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
52771 index fe92eed..106e085 100644
52772 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
52773 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
52774 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
52775 struct mb862xxfb_par *par = info->par;
52776
52777 if (info->var.bits_per_pixel == 32) {
52778 - info->fbops->fb_fillrect = cfb_fillrect;
52779 - info->fbops->fb_copyarea = cfb_copyarea;
52780 - info->fbops->fb_imageblit = cfb_imageblit;
52781 + pax_open_kernel();
52782 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52783 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52784 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52785 + pax_close_kernel();
52786 } else {
52787 outreg(disp, GC_L0EM, 3);
52788 - info->fbops->fb_fillrect = mb86290fb_fillrect;
52789 - info->fbops->fb_copyarea = mb86290fb_copyarea;
52790 - info->fbops->fb_imageblit = mb86290fb_imageblit;
52791 + pax_open_kernel();
52792 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
52793 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
52794 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
52795 + pax_close_kernel();
52796 }
52797 outreg(draw, GDC_REG_DRAW_BASE, 0);
52798 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
52799 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
52800 index ff22871..b129bed 100644
52801 --- a/drivers/video/nvidia/nvidia.c
52802 +++ b/drivers/video/nvidia/nvidia.c
52803 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
52804 info->fix.line_length = (info->var.xres_virtual *
52805 info->var.bits_per_pixel) >> 3;
52806 if (info->var.accel_flags) {
52807 - info->fbops->fb_imageblit = nvidiafb_imageblit;
52808 - info->fbops->fb_fillrect = nvidiafb_fillrect;
52809 - info->fbops->fb_copyarea = nvidiafb_copyarea;
52810 - info->fbops->fb_sync = nvidiafb_sync;
52811 + pax_open_kernel();
52812 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
52813 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
52814 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
52815 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
52816 + pax_close_kernel();
52817 info->pixmap.scan_align = 4;
52818 info->flags &= ~FBINFO_HWACCEL_DISABLED;
52819 info->flags |= FBINFO_READS_FAST;
52820 NVResetGraphics(info);
52821 } else {
52822 - info->fbops->fb_imageblit = cfb_imageblit;
52823 - info->fbops->fb_fillrect = cfb_fillrect;
52824 - info->fbops->fb_copyarea = cfb_copyarea;
52825 - info->fbops->fb_sync = NULL;
52826 + pax_open_kernel();
52827 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52828 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52829 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52830 + *(void **)&info->fbops->fb_sync = NULL;
52831 + pax_close_kernel();
52832 info->pixmap.scan_align = 1;
52833 info->flags |= FBINFO_HWACCEL_DISABLED;
52834 info->flags &= ~FBINFO_READS_FAST;
52835 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
52836 info->pixmap.size = 8 * 1024;
52837 info->pixmap.flags = FB_PIXMAP_SYSTEM;
52838
52839 - if (!hwcur)
52840 - info->fbops->fb_cursor = NULL;
52841 + if (!hwcur) {
52842 + pax_open_kernel();
52843 + *(void **)&info->fbops->fb_cursor = NULL;
52844 + pax_close_kernel();
52845 + }
52846
52847 info->var.accel_flags = (!noaccel);
52848
52849 diff --git a/drivers/video/omap2/dss/display.c b/drivers/video/omap2/dss/display.c
52850 index fafe7c9..93197b9 100644
52851 --- a/drivers/video/omap2/dss/display.c
52852 +++ b/drivers/video/omap2/dss/display.c
52853 @@ -137,12 +137,14 @@ int omapdss_register_display(struct omap_dss_device *dssdev)
52854 snprintf(dssdev->alias, sizeof(dssdev->alias),
52855 "display%d", disp_num_counter++);
52856
52857 + pax_open_kernel();
52858 if (drv && drv->get_resolution == NULL)
52859 - drv->get_resolution = omapdss_default_get_resolution;
52860 + *(void **)&drv->get_resolution = omapdss_default_get_resolution;
52861 if (drv && drv->get_recommended_bpp == NULL)
52862 - drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
52863 + *(void **)&drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
52864 if (drv && drv->get_timings == NULL)
52865 - drv->get_timings = omapdss_default_get_timings;
52866 + *(void **)&drv->get_timings = omapdss_default_get_timings;
52867 + pax_close_kernel();
52868
52869 mutex_lock(&panel_list_mutex);
52870 list_add_tail(&dssdev->panel_list, &panel_list);
52871 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
52872 index 05c2dc3..ea1f391 100644
52873 --- a/drivers/video/s1d13xxxfb.c
52874 +++ b/drivers/video/s1d13xxxfb.c
52875 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
52876
52877 switch(prod_id) {
52878 case S1D13506_PROD_ID: /* activate acceleration */
52879 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52880 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52881 + pax_open_kernel();
52882 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52883 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52884 + pax_close_kernel();
52885 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
52886 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
52887 break;
52888 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
52889 index e188ada..aac63c8 100644
52890 --- a/drivers/video/smscufx.c
52891 +++ b/drivers/video/smscufx.c
52892 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
52893 fb_deferred_io_cleanup(info);
52894 kfree(info->fbdefio);
52895 info->fbdefio = NULL;
52896 - info->fbops->fb_mmap = ufx_ops_mmap;
52897 + pax_open_kernel();
52898 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
52899 + pax_close_kernel();
52900 }
52901
52902 pr_debug("released /dev/fb%d user=%d count=%d",
52903 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
52904 index d2e5bc3..4cb05d1 100644
52905 --- a/drivers/video/udlfb.c
52906 +++ b/drivers/video/udlfb.c
52907 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
52908 dlfb_urb_completion(urb);
52909
52910 error:
52911 - atomic_add(bytes_sent, &dev->bytes_sent);
52912 - atomic_add(bytes_identical, &dev->bytes_identical);
52913 - atomic_add(width*height*2, &dev->bytes_rendered);
52914 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52915 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52916 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
52917 end_cycles = get_cycles();
52918 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52919 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52920 >> 10)), /* Kcycles */
52921 &dev->cpu_kcycles_used);
52922
52923 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
52924 dlfb_urb_completion(urb);
52925
52926 error:
52927 - atomic_add(bytes_sent, &dev->bytes_sent);
52928 - atomic_add(bytes_identical, &dev->bytes_identical);
52929 - atomic_add(bytes_rendered, &dev->bytes_rendered);
52930 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52931 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52932 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
52933 end_cycles = get_cycles();
52934 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52935 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52936 >> 10)), /* Kcycles */
52937 &dev->cpu_kcycles_used);
52938 }
52939 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
52940 fb_deferred_io_cleanup(info);
52941 kfree(info->fbdefio);
52942 info->fbdefio = NULL;
52943 - info->fbops->fb_mmap = dlfb_ops_mmap;
52944 + pax_open_kernel();
52945 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
52946 + pax_close_kernel();
52947 }
52948
52949 pr_warn("released /dev/fb%d user=%d count=%d\n",
52950 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
52951 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52952 struct dlfb_data *dev = fb_info->par;
52953 return snprintf(buf, PAGE_SIZE, "%u\n",
52954 - atomic_read(&dev->bytes_rendered));
52955 + atomic_read_unchecked(&dev->bytes_rendered));
52956 }
52957
52958 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52959 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52960 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52961 struct dlfb_data *dev = fb_info->par;
52962 return snprintf(buf, PAGE_SIZE, "%u\n",
52963 - atomic_read(&dev->bytes_identical));
52964 + atomic_read_unchecked(&dev->bytes_identical));
52965 }
52966
52967 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52968 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52969 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52970 struct dlfb_data *dev = fb_info->par;
52971 return snprintf(buf, PAGE_SIZE, "%u\n",
52972 - atomic_read(&dev->bytes_sent));
52973 + atomic_read_unchecked(&dev->bytes_sent));
52974 }
52975
52976 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52977 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52978 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52979 struct dlfb_data *dev = fb_info->par;
52980 return snprintf(buf, PAGE_SIZE, "%u\n",
52981 - atomic_read(&dev->cpu_kcycles_used));
52982 + atomic_read_unchecked(&dev->cpu_kcycles_used));
52983 }
52984
52985 static ssize_t edid_show(
52986 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
52987 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52988 struct dlfb_data *dev = fb_info->par;
52989
52990 - atomic_set(&dev->bytes_rendered, 0);
52991 - atomic_set(&dev->bytes_identical, 0);
52992 - atomic_set(&dev->bytes_sent, 0);
52993 - atomic_set(&dev->cpu_kcycles_used, 0);
52994 + atomic_set_unchecked(&dev->bytes_rendered, 0);
52995 + atomic_set_unchecked(&dev->bytes_identical, 0);
52996 + atomic_set_unchecked(&dev->bytes_sent, 0);
52997 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
52998
52999 return count;
53000 }
53001 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
53002 index 7aec6f3..e3b2d55 100644
53003 --- a/drivers/video/uvesafb.c
53004 +++ b/drivers/video/uvesafb.c
53005 @@ -19,6 +19,7 @@
53006 #include <linux/io.h>
53007 #include <linux/mutex.h>
53008 #include <linux/slab.h>
53009 +#include <linux/moduleloader.h>
53010 #include <video/edid.h>
53011 #include <video/uvesafb.h>
53012 #ifdef CONFIG_X86
53013 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
53014 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
53015 par->pmi_setpal = par->ypan = 0;
53016 } else {
53017 +
53018 +#ifdef CONFIG_PAX_KERNEXEC
53019 +#ifdef CONFIG_MODULES
53020 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
53021 +#endif
53022 + if (!par->pmi_code) {
53023 + par->pmi_setpal = par->ypan = 0;
53024 + return 0;
53025 + }
53026 +#endif
53027 +
53028 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
53029 + task->t.regs.edi);
53030 +
53031 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53032 + pax_open_kernel();
53033 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
53034 + pax_close_kernel();
53035 +
53036 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
53037 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
53038 +#else
53039 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
53040 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
53041 +#endif
53042 +
53043 printk(KERN_INFO "uvesafb: protected mode interface info at "
53044 "%04x:%04x\n",
53045 (u16)task->t.regs.es, (u16)task->t.regs.edi);
53046 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
53047 par->ypan = ypan;
53048
53049 if (par->pmi_setpal || par->ypan) {
53050 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
53051 if (__supported_pte_mask & _PAGE_NX) {
53052 par->pmi_setpal = par->ypan = 0;
53053 printk(KERN_WARNING "uvesafb: NX protection is active, "
53054 "better not use the PMI.\n");
53055 - } else {
53056 + } else
53057 +#endif
53058 uvesafb_vbe_getpmi(task, par);
53059 - }
53060 }
53061 #else
53062 /* The protected mode interface is not available on non-x86. */
53063 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
53064 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
53065
53066 /* Disable blanking if the user requested so. */
53067 - if (!blank)
53068 - info->fbops->fb_blank = NULL;
53069 + if (!blank) {
53070 + pax_open_kernel();
53071 + *(void **)&info->fbops->fb_blank = NULL;
53072 + pax_close_kernel();
53073 + }
53074
53075 /*
53076 * Find out how much IO memory is required for the mode with
53077 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
53078 info->flags = FBINFO_FLAG_DEFAULT |
53079 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
53080
53081 - if (!par->ypan)
53082 - info->fbops->fb_pan_display = NULL;
53083 + if (!par->ypan) {
53084 + pax_open_kernel();
53085 + *(void **)&info->fbops->fb_pan_display = NULL;
53086 + pax_close_kernel();
53087 + }
53088 }
53089
53090 static void uvesafb_init_mtrr(struct fb_info *info)
53091 @@ -1796,6 +1826,11 @@ out:
53092 if (par->vbe_modes)
53093 kfree(par->vbe_modes);
53094
53095 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53096 + if (par->pmi_code)
53097 + module_free_exec(NULL, par->pmi_code);
53098 +#endif
53099 +
53100 framebuffer_release(info);
53101 return err;
53102 }
53103 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
53104 kfree(par->vbe_state_orig);
53105 if (par->vbe_state_saved)
53106 kfree(par->vbe_state_saved);
53107 +
53108 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53109 + if (par->pmi_code)
53110 + module_free_exec(NULL, par->pmi_code);
53111 +#endif
53112 +
53113 }
53114
53115 framebuffer_release(info);
53116 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
53117 index bd83233..7d8a5aa 100644
53118 --- a/drivers/video/vesafb.c
53119 +++ b/drivers/video/vesafb.c
53120 @@ -9,6 +9,7 @@
53121 */
53122
53123 #include <linux/module.h>
53124 +#include <linux/moduleloader.h>
53125 #include <linux/kernel.h>
53126 #include <linux/errno.h>
53127 #include <linux/string.h>
53128 @@ -52,8 +53,8 @@ static int vram_remap; /* Set amount of memory to be used */
53129 static int vram_total; /* Set total amount of memory */
53130 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
53131 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
53132 -static void (*pmi_start)(void) __read_mostly;
53133 -static void (*pmi_pal) (void) __read_mostly;
53134 +static void (*pmi_start)(void) __read_only;
53135 +static void (*pmi_pal) (void) __read_only;
53136 static int depth __read_mostly;
53137 static int vga_compat __read_mostly;
53138 /* --------------------------------------------------------------------- */
53139 @@ -234,6 +235,7 @@ static int vesafb_probe(struct platform_device *dev)
53140 unsigned int size_remap;
53141 unsigned int size_total;
53142 char *option = NULL;
53143 + void *pmi_code = NULL;
53144
53145 /* ignore error return of fb_get_options */
53146 fb_get_options("vesafb", &option);
53147 @@ -280,10 +282,6 @@ static int vesafb_probe(struct platform_device *dev)
53148 size_remap = size_total;
53149 vesafb_fix.smem_len = size_remap;
53150
53151 -#ifndef __i386__
53152 - screen_info.vesapm_seg = 0;
53153 -#endif
53154 -
53155 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
53156 printk(KERN_WARNING
53157 "vesafb: cannot reserve video memory at 0x%lx\n",
53158 @@ -312,9 +310,21 @@ static int vesafb_probe(struct platform_device *dev)
53159 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
53160 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
53161
53162 +#ifdef __i386__
53163 +
53164 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53165 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
53166 + if (!pmi_code)
53167 +#elif !defined(CONFIG_PAX_KERNEXEC)
53168 + if (0)
53169 +#endif
53170 +
53171 +#endif
53172 + screen_info.vesapm_seg = 0;
53173 +
53174 if (screen_info.vesapm_seg) {
53175 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
53176 - screen_info.vesapm_seg,screen_info.vesapm_off);
53177 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
53178 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
53179 }
53180
53181 if (screen_info.vesapm_seg < 0xc000)
53182 @@ -322,9 +332,25 @@ static int vesafb_probe(struct platform_device *dev)
53183
53184 if (ypan || pmi_setpal) {
53185 unsigned short *pmi_base;
53186 +
53187 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
53188 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
53189 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
53190 +
53191 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53192 + pax_open_kernel();
53193 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
53194 +#else
53195 + pmi_code = pmi_base;
53196 +#endif
53197 +
53198 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
53199 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
53200 +
53201 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53202 + pmi_start = ktva_ktla(pmi_start);
53203 + pmi_pal = ktva_ktla(pmi_pal);
53204 + pax_close_kernel();
53205 +#endif
53206 +
53207 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
53208 if (pmi_base[3]) {
53209 printk(KERN_INFO "vesafb: pmi: ports = ");
53210 @@ -477,8 +503,11 @@ static int vesafb_probe(struct platform_device *dev)
53211 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
53212 (ypan ? FBINFO_HWACCEL_YPAN : 0);
53213
53214 - if (!ypan)
53215 - info->fbops->fb_pan_display = NULL;
53216 + if (!ypan) {
53217 + pax_open_kernel();
53218 + *(void **)&info->fbops->fb_pan_display = NULL;
53219 + pax_close_kernel();
53220 + }
53221
53222 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
53223 err = -ENOMEM;
53224 @@ -493,6 +522,11 @@ static int vesafb_probe(struct platform_device *dev)
53225 info->node, info->fix.id);
53226 return 0;
53227 err:
53228 +
53229 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53230 + module_free_exec(NULL, pmi_code);
53231 +#endif
53232 +
53233 if (info->screen_base)
53234 iounmap(info->screen_base);
53235 framebuffer_release(info);
53236 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
53237 index 88714ae..16c2e11 100644
53238 --- a/drivers/video/via/via_clock.h
53239 +++ b/drivers/video/via/via_clock.h
53240 @@ -56,7 +56,7 @@ struct via_clock {
53241
53242 void (*set_engine_pll_state)(u8 state);
53243 void (*set_engine_pll)(struct via_pll_config config);
53244 -};
53245 +} __no_const;
53246
53247
53248 static inline u32 get_pll_internal_frequency(u32 ref_freq,
53249 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
53250 index fef20db..d28b1ab 100644
53251 --- a/drivers/xen/xenfs/xenstored.c
53252 +++ b/drivers/xen/xenfs/xenstored.c
53253 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
53254 static int xsd_kva_open(struct inode *inode, struct file *file)
53255 {
53256 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
53257 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53258 + NULL);
53259 +#else
53260 xen_store_interface);
53261 +#endif
53262 +
53263 if (!file->private_data)
53264 return -ENOMEM;
53265 return 0;
53266 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
53267 index 9ff073f..05cef23 100644
53268 --- a/fs/9p/vfs_addr.c
53269 +++ b/fs/9p/vfs_addr.c
53270 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
53271
53272 retval = v9fs_file_write_internal(inode,
53273 v9inode->writeback_fid,
53274 - (__force const char __user *)buffer,
53275 + (const char __force_user *)buffer,
53276 len, &offset, 0);
53277 if (retval > 0)
53278 retval = 0;
53279 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
53280 index 94de6d1..8d81256 100644
53281 --- a/fs/9p/vfs_inode.c
53282 +++ b/fs/9p/vfs_inode.c
53283 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
53284 void
53285 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53286 {
53287 - char *s = nd_get_link(nd);
53288 + const char *s = nd_get_link(nd);
53289
53290 p9_debug(P9_DEBUG_VFS, " %s %s\n",
53291 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
53292 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
53293 index 370b24c..ff0be7b 100644
53294 --- a/fs/Kconfig.binfmt
53295 +++ b/fs/Kconfig.binfmt
53296 @@ -103,7 +103,7 @@ config HAVE_AOUT
53297
53298 config BINFMT_AOUT
53299 tristate "Kernel support for a.out and ECOFF binaries"
53300 - depends on HAVE_AOUT
53301 + depends on HAVE_AOUT && BROKEN
53302 ---help---
53303 A.out (Assembler.OUTput) is a set of formats for libraries and
53304 executables used in the earliest versions of UNIX. Linux used
53305 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
53306 index 789bc25..fafaeea 100644
53307 --- a/fs/afs/inode.c
53308 +++ b/fs/afs/inode.c
53309 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
53310 struct afs_vnode *vnode;
53311 struct super_block *sb;
53312 struct inode *inode;
53313 - static atomic_t afs_autocell_ino;
53314 + static atomic_unchecked_t afs_autocell_ino;
53315
53316 _enter("{%x:%u},%*.*s,",
53317 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
53318 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
53319 data.fid.unique = 0;
53320 data.fid.vnode = 0;
53321
53322 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
53323 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
53324 afs_iget5_autocell_test, afs_iget5_set,
53325 &data);
53326 if (!inode) {
53327 diff --git a/fs/aio.c b/fs/aio.c
53328 index 062a5f6..e5618e0 100644
53329 --- a/fs/aio.c
53330 +++ b/fs/aio.c
53331 @@ -374,7 +374,7 @@ static int aio_setup_ring(struct kioctx *ctx)
53332 size += sizeof(struct io_event) * nr_events;
53333
53334 nr_pages = PFN_UP(size);
53335 - if (nr_pages < 0)
53336 + if (nr_pages <= 0)
53337 return -EINVAL;
53338
53339 file = aio_private_file(ctx, nr_pages);
53340 diff --git a/fs/attr.c b/fs/attr.c
53341 index 1449adb..a2038c2 100644
53342 --- a/fs/attr.c
53343 +++ b/fs/attr.c
53344 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
53345 unsigned long limit;
53346
53347 limit = rlimit(RLIMIT_FSIZE);
53348 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
53349 if (limit != RLIM_INFINITY && offset > limit)
53350 goto out_sig;
53351 if (offset > inode->i_sb->s_maxbytes)
53352 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
53353 index 689e40d..515cac5 100644
53354 --- a/fs/autofs4/waitq.c
53355 +++ b/fs/autofs4/waitq.c
53356 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
53357 {
53358 unsigned long sigpipe, flags;
53359 mm_segment_t fs;
53360 - const char *data = (const char *)addr;
53361 + const char __user *data = (const char __force_user *)addr;
53362 ssize_t wr = 0;
53363
53364 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
53365 @@ -340,6 +340,10 @@ static int validate_request(struct autofs_wait_queue **wait,
53366 return 1;
53367 }
53368
53369 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53370 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
53371 +#endif
53372 +
53373 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
53374 enum autofs_notify notify)
53375 {
53376 @@ -373,7 +377,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
53377
53378 /* If this is a direct mount request create a dummy name */
53379 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
53380 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53381 + /* this name does get written to userland via autofs4_write() */
53382 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
53383 +#else
53384 qstr.len = sprintf(name, "%p", dentry);
53385 +#endif
53386 else {
53387 qstr.len = autofs4_getpath(sbi, dentry, &name);
53388 if (!qstr.len) {
53389 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
53390 index 2722387..56059b5 100644
53391 --- a/fs/befs/endian.h
53392 +++ b/fs/befs/endian.h
53393 @@ -11,7 +11,7 @@
53394
53395 #include <asm/byteorder.h>
53396
53397 -static inline u64
53398 +static inline u64 __intentional_overflow(-1)
53399 fs64_to_cpu(const struct super_block *sb, fs64 n)
53400 {
53401 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
53402 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
53403 return (__force fs64)cpu_to_be64(n);
53404 }
53405
53406 -static inline u32
53407 +static inline u32 __intentional_overflow(-1)
53408 fs32_to_cpu(const struct super_block *sb, fs32 n)
53409 {
53410 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
53411 @@ -47,7 +47,7 @@ cpu_to_fs32(const struct super_block *sb, u32 n)
53412 return (__force fs32)cpu_to_be32(n);
53413 }
53414
53415 -static inline u16
53416 +static inline u16 __intentional_overflow(-1)
53417 fs16_to_cpu(const struct super_block *sb, fs16 n)
53418 {
53419 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
53420 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
53421 index e9c75e2..1baece1 100644
53422 --- a/fs/befs/linuxvfs.c
53423 +++ b/fs/befs/linuxvfs.c
53424 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53425 {
53426 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
53427 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
53428 - char *link = nd_get_link(nd);
53429 + const char *link = nd_get_link(nd);
53430 if (!IS_ERR(link))
53431 kfree(link);
53432 }
53433 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
53434 index 89dec7f..361b0d75 100644
53435 --- a/fs/binfmt_aout.c
53436 +++ b/fs/binfmt_aout.c
53437 @@ -16,6 +16,7 @@
53438 #include <linux/string.h>
53439 #include <linux/fs.h>
53440 #include <linux/file.h>
53441 +#include <linux/security.h>
53442 #include <linux/stat.h>
53443 #include <linux/fcntl.h>
53444 #include <linux/ptrace.h>
53445 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
53446 #endif
53447 # define START_STACK(u) ((void __user *)u.start_stack)
53448
53449 + memset(&dump, 0, sizeof(dump));
53450 +
53451 fs = get_fs();
53452 set_fs(KERNEL_DS);
53453 has_dumped = 1;
53454 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
53455
53456 /* If the size of the dump file exceeds the rlimit, then see what would happen
53457 if we wrote the stack, but not the data area. */
53458 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
53459 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
53460 dump.u_dsize = 0;
53461
53462 /* Make sure we have enough room to write the stack and data areas. */
53463 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
53464 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
53465 dump.u_ssize = 0;
53466
53467 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
53468 rlim = rlimit(RLIMIT_DATA);
53469 if (rlim >= RLIM_INFINITY)
53470 rlim = ~0;
53471 +
53472 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
53473 if (ex.a_data + ex.a_bss > rlim)
53474 return -ENOMEM;
53475
53476 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
53477
53478 install_exec_creds(bprm);
53479
53480 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53481 + current->mm->pax_flags = 0UL;
53482 +#endif
53483 +
53484 +#ifdef CONFIG_PAX_PAGEEXEC
53485 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
53486 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
53487 +
53488 +#ifdef CONFIG_PAX_EMUTRAMP
53489 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
53490 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
53491 +#endif
53492 +
53493 +#ifdef CONFIG_PAX_MPROTECT
53494 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
53495 + current->mm->pax_flags |= MF_PAX_MPROTECT;
53496 +#endif
53497 +
53498 + }
53499 +#endif
53500 +
53501 if (N_MAGIC(ex) == OMAGIC) {
53502 unsigned long text_addr, map_size;
53503 loff_t pos;
53504 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
53505 }
53506
53507 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
53508 - PROT_READ | PROT_WRITE | PROT_EXEC,
53509 + PROT_READ | PROT_WRITE,
53510 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
53511 fd_offset + ex.a_text);
53512 if (error != N_DATADDR(ex)) {
53513 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
53514 index 4c94a79..2610454 100644
53515 --- a/fs/binfmt_elf.c
53516 +++ b/fs/binfmt_elf.c
53517 @@ -34,6 +34,7 @@
53518 #include <linux/utsname.h>
53519 #include <linux/coredump.h>
53520 #include <linux/sched.h>
53521 +#include <linux/xattr.h>
53522 #include <asm/uaccess.h>
53523 #include <asm/param.h>
53524 #include <asm/page.h>
53525 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
53526 #define elf_core_dump NULL
53527 #endif
53528
53529 +#ifdef CONFIG_PAX_MPROTECT
53530 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
53531 +#endif
53532 +
53533 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53534 +static void elf_handle_mmap(struct file *file);
53535 +#endif
53536 +
53537 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
53538 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
53539 #else
53540 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
53541 .load_binary = load_elf_binary,
53542 .load_shlib = load_elf_library,
53543 .core_dump = elf_core_dump,
53544 +
53545 +#ifdef CONFIG_PAX_MPROTECT
53546 + .handle_mprotect= elf_handle_mprotect,
53547 +#endif
53548 +
53549 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53550 + .handle_mmap = elf_handle_mmap,
53551 +#endif
53552 +
53553 .min_coredump = ELF_EXEC_PAGESIZE,
53554 };
53555
53556 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
53557
53558 static int set_brk(unsigned long start, unsigned long end)
53559 {
53560 + unsigned long e = end;
53561 +
53562 start = ELF_PAGEALIGN(start);
53563 end = ELF_PAGEALIGN(end);
53564 if (end > start) {
53565 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
53566 if (BAD_ADDR(addr))
53567 return addr;
53568 }
53569 - current->mm->start_brk = current->mm->brk = end;
53570 + current->mm->start_brk = current->mm->brk = e;
53571 return 0;
53572 }
53573
53574 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53575 elf_addr_t __user *u_rand_bytes;
53576 const char *k_platform = ELF_PLATFORM;
53577 const char *k_base_platform = ELF_BASE_PLATFORM;
53578 - unsigned char k_rand_bytes[16];
53579 + u32 k_rand_bytes[4];
53580 int items;
53581 elf_addr_t *elf_info;
53582 int ei_index = 0;
53583 const struct cred *cred = current_cred();
53584 struct vm_area_struct *vma;
53585 + unsigned long saved_auxv[AT_VECTOR_SIZE];
53586
53587 /*
53588 * In some cases (e.g. Hyper-Threading), we want to avoid L1
53589 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53590 * Generate 16 random bytes for userspace PRNG seeding.
53591 */
53592 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
53593 - u_rand_bytes = (elf_addr_t __user *)
53594 - STACK_ALLOC(p, sizeof(k_rand_bytes));
53595 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
53596 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
53597 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
53598 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
53599 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
53600 + u_rand_bytes = (elf_addr_t __user *) p;
53601 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
53602 return -EFAULT;
53603
53604 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53605 return -EFAULT;
53606 current->mm->env_end = p;
53607
53608 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
53609 +
53610 /* Put the elf_info on the stack in the right place. */
53611 sp = (elf_addr_t __user *)envp + 1;
53612 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
53613 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
53614 return -EFAULT;
53615 return 0;
53616 }
53617 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
53618 an ELF header */
53619
53620 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53621 - struct file *interpreter, unsigned long *interp_map_addr,
53622 - unsigned long no_base)
53623 + struct file *interpreter, unsigned long no_base)
53624 {
53625 struct elf_phdr *elf_phdata;
53626 struct elf_phdr *eppnt;
53627 - unsigned long load_addr = 0;
53628 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
53629 int load_addr_set = 0;
53630 unsigned long last_bss = 0, elf_bss = 0;
53631 - unsigned long error = ~0UL;
53632 + unsigned long error = -EINVAL;
53633 unsigned long total_size;
53634 int retval, i, size;
53635
53636 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53637 goto out_close;
53638 }
53639
53640 +#ifdef CONFIG_PAX_SEGMEXEC
53641 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
53642 + pax_task_size = SEGMEXEC_TASK_SIZE;
53643 +#endif
53644 +
53645 eppnt = elf_phdata;
53646 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
53647 if (eppnt->p_type == PT_LOAD) {
53648 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53649 map_addr = elf_map(interpreter, load_addr + vaddr,
53650 eppnt, elf_prot, elf_type, total_size);
53651 total_size = 0;
53652 - if (!*interp_map_addr)
53653 - *interp_map_addr = map_addr;
53654 error = map_addr;
53655 if (BAD_ADDR(map_addr))
53656 goto out_close;
53657 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53658 k = load_addr + eppnt->p_vaddr;
53659 if (BAD_ADDR(k) ||
53660 eppnt->p_filesz > eppnt->p_memsz ||
53661 - eppnt->p_memsz > TASK_SIZE ||
53662 - TASK_SIZE - eppnt->p_memsz < k) {
53663 + eppnt->p_memsz > pax_task_size ||
53664 + pax_task_size - eppnt->p_memsz < k) {
53665 error = -ENOMEM;
53666 goto out_close;
53667 }
53668 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53669 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
53670
53671 /* Map the last of the bss segment */
53672 - error = vm_brk(elf_bss, last_bss - elf_bss);
53673 - if (BAD_ADDR(error))
53674 - goto out_close;
53675 + if (last_bss > elf_bss) {
53676 + error = vm_brk(elf_bss, last_bss - elf_bss);
53677 + if (BAD_ADDR(error))
53678 + goto out_close;
53679 + }
53680 }
53681
53682 error = load_addr;
53683 @@ -538,6 +569,315 @@ out:
53684 return error;
53685 }
53686
53687 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53688 +#ifdef CONFIG_PAX_SOFTMODE
53689 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
53690 +{
53691 + unsigned long pax_flags = 0UL;
53692 +
53693 +#ifdef CONFIG_PAX_PAGEEXEC
53694 + if (elf_phdata->p_flags & PF_PAGEEXEC)
53695 + pax_flags |= MF_PAX_PAGEEXEC;
53696 +#endif
53697 +
53698 +#ifdef CONFIG_PAX_SEGMEXEC
53699 + if (elf_phdata->p_flags & PF_SEGMEXEC)
53700 + pax_flags |= MF_PAX_SEGMEXEC;
53701 +#endif
53702 +
53703 +#ifdef CONFIG_PAX_EMUTRAMP
53704 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53705 + pax_flags |= MF_PAX_EMUTRAMP;
53706 +#endif
53707 +
53708 +#ifdef CONFIG_PAX_MPROTECT
53709 + if (elf_phdata->p_flags & PF_MPROTECT)
53710 + pax_flags |= MF_PAX_MPROTECT;
53711 +#endif
53712 +
53713 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53714 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
53715 + pax_flags |= MF_PAX_RANDMMAP;
53716 +#endif
53717 +
53718 + return pax_flags;
53719 +}
53720 +#endif
53721 +
53722 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
53723 +{
53724 + unsigned long pax_flags = 0UL;
53725 +
53726 +#ifdef CONFIG_PAX_PAGEEXEC
53727 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
53728 + pax_flags |= MF_PAX_PAGEEXEC;
53729 +#endif
53730 +
53731 +#ifdef CONFIG_PAX_SEGMEXEC
53732 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
53733 + pax_flags |= MF_PAX_SEGMEXEC;
53734 +#endif
53735 +
53736 +#ifdef CONFIG_PAX_EMUTRAMP
53737 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
53738 + pax_flags |= MF_PAX_EMUTRAMP;
53739 +#endif
53740 +
53741 +#ifdef CONFIG_PAX_MPROTECT
53742 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
53743 + pax_flags |= MF_PAX_MPROTECT;
53744 +#endif
53745 +
53746 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53747 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
53748 + pax_flags |= MF_PAX_RANDMMAP;
53749 +#endif
53750 +
53751 + return pax_flags;
53752 +}
53753 +#endif
53754 +
53755 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53756 +#ifdef CONFIG_PAX_SOFTMODE
53757 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
53758 +{
53759 + unsigned long pax_flags = 0UL;
53760 +
53761 +#ifdef CONFIG_PAX_PAGEEXEC
53762 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
53763 + pax_flags |= MF_PAX_PAGEEXEC;
53764 +#endif
53765 +
53766 +#ifdef CONFIG_PAX_SEGMEXEC
53767 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
53768 + pax_flags |= MF_PAX_SEGMEXEC;
53769 +#endif
53770 +
53771 +#ifdef CONFIG_PAX_EMUTRAMP
53772 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53773 + pax_flags |= MF_PAX_EMUTRAMP;
53774 +#endif
53775 +
53776 +#ifdef CONFIG_PAX_MPROTECT
53777 + if (pax_flags_softmode & MF_PAX_MPROTECT)
53778 + pax_flags |= MF_PAX_MPROTECT;
53779 +#endif
53780 +
53781 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53782 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
53783 + pax_flags |= MF_PAX_RANDMMAP;
53784 +#endif
53785 +
53786 + return pax_flags;
53787 +}
53788 +#endif
53789 +
53790 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
53791 +{
53792 + unsigned long pax_flags = 0UL;
53793 +
53794 +#ifdef CONFIG_PAX_PAGEEXEC
53795 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
53796 + pax_flags |= MF_PAX_PAGEEXEC;
53797 +#endif
53798 +
53799 +#ifdef CONFIG_PAX_SEGMEXEC
53800 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
53801 + pax_flags |= MF_PAX_SEGMEXEC;
53802 +#endif
53803 +
53804 +#ifdef CONFIG_PAX_EMUTRAMP
53805 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
53806 + pax_flags |= MF_PAX_EMUTRAMP;
53807 +#endif
53808 +
53809 +#ifdef CONFIG_PAX_MPROTECT
53810 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
53811 + pax_flags |= MF_PAX_MPROTECT;
53812 +#endif
53813 +
53814 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53815 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
53816 + pax_flags |= MF_PAX_RANDMMAP;
53817 +#endif
53818 +
53819 + return pax_flags;
53820 +}
53821 +#endif
53822 +
53823 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53824 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
53825 +{
53826 + unsigned long pax_flags = 0UL;
53827 +
53828 +#ifdef CONFIG_PAX_EI_PAX
53829 +
53830 +#ifdef CONFIG_PAX_PAGEEXEC
53831 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
53832 + pax_flags |= MF_PAX_PAGEEXEC;
53833 +#endif
53834 +
53835 +#ifdef CONFIG_PAX_SEGMEXEC
53836 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
53837 + pax_flags |= MF_PAX_SEGMEXEC;
53838 +#endif
53839 +
53840 +#ifdef CONFIG_PAX_EMUTRAMP
53841 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
53842 + pax_flags |= MF_PAX_EMUTRAMP;
53843 +#endif
53844 +
53845 +#ifdef CONFIG_PAX_MPROTECT
53846 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
53847 + pax_flags |= MF_PAX_MPROTECT;
53848 +#endif
53849 +
53850 +#ifdef CONFIG_PAX_ASLR
53851 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
53852 + pax_flags |= MF_PAX_RANDMMAP;
53853 +#endif
53854 +
53855 +#else
53856 +
53857 +#ifdef CONFIG_PAX_PAGEEXEC
53858 + pax_flags |= MF_PAX_PAGEEXEC;
53859 +#endif
53860 +
53861 +#ifdef CONFIG_PAX_SEGMEXEC
53862 + pax_flags |= MF_PAX_SEGMEXEC;
53863 +#endif
53864 +
53865 +#ifdef CONFIG_PAX_MPROTECT
53866 + pax_flags |= MF_PAX_MPROTECT;
53867 +#endif
53868 +
53869 +#ifdef CONFIG_PAX_RANDMMAP
53870 + if (randomize_va_space)
53871 + pax_flags |= MF_PAX_RANDMMAP;
53872 +#endif
53873 +
53874 +#endif
53875 +
53876 + return pax_flags;
53877 +}
53878 +
53879 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
53880 +{
53881 +
53882 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53883 + unsigned long i;
53884 +
53885 + for (i = 0UL; i < elf_ex->e_phnum; i++)
53886 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
53887 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
53888 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
53889 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
53890 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
53891 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
53892 + return ~0UL;
53893 +
53894 +#ifdef CONFIG_PAX_SOFTMODE
53895 + if (pax_softmode)
53896 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
53897 + else
53898 +#endif
53899 +
53900 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
53901 + break;
53902 + }
53903 +#endif
53904 +
53905 + return ~0UL;
53906 +}
53907 +
53908 +static unsigned long pax_parse_xattr_pax(struct file * const file)
53909 +{
53910 +
53911 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53912 + ssize_t xattr_size, i;
53913 + unsigned char xattr_value[sizeof("pemrs") - 1];
53914 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
53915 +
53916 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
53917 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
53918 + return ~0UL;
53919 +
53920 + for (i = 0; i < xattr_size; i++)
53921 + switch (xattr_value[i]) {
53922 + default:
53923 + return ~0UL;
53924 +
53925 +#define parse_flag(option1, option2, flag) \
53926 + case option1: \
53927 + if (pax_flags_hardmode & MF_PAX_##flag) \
53928 + return ~0UL; \
53929 + pax_flags_hardmode |= MF_PAX_##flag; \
53930 + break; \
53931 + case option2: \
53932 + if (pax_flags_softmode & MF_PAX_##flag) \
53933 + return ~0UL; \
53934 + pax_flags_softmode |= MF_PAX_##flag; \
53935 + break;
53936 +
53937 + parse_flag('p', 'P', PAGEEXEC);
53938 + parse_flag('e', 'E', EMUTRAMP);
53939 + parse_flag('m', 'M', MPROTECT);
53940 + parse_flag('r', 'R', RANDMMAP);
53941 + parse_flag('s', 'S', SEGMEXEC);
53942 +
53943 +#undef parse_flag
53944 + }
53945 +
53946 + if (pax_flags_hardmode & pax_flags_softmode)
53947 + return ~0UL;
53948 +
53949 +#ifdef CONFIG_PAX_SOFTMODE
53950 + if (pax_softmode)
53951 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
53952 + else
53953 +#endif
53954 +
53955 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
53956 +#else
53957 + return ~0UL;
53958 +#endif
53959 +
53960 +}
53961 +
53962 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
53963 +{
53964 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
53965 +
53966 + pax_flags = pax_parse_ei_pax(elf_ex);
53967 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
53968 + xattr_pax_flags = pax_parse_xattr_pax(file);
53969 +
53970 + if (pt_pax_flags == ~0UL)
53971 + pt_pax_flags = xattr_pax_flags;
53972 + else if (xattr_pax_flags == ~0UL)
53973 + xattr_pax_flags = pt_pax_flags;
53974 + if (pt_pax_flags != xattr_pax_flags)
53975 + return -EINVAL;
53976 + if (pt_pax_flags != ~0UL)
53977 + pax_flags = pt_pax_flags;
53978 +
53979 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
53980 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53981 + if ((__supported_pte_mask & _PAGE_NX))
53982 + pax_flags &= ~MF_PAX_SEGMEXEC;
53983 + else
53984 + pax_flags &= ~MF_PAX_PAGEEXEC;
53985 + }
53986 +#endif
53987 +
53988 + if (0 > pax_check_flags(&pax_flags))
53989 + return -EINVAL;
53990 +
53991 + current->mm->pax_flags = pax_flags;
53992 + return 0;
53993 +}
53994 +#endif
53995 +
53996 /*
53997 * These are the functions used to load ELF style executables and shared
53998 * libraries. There is no binary dependent code anywhere else.
53999 @@ -554,6 +894,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
54000 {
54001 unsigned int random_variable = 0;
54002
54003 +#ifdef CONFIG_PAX_RANDUSTACK
54004 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
54005 + return stack_top - current->mm->delta_stack;
54006 +#endif
54007 +
54008 if ((current->flags & PF_RANDOMIZE) &&
54009 !(current->personality & ADDR_NO_RANDOMIZE)) {
54010 random_variable = get_random_int() & STACK_RND_MASK;
54011 @@ -572,7 +917,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
54012 unsigned long load_addr = 0, load_bias = 0;
54013 int load_addr_set = 0;
54014 char * elf_interpreter = NULL;
54015 - unsigned long error;
54016 + unsigned long error = 0;
54017 struct elf_phdr *elf_ppnt, *elf_phdata;
54018 unsigned long elf_bss, elf_brk;
54019 int retval, i;
54020 @@ -582,12 +927,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
54021 unsigned long start_code, end_code, start_data, end_data;
54022 unsigned long reloc_func_desc __maybe_unused = 0;
54023 int executable_stack = EXSTACK_DEFAULT;
54024 - unsigned long def_flags = 0;
54025 struct pt_regs *regs = current_pt_regs();
54026 struct {
54027 struct elfhdr elf_ex;
54028 struct elfhdr interp_elf_ex;
54029 } *loc;
54030 + unsigned long pax_task_size;
54031
54032 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
54033 if (!loc) {
54034 @@ -723,11 +1068,82 @@ static int load_elf_binary(struct linux_binprm *bprm)
54035 goto out_free_dentry;
54036
54037 /* OK, This is the point of no return */
54038 - current->mm->def_flags = def_flags;
54039 + current->mm->def_flags = 0;
54040
54041 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
54042 may depend on the personality. */
54043 SET_PERSONALITY(loc->elf_ex);
54044 +
54045 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54046 + current->mm->pax_flags = 0UL;
54047 +#endif
54048 +
54049 +#ifdef CONFIG_PAX_DLRESOLVE
54050 + current->mm->call_dl_resolve = 0UL;
54051 +#endif
54052 +
54053 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
54054 + current->mm->call_syscall = 0UL;
54055 +#endif
54056 +
54057 +#ifdef CONFIG_PAX_ASLR
54058 + current->mm->delta_mmap = 0UL;
54059 + current->mm->delta_stack = 0UL;
54060 +#endif
54061 +
54062 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54063 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
54064 + send_sig(SIGKILL, current, 0);
54065 + goto out_free_dentry;
54066 + }
54067 +#endif
54068 +
54069 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
54070 + pax_set_initial_flags(bprm);
54071 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
54072 + if (pax_set_initial_flags_func)
54073 + (pax_set_initial_flags_func)(bprm);
54074 +#endif
54075 +
54076 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
54077 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
54078 + current->mm->context.user_cs_limit = PAGE_SIZE;
54079 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
54080 + }
54081 +#endif
54082 +
54083 +#ifdef CONFIG_PAX_SEGMEXEC
54084 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
54085 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
54086 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
54087 + pax_task_size = SEGMEXEC_TASK_SIZE;
54088 + current->mm->def_flags |= VM_NOHUGEPAGE;
54089 + } else
54090 +#endif
54091 +
54092 + pax_task_size = TASK_SIZE;
54093 +
54094 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
54095 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54096 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
54097 + put_cpu();
54098 + }
54099 +#endif
54100 +
54101 +#ifdef CONFIG_PAX_ASLR
54102 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
54103 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
54104 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
54105 + }
54106 +#endif
54107 +
54108 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
54109 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54110 + executable_stack = EXSTACK_DISABLE_X;
54111 + current->personality &= ~READ_IMPLIES_EXEC;
54112 + } else
54113 +#endif
54114 +
54115 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
54116 current->personality |= READ_IMPLIES_EXEC;
54117
54118 @@ -817,6 +1233,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
54119 #else
54120 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
54121 #endif
54122 +
54123 +#ifdef CONFIG_PAX_RANDMMAP
54124 + /* PaX: randomize base address at the default exe base if requested */
54125 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
54126 +#ifdef CONFIG_SPARC64
54127 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
54128 +#else
54129 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
54130 +#endif
54131 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
54132 + elf_flags |= MAP_FIXED;
54133 + }
54134 +#endif
54135 +
54136 }
54137
54138 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
54139 @@ -849,9 +1279,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
54140 * allowed task size. Note that p_filesz must always be
54141 * <= p_memsz so it is only necessary to check p_memsz.
54142 */
54143 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
54144 - elf_ppnt->p_memsz > TASK_SIZE ||
54145 - TASK_SIZE - elf_ppnt->p_memsz < k) {
54146 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
54147 + elf_ppnt->p_memsz > pax_task_size ||
54148 + pax_task_size - elf_ppnt->p_memsz < k) {
54149 /* set_brk can never work. Avoid overflows. */
54150 send_sig(SIGKILL, current, 0);
54151 retval = -EINVAL;
54152 @@ -890,17 +1320,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
54153 goto out_free_dentry;
54154 }
54155 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
54156 - send_sig(SIGSEGV, current, 0);
54157 - retval = -EFAULT; /* Nobody gets to see this, but.. */
54158 - goto out_free_dentry;
54159 + /*
54160 + * This bss-zeroing can fail if the ELF
54161 + * file specifies odd protections. So
54162 + * we don't check the return value
54163 + */
54164 }
54165
54166 +#ifdef CONFIG_PAX_RANDMMAP
54167 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
54168 + unsigned long start, size, flags;
54169 + vm_flags_t vm_flags;
54170 +
54171 + start = ELF_PAGEALIGN(elf_brk);
54172 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
54173 + flags = MAP_FIXED | MAP_PRIVATE;
54174 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
54175 +
54176 + down_write(&current->mm->mmap_sem);
54177 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
54178 + retval = -ENOMEM;
54179 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
54180 +// if (current->personality & ADDR_NO_RANDOMIZE)
54181 +// vm_flags |= VM_READ | VM_MAYREAD;
54182 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
54183 + retval = IS_ERR_VALUE(start) ? start : 0;
54184 + }
54185 + up_write(&current->mm->mmap_sem);
54186 + if (retval == 0)
54187 + retval = set_brk(start + size, start + size + PAGE_SIZE);
54188 + if (retval < 0) {
54189 + send_sig(SIGKILL, current, 0);
54190 + goto out_free_dentry;
54191 + }
54192 + }
54193 +#endif
54194 +
54195 if (elf_interpreter) {
54196 - unsigned long interp_map_addr = 0;
54197 -
54198 elf_entry = load_elf_interp(&loc->interp_elf_ex,
54199 interpreter,
54200 - &interp_map_addr,
54201 load_bias);
54202 if (!IS_ERR((void *)elf_entry)) {
54203 /*
54204 @@ -1122,7 +1580,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
54205 * Decide what to dump of a segment, part, all or none.
54206 */
54207 static unsigned long vma_dump_size(struct vm_area_struct *vma,
54208 - unsigned long mm_flags)
54209 + unsigned long mm_flags, long signr)
54210 {
54211 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
54212
54213 @@ -1160,7 +1618,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
54214 if (vma->vm_file == NULL)
54215 return 0;
54216
54217 - if (FILTER(MAPPED_PRIVATE))
54218 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
54219 goto whole;
54220
54221 /*
54222 @@ -1385,9 +1843,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
54223 {
54224 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
54225 int i = 0;
54226 - do
54227 + do {
54228 i += 2;
54229 - while (auxv[i - 2] != AT_NULL);
54230 + } while (auxv[i - 2] != AT_NULL);
54231 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
54232 }
54233
54234 @@ -1396,7 +1854,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
54235 {
54236 mm_segment_t old_fs = get_fs();
54237 set_fs(KERNEL_DS);
54238 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
54239 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
54240 set_fs(old_fs);
54241 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
54242 }
54243 @@ -2023,14 +2481,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
54244 }
54245
54246 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
54247 - unsigned long mm_flags)
54248 + struct coredump_params *cprm)
54249 {
54250 struct vm_area_struct *vma;
54251 size_t size = 0;
54252
54253 for (vma = first_vma(current, gate_vma); vma != NULL;
54254 vma = next_vma(vma, gate_vma))
54255 - size += vma_dump_size(vma, mm_flags);
54256 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54257 return size;
54258 }
54259
54260 @@ -2123,7 +2581,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54261
54262 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
54263
54264 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
54265 + offset += elf_core_vma_data_size(gate_vma, cprm);
54266 offset += elf_core_extra_data_size();
54267 e_shoff = offset;
54268
54269 @@ -2137,10 +2595,12 @@ static int elf_core_dump(struct coredump_params *cprm)
54270 offset = dataoff;
54271
54272 size += sizeof(*elf);
54273 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54274 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
54275 goto end_coredump;
54276
54277 size += sizeof(*phdr4note);
54278 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54279 if (size > cprm->limit
54280 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
54281 goto end_coredump;
54282 @@ -2154,7 +2614,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54283 phdr.p_offset = offset;
54284 phdr.p_vaddr = vma->vm_start;
54285 phdr.p_paddr = 0;
54286 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
54287 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54288 phdr.p_memsz = vma->vm_end - vma->vm_start;
54289 offset += phdr.p_filesz;
54290 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
54291 @@ -2165,6 +2625,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54292 phdr.p_align = ELF_EXEC_PAGESIZE;
54293
54294 size += sizeof(phdr);
54295 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54296 if (size > cprm->limit
54297 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
54298 goto end_coredump;
54299 @@ -2189,7 +2650,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54300 unsigned long addr;
54301 unsigned long end;
54302
54303 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
54304 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54305
54306 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
54307 struct page *page;
54308 @@ -2198,6 +2659,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54309 page = get_dump_page(addr);
54310 if (page) {
54311 void *kaddr = kmap(page);
54312 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
54313 stop = ((size += PAGE_SIZE) > cprm->limit) ||
54314 !dump_write(cprm->file, kaddr,
54315 PAGE_SIZE);
54316 @@ -2215,6 +2677,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54317
54318 if (e_phnum == PN_XNUM) {
54319 size += sizeof(*shdr4extnum);
54320 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54321 if (size > cprm->limit
54322 || !dump_write(cprm->file, shdr4extnum,
54323 sizeof(*shdr4extnum)))
54324 @@ -2235,6 +2698,167 @@ out:
54325
54326 #endif /* CONFIG_ELF_CORE */
54327
54328 +#ifdef CONFIG_PAX_MPROTECT
54329 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
54330 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
54331 + * we'll remove VM_MAYWRITE for good on RELRO segments.
54332 + *
54333 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
54334 + * basis because we want to allow the common case and not the special ones.
54335 + */
54336 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
54337 +{
54338 + struct elfhdr elf_h;
54339 + struct elf_phdr elf_p;
54340 + unsigned long i;
54341 + unsigned long oldflags;
54342 + bool is_textrel_rw, is_textrel_rx, is_relro;
54343 +
54344 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
54345 + return;
54346 +
54347 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
54348 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
54349 +
54350 +#ifdef CONFIG_PAX_ELFRELOCS
54351 + /* possible TEXTREL */
54352 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
54353 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
54354 +#else
54355 + is_textrel_rw = false;
54356 + is_textrel_rx = false;
54357 +#endif
54358 +
54359 + /* possible RELRO */
54360 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
54361 +
54362 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
54363 + return;
54364 +
54365 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
54366 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
54367 +
54368 +#ifdef CONFIG_PAX_ETEXECRELOCS
54369 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
54370 +#else
54371 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
54372 +#endif
54373 +
54374 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
54375 + !elf_check_arch(&elf_h) ||
54376 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
54377 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
54378 + return;
54379 +
54380 + for (i = 0UL; i < elf_h.e_phnum; i++) {
54381 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
54382 + return;
54383 + switch (elf_p.p_type) {
54384 + case PT_DYNAMIC:
54385 + if (!is_textrel_rw && !is_textrel_rx)
54386 + continue;
54387 + i = 0UL;
54388 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
54389 + elf_dyn dyn;
54390 +
54391 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
54392 + break;
54393 + if (dyn.d_tag == DT_NULL)
54394 + break;
54395 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
54396 + gr_log_textrel(vma);
54397 + if (is_textrel_rw)
54398 + vma->vm_flags |= VM_MAYWRITE;
54399 + else
54400 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
54401 + vma->vm_flags &= ~VM_MAYWRITE;
54402 + break;
54403 + }
54404 + i++;
54405 + }
54406 + is_textrel_rw = false;
54407 + is_textrel_rx = false;
54408 + continue;
54409 +
54410 + case PT_GNU_RELRO:
54411 + if (!is_relro)
54412 + continue;
54413 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
54414 + vma->vm_flags &= ~VM_MAYWRITE;
54415 + is_relro = false;
54416 + continue;
54417 +
54418 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
54419 + case PT_PAX_FLAGS: {
54420 + const char *msg_mprotect = "", *msg_emutramp = "";
54421 + char *buffer_lib, *buffer_exe;
54422 +
54423 + if (elf_p.p_flags & PF_NOMPROTECT)
54424 + msg_mprotect = "MPROTECT disabled";
54425 +
54426 +#ifdef CONFIG_PAX_EMUTRAMP
54427 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
54428 + msg_emutramp = "EMUTRAMP enabled";
54429 +#endif
54430 +
54431 + if (!msg_mprotect[0] && !msg_emutramp[0])
54432 + continue;
54433 +
54434 + if (!printk_ratelimit())
54435 + continue;
54436 +
54437 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
54438 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
54439 + if (buffer_lib && buffer_exe) {
54440 + char *path_lib, *path_exe;
54441 +
54442 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
54443 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
54444 +
54445 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
54446 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
54447 +
54448 + }
54449 + free_page((unsigned long)buffer_exe);
54450 + free_page((unsigned long)buffer_lib);
54451 + continue;
54452 + }
54453 +#endif
54454 +
54455 + }
54456 + }
54457 +}
54458 +#endif
54459 +
54460 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
54461 +
54462 +extern int grsec_enable_log_rwxmaps;
54463 +
54464 +static void elf_handle_mmap(struct file *file)
54465 +{
54466 + struct elfhdr elf_h;
54467 + struct elf_phdr elf_p;
54468 + unsigned long i;
54469 +
54470 + if (!grsec_enable_log_rwxmaps)
54471 + return;
54472 +
54473 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
54474 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
54475 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
54476 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
54477 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
54478 + return;
54479 +
54480 + for (i = 0UL; i < elf_h.e_phnum; i++) {
54481 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
54482 + return;
54483 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
54484 + gr_log_ptgnustack(file);
54485 + }
54486 +}
54487 +#endif
54488 +
54489 static int __init init_elf_binfmt(void)
54490 {
54491 register_binfmt(&elf_format);
54492 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
54493 index d50bbe5..af3b649 100644
54494 --- a/fs/binfmt_flat.c
54495 +++ b/fs/binfmt_flat.c
54496 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
54497 realdatastart = (unsigned long) -ENOMEM;
54498 printk("Unable to allocate RAM for process data, errno %d\n",
54499 (int)-realdatastart);
54500 + down_write(&current->mm->mmap_sem);
54501 vm_munmap(textpos, text_len);
54502 + up_write(&current->mm->mmap_sem);
54503 ret = realdatastart;
54504 goto err;
54505 }
54506 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
54507 }
54508 if (IS_ERR_VALUE(result)) {
54509 printk("Unable to read data+bss, errno %d\n", (int)-result);
54510 + down_write(&current->mm->mmap_sem);
54511 vm_munmap(textpos, text_len);
54512 vm_munmap(realdatastart, len);
54513 + up_write(&current->mm->mmap_sem);
54514 ret = result;
54515 goto err;
54516 }
54517 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
54518 }
54519 if (IS_ERR_VALUE(result)) {
54520 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
54521 + down_write(&current->mm->mmap_sem);
54522 vm_munmap(textpos, text_len + data_len + extra +
54523 MAX_SHARED_LIBS * sizeof(unsigned long));
54524 + up_write(&current->mm->mmap_sem);
54525 ret = result;
54526 goto err;
54527 }
54528 diff --git a/fs/bio.c b/fs/bio.c
54529 index ea5035d..a2932eb 100644
54530 --- a/fs/bio.c
54531 +++ b/fs/bio.c
54532 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
54533 /*
54534 * Overflow, abort
54535 */
54536 - if (end < start)
54537 + if (end < start || end - start > INT_MAX - nr_pages)
54538 return ERR_PTR(-EINVAL);
54539
54540 nr_pages += end - start;
54541 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
54542 /*
54543 * Overflow, abort
54544 */
54545 - if (end < start)
54546 + if (end < start || end - start > INT_MAX - nr_pages)
54547 return ERR_PTR(-EINVAL);
54548
54549 nr_pages += end - start;
54550 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
54551 const int read = bio_data_dir(bio) == READ;
54552 struct bio_map_data *bmd = bio->bi_private;
54553 int i;
54554 - char *p = bmd->sgvecs[0].iov_base;
54555 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
54556
54557 bio_for_each_segment_all(bvec, bio, i) {
54558 char *addr = page_address(bvec->bv_page);
54559 diff --git a/fs/block_dev.c b/fs/block_dev.c
54560 index 1e86823..8e34695 100644
54561 --- a/fs/block_dev.c
54562 +++ b/fs/block_dev.c
54563 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
54564 else if (bdev->bd_contains == bdev)
54565 return true; /* is a whole device which isn't held */
54566
54567 - else if (whole->bd_holder == bd_may_claim)
54568 + else if (whole->bd_holder == (void *)bd_may_claim)
54569 return true; /* is a partition of a device that is being partitioned */
54570 else if (whole->bd_holder != NULL)
54571 return false; /* is a partition of a held device */
54572 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
54573 index b544a44..f3fb987 100644
54574 --- a/fs/btrfs/ctree.c
54575 +++ b/fs/btrfs/ctree.c
54576 @@ -1028,9 +1028,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
54577 free_extent_buffer(buf);
54578 add_root_to_dirty_list(root);
54579 } else {
54580 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
54581 - parent_start = parent->start;
54582 - else
54583 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
54584 + if (parent)
54585 + parent_start = parent->start;
54586 + else
54587 + parent_start = 0;
54588 + } else
54589 parent_start = 0;
54590
54591 WARN_ON(trans->transid != btrfs_header_generation(parent));
54592 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
54593 index cbd9523..5cca781 100644
54594 --- a/fs/btrfs/delayed-inode.c
54595 +++ b/fs/btrfs/delayed-inode.c
54596 @@ -459,7 +459,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
54597
54598 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
54599 {
54600 - int seq = atomic_inc_return(&delayed_root->items_seq);
54601 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
54602 if ((atomic_dec_return(&delayed_root->items) <
54603 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
54604 waitqueue_active(&delayed_root->wait))
54605 @@ -1378,7 +1378,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
54606 static int refs_newer(struct btrfs_delayed_root *delayed_root,
54607 int seq, int count)
54608 {
54609 - int val = atomic_read(&delayed_root->items_seq);
54610 + int val = atomic_read_unchecked(&delayed_root->items_seq);
54611
54612 if (val < seq || val >= seq + count)
54613 return 1;
54614 @@ -1395,7 +1395,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
54615 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
54616 return;
54617
54618 - seq = atomic_read(&delayed_root->items_seq);
54619 + seq = atomic_read_unchecked(&delayed_root->items_seq);
54620
54621 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
54622 int ret;
54623 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
54624 index a4b38f9..f86a509 100644
54625 --- a/fs/btrfs/delayed-inode.h
54626 +++ b/fs/btrfs/delayed-inode.h
54627 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
54628 */
54629 struct list_head prepare_list;
54630 atomic_t items; /* for delayed items */
54631 - atomic_t items_seq; /* for delayed items */
54632 + atomic_unchecked_t items_seq; /* for delayed items */
54633 int nodes; /* for delayed nodes */
54634 wait_queue_head_t wait;
54635 };
54636 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
54637 struct btrfs_delayed_root *delayed_root)
54638 {
54639 atomic_set(&delayed_root->items, 0);
54640 - atomic_set(&delayed_root->items_seq, 0);
54641 + atomic_set_unchecked(&delayed_root->items_seq, 0);
54642 delayed_root->nodes = 0;
54643 spin_lock_init(&delayed_root->lock);
54644 init_waitqueue_head(&delayed_root->wait);
54645 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
54646 index 8747feb..ad1655c 100644
54647 --- a/fs/btrfs/ioctl.c
54648 +++ b/fs/btrfs/ioctl.c
54649 @@ -3465,9 +3465,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
54650 for (i = 0; i < num_types; i++) {
54651 struct btrfs_space_info *tmp;
54652
54653 + /* Don't copy in more than we allocated */
54654 if (!slot_count)
54655 break;
54656
54657 + slot_count--;
54658 +
54659 info = NULL;
54660 rcu_read_lock();
54661 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
54662 @@ -3489,10 +3492,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
54663 memcpy(dest, &space, sizeof(space));
54664 dest++;
54665 space_args.total_spaces++;
54666 - slot_count--;
54667 }
54668 - if (!slot_count)
54669 - break;
54670 }
54671 up_read(&info->groups_sem);
54672 }
54673 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
54674 index e913328..a34fb36 100644
54675 --- a/fs/btrfs/super.c
54676 +++ b/fs/btrfs/super.c
54677 @@ -266,7 +266,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
54678 function, line, errstr);
54679 return;
54680 }
54681 - ACCESS_ONCE(trans->transaction->aborted) = errno;
54682 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
54683 /* Wake up anybody who may be waiting on this transaction */
54684 wake_up(&root->fs_info->transaction_wait);
54685 wake_up(&root->fs_info->transaction_blocked_wait);
54686 diff --git a/fs/buffer.c b/fs/buffer.c
54687 index 6024877..7bd000a 100644
54688 --- a/fs/buffer.c
54689 +++ b/fs/buffer.c
54690 @@ -3426,7 +3426,7 @@ void __init buffer_init(void)
54691 bh_cachep = kmem_cache_create("buffer_head",
54692 sizeof(struct buffer_head), 0,
54693 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
54694 - SLAB_MEM_SPREAD),
54695 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
54696 NULL);
54697
54698 /*
54699 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
54700 index 622f469..e8d2d55 100644
54701 --- a/fs/cachefiles/bind.c
54702 +++ b/fs/cachefiles/bind.c
54703 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
54704 args);
54705
54706 /* start by checking things over */
54707 - ASSERT(cache->fstop_percent >= 0 &&
54708 - cache->fstop_percent < cache->fcull_percent &&
54709 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
54710 cache->fcull_percent < cache->frun_percent &&
54711 cache->frun_percent < 100);
54712
54713 - ASSERT(cache->bstop_percent >= 0 &&
54714 - cache->bstop_percent < cache->bcull_percent &&
54715 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
54716 cache->bcull_percent < cache->brun_percent &&
54717 cache->brun_percent < 100);
54718
54719 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
54720 index 0a1467b..6a53245 100644
54721 --- a/fs/cachefiles/daemon.c
54722 +++ b/fs/cachefiles/daemon.c
54723 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
54724 if (n > buflen)
54725 return -EMSGSIZE;
54726
54727 - if (copy_to_user(_buffer, buffer, n) != 0)
54728 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
54729 return -EFAULT;
54730
54731 return n;
54732 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
54733 if (test_bit(CACHEFILES_DEAD, &cache->flags))
54734 return -EIO;
54735
54736 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
54737 + if (datalen > PAGE_SIZE - 1)
54738 return -EOPNOTSUPP;
54739
54740 /* drag the command string into the kernel so we can parse it */
54741 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
54742 if (args[0] != '%' || args[1] != '\0')
54743 return -EINVAL;
54744
54745 - if (fstop < 0 || fstop >= cache->fcull_percent)
54746 + if (fstop >= cache->fcull_percent)
54747 return cachefiles_daemon_range_error(cache, args);
54748
54749 cache->fstop_percent = fstop;
54750 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
54751 if (args[0] != '%' || args[1] != '\0')
54752 return -EINVAL;
54753
54754 - if (bstop < 0 || bstop >= cache->bcull_percent)
54755 + if (bstop >= cache->bcull_percent)
54756 return cachefiles_daemon_range_error(cache, args);
54757
54758 cache->bstop_percent = bstop;
54759 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
54760 index 5349473..d6c0b93 100644
54761 --- a/fs/cachefiles/internal.h
54762 +++ b/fs/cachefiles/internal.h
54763 @@ -59,7 +59,7 @@ struct cachefiles_cache {
54764 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
54765 struct rb_root active_nodes; /* active nodes (can't be culled) */
54766 rwlock_t active_lock; /* lock for active_nodes */
54767 - atomic_t gravecounter; /* graveyard uniquifier */
54768 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
54769 unsigned frun_percent; /* when to stop culling (% files) */
54770 unsigned fcull_percent; /* when to start culling (% files) */
54771 unsigned fstop_percent; /* when to stop allocating (% files) */
54772 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
54773 * proc.c
54774 */
54775 #ifdef CONFIG_CACHEFILES_HISTOGRAM
54776 -extern atomic_t cachefiles_lookup_histogram[HZ];
54777 -extern atomic_t cachefiles_mkdir_histogram[HZ];
54778 -extern atomic_t cachefiles_create_histogram[HZ];
54779 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54780 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54781 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
54782
54783 extern int __init cachefiles_proc_init(void);
54784 extern void cachefiles_proc_cleanup(void);
54785 static inline
54786 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
54787 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
54788 {
54789 unsigned long jif = jiffies - start_jif;
54790 if (jif >= HZ)
54791 jif = HZ - 1;
54792 - atomic_inc(&histogram[jif]);
54793 + atomic_inc_unchecked(&histogram[jif]);
54794 }
54795
54796 #else
54797 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
54798 index f4a08d7..5aa4599 100644
54799 --- a/fs/cachefiles/namei.c
54800 +++ b/fs/cachefiles/namei.c
54801 @@ -317,7 +317,7 @@ try_again:
54802 /* first step is to make up a grave dentry in the graveyard */
54803 sprintf(nbuffer, "%08x%08x",
54804 (uint32_t) get_seconds(),
54805 - (uint32_t) atomic_inc_return(&cache->gravecounter));
54806 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
54807
54808 /* do the multiway lock magic */
54809 trap = lock_rename(cache->graveyard, dir);
54810 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
54811 index eccd339..4c1d995 100644
54812 --- a/fs/cachefiles/proc.c
54813 +++ b/fs/cachefiles/proc.c
54814 @@ -14,9 +14,9 @@
54815 #include <linux/seq_file.h>
54816 #include "internal.h"
54817
54818 -atomic_t cachefiles_lookup_histogram[HZ];
54819 -atomic_t cachefiles_mkdir_histogram[HZ];
54820 -atomic_t cachefiles_create_histogram[HZ];
54821 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54822 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54823 +atomic_unchecked_t cachefiles_create_histogram[HZ];
54824
54825 /*
54826 * display the latency histogram
54827 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
54828 return 0;
54829 default:
54830 index = (unsigned long) v - 3;
54831 - x = atomic_read(&cachefiles_lookup_histogram[index]);
54832 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
54833 - z = atomic_read(&cachefiles_create_histogram[index]);
54834 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
54835 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
54836 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
54837 if (x == 0 && y == 0 && z == 0)
54838 return 0;
54839
54840 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
54841 index ebaff36..7e3ea26 100644
54842 --- a/fs/cachefiles/rdwr.c
54843 +++ b/fs/cachefiles/rdwr.c
54844 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
54845 old_fs = get_fs();
54846 set_fs(KERNEL_DS);
54847 ret = file->f_op->write(
54848 - file, (const void __user *) data, len, &pos);
54849 + file, (const void __force_user *) data, len, &pos);
54850 set_fs(old_fs);
54851 kunmap(page);
54852 file_end_write(file);
54853 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
54854 index 868b61d..58835a5 100644
54855 --- a/fs/ceph/dir.c
54856 +++ b/fs/ceph/dir.c
54857 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
54858 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
54859 struct ceph_mds_client *mdsc = fsc->mdsc;
54860 unsigned frag = fpos_frag(ctx->pos);
54861 - int off = fpos_off(ctx->pos);
54862 + unsigned int off = fpos_off(ctx->pos);
54863 int err;
54864 u32 ftype;
54865 struct ceph_mds_reply_info_parsed *rinfo;
54866 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
54867 index 6a0951e..03fac6d 100644
54868 --- a/fs/ceph/super.c
54869 +++ b/fs/ceph/super.c
54870 @@ -870,7 +870,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
54871 /*
54872 * construct our own bdi so we can control readahead, etc.
54873 */
54874 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
54875 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
54876
54877 static int ceph_register_bdi(struct super_block *sb,
54878 struct ceph_fs_client *fsc)
54879 @@ -887,7 +887,7 @@ static int ceph_register_bdi(struct super_block *sb,
54880 default_backing_dev_info.ra_pages;
54881
54882 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
54883 - atomic_long_inc_return(&bdi_seq));
54884 + atomic_long_inc_return_unchecked(&bdi_seq));
54885 if (!err)
54886 sb->s_bdi = &fsc->backing_dev_info;
54887 return err;
54888 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
54889 index f3ac415..3d2420c 100644
54890 --- a/fs/cifs/cifs_debug.c
54891 +++ b/fs/cifs/cifs_debug.c
54892 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54893
54894 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
54895 #ifdef CONFIG_CIFS_STATS2
54896 - atomic_set(&totBufAllocCount, 0);
54897 - atomic_set(&totSmBufAllocCount, 0);
54898 + atomic_set_unchecked(&totBufAllocCount, 0);
54899 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54900 #endif /* CONFIG_CIFS_STATS2 */
54901 spin_lock(&cifs_tcp_ses_lock);
54902 list_for_each(tmp1, &cifs_tcp_ses_list) {
54903 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54904 tcon = list_entry(tmp3,
54905 struct cifs_tcon,
54906 tcon_list);
54907 - atomic_set(&tcon->num_smbs_sent, 0);
54908 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
54909 if (server->ops->clear_stats)
54910 server->ops->clear_stats(tcon);
54911 }
54912 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54913 smBufAllocCount.counter, cifs_min_small);
54914 #ifdef CONFIG_CIFS_STATS2
54915 seq_printf(m, "Total Large %d Small %d Allocations\n",
54916 - atomic_read(&totBufAllocCount),
54917 - atomic_read(&totSmBufAllocCount));
54918 + atomic_read_unchecked(&totBufAllocCount),
54919 + atomic_read_unchecked(&totSmBufAllocCount));
54920 #endif /* CONFIG_CIFS_STATS2 */
54921
54922 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
54923 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54924 if (tcon->need_reconnect)
54925 seq_puts(m, "\tDISCONNECTED ");
54926 seq_printf(m, "\nSMBs: %d",
54927 - atomic_read(&tcon->num_smbs_sent));
54928 + atomic_read_unchecked(&tcon->num_smbs_sent));
54929 if (server->ops->print_stats)
54930 server->ops->print_stats(m, tcon);
54931 }
54932 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
54933 index 77fc5e1..e3d13e6 100644
54934 --- a/fs/cifs/cifsfs.c
54935 +++ b/fs/cifs/cifsfs.c
54936 @@ -1056,7 +1056,7 @@ cifs_init_request_bufs(void)
54937 */
54938 cifs_req_cachep = kmem_cache_create("cifs_request",
54939 CIFSMaxBufSize + max_hdr_size, 0,
54940 - SLAB_HWCACHE_ALIGN, NULL);
54941 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
54942 if (cifs_req_cachep == NULL)
54943 return -ENOMEM;
54944
54945 @@ -1083,7 +1083,7 @@ cifs_init_request_bufs(void)
54946 efficient to alloc 1 per page off the slab compared to 17K (5page)
54947 alloc of large cifs buffers even when page debugging is on */
54948 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
54949 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
54950 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
54951 NULL);
54952 if (cifs_sm_req_cachep == NULL) {
54953 mempool_destroy(cifs_req_poolp);
54954 @@ -1168,8 +1168,8 @@ init_cifs(void)
54955 atomic_set(&bufAllocCount, 0);
54956 atomic_set(&smBufAllocCount, 0);
54957 #ifdef CONFIG_CIFS_STATS2
54958 - atomic_set(&totBufAllocCount, 0);
54959 - atomic_set(&totSmBufAllocCount, 0);
54960 + atomic_set_unchecked(&totBufAllocCount, 0);
54961 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54962 #endif /* CONFIG_CIFS_STATS2 */
54963
54964 atomic_set(&midCount, 0);
54965 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
54966 index c8e03f8..75362f6 100644
54967 --- a/fs/cifs/cifsglob.h
54968 +++ b/fs/cifs/cifsglob.h
54969 @@ -758,35 +758,35 @@ struct cifs_tcon {
54970 __u16 Flags; /* optional support bits */
54971 enum statusEnum tidStatus;
54972 #ifdef CONFIG_CIFS_STATS
54973 - atomic_t num_smbs_sent;
54974 + atomic_unchecked_t num_smbs_sent;
54975 union {
54976 struct {
54977 - atomic_t num_writes;
54978 - atomic_t num_reads;
54979 - atomic_t num_flushes;
54980 - atomic_t num_oplock_brks;
54981 - atomic_t num_opens;
54982 - atomic_t num_closes;
54983 - atomic_t num_deletes;
54984 - atomic_t num_mkdirs;
54985 - atomic_t num_posixopens;
54986 - atomic_t num_posixmkdirs;
54987 - atomic_t num_rmdirs;
54988 - atomic_t num_renames;
54989 - atomic_t num_t2renames;
54990 - atomic_t num_ffirst;
54991 - atomic_t num_fnext;
54992 - atomic_t num_fclose;
54993 - atomic_t num_hardlinks;
54994 - atomic_t num_symlinks;
54995 - atomic_t num_locks;
54996 - atomic_t num_acl_get;
54997 - atomic_t num_acl_set;
54998 + atomic_unchecked_t num_writes;
54999 + atomic_unchecked_t num_reads;
55000 + atomic_unchecked_t num_flushes;
55001 + atomic_unchecked_t num_oplock_brks;
55002 + atomic_unchecked_t num_opens;
55003 + atomic_unchecked_t num_closes;
55004 + atomic_unchecked_t num_deletes;
55005 + atomic_unchecked_t num_mkdirs;
55006 + atomic_unchecked_t num_posixopens;
55007 + atomic_unchecked_t num_posixmkdirs;
55008 + atomic_unchecked_t num_rmdirs;
55009 + atomic_unchecked_t num_renames;
55010 + atomic_unchecked_t num_t2renames;
55011 + atomic_unchecked_t num_ffirst;
55012 + atomic_unchecked_t num_fnext;
55013 + atomic_unchecked_t num_fclose;
55014 + atomic_unchecked_t num_hardlinks;
55015 + atomic_unchecked_t num_symlinks;
55016 + atomic_unchecked_t num_locks;
55017 + atomic_unchecked_t num_acl_get;
55018 + atomic_unchecked_t num_acl_set;
55019 } cifs_stats;
55020 #ifdef CONFIG_CIFS_SMB2
55021 struct {
55022 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
55023 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
55024 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
55025 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
55026 } smb2_stats;
55027 #endif /* CONFIG_CIFS_SMB2 */
55028 } stats;
55029 @@ -1111,7 +1111,7 @@ convert_delimiter(char *path, char delim)
55030 }
55031
55032 #ifdef CONFIG_CIFS_STATS
55033 -#define cifs_stats_inc atomic_inc
55034 +#define cifs_stats_inc atomic_inc_unchecked
55035
55036 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
55037 unsigned int bytes)
55038 @@ -1477,8 +1477,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
55039 /* Various Debug counters */
55040 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
55041 #ifdef CONFIG_CIFS_STATS2
55042 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
55043 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
55044 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
55045 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
55046 #endif
55047 GLOBAL_EXTERN atomic_t smBufAllocCount;
55048 GLOBAL_EXTERN atomic_t midCount;
55049 diff --git a/fs/cifs/file.c b/fs/cifs/file.c
55050 index 7ddddf2..2e12dbc 100644
55051 --- a/fs/cifs/file.c
55052 +++ b/fs/cifs/file.c
55053 @@ -1900,10 +1900,14 @@ static int cifs_writepages(struct address_space *mapping,
55054 index = mapping->writeback_index; /* Start from prev offset */
55055 end = -1;
55056 } else {
55057 - index = wbc->range_start >> PAGE_CACHE_SHIFT;
55058 - end = wbc->range_end >> PAGE_CACHE_SHIFT;
55059 - if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
55060 + if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) {
55061 range_whole = true;
55062 + index = 0;
55063 + end = ULONG_MAX;
55064 + } else {
55065 + index = wbc->range_start >> PAGE_CACHE_SHIFT;
55066 + end = wbc->range_end >> PAGE_CACHE_SHIFT;
55067 + }
55068 scanned = true;
55069 }
55070 retry:
55071 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
55072 index 477e53b..7a32216 100644
55073 --- a/fs/cifs/link.c
55074 +++ b/fs/cifs/link.c
55075 @@ -620,7 +620,7 @@ symlink_exit:
55076
55077 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
55078 {
55079 - char *p = nd_get_link(nd);
55080 + const char *p = nd_get_link(nd);
55081 if (!IS_ERR(p))
55082 kfree(p);
55083 }
55084 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
55085 index 138a011..cf9e13a 100644
55086 --- a/fs/cifs/misc.c
55087 +++ b/fs/cifs/misc.c
55088 @@ -170,7 +170,7 @@ cifs_buf_get(void)
55089 memset(ret_buf, 0, buf_size + 3);
55090 atomic_inc(&bufAllocCount);
55091 #ifdef CONFIG_CIFS_STATS2
55092 - atomic_inc(&totBufAllocCount);
55093 + atomic_inc_unchecked(&totBufAllocCount);
55094 #endif /* CONFIG_CIFS_STATS2 */
55095 }
55096
55097 @@ -205,7 +205,7 @@ cifs_small_buf_get(void)
55098 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
55099 atomic_inc(&smBufAllocCount);
55100 #ifdef CONFIG_CIFS_STATS2
55101 - atomic_inc(&totSmBufAllocCount);
55102 + atomic_inc_unchecked(&totSmBufAllocCount);
55103 #endif /* CONFIG_CIFS_STATS2 */
55104
55105 }
55106 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
55107 index e50554b..c011413 100644
55108 --- a/fs/cifs/smb1ops.c
55109 +++ b/fs/cifs/smb1ops.c
55110 @@ -609,27 +609,27 @@ static void
55111 cifs_clear_stats(struct cifs_tcon *tcon)
55112 {
55113 #ifdef CONFIG_CIFS_STATS
55114 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
55115 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
55116 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
55117 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
55118 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
55119 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
55120 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
55121 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
55122 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
55123 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
55124 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
55125 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
55126 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
55127 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
55128 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
55129 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
55130 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
55131 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
55132 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
55133 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
55134 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
55135 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
55136 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
55137 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
55138 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
55139 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
55140 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
55141 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
55142 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
55143 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
55144 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
55145 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
55146 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
55147 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
55148 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
55149 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
55150 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
55151 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
55152 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
55153 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
55154 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
55155 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
55156 #endif
55157 }
55158
55159 @@ -638,36 +638,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
55160 {
55161 #ifdef CONFIG_CIFS_STATS
55162 seq_printf(m, " Oplocks breaks: %d",
55163 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
55164 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
55165 seq_printf(m, "\nReads: %d Bytes: %llu",
55166 - atomic_read(&tcon->stats.cifs_stats.num_reads),
55167 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
55168 (long long)(tcon->bytes_read));
55169 seq_printf(m, "\nWrites: %d Bytes: %llu",
55170 - atomic_read(&tcon->stats.cifs_stats.num_writes),
55171 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
55172 (long long)(tcon->bytes_written));
55173 seq_printf(m, "\nFlushes: %d",
55174 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
55175 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
55176 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
55177 - atomic_read(&tcon->stats.cifs_stats.num_locks),
55178 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
55179 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
55180 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
55181 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
55182 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
55183 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
55184 - atomic_read(&tcon->stats.cifs_stats.num_opens),
55185 - atomic_read(&tcon->stats.cifs_stats.num_closes),
55186 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
55187 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
55188 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
55189 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
55190 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
55191 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
55192 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
55193 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
55194 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
55195 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
55196 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
55197 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
55198 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
55199 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
55200 seq_printf(m, "\nRenames: %d T2 Renames %d",
55201 - atomic_read(&tcon->stats.cifs_stats.num_renames),
55202 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
55203 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
55204 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
55205 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
55206 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
55207 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
55208 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
55209 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
55210 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
55211 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
55212 #endif
55213 }
55214
55215 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
55216 index 861b332..5506392 100644
55217 --- a/fs/cifs/smb2ops.c
55218 +++ b/fs/cifs/smb2ops.c
55219 @@ -282,8 +282,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
55220 #ifdef CONFIG_CIFS_STATS
55221 int i;
55222 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
55223 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
55224 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
55225 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
55226 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
55227 }
55228 #endif
55229 }
55230 @@ -311,65 +311,65 @@ static void
55231 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
55232 {
55233 #ifdef CONFIG_CIFS_STATS
55234 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
55235 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
55236 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
55237 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
55238 seq_printf(m, "\nNegotiates: %d sent %d failed",
55239 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
55240 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
55241 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
55242 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
55243 seq_printf(m, "\nSessionSetups: %d sent %d failed",
55244 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
55245 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
55246 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
55247 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
55248 seq_printf(m, "\nLogoffs: %d sent %d failed",
55249 - atomic_read(&sent[SMB2_LOGOFF_HE]),
55250 - atomic_read(&failed[SMB2_LOGOFF_HE]));
55251 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
55252 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
55253 seq_printf(m, "\nTreeConnects: %d sent %d failed",
55254 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
55255 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
55256 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
55257 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
55258 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
55259 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
55260 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
55261 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
55262 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
55263 seq_printf(m, "\nCreates: %d sent %d failed",
55264 - atomic_read(&sent[SMB2_CREATE_HE]),
55265 - atomic_read(&failed[SMB2_CREATE_HE]));
55266 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
55267 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
55268 seq_printf(m, "\nCloses: %d sent %d failed",
55269 - atomic_read(&sent[SMB2_CLOSE_HE]),
55270 - atomic_read(&failed[SMB2_CLOSE_HE]));
55271 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
55272 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
55273 seq_printf(m, "\nFlushes: %d sent %d failed",
55274 - atomic_read(&sent[SMB2_FLUSH_HE]),
55275 - atomic_read(&failed[SMB2_FLUSH_HE]));
55276 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
55277 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
55278 seq_printf(m, "\nReads: %d sent %d failed",
55279 - atomic_read(&sent[SMB2_READ_HE]),
55280 - atomic_read(&failed[SMB2_READ_HE]));
55281 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
55282 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
55283 seq_printf(m, "\nWrites: %d sent %d failed",
55284 - atomic_read(&sent[SMB2_WRITE_HE]),
55285 - atomic_read(&failed[SMB2_WRITE_HE]));
55286 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
55287 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
55288 seq_printf(m, "\nLocks: %d sent %d failed",
55289 - atomic_read(&sent[SMB2_LOCK_HE]),
55290 - atomic_read(&failed[SMB2_LOCK_HE]));
55291 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
55292 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
55293 seq_printf(m, "\nIOCTLs: %d sent %d failed",
55294 - atomic_read(&sent[SMB2_IOCTL_HE]),
55295 - atomic_read(&failed[SMB2_IOCTL_HE]));
55296 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
55297 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
55298 seq_printf(m, "\nCancels: %d sent %d failed",
55299 - atomic_read(&sent[SMB2_CANCEL_HE]),
55300 - atomic_read(&failed[SMB2_CANCEL_HE]));
55301 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
55302 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
55303 seq_printf(m, "\nEchos: %d sent %d failed",
55304 - atomic_read(&sent[SMB2_ECHO_HE]),
55305 - atomic_read(&failed[SMB2_ECHO_HE]));
55306 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
55307 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
55308 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
55309 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
55310 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
55311 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
55312 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
55313 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
55314 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
55315 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
55316 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
55317 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
55318 seq_printf(m, "\nQueryInfos: %d sent %d failed",
55319 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
55320 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
55321 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
55322 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
55323 seq_printf(m, "\nSetInfos: %d sent %d failed",
55324 - atomic_read(&sent[SMB2_SET_INFO_HE]),
55325 - atomic_read(&failed[SMB2_SET_INFO_HE]));
55326 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
55327 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
55328 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
55329 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
55330 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
55331 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
55332 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
55333 #endif
55334 }
55335
55336 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
55337 index edccb52..16bc6db 100644
55338 --- a/fs/cifs/smb2pdu.c
55339 +++ b/fs/cifs/smb2pdu.c
55340 @@ -1957,8 +1957,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
55341 default:
55342 cifs_dbg(VFS, "info level %u isn't supported\n",
55343 srch_inf->info_level);
55344 - rc = -EINVAL;
55345 - goto qdir_exit;
55346 + return -EINVAL;
55347 }
55348
55349 req->FileIndex = cpu_to_le32(index);
55350 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
55351 index 1da168c..8bc7ff6 100644
55352 --- a/fs/coda/cache.c
55353 +++ b/fs/coda/cache.c
55354 @@ -24,7 +24,7 @@
55355 #include "coda_linux.h"
55356 #include "coda_cache.h"
55357
55358 -static atomic_t permission_epoch = ATOMIC_INIT(0);
55359 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
55360
55361 /* replace or extend an acl cache hit */
55362 void coda_cache_enter(struct inode *inode, int mask)
55363 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
55364 struct coda_inode_info *cii = ITOC(inode);
55365
55366 spin_lock(&cii->c_lock);
55367 - cii->c_cached_epoch = atomic_read(&permission_epoch);
55368 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
55369 if (!uid_eq(cii->c_uid, current_fsuid())) {
55370 cii->c_uid = current_fsuid();
55371 cii->c_cached_perm = mask;
55372 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
55373 {
55374 struct coda_inode_info *cii = ITOC(inode);
55375 spin_lock(&cii->c_lock);
55376 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
55377 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
55378 spin_unlock(&cii->c_lock);
55379 }
55380
55381 /* remove all acl caches */
55382 void coda_cache_clear_all(struct super_block *sb)
55383 {
55384 - atomic_inc(&permission_epoch);
55385 + atomic_inc_unchecked(&permission_epoch);
55386 }
55387
55388
55389 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
55390 spin_lock(&cii->c_lock);
55391 hit = (mask & cii->c_cached_perm) == mask &&
55392 uid_eq(cii->c_uid, current_fsuid()) &&
55393 - cii->c_cached_epoch == atomic_read(&permission_epoch);
55394 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
55395 spin_unlock(&cii->c_lock);
55396
55397 return hit;
55398 diff --git a/fs/compat.c b/fs/compat.c
55399 index 6af20de..fec3fbb 100644
55400 --- a/fs/compat.c
55401 +++ b/fs/compat.c
55402 @@ -54,7 +54,7 @@
55403 #include <asm/ioctls.h>
55404 #include "internal.h"
55405
55406 -int compat_log = 1;
55407 +int compat_log = 0;
55408
55409 int compat_printk(const char *fmt, ...)
55410 {
55411 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
55412
55413 set_fs(KERNEL_DS);
55414 /* The __user pointer cast is valid because of the set_fs() */
55415 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
55416 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
55417 set_fs(oldfs);
55418 /* truncating is ok because it's a user address */
55419 if (!ret)
55420 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
55421 goto out;
55422
55423 ret = -EINVAL;
55424 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
55425 + if (nr_segs > UIO_MAXIOV)
55426 goto out;
55427 if (nr_segs > fast_segs) {
55428 ret = -ENOMEM;
55429 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
55430 struct compat_readdir_callback {
55431 struct dir_context ctx;
55432 struct compat_old_linux_dirent __user *dirent;
55433 + struct file * file;
55434 int result;
55435 };
55436
55437 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
55438 buf->result = -EOVERFLOW;
55439 return -EOVERFLOW;
55440 }
55441 +
55442 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55443 + return 0;
55444 +
55445 buf->result++;
55446 dirent = buf->dirent;
55447 if (!access_ok(VERIFY_WRITE, dirent,
55448 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
55449 if (!f.file)
55450 return -EBADF;
55451
55452 + buf.file = f.file;
55453 error = iterate_dir(f.file, &buf.ctx);
55454 if (buf.result)
55455 error = buf.result;
55456 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
55457 struct dir_context ctx;
55458 struct compat_linux_dirent __user *current_dir;
55459 struct compat_linux_dirent __user *previous;
55460 + struct file * file;
55461 int count;
55462 int error;
55463 };
55464 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
55465 buf->error = -EOVERFLOW;
55466 return -EOVERFLOW;
55467 }
55468 +
55469 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55470 + return 0;
55471 +
55472 dirent = buf->previous;
55473 if (dirent) {
55474 if (__put_user(offset, &dirent->d_off))
55475 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
55476 if (!f.file)
55477 return -EBADF;
55478
55479 + buf.file = f.file;
55480 error = iterate_dir(f.file, &buf.ctx);
55481 if (error >= 0)
55482 error = buf.error;
55483 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
55484 struct dir_context ctx;
55485 struct linux_dirent64 __user *current_dir;
55486 struct linux_dirent64 __user *previous;
55487 + struct file * file;
55488 int count;
55489 int error;
55490 };
55491 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
55492 buf->error = -EINVAL; /* only used if we fail.. */
55493 if (reclen > buf->count)
55494 return -EINVAL;
55495 +
55496 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55497 + return 0;
55498 +
55499 dirent = buf->previous;
55500
55501 if (dirent) {
55502 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
55503 if (!f.file)
55504 return -EBADF;
55505
55506 + buf.file = f.file;
55507 error = iterate_dir(f.file, &buf.ctx);
55508 if (error >= 0)
55509 error = buf.error;
55510 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
55511 index a81147e..20bf2b5 100644
55512 --- a/fs/compat_binfmt_elf.c
55513 +++ b/fs/compat_binfmt_elf.c
55514 @@ -30,11 +30,13 @@
55515 #undef elf_phdr
55516 #undef elf_shdr
55517 #undef elf_note
55518 +#undef elf_dyn
55519 #undef elf_addr_t
55520 #define elfhdr elf32_hdr
55521 #define elf_phdr elf32_phdr
55522 #define elf_shdr elf32_shdr
55523 #define elf_note elf32_note
55524 +#define elf_dyn Elf32_Dyn
55525 #define elf_addr_t Elf32_Addr
55526
55527 /*
55528 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
55529 index 5d19acf..9ab093b 100644
55530 --- a/fs/compat_ioctl.c
55531 +++ b/fs/compat_ioctl.c
55532 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
55533 return -EFAULT;
55534 if (__get_user(udata, &ss32->iomem_base))
55535 return -EFAULT;
55536 - ss.iomem_base = compat_ptr(udata);
55537 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
55538 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
55539 __get_user(ss.port_high, &ss32->port_high))
55540 return -EFAULT;
55541 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
55542 for (i = 0; i < nmsgs; i++) {
55543 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
55544 return -EFAULT;
55545 - if (get_user(datap, &umsgs[i].buf) ||
55546 - put_user(compat_ptr(datap), &tmsgs[i].buf))
55547 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
55548 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
55549 return -EFAULT;
55550 }
55551 return sys_ioctl(fd, cmd, (unsigned long)tdata);
55552 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
55553 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
55554 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
55555 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
55556 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
55557 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
55558 return -EFAULT;
55559
55560 return ioctl_preallocate(file, p);
55561 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
55562 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
55563 {
55564 unsigned int a, b;
55565 - a = *(unsigned int *)p;
55566 - b = *(unsigned int *)q;
55567 + a = *(const unsigned int *)p;
55568 + b = *(const unsigned int *)q;
55569 if (a > b)
55570 return 1;
55571 if (a < b)
55572 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
55573 index 511d415..319d0e5 100644
55574 --- a/fs/configfs/dir.c
55575 +++ b/fs/configfs/dir.c
55576 @@ -1558,7 +1558,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
55577 }
55578 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
55579 struct configfs_dirent *next;
55580 - const char *name;
55581 + const unsigned char * name;
55582 + char d_name[sizeof(next->s_dentry->d_iname)];
55583 int len;
55584 struct inode *inode = NULL;
55585
55586 @@ -1567,7 +1568,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
55587 continue;
55588
55589 name = configfs_get_name(next);
55590 - len = strlen(name);
55591 + if (next->s_dentry && name == next->s_dentry->d_iname) {
55592 + len = next->s_dentry->d_name.len;
55593 + memcpy(d_name, name, len);
55594 + name = d_name;
55595 + } else
55596 + len = strlen(name);
55597
55598 /*
55599 * We'll have a dentry and an inode for
55600 diff --git a/fs/coredump.c b/fs/coredump.c
55601 index 9bdeca1..2a9b08d 100644
55602 --- a/fs/coredump.c
55603 +++ b/fs/coredump.c
55604 @@ -438,8 +438,8 @@ static void wait_for_dump_helpers(struct file *file)
55605 struct pipe_inode_info *pipe = file->private_data;
55606
55607 pipe_lock(pipe);
55608 - pipe->readers++;
55609 - pipe->writers--;
55610 + atomic_inc(&pipe->readers);
55611 + atomic_dec(&pipe->writers);
55612 wake_up_interruptible_sync(&pipe->wait);
55613 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
55614 pipe_unlock(pipe);
55615 @@ -448,11 +448,11 @@ static void wait_for_dump_helpers(struct file *file)
55616 * We actually want wait_event_freezable() but then we need
55617 * to clear TIF_SIGPENDING and improve dump_interrupted().
55618 */
55619 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
55620 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
55621
55622 pipe_lock(pipe);
55623 - pipe->readers--;
55624 - pipe->writers++;
55625 + atomic_dec(&pipe->readers);
55626 + atomic_inc(&pipe->writers);
55627 pipe_unlock(pipe);
55628 }
55629
55630 @@ -499,7 +499,9 @@ void do_coredump(siginfo_t *siginfo)
55631 struct files_struct *displaced;
55632 bool need_nonrelative = false;
55633 bool core_dumped = false;
55634 - static atomic_t core_dump_count = ATOMIC_INIT(0);
55635 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
55636 + long signr = siginfo->si_signo;
55637 + int dumpable;
55638 struct coredump_params cprm = {
55639 .siginfo = siginfo,
55640 .regs = signal_pt_regs(),
55641 @@ -512,12 +514,17 @@ void do_coredump(siginfo_t *siginfo)
55642 .mm_flags = mm->flags,
55643 };
55644
55645 - audit_core_dumps(siginfo->si_signo);
55646 + audit_core_dumps(signr);
55647 +
55648 + dumpable = __get_dumpable(cprm.mm_flags);
55649 +
55650 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
55651 + gr_handle_brute_attach(dumpable);
55652
55653 binfmt = mm->binfmt;
55654 if (!binfmt || !binfmt->core_dump)
55655 goto fail;
55656 - if (!__get_dumpable(cprm.mm_flags))
55657 + if (!dumpable)
55658 goto fail;
55659
55660 cred = prepare_creds();
55661 @@ -536,7 +543,7 @@ void do_coredump(siginfo_t *siginfo)
55662 need_nonrelative = true;
55663 }
55664
55665 - retval = coredump_wait(siginfo->si_signo, &core_state);
55666 + retval = coredump_wait(signr, &core_state);
55667 if (retval < 0)
55668 goto fail_creds;
55669
55670 @@ -579,7 +586,7 @@ void do_coredump(siginfo_t *siginfo)
55671 }
55672 cprm.limit = RLIM_INFINITY;
55673
55674 - dump_count = atomic_inc_return(&core_dump_count);
55675 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
55676 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
55677 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
55678 task_tgid_vnr(current), current->comm);
55679 @@ -611,6 +618,8 @@ void do_coredump(siginfo_t *siginfo)
55680 } else {
55681 struct inode *inode;
55682
55683 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
55684 +
55685 if (cprm.limit < binfmt->min_coredump)
55686 goto fail_unlock;
55687
55688 @@ -669,7 +678,7 @@ close_fail:
55689 filp_close(cprm.file, NULL);
55690 fail_dropcount:
55691 if (ispipe)
55692 - atomic_dec(&core_dump_count);
55693 + atomic_dec_unchecked(&core_dump_count);
55694 fail_unlock:
55695 kfree(cn.corename);
55696 coredump_finish(mm, core_dumped);
55697 @@ -689,7 +698,7 @@ int dump_write(struct file *file, const void *addr, int nr)
55698 {
55699 return !dump_interrupted() &&
55700 access_ok(VERIFY_READ, addr, nr) &&
55701 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
55702 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
55703 }
55704 EXPORT_SYMBOL(dump_write);
55705
55706 diff --git a/fs/dcache.c b/fs/dcache.c
55707 index 89f9671..d2dce57 100644
55708 --- a/fs/dcache.c
55709 +++ b/fs/dcache.c
55710 @@ -1570,7 +1570,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
55711 */
55712 dentry->d_iname[DNAME_INLINE_LEN-1] = 0;
55713 if (name->len > DNAME_INLINE_LEN-1) {
55714 - dname = kmalloc(name->len + 1, GFP_KERNEL);
55715 + dname = kmalloc(round_up(name->len + 1, sizeof(unsigned long)), GFP_KERNEL);
55716 if (!dname) {
55717 kmem_cache_free(dentry_cache, dentry);
55718 return NULL;
55719 @@ -2893,6 +2893,7 @@ static int prepend_path(const struct path *path,
55720 restart:
55721 bptr = *buffer;
55722 blen = *buflen;
55723 + error = 0;
55724 dentry = path->dentry;
55725 vfsmnt = path->mnt;
55726 mnt = real_mount(vfsmnt);
55727 @@ -3432,7 +3433,8 @@ void __init vfs_caches_init(unsigned long mempages)
55728 mempages -= reserve;
55729
55730 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
55731 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
55732 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
55733 + SLAB_NO_SANITIZE, NULL);
55734
55735 dcache_init();
55736 inode_init();
55737 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
55738 index c7c83ff..bda9461 100644
55739 --- a/fs/debugfs/inode.c
55740 +++ b/fs/debugfs/inode.c
55741 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
55742 */
55743 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
55744 {
55745 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
55746 + return __create_file(name, S_IFDIR | S_IRWXU,
55747 +#else
55748 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
55749 +#endif
55750 parent, NULL, NULL);
55751 }
55752 EXPORT_SYMBOL_GPL(debugfs_create_dir);
55753 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
55754 index 67e9b63..a9adb68 100644
55755 --- a/fs/ecryptfs/inode.c
55756 +++ b/fs/ecryptfs/inode.c
55757 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
55758 old_fs = get_fs();
55759 set_fs(get_ds());
55760 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
55761 - (char __user *)lower_buf,
55762 + (char __force_user *)lower_buf,
55763 PATH_MAX);
55764 set_fs(old_fs);
55765 if (rc < 0)
55766 @@ -706,7 +706,7 @@ out:
55767 static void
55768 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
55769 {
55770 - char *buf = nd_get_link(nd);
55771 + const char *buf = nd_get_link(nd);
55772 if (!IS_ERR(buf)) {
55773 /* Free the char* */
55774 kfree(buf);
55775 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
55776 index e4141f2..d8263e8 100644
55777 --- a/fs/ecryptfs/miscdev.c
55778 +++ b/fs/ecryptfs/miscdev.c
55779 @@ -304,7 +304,7 @@ check_list:
55780 goto out_unlock_msg_ctx;
55781 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
55782 if (msg_ctx->msg) {
55783 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
55784 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
55785 goto out_unlock_msg_ctx;
55786 i += packet_length_size;
55787 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
55788 diff --git a/fs/exec.c b/fs/exec.c
55789 index bb8afc1..2f5087e 100644
55790 --- a/fs/exec.c
55791 +++ b/fs/exec.c
55792 @@ -55,8 +55,20 @@
55793 #include <linux/pipe_fs_i.h>
55794 #include <linux/oom.h>
55795 #include <linux/compat.h>
55796 +#include <linux/random.h>
55797 +#include <linux/seq_file.h>
55798 +#include <linux/coredump.h>
55799 +#include <linux/mman.h>
55800 +
55801 +#ifdef CONFIG_PAX_REFCOUNT
55802 +#include <linux/kallsyms.h>
55803 +#include <linux/kdebug.h>
55804 +#endif
55805 +
55806 +#include <trace/events/fs.h>
55807
55808 #include <asm/uaccess.h>
55809 +#include <asm/sections.h>
55810 #include <asm/mmu_context.h>
55811 #include <asm/tlb.h>
55812
55813 @@ -66,19 +78,34 @@
55814
55815 #include <trace/events/sched.h>
55816
55817 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
55818 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
55819 +{
55820 + 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");
55821 +}
55822 +#endif
55823 +
55824 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
55825 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
55826 +EXPORT_SYMBOL(pax_set_initial_flags_func);
55827 +#endif
55828 +
55829 int suid_dumpable = 0;
55830
55831 static LIST_HEAD(formats);
55832 static DEFINE_RWLOCK(binfmt_lock);
55833
55834 +extern int gr_process_kernel_exec_ban(void);
55835 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
55836 +
55837 void __register_binfmt(struct linux_binfmt * fmt, int insert)
55838 {
55839 BUG_ON(!fmt);
55840 if (WARN_ON(!fmt->load_binary))
55841 return;
55842 write_lock(&binfmt_lock);
55843 - insert ? list_add(&fmt->lh, &formats) :
55844 - list_add_tail(&fmt->lh, &formats);
55845 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
55846 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
55847 write_unlock(&binfmt_lock);
55848 }
55849
55850 @@ -87,7 +114,7 @@ EXPORT_SYMBOL(__register_binfmt);
55851 void unregister_binfmt(struct linux_binfmt * fmt)
55852 {
55853 write_lock(&binfmt_lock);
55854 - list_del(&fmt->lh);
55855 + pax_list_del((struct list_head *)&fmt->lh);
55856 write_unlock(&binfmt_lock);
55857 }
55858
55859 @@ -183,18 +210,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55860 int write)
55861 {
55862 struct page *page;
55863 - int ret;
55864
55865 -#ifdef CONFIG_STACK_GROWSUP
55866 - if (write) {
55867 - ret = expand_downwards(bprm->vma, pos);
55868 - if (ret < 0)
55869 - return NULL;
55870 - }
55871 -#endif
55872 - ret = get_user_pages(current, bprm->mm, pos,
55873 - 1, write, 1, &page, NULL);
55874 - if (ret <= 0)
55875 + if (0 > expand_downwards(bprm->vma, pos))
55876 + return NULL;
55877 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
55878 return NULL;
55879
55880 if (write) {
55881 @@ -210,6 +229,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55882 if (size <= ARG_MAX)
55883 return page;
55884
55885 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55886 + // only allow 512KB for argv+env on suid/sgid binaries
55887 + // to prevent easy ASLR exhaustion
55888 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
55889 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
55890 + (size > (512 * 1024))) {
55891 + put_page(page);
55892 + return NULL;
55893 + }
55894 +#endif
55895 +
55896 /*
55897 * Limit to 1/4-th the stack size for the argv+env strings.
55898 * This ensures that:
55899 @@ -269,6 +299,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55900 vma->vm_end = STACK_TOP_MAX;
55901 vma->vm_start = vma->vm_end - PAGE_SIZE;
55902 vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
55903 +
55904 +#ifdef CONFIG_PAX_SEGMEXEC
55905 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
55906 +#endif
55907 +
55908 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
55909 INIT_LIST_HEAD(&vma->anon_vma_chain);
55910
55911 @@ -279,6 +314,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55912 mm->stack_vm = mm->total_vm = 1;
55913 up_write(&mm->mmap_sem);
55914 bprm->p = vma->vm_end - sizeof(void *);
55915 +
55916 +#ifdef CONFIG_PAX_RANDUSTACK
55917 + if (randomize_va_space)
55918 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
55919 +#endif
55920 +
55921 return 0;
55922 err:
55923 up_write(&mm->mmap_sem);
55924 @@ -399,7 +440,7 @@ struct user_arg_ptr {
55925 } ptr;
55926 };
55927
55928 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55929 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55930 {
55931 const char __user *native;
55932
55933 @@ -408,14 +449,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55934 compat_uptr_t compat;
55935
55936 if (get_user(compat, argv.ptr.compat + nr))
55937 - return ERR_PTR(-EFAULT);
55938 + return (const char __force_user *)ERR_PTR(-EFAULT);
55939
55940 return compat_ptr(compat);
55941 }
55942 #endif
55943
55944 if (get_user(native, argv.ptr.native + nr))
55945 - return ERR_PTR(-EFAULT);
55946 + return (const char __force_user *)ERR_PTR(-EFAULT);
55947
55948 return native;
55949 }
55950 @@ -434,7 +475,7 @@ static int count(struct user_arg_ptr argv, int max)
55951 if (!p)
55952 break;
55953
55954 - if (IS_ERR(p))
55955 + if (IS_ERR((const char __force_kernel *)p))
55956 return -EFAULT;
55957
55958 if (i >= max)
55959 @@ -469,7 +510,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
55960
55961 ret = -EFAULT;
55962 str = get_user_arg_ptr(argv, argc);
55963 - if (IS_ERR(str))
55964 + if (IS_ERR((const char __force_kernel *)str))
55965 goto out;
55966
55967 len = strnlen_user(str, MAX_ARG_STRLEN);
55968 @@ -551,7 +592,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
55969 int r;
55970 mm_segment_t oldfs = get_fs();
55971 struct user_arg_ptr argv = {
55972 - .ptr.native = (const char __user *const __user *)__argv,
55973 + .ptr.native = (const char __force_user * const __force_user *)__argv,
55974 };
55975
55976 set_fs(KERNEL_DS);
55977 @@ -586,7 +627,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55978 unsigned long new_end = old_end - shift;
55979 struct mmu_gather tlb;
55980
55981 - BUG_ON(new_start > new_end);
55982 + if (new_start >= new_end || new_start < mmap_min_addr)
55983 + return -ENOMEM;
55984
55985 /*
55986 * ensure there are no vmas between where we want to go
55987 @@ -595,6 +637,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55988 if (vma != find_vma(mm, new_start))
55989 return -EFAULT;
55990
55991 +#ifdef CONFIG_PAX_SEGMEXEC
55992 + BUG_ON(pax_find_mirror_vma(vma));
55993 +#endif
55994 +
55995 /*
55996 * cover the whole range: [new_start, old_end)
55997 */
55998 @@ -675,10 +721,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
55999 stack_top = arch_align_stack(stack_top);
56000 stack_top = PAGE_ALIGN(stack_top);
56001
56002 - if (unlikely(stack_top < mmap_min_addr) ||
56003 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
56004 - return -ENOMEM;
56005 -
56006 stack_shift = vma->vm_end - stack_top;
56007
56008 bprm->p -= stack_shift;
56009 @@ -690,8 +732,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
56010 bprm->exec -= stack_shift;
56011
56012 down_write(&mm->mmap_sem);
56013 +
56014 + /* Move stack pages down in memory. */
56015 + if (stack_shift) {
56016 + ret = shift_arg_pages(vma, stack_shift);
56017 + if (ret)
56018 + goto out_unlock;
56019 + }
56020 +
56021 vm_flags = VM_STACK_FLAGS;
56022
56023 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
56024 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
56025 + vm_flags &= ~VM_EXEC;
56026 +
56027 +#ifdef CONFIG_PAX_MPROTECT
56028 + if (mm->pax_flags & MF_PAX_MPROTECT)
56029 + vm_flags &= ~VM_MAYEXEC;
56030 +#endif
56031 +
56032 + }
56033 +#endif
56034 +
56035 /*
56036 * Adjust stack execute permissions; explicitly enable for
56037 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
56038 @@ -710,13 +772,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
56039 goto out_unlock;
56040 BUG_ON(prev != vma);
56041
56042 - /* Move stack pages down in memory. */
56043 - if (stack_shift) {
56044 - ret = shift_arg_pages(vma, stack_shift);
56045 - if (ret)
56046 - goto out_unlock;
56047 - }
56048 -
56049 /* mprotect_fixup is overkill to remove the temporary stack flags */
56050 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
56051
56052 @@ -740,6 +795,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
56053 #endif
56054 current->mm->start_stack = bprm->p;
56055 ret = expand_stack(vma, stack_base);
56056 +
56057 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
56058 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
56059 + unsigned long size;
56060 + vm_flags_t vm_flags;
56061 +
56062 + size = STACK_TOP - vma->vm_end;
56063 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
56064 +
56065 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
56066 +
56067 +#ifdef CONFIG_X86
56068 + if (!ret) {
56069 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
56070 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
56071 + }
56072 +#endif
56073 +
56074 + }
56075 +#endif
56076 +
56077 if (ret)
56078 ret = -EFAULT;
56079
56080 @@ -776,6 +852,8 @@ struct file *open_exec(const char *name)
56081
56082 fsnotify_open(file);
56083
56084 + trace_open_exec(name);
56085 +
56086 err = deny_write_access(file);
56087 if (err)
56088 goto exit;
56089 @@ -799,7 +877,7 @@ int kernel_read(struct file *file, loff_t offset,
56090 old_fs = get_fs();
56091 set_fs(get_ds());
56092 /* The cast to a user pointer is valid due to the set_fs() */
56093 - result = vfs_read(file, (void __user *)addr, count, &pos);
56094 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
56095 set_fs(old_fs);
56096 return result;
56097 }
56098 @@ -1255,7 +1333,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
56099 }
56100 rcu_read_unlock();
56101
56102 - if (p->fs->users > n_fs) {
56103 + if (atomic_read(&p->fs->users) > n_fs) {
56104 bprm->unsafe |= LSM_UNSAFE_SHARE;
56105 } else {
56106 res = -EAGAIN;
56107 @@ -1451,6 +1529,31 @@ static int exec_binprm(struct linux_binprm *bprm)
56108 return ret;
56109 }
56110
56111 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56112 +static DEFINE_PER_CPU(u64, exec_counter);
56113 +static int __init init_exec_counters(void)
56114 +{
56115 + unsigned int cpu;
56116 +
56117 + for_each_possible_cpu(cpu) {
56118 + per_cpu(exec_counter, cpu) = (u64)cpu;
56119 + }
56120 +
56121 + return 0;
56122 +}
56123 +early_initcall(init_exec_counters);
56124 +static inline void increment_exec_counter(void)
56125 +{
56126 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
56127 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
56128 +}
56129 +#else
56130 +static inline void increment_exec_counter(void) {}
56131 +#endif
56132 +
56133 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
56134 + struct user_arg_ptr argv);
56135 +
56136 /*
56137 * sys_execve() executes a new program.
56138 */
56139 @@ -1458,12 +1561,19 @@ static int do_execve_common(const char *filename,
56140 struct user_arg_ptr argv,
56141 struct user_arg_ptr envp)
56142 {
56143 +#ifdef CONFIG_GRKERNSEC
56144 + struct file *old_exec_file;
56145 + struct acl_subject_label *old_acl;
56146 + struct rlimit old_rlim[RLIM_NLIMITS];
56147 +#endif
56148 struct linux_binprm *bprm;
56149 struct file *file;
56150 struct files_struct *displaced;
56151 bool clear_in_exec;
56152 int retval;
56153
56154 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
56155 +
56156 /*
56157 * We move the actual failure in case of RLIMIT_NPROC excess from
56158 * set*uid() to execve() because too many poorly written programs
56159 @@ -1504,12 +1614,22 @@ static int do_execve_common(const char *filename,
56160 if (IS_ERR(file))
56161 goto out_unmark;
56162
56163 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
56164 + retval = -EPERM;
56165 + goto out_file;
56166 + }
56167 +
56168 sched_exec();
56169
56170 bprm->file = file;
56171 bprm->filename = filename;
56172 bprm->interp = filename;
56173
56174 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
56175 + retval = -EACCES;
56176 + goto out_file;
56177 + }
56178 +
56179 retval = bprm_mm_init(bprm);
56180 if (retval)
56181 goto out_file;
56182 @@ -1526,24 +1646,70 @@ static int do_execve_common(const char *filename,
56183 if (retval < 0)
56184 goto out;
56185
56186 +#ifdef CONFIG_GRKERNSEC
56187 + old_acl = current->acl;
56188 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
56189 + old_exec_file = current->exec_file;
56190 + get_file(file);
56191 + current->exec_file = file;
56192 +#endif
56193 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56194 + /* limit suid stack to 8MB
56195 + * we saved the old limits above and will restore them if this exec fails
56196 + */
56197 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
56198 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
56199 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
56200 +#endif
56201 +
56202 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
56203 + retval = -EPERM;
56204 + goto out_fail;
56205 + }
56206 +
56207 + if (!gr_tpe_allow(file)) {
56208 + retval = -EACCES;
56209 + goto out_fail;
56210 + }
56211 +
56212 + if (gr_check_crash_exec(file)) {
56213 + retval = -EACCES;
56214 + goto out_fail;
56215 + }
56216 +
56217 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
56218 + bprm->unsafe);
56219 + if (retval < 0)
56220 + goto out_fail;
56221 +
56222 retval = copy_strings_kernel(1, &bprm->filename, bprm);
56223 if (retval < 0)
56224 - goto out;
56225 + goto out_fail;
56226
56227 bprm->exec = bprm->p;
56228 retval = copy_strings(bprm->envc, envp, bprm);
56229 if (retval < 0)
56230 - goto out;
56231 + goto out_fail;
56232
56233 retval = copy_strings(bprm->argc, argv, bprm);
56234 if (retval < 0)
56235 - goto out;
56236 + goto out_fail;
56237 +
56238 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
56239 +
56240 + gr_handle_exec_args(bprm, argv);
56241
56242 retval = exec_binprm(bprm);
56243 if (retval < 0)
56244 - goto out;
56245 + goto out_fail;
56246 +#ifdef CONFIG_GRKERNSEC
56247 + if (old_exec_file)
56248 + fput(old_exec_file);
56249 +#endif
56250
56251 /* execve succeeded */
56252 +
56253 + increment_exec_counter();
56254 current->fs->in_exec = 0;
56255 current->in_execve = 0;
56256 acct_update_integrals(current);
56257 @@ -1552,6 +1718,14 @@ static int do_execve_common(const char *filename,
56258 put_files_struct(displaced);
56259 return retval;
56260
56261 +out_fail:
56262 +#ifdef CONFIG_GRKERNSEC
56263 + current->acl = old_acl;
56264 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
56265 + fput(current->exec_file);
56266 + current->exec_file = old_exec_file;
56267 +#endif
56268 +
56269 out:
56270 if (bprm->mm) {
56271 acct_arg_size(bprm, 0);
56272 @@ -1706,3 +1880,295 @@ asmlinkage long compat_sys_execve(const char __user * filename,
56273 return error;
56274 }
56275 #endif
56276 +
56277 +int pax_check_flags(unsigned long *flags)
56278 +{
56279 + int retval = 0;
56280 +
56281 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
56282 + if (*flags & MF_PAX_SEGMEXEC)
56283 + {
56284 + *flags &= ~MF_PAX_SEGMEXEC;
56285 + retval = -EINVAL;
56286 + }
56287 +#endif
56288 +
56289 + if ((*flags & MF_PAX_PAGEEXEC)
56290 +
56291 +#ifdef CONFIG_PAX_PAGEEXEC
56292 + && (*flags & MF_PAX_SEGMEXEC)
56293 +#endif
56294 +
56295 + )
56296 + {
56297 + *flags &= ~MF_PAX_PAGEEXEC;
56298 + retval = -EINVAL;
56299 + }
56300 +
56301 + if ((*flags & MF_PAX_MPROTECT)
56302 +
56303 +#ifdef CONFIG_PAX_MPROTECT
56304 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
56305 +#endif
56306 +
56307 + )
56308 + {
56309 + *flags &= ~MF_PAX_MPROTECT;
56310 + retval = -EINVAL;
56311 + }
56312 +
56313 + if ((*flags & MF_PAX_EMUTRAMP)
56314 +
56315 +#ifdef CONFIG_PAX_EMUTRAMP
56316 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
56317 +#endif
56318 +
56319 + )
56320 + {
56321 + *flags &= ~MF_PAX_EMUTRAMP;
56322 + retval = -EINVAL;
56323 + }
56324 +
56325 + return retval;
56326 +}
56327 +
56328 +EXPORT_SYMBOL(pax_check_flags);
56329 +
56330 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
56331 +char *pax_get_path(const struct path *path, char *buf, int buflen)
56332 +{
56333 + char *pathname = d_path(path, buf, buflen);
56334 +
56335 + if (IS_ERR(pathname))
56336 + goto toolong;
56337 +
56338 + pathname = mangle_path(buf, pathname, "\t\n\\");
56339 + if (!pathname)
56340 + goto toolong;
56341 +
56342 + *pathname = 0;
56343 + return buf;
56344 +
56345 +toolong:
56346 + return "<path too long>";
56347 +}
56348 +EXPORT_SYMBOL(pax_get_path);
56349 +
56350 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
56351 +{
56352 + struct task_struct *tsk = current;
56353 + struct mm_struct *mm = current->mm;
56354 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
56355 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
56356 + char *path_exec = NULL;
56357 + char *path_fault = NULL;
56358 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
56359 + siginfo_t info = { };
56360 +
56361 + if (buffer_exec && buffer_fault) {
56362 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
56363 +
56364 + down_read(&mm->mmap_sem);
56365 + vma = mm->mmap;
56366 + while (vma && (!vma_exec || !vma_fault)) {
56367 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
56368 + vma_exec = vma;
56369 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
56370 + vma_fault = vma;
56371 + vma = vma->vm_next;
56372 + }
56373 + if (vma_exec)
56374 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
56375 + if (vma_fault) {
56376 + start = vma_fault->vm_start;
56377 + end = vma_fault->vm_end;
56378 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
56379 + if (vma_fault->vm_file)
56380 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
56381 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
56382 + path_fault = "<heap>";
56383 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
56384 + path_fault = "<stack>";
56385 + else
56386 + path_fault = "<anonymous mapping>";
56387 + }
56388 + up_read(&mm->mmap_sem);
56389 + }
56390 + if (tsk->signal->curr_ip)
56391 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
56392 + else
56393 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
56394 + 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),
56395 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
56396 + free_page((unsigned long)buffer_exec);
56397 + free_page((unsigned long)buffer_fault);
56398 + pax_report_insns(regs, pc, sp);
56399 + info.si_signo = SIGKILL;
56400 + info.si_errno = 0;
56401 + info.si_code = SI_KERNEL;
56402 + info.si_pid = 0;
56403 + info.si_uid = 0;
56404 + do_coredump(&info);
56405 +}
56406 +#endif
56407 +
56408 +#ifdef CONFIG_PAX_REFCOUNT
56409 +void pax_report_refcount_overflow(struct pt_regs *regs)
56410 +{
56411 + if (current->signal->curr_ip)
56412 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
56413 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
56414 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
56415 + else
56416 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
56417 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
56418 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
56419 + preempt_disable();
56420 + show_regs(regs);
56421 + preempt_enable();
56422 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
56423 +}
56424 +#endif
56425 +
56426 +#ifdef CONFIG_PAX_USERCOPY
56427 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
56428 +static noinline int check_stack_object(const void *obj, unsigned long len)
56429 +{
56430 + const void * const stack = task_stack_page(current);
56431 + const void * const stackend = stack + THREAD_SIZE;
56432 +
56433 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
56434 + const void *frame = NULL;
56435 + const void *oldframe;
56436 +#endif
56437 +
56438 + if (obj + len < obj)
56439 + return -1;
56440 +
56441 + if (obj + len <= stack || stackend <= obj)
56442 + return 0;
56443 +
56444 + if (obj < stack || stackend < obj + len)
56445 + return -1;
56446 +
56447 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
56448 + oldframe = __builtin_frame_address(1);
56449 + if (oldframe)
56450 + frame = __builtin_frame_address(2);
56451 + /*
56452 + low ----------------------------------------------> high
56453 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
56454 + ^----------------^
56455 + allow copies only within here
56456 + */
56457 + while (stack <= frame && frame < stackend) {
56458 + /* if obj + len extends past the last frame, this
56459 + check won't pass and the next frame will be 0,
56460 + causing us to bail out and correctly report
56461 + the copy as invalid
56462 + */
56463 + if (obj + len <= frame)
56464 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
56465 + oldframe = frame;
56466 + frame = *(const void * const *)frame;
56467 + }
56468 + return -1;
56469 +#else
56470 + return 1;
56471 +#endif
56472 +}
56473 +
56474 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
56475 +{
56476 + if (current->signal->curr_ip)
56477 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
56478 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
56479 + else
56480 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
56481 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
56482 + dump_stack();
56483 + gr_handle_kernel_exploit();
56484 + do_group_exit(SIGKILL);
56485 +}
56486 +#endif
56487 +
56488 +#ifdef CONFIG_PAX_USERCOPY
56489 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
56490 +{
56491 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
56492 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
56493 +#ifdef CONFIG_MODULES
56494 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
56495 +#else
56496 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
56497 +#endif
56498 +
56499 +#else
56500 + unsigned long textlow = (unsigned long)_stext;
56501 + unsigned long texthigh = (unsigned long)_etext;
56502 +
56503 +#ifdef CONFIG_X86_64
56504 + /* check against linear mapping as well */
56505 + if (high > (unsigned long)__va(__pa(textlow)) &&
56506 + low <= (unsigned long)__va(__pa(texthigh)))
56507 + return true;
56508 +#endif
56509 +
56510 +#endif
56511 +
56512 + if (high <= textlow || low > texthigh)
56513 + return false;
56514 + else
56515 + return true;
56516 +}
56517 +#endif
56518 +
56519 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
56520 +{
56521 +
56522 +#ifdef CONFIG_PAX_USERCOPY
56523 + const char *type;
56524 +
56525 + if (!n)
56526 + return;
56527 +
56528 + type = check_heap_object(ptr, n);
56529 + if (!type) {
56530 + int ret = check_stack_object(ptr, n);
56531 + if (ret == 1 || ret == 2)
56532 + return;
56533 + if (ret == 0) {
56534 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
56535 + type = "<kernel text>";
56536 + else
56537 + return;
56538 + } else
56539 + type = "<process stack>";
56540 + }
56541 +
56542 + pax_report_usercopy(ptr, n, to_user, type);
56543 +#endif
56544 +
56545 +}
56546 +EXPORT_SYMBOL(__check_object_size);
56547 +
56548 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
56549 +void pax_track_stack(void)
56550 +{
56551 + unsigned long sp = (unsigned long)&sp;
56552 + if (sp < current_thread_info()->lowest_stack &&
56553 + sp > (unsigned long)task_stack_page(current))
56554 + current_thread_info()->lowest_stack = sp;
56555 +}
56556 +EXPORT_SYMBOL(pax_track_stack);
56557 +#endif
56558 +
56559 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
56560 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
56561 +{
56562 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
56563 + dump_stack();
56564 + do_group_exit(SIGKILL);
56565 +}
56566 +EXPORT_SYMBOL(report_size_overflow);
56567 +#endif
56568 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
56569 index 9f9992b..8b59411 100644
56570 --- a/fs/ext2/balloc.c
56571 +++ b/fs/ext2/balloc.c
56572 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
56573
56574 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
56575 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
56576 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
56577 + if (free_blocks < root_blocks + 1 &&
56578 !uid_eq(sbi->s_resuid, current_fsuid()) &&
56579 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
56580 - !in_group_p (sbi->s_resgid))) {
56581 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
56582 return 0;
56583 }
56584 return 1;
56585 diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
56586 index 2d7557d..14e38f94 100644
56587 --- a/fs/ext2/xattr.c
56588 +++ b/fs/ext2/xattr.c
56589 @@ -247,7 +247,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
56590 struct buffer_head *bh = NULL;
56591 struct ext2_xattr_entry *entry;
56592 char *end;
56593 - size_t rest = buffer_size;
56594 + size_t rest = buffer_size, total_size = 0;
56595 int error;
56596
56597 ea_idebug(inode, "buffer=%p, buffer_size=%ld",
56598 @@ -305,9 +305,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
56599 buffer += size;
56600 }
56601 rest -= size;
56602 + total_size += size;
56603 }
56604 }
56605 - error = buffer_size - rest; /* total size */
56606 + error = total_size;
56607
56608 cleanup:
56609 brelse(bh);
56610 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
56611 index 22548f5..41521d8 100644
56612 --- a/fs/ext3/balloc.c
56613 +++ b/fs/ext3/balloc.c
56614 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
56615
56616 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
56617 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
56618 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
56619 + if (free_blocks < root_blocks + 1 &&
56620 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
56621 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
56622 - !in_group_p (sbi->s_resgid))) {
56623 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
56624 return 0;
56625 }
56626 return 1;
56627 diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
56628 index b1fc963..881228c 100644
56629 --- a/fs/ext3/xattr.c
56630 +++ b/fs/ext3/xattr.c
56631 @@ -330,7 +330,7 @@ static int
56632 ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
56633 char *buffer, size_t buffer_size)
56634 {
56635 - size_t rest = buffer_size;
56636 + size_t rest = buffer_size, total_size = 0;
56637
56638 for (; !IS_LAST_ENTRY(entry); entry = EXT3_XATTR_NEXT(entry)) {
56639 const struct xattr_handler *handler =
56640 @@ -347,9 +347,10 @@ ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
56641 buffer += size;
56642 }
56643 rest -= size;
56644 + total_size += size;
56645 }
56646 }
56647 - return buffer_size - rest;
56648 + return total_size;
56649 }
56650
56651 static int
56652 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
56653 index dc5d572..4c21f8e 100644
56654 --- a/fs/ext4/balloc.c
56655 +++ b/fs/ext4/balloc.c
56656 @@ -534,8 +534,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
56657 /* Hm, nope. Are (enough) root reserved clusters available? */
56658 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
56659 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
56660 - capable(CAP_SYS_RESOURCE) ||
56661 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
56662 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
56663 + capable_nolog(CAP_SYS_RESOURCE)) {
56664
56665 if (free_clusters >= (nclusters + dirty_clusters +
56666 resv_clusters))
56667 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
56668 index 745faaa..a072816 100644
56669 --- a/fs/ext4/ext4.h
56670 +++ b/fs/ext4/ext4.h
56671 @@ -1266,19 +1266,19 @@ struct ext4_sb_info {
56672 unsigned long s_mb_last_start;
56673
56674 /* stats for buddy allocator */
56675 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
56676 - atomic_t s_bal_success; /* we found long enough chunks */
56677 - atomic_t s_bal_allocated; /* in blocks */
56678 - atomic_t s_bal_ex_scanned; /* total extents scanned */
56679 - atomic_t s_bal_goals; /* goal hits */
56680 - atomic_t s_bal_breaks; /* too long searches */
56681 - atomic_t s_bal_2orders; /* 2^order hits */
56682 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
56683 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
56684 + atomic_unchecked_t s_bal_allocated; /* in blocks */
56685 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
56686 + atomic_unchecked_t s_bal_goals; /* goal hits */
56687 + atomic_unchecked_t s_bal_breaks; /* too long searches */
56688 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
56689 spinlock_t s_bal_lock;
56690 unsigned long s_mb_buddies_generated;
56691 unsigned long long s_mb_generation_time;
56692 - atomic_t s_mb_lost_chunks;
56693 - atomic_t s_mb_preallocated;
56694 - atomic_t s_mb_discarded;
56695 + atomic_unchecked_t s_mb_lost_chunks;
56696 + atomic_unchecked_t s_mb_preallocated;
56697 + atomic_unchecked_t s_mb_discarded;
56698 atomic_t s_lock_busy;
56699
56700 /* locality groups */
56701 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
56702 index 04a5c75..09894fa 100644
56703 --- a/fs/ext4/mballoc.c
56704 +++ b/fs/ext4/mballoc.c
56705 @@ -1880,7 +1880,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
56706 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
56707
56708 if (EXT4_SB(sb)->s_mb_stats)
56709 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
56710 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
56711
56712 break;
56713 }
56714 @@ -2189,7 +2189,7 @@ repeat:
56715 ac->ac_status = AC_STATUS_CONTINUE;
56716 ac->ac_flags |= EXT4_MB_HINT_FIRST;
56717 cr = 3;
56718 - atomic_inc(&sbi->s_mb_lost_chunks);
56719 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
56720 goto repeat;
56721 }
56722 }
56723 @@ -2697,25 +2697,25 @@ int ext4_mb_release(struct super_block *sb)
56724 if (sbi->s_mb_stats) {
56725 ext4_msg(sb, KERN_INFO,
56726 "mballoc: %u blocks %u reqs (%u success)",
56727 - atomic_read(&sbi->s_bal_allocated),
56728 - atomic_read(&sbi->s_bal_reqs),
56729 - atomic_read(&sbi->s_bal_success));
56730 + atomic_read_unchecked(&sbi->s_bal_allocated),
56731 + atomic_read_unchecked(&sbi->s_bal_reqs),
56732 + atomic_read_unchecked(&sbi->s_bal_success));
56733 ext4_msg(sb, KERN_INFO,
56734 "mballoc: %u extents scanned, %u goal hits, "
56735 "%u 2^N hits, %u breaks, %u lost",
56736 - atomic_read(&sbi->s_bal_ex_scanned),
56737 - atomic_read(&sbi->s_bal_goals),
56738 - atomic_read(&sbi->s_bal_2orders),
56739 - atomic_read(&sbi->s_bal_breaks),
56740 - atomic_read(&sbi->s_mb_lost_chunks));
56741 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
56742 + atomic_read_unchecked(&sbi->s_bal_goals),
56743 + atomic_read_unchecked(&sbi->s_bal_2orders),
56744 + atomic_read_unchecked(&sbi->s_bal_breaks),
56745 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
56746 ext4_msg(sb, KERN_INFO,
56747 "mballoc: %lu generated and it took %Lu",
56748 sbi->s_mb_buddies_generated,
56749 sbi->s_mb_generation_time);
56750 ext4_msg(sb, KERN_INFO,
56751 "mballoc: %u preallocated, %u discarded",
56752 - atomic_read(&sbi->s_mb_preallocated),
56753 - atomic_read(&sbi->s_mb_discarded));
56754 + atomic_read_unchecked(&sbi->s_mb_preallocated),
56755 + atomic_read_unchecked(&sbi->s_mb_discarded));
56756 }
56757
56758 free_percpu(sbi->s_locality_groups);
56759 @@ -3169,16 +3169,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
56760 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
56761
56762 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
56763 - atomic_inc(&sbi->s_bal_reqs);
56764 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
56765 + atomic_inc_unchecked(&sbi->s_bal_reqs);
56766 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
56767 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
56768 - atomic_inc(&sbi->s_bal_success);
56769 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
56770 + atomic_inc_unchecked(&sbi->s_bal_success);
56771 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
56772 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
56773 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
56774 - atomic_inc(&sbi->s_bal_goals);
56775 + atomic_inc_unchecked(&sbi->s_bal_goals);
56776 if (ac->ac_found > sbi->s_mb_max_to_scan)
56777 - atomic_inc(&sbi->s_bal_breaks);
56778 + atomic_inc_unchecked(&sbi->s_bal_breaks);
56779 }
56780
56781 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
56782 @@ -3583,7 +3583,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
56783 trace_ext4_mb_new_inode_pa(ac, pa);
56784
56785 ext4_mb_use_inode_pa(ac, pa);
56786 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
56787 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
56788
56789 ei = EXT4_I(ac->ac_inode);
56790 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56791 @@ -3643,7 +3643,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
56792 trace_ext4_mb_new_group_pa(ac, pa);
56793
56794 ext4_mb_use_group_pa(ac, pa);
56795 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56796 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56797
56798 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56799 lg = ac->ac_lg;
56800 @@ -3732,7 +3732,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
56801 * from the bitmap and continue.
56802 */
56803 }
56804 - atomic_add(free, &sbi->s_mb_discarded);
56805 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
56806
56807 return err;
56808 }
56809 @@ -3750,7 +3750,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
56810 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
56811 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
56812 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
56813 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56814 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56815 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
56816
56817 return 0;
56818 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
56819 index 214461e..3614c89 100644
56820 --- a/fs/ext4/mmp.c
56821 +++ b/fs/ext4/mmp.c
56822 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
56823 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
56824 const char *function, unsigned int line, const char *msg)
56825 {
56826 - __ext4_warning(sb, function, line, msg);
56827 + __ext4_warning(sb, function, line, "%s", msg);
56828 __ext4_warning(sb, function, line,
56829 "MMP failure info: last update time: %llu, last update "
56830 "node: %s, last update device: %s\n",
56831 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
56832 index b947e0a..c102e3b 100644
56833 --- a/fs/ext4/super.c
56834 +++ b/fs/ext4/super.c
56835 @@ -1251,7 +1251,7 @@ static ext4_fsblk_t get_sb_block(void **data)
56836 }
56837
56838 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
56839 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56840 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56841 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
56842
56843 #ifdef CONFIG_QUOTA
56844 @@ -2431,7 +2431,7 @@ struct ext4_attr {
56845 int offset;
56846 int deprecated_val;
56847 } u;
56848 -};
56849 +} __do_const;
56850
56851 static int parse_strtoull(const char *buf,
56852 unsigned long long max, unsigned long long *value)
56853 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
56854 index 1423c48..9c0c6dc 100644
56855 --- a/fs/ext4/xattr.c
56856 +++ b/fs/ext4/xattr.c
56857 @@ -381,7 +381,7 @@ static int
56858 ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
56859 char *buffer, size_t buffer_size)
56860 {
56861 - size_t rest = buffer_size;
56862 + size_t rest = buffer_size, total_size = 0;
56863
56864 for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
56865 const struct xattr_handler *handler =
56866 @@ -398,9 +398,10 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
56867 buffer += size;
56868 }
56869 rest -= size;
56870 + total_size += size;
56871 }
56872 }
56873 - return buffer_size - rest;
56874 + return total_size;
56875 }
56876
56877 static int
56878 diff --git a/fs/fcntl.c b/fs/fcntl.c
56879 index 65343c3..9969dcf 100644
56880 --- a/fs/fcntl.c
56881 +++ b/fs/fcntl.c
56882 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
56883 if (err)
56884 return err;
56885
56886 + if (gr_handle_chroot_fowner(pid, type))
56887 + return -ENOENT;
56888 + if (gr_check_protected_task_fowner(pid, type))
56889 + return -EACCES;
56890 +
56891 f_modown(filp, pid, type, force);
56892 return 0;
56893 }
56894 diff --git a/fs/fhandle.c b/fs/fhandle.c
56895 index 999ff5c..41f4109 100644
56896 --- a/fs/fhandle.c
56897 +++ b/fs/fhandle.c
56898 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
56899 } else
56900 retval = 0;
56901 /* copy the mount id */
56902 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
56903 - sizeof(*mnt_id)) ||
56904 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
56905 copy_to_user(ufh, handle,
56906 sizeof(struct file_handle) + handle_bytes))
56907 retval = -EFAULT;
56908 diff --git a/fs/file.c b/fs/file.c
56909 index 4a78f98..f9a6d25 100644
56910 --- a/fs/file.c
56911 +++ b/fs/file.c
56912 @@ -16,6 +16,7 @@
56913 #include <linux/slab.h>
56914 #include <linux/vmalloc.h>
56915 #include <linux/file.h>
56916 +#include <linux/security.h>
56917 #include <linux/fdtable.h>
56918 #include <linux/bitops.h>
56919 #include <linux/interrupt.h>
56920 @@ -141,7 +142,7 @@ out:
56921 * Return <0 error code on error; 1 on successful completion.
56922 * The files->file_lock should be held on entry, and will be held on exit.
56923 */
56924 -static int expand_fdtable(struct files_struct *files, int nr)
56925 +static int expand_fdtable(struct files_struct *files, unsigned int nr)
56926 __releases(files->file_lock)
56927 __acquires(files->file_lock)
56928 {
56929 @@ -186,7 +187,7 @@ static int expand_fdtable(struct files_struct *files, int nr)
56930 * expanded and execution may have blocked.
56931 * The files->file_lock should be held on entry, and will be held on exit.
56932 */
56933 -static int expand_files(struct files_struct *files, int nr)
56934 +static int expand_files(struct files_struct *files, unsigned int nr)
56935 {
56936 struct fdtable *fdt;
56937
56938 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
56939 if (!file)
56940 return __close_fd(files, fd);
56941
56942 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
56943 if (fd >= rlimit(RLIMIT_NOFILE))
56944 return -EBADF;
56945
56946 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
56947 if (unlikely(oldfd == newfd))
56948 return -EINVAL;
56949
56950 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
56951 if (newfd >= rlimit(RLIMIT_NOFILE))
56952 return -EBADF;
56953
56954 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
56955 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
56956 {
56957 int err;
56958 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
56959 if (from >= rlimit(RLIMIT_NOFILE))
56960 return -EINVAL;
56961 err = alloc_fd(from, flags);
56962 diff --git a/fs/filesystems.c b/fs/filesystems.c
56963 index 92567d9..fcd8cbf 100644
56964 --- a/fs/filesystems.c
56965 +++ b/fs/filesystems.c
56966 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
56967 int len = dot ? dot - name : strlen(name);
56968
56969 fs = __get_fs_type(name, len);
56970 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
56971 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
56972 +#else
56973 if (!fs && (request_module("fs-%.*s", len, name) == 0))
56974 +#endif
56975 fs = __get_fs_type(name, len);
56976
56977 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
56978 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
56979 index d8ac61d..79a36f0 100644
56980 --- a/fs/fs_struct.c
56981 +++ b/fs/fs_struct.c
56982 @@ -4,6 +4,7 @@
56983 #include <linux/path.h>
56984 #include <linux/slab.h>
56985 #include <linux/fs_struct.h>
56986 +#include <linux/grsecurity.h>
56987 #include "internal.h"
56988
56989 /*
56990 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
56991 write_seqcount_begin(&fs->seq);
56992 old_root = fs->root;
56993 fs->root = *path;
56994 + gr_set_chroot_entries(current, path);
56995 write_seqcount_end(&fs->seq);
56996 spin_unlock(&fs->lock);
56997 if (old_root.dentry)
56998 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
56999 int hits = 0;
57000 spin_lock(&fs->lock);
57001 write_seqcount_begin(&fs->seq);
57002 + /* this root replacement is only done by pivot_root,
57003 + leave grsec's chroot tagging alone for this task
57004 + so that a pivoted root isn't treated as a chroot
57005 + */
57006 hits += replace_path(&fs->root, old_root, new_root);
57007 hits += replace_path(&fs->pwd, old_root, new_root);
57008 write_seqcount_end(&fs->seq);
57009 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
57010 task_lock(tsk);
57011 spin_lock(&fs->lock);
57012 tsk->fs = NULL;
57013 - kill = !--fs->users;
57014 + gr_clear_chroot_entries(tsk);
57015 + kill = !atomic_dec_return(&fs->users);
57016 spin_unlock(&fs->lock);
57017 task_unlock(tsk);
57018 if (kill)
57019 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
57020 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
57021 /* We don't need to lock fs - think why ;-) */
57022 if (fs) {
57023 - fs->users = 1;
57024 + atomic_set(&fs->users, 1);
57025 fs->in_exec = 0;
57026 spin_lock_init(&fs->lock);
57027 seqcount_init(&fs->seq);
57028 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
57029 spin_lock(&old->lock);
57030 fs->root = old->root;
57031 path_get(&fs->root);
57032 + /* instead of calling gr_set_chroot_entries here,
57033 + we call it from every caller of this function
57034 + */
57035 fs->pwd = old->pwd;
57036 path_get(&fs->pwd);
57037 spin_unlock(&old->lock);
57038 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
57039
57040 task_lock(current);
57041 spin_lock(&fs->lock);
57042 - kill = !--fs->users;
57043 + kill = !atomic_dec_return(&fs->users);
57044 current->fs = new_fs;
57045 + gr_set_chroot_entries(current, &new_fs->root);
57046 spin_unlock(&fs->lock);
57047 task_unlock(current);
57048
57049 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
57050
57051 int current_umask(void)
57052 {
57053 - return current->fs->umask;
57054 + return current->fs->umask | gr_acl_umask();
57055 }
57056 EXPORT_SYMBOL(current_umask);
57057
57058 /* to be mentioned only in INIT_TASK */
57059 struct fs_struct init_fs = {
57060 - .users = 1,
57061 + .users = ATOMIC_INIT(1),
57062 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
57063 .seq = SEQCNT_ZERO,
57064 .umask = 0022,
57065 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
57066 index b2a86e3..37f425a 100644
57067 --- a/fs/fscache/cookie.c
57068 +++ b/fs/fscache/cookie.c
57069 @@ -19,7 +19,7 @@
57070
57071 struct kmem_cache *fscache_cookie_jar;
57072
57073 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
57074 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
57075
57076 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
57077 static int fscache_alloc_object(struct fscache_cache *cache,
57078 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
57079 parent ? (char *) parent->def->name : "<no-parent>",
57080 def->name, netfs_data);
57081
57082 - fscache_stat(&fscache_n_acquires);
57083 + fscache_stat_unchecked(&fscache_n_acquires);
57084
57085 /* if there's no parent cookie, then we don't create one here either */
57086 if (!parent) {
57087 - fscache_stat(&fscache_n_acquires_null);
57088 + fscache_stat_unchecked(&fscache_n_acquires_null);
57089 _leave(" [no parent]");
57090 return NULL;
57091 }
57092 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
57093 /* allocate and initialise a cookie */
57094 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
57095 if (!cookie) {
57096 - fscache_stat(&fscache_n_acquires_oom);
57097 + fscache_stat_unchecked(&fscache_n_acquires_oom);
57098 _leave(" [ENOMEM]");
57099 return NULL;
57100 }
57101 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
57102
57103 switch (cookie->def->type) {
57104 case FSCACHE_COOKIE_TYPE_INDEX:
57105 - fscache_stat(&fscache_n_cookie_index);
57106 + fscache_stat_unchecked(&fscache_n_cookie_index);
57107 break;
57108 case FSCACHE_COOKIE_TYPE_DATAFILE:
57109 - fscache_stat(&fscache_n_cookie_data);
57110 + fscache_stat_unchecked(&fscache_n_cookie_data);
57111 break;
57112 default:
57113 - fscache_stat(&fscache_n_cookie_special);
57114 + fscache_stat_unchecked(&fscache_n_cookie_special);
57115 break;
57116 }
57117
57118 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
57119 if (fscache_acquire_non_index_cookie(cookie) < 0) {
57120 atomic_dec(&parent->n_children);
57121 __fscache_cookie_put(cookie);
57122 - fscache_stat(&fscache_n_acquires_nobufs);
57123 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
57124 _leave(" = NULL");
57125 return NULL;
57126 }
57127 }
57128
57129 - fscache_stat(&fscache_n_acquires_ok);
57130 + fscache_stat_unchecked(&fscache_n_acquires_ok);
57131 _leave(" = %p", cookie);
57132 return cookie;
57133 }
57134 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
57135 cache = fscache_select_cache_for_object(cookie->parent);
57136 if (!cache) {
57137 up_read(&fscache_addremove_sem);
57138 - fscache_stat(&fscache_n_acquires_no_cache);
57139 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
57140 _leave(" = -ENOMEDIUM [no cache]");
57141 return -ENOMEDIUM;
57142 }
57143 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
57144 object = cache->ops->alloc_object(cache, cookie);
57145 fscache_stat_d(&fscache_n_cop_alloc_object);
57146 if (IS_ERR(object)) {
57147 - fscache_stat(&fscache_n_object_no_alloc);
57148 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
57149 ret = PTR_ERR(object);
57150 goto error;
57151 }
57152
57153 - fscache_stat(&fscache_n_object_alloc);
57154 + fscache_stat_unchecked(&fscache_n_object_alloc);
57155
57156 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
57157 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
57158
57159 _debug("ALLOC OBJ%x: %s {%lx}",
57160 object->debug_id, cookie->def->name, object->events);
57161 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
57162
57163 _enter("{%s}", cookie->def->name);
57164
57165 - fscache_stat(&fscache_n_invalidates);
57166 + fscache_stat_unchecked(&fscache_n_invalidates);
57167
57168 /* Only permit invalidation of data files. Invalidating an index will
57169 * require the caller to release all its attachments to the tree rooted
57170 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
57171 {
57172 struct fscache_object *object;
57173
57174 - fscache_stat(&fscache_n_updates);
57175 + fscache_stat_unchecked(&fscache_n_updates);
57176
57177 if (!cookie) {
57178 - fscache_stat(&fscache_n_updates_null);
57179 + fscache_stat_unchecked(&fscache_n_updates_null);
57180 _leave(" [no cookie]");
57181 return;
57182 }
57183 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
57184 {
57185 struct fscache_object *object;
57186
57187 - fscache_stat(&fscache_n_relinquishes);
57188 + fscache_stat_unchecked(&fscache_n_relinquishes);
57189 if (retire)
57190 - fscache_stat(&fscache_n_relinquishes_retire);
57191 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
57192
57193 if (!cookie) {
57194 - fscache_stat(&fscache_n_relinquishes_null);
57195 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
57196 _leave(" [no cookie]");
57197 return;
57198 }
57199 @@ -598,7 +598,7 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
57200 if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
57201 goto inconsistent;
57202
57203 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
57204 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
57205
57206 atomic_inc(&cookie->n_active);
57207 if (fscache_submit_op(object, op) < 0)
57208 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
57209 index 4226f66..0fb3f45 100644
57210 --- a/fs/fscache/internal.h
57211 +++ b/fs/fscache/internal.h
57212 @@ -133,8 +133,8 @@ extern void fscache_operation_gc(struct work_struct *);
57213 extern int fscache_wait_for_deferred_lookup(struct fscache_cookie *);
57214 extern int fscache_wait_for_operation_activation(struct fscache_object *,
57215 struct fscache_operation *,
57216 - atomic_t *,
57217 - atomic_t *,
57218 + atomic_unchecked_t *,
57219 + atomic_unchecked_t *,
57220 void (*)(struct fscache_operation *));
57221 extern void fscache_invalidate_writes(struct fscache_cookie *);
57222
57223 @@ -153,101 +153,101 @@ extern void fscache_proc_cleanup(void);
57224 * stats.c
57225 */
57226 #ifdef CONFIG_FSCACHE_STATS
57227 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
57228 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
57229 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
57230 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
57231
57232 -extern atomic_t fscache_n_op_pend;
57233 -extern atomic_t fscache_n_op_run;
57234 -extern atomic_t fscache_n_op_enqueue;
57235 -extern atomic_t fscache_n_op_deferred_release;
57236 -extern atomic_t fscache_n_op_release;
57237 -extern atomic_t fscache_n_op_gc;
57238 -extern atomic_t fscache_n_op_cancelled;
57239 -extern atomic_t fscache_n_op_rejected;
57240 +extern atomic_unchecked_t fscache_n_op_pend;
57241 +extern atomic_unchecked_t fscache_n_op_run;
57242 +extern atomic_unchecked_t fscache_n_op_enqueue;
57243 +extern atomic_unchecked_t fscache_n_op_deferred_release;
57244 +extern atomic_unchecked_t fscache_n_op_release;
57245 +extern atomic_unchecked_t fscache_n_op_gc;
57246 +extern atomic_unchecked_t fscache_n_op_cancelled;
57247 +extern atomic_unchecked_t fscache_n_op_rejected;
57248
57249 -extern atomic_t fscache_n_attr_changed;
57250 -extern atomic_t fscache_n_attr_changed_ok;
57251 -extern atomic_t fscache_n_attr_changed_nobufs;
57252 -extern atomic_t fscache_n_attr_changed_nomem;
57253 -extern atomic_t fscache_n_attr_changed_calls;
57254 +extern atomic_unchecked_t fscache_n_attr_changed;
57255 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
57256 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
57257 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
57258 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
57259
57260 -extern atomic_t fscache_n_allocs;
57261 -extern atomic_t fscache_n_allocs_ok;
57262 -extern atomic_t fscache_n_allocs_wait;
57263 -extern atomic_t fscache_n_allocs_nobufs;
57264 -extern atomic_t fscache_n_allocs_intr;
57265 -extern atomic_t fscache_n_allocs_object_dead;
57266 -extern atomic_t fscache_n_alloc_ops;
57267 -extern atomic_t fscache_n_alloc_op_waits;
57268 +extern atomic_unchecked_t fscache_n_allocs;
57269 +extern atomic_unchecked_t fscache_n_allocs_ok;
57270 +extern atomic_unchecked_t fscache_n_allocs_wait;
57271 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
57272 +extern atomic_unchecked_t fscache_n_allocs_intr;
57273 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
57274 +extern atomic_unchecked_t fscache_n_alloc_ops;
57275 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
57276
57277 -extern atomic_t fscache_n_retrievals;
57278 -extern atomic_t fscache_n_retrievals_ok;
57279 -extern atomic_t fscache_n_retrievals_wait;
57280 -extern atomic_t fscache_n_retrievals_nodata;
57281 -extern atomic_t fscache_n_retrievals_nobufs;
57282 -extern atomic_t fscache_n_retrievals_intr;
57283 -extern atomic_t fscache_n_retrievals_nomem;
57284 -extern atomic_t fscache_n_retrievals_object_dead;
57285 -extern atomic_t fscache_n_retrieval_ops;
57286 -extern atomic_t fscache_n_retrieval_op_waits;
57287 +extern atomic_unchecked_t fscache_n_retrievals;
57288 +extern atomic_unchecked_t fscache_n_retrievals_ok;
57289 +extern atomic_unchecked_t fscache_n_retrievals_wait;
57290 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
57291 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
57292 +extern atomic_unchecked_t fscache_n_retrievals_intr;
57293 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
57294 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
57295 +extern atomic_unchecked_t fscache_n_retrieval_ops;
57296 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
57297
57298 -extern atomic_t fscache_n_stores;
57299 -extern atomic_t fscache_n_stores_ok;
57300 -extern atomic_t fscache_n_stores_again;
57301 -extern atomic_t fscache_n_stores_nobufs;
57302 -extern atomic_t fscache_n_stores_oom;
57303 -extern atomic_t fscache_n_store_ops;
57304 -extern atomic_t fscache_n_store_calls;
57305 -extern atomic_t fscache_n_store_pages;
57306 -extern atomic_t fscache_n_store_radix_deletes;
57307 -extern atomic_t fscache_n_store_pages_over_limit;
57308 +extern atomic_unchecked_t fscache_n_stores;
57309 +extern atomic_unchecked_t fscache_n_stores_ok;
57310 +extern atomic_unchecked_t fscache_n_stores_again;
57311 +extern atomic_unchecked_t fscache_n_stores_nobufs;
57312 +extern atomic_unchecked_t fscache_n_stores_oom;
57313 +extern atomic_unchecked_t fscache_n_store_ops;
57314 +extern atomic_unchecked_t fscache_n_store_calls;
57315 +extern atomic_unchecked_t fscache_n_store_pages;
57316 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
57317 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
57318
57319 -extern atomic_t fscache_n_store_vmscan_not_storing;
57320 -extern atomic_t fscache_n_store_vmscan_gone;
57321 -extern atomic_t fscache_n_store_vmscan_busy;
57322 -extern atomic_t fscache_n_store_vmscan_cancelled;
57323 -extern atomic_t fscache_n_store_vmscan_wait;
57324 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
57325 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
57326 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
57327 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
57328 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
57329
57330 -extern atomic_t fscache_n_marks;
57331 -extern atomic_t fscache_n_uncaches;
57332 +extern atomic_unchecked_t fscache_n_marks;
57333 +extern atomic_unchecked_t fscache_n_uncaches;
57334
57335 -extern atomic_t fscache_n_acquires;
57336 -extern atomic_t fscache_n_acquires_null;
57337 -extern atomic_t fscache_n_acquires_no_cache;
57338 -extern atomic_t fscache_n_acquires_ok;
57339 -extern atomic_t fscache_n_acquires_nobufs;
57340 -extern atomic_t fscache_n_acquires_oom;
57341 +extern atomic_unchecked_t fscache_n_acquires;
57342 +extern atomic_unchecked_t fscache_n_acquires_null;
57343 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
57344 +extern atomic_unchecked_t fscache_n_acquires_ok;
57345 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
57346 +extern atomic_unchecked_t fscache_n_acquires_oom;
57347
57348 -extern atomic_t fscache_n_invalidates;
57349 -extern atomic_t fscache_n_invalidates_run;
57350 +extern atomic_unchecked_t fscache_n_invalidates;
57351 +extern atomic_unchecked_t fscache_n_invalidates_run;
57352
57353 -extern atomic_t fscache_n_updates;
57354 -extern atomic_t fscache_n_updates_null;
57355 -extern atomic_t fscache_n_updates_run;
57356 +extern atomic_unchecked_t fscache_n_updates;
57357 +extern atomic_unchecked_t fscache_n_updates_null;
57358 +extern atomic_unchecked_t fscache_n_updates_run;
57359
57360 -extern atomic_t fscache_n_relinquishes;
57361 -extern atomic_t fscache_n_relinquishes_null;
57362 -extern atomic_t fscache_n_relinquishes_waitcrt;
57363 -extern atomic_t fscache_n_relinquishes_retire;
57364 +extern atomic_unchecked_t fscache_n_relinquishes;
57365 +extern atomic_unchecked_t fscache_n_relinquishes_null;
57366 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
57367 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
57368
57369 -extern atomic_t fscache_n_cookie_index;
57370 -extern atomic_t fscache_n_cookie_data;
57371 -extern atomic_t fscache_n_cookie_special;
57372 +extern atomic_unchecked_t fscache_n_cookie_index;
57373 +extern atomic_unchecked_t fscache_n_cookie_data;
57374 +extern atomic_unchecked_t fscache_n_cookie_special;
57375
57376 -extern atomic_t fscache_n_object_alloc;
57377 -extern atomic_t fscache_n_object_no_alloc;
57378 -extern atomic_t fscache_n_object_lookups;
57379 -extern atomic_t fscache_n_object_lookups_negative;
57380 -extern atomic_t fscache_n_object_lookups_positive;
57381 -extern atomic_t fscache_n_object_lookups_timed_out;
57382 -extern atomic_t fscache_n_object_created;
57383 -extern atomic_t fscache_n_object_avail;
57384 -extern atomic_t fscache_n_object_dead;
57385 +extern atomic_unchecked_t fscache_n_object_alloc;
57386 +extern atomic_unchecked_t fscache_n_object_no_alloc;
57387 +extern atomic_unchecked_t fscache_n_object_lookups;
57388 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
57389 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
57390 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
57391 +extern atomic_unchecked_t fscache_n_object_created;
57392 +extern atomic_unchecked_t fscache_n_object_avail;
57393 +extern atomic_unchecked_t fscache_n_object_dead;
57394
57395 -extern atomic_t fscache_n_checkaux_none;
57396 -extern atomic_t fscache_n_checkaux_okay;
57397 -extern atomic_t fscache_n_checkaux_update;
57398 -extern atomic_t fscache_n_checkaux_obsolete;
57399 +extern atomic_unchecked_t fscache_n_checkaux_none;
57400 +extern atomic_unchecked_t fscache_n_checkaux_okay;
57401 +extern atomic_unchecked_t fscache_n_checkaux_update;
57402 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
57403
57404 extern atomic_t fscache_n_cop_alloc_object;
57405 extern atomic_t fscache_n_cop_lookup_object;
57406 @@ -272,6 +272,11 @@ static inline void fscache_stat(atomic_t *stat)
57407 atomic_inc(stat);
57408 }
57409
57410 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
57411 +{
57412 + atomic_inc_unchecked(stat);
57413 +}
57414 +
57415 static inline void fscache_stat_d(atomic_t *stat)
57416 {
57417 atomic_dec(stat);
57418 @@ -284,6 +289,7 @@ extern const struct file_operations fscache_stats_fops;
57419
57420 #define __fscache_stat(stat) (NULL)
57421 #define fscache_stat(stat) do {} while (0)
57422 +#define fscache_stat_unchecked(stat) do {} while (0)
57423 #define fscache_stat_d(stat) do {} while (0)
57424 #endif
57425
57426 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
57427 index 86d75a6..5f3d7a0 100644
57428 --- a/fs/fscache/object.c
57429 +++ b/fs/fscache/object.c
57430 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
57431 _debug("LOOKUP \"%s\" in \"%s\"",
57432 cookie->def->name, object->cache->tag->name);
57433
57434 - fscache_stat(&fscache_n_object_lookups);
57435 + fscache_stat_unchecked(&fscache_n_object_lookups);
57436 fscache_stat(&fscache_n_cop_lookup_object);
57437 ret = object->cache->ops->lookup_object(object);
57438 fscache_stat_d(&fscache_n_cop_lookup_object);
57439 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
57440 if (ret == -ETIMEDOUT) {
57441 /* probably stuck behind another object, so move this one to
57442 * the back of the queue */
57443 - fscache_stat(&fscache_n_object_lookups_timed_out);
57444 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
57445 _leave(" [timeout]");
57446 return NO_TRANSIT;
57447 }
57448 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
57449 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
57450
57451 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
57452 - fscache_stat(&fscache_n_object_lookups_negative);
57453 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
57454
57455 /* Allow write requests to begin stacking up and read requests to begin
57456 * returning ENODATA.
57457 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
57458 /* if we were still looking up, then we must have a positive lookup
57459 * result, in which case there may be data available */
57460 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
57461 - fscache_stat(&fscache_n_object_lookups_positive);
57462 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
57463
57464 /* We do (presumably) have data */
57465 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
57466 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
57467 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
57468 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
57469 } else {
57470 - fscache_stat(&fscache_n_object_created);
57471 + fscache_stat_unchecked(&fscache_n_object_created);
57472 }
57473
57474 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
57475 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
57476 fscache_stat_d(&fscache_n_cop_lookup_complete);
57477
57478 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
57479 - fscache_stat(&fscache_n_object_avail);
57480 + fscache_stat_unchecked(&fscache_n_object_avail);
57481
57482 _leave("");
57483 return transit_to(JUMPSTART_DEPS);
57484 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
57485
57486 /* this just shifts the object release to the work processor */
57487 fscache_put_object(object);
57488 - fscache_stat(&fscache_n_object_dead);
57489 + fscache_stat_unchecked(&fscache_n_object_dead);
57490
57491 _leave("");
57492 return transit_to(OBJECT_DEAD);
57493 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
57494 enum fscache_checkaux result;
57495
57496 if (!object->cookie->def->check_aux) {
57497 - fscache_stat(&fscache_n_checkaux_none);
57498 + fscache_stat_unchecked(&fscache_n_checkaux_none);
57499 return FSCACHE_CHECKAUX_OKAY;
57500 }
57501
57502 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
57503 switch (result) {
57504 /* entry okay as is */
57505 case FSCACHE_CHECKAUX_OKAY:
57506 - fscache_stat(&fscache_n_checkaux_okay);
57507 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
57508 break;
57509
57510 /* entry requires update */
57511 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
57512 - fscache_stat(&fscache_n_checkaux_update);
57513 + fscache_stat_unchecked(&fscache_n_checkaux_update);
57514 break;
57515
57516 /* entry requires deletion */
57517 case FSCACHE_CHECKAUX_OBSOLETE:
57518 - fscache_stat(&fscache_n_checkaux_obsolete);
57519 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
57520 break;
57521
57522 default:
57523 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
57524 {
57525 const struct fscache_state *s;
57526
57527 - fscache_stat(&fscache_n_invalidates_run);
57528 + fscache_stat_unchecked(&fscache_n_invalidates_run);
57529 fscache_stat(&fscache_n_cop_invalidate_object);
57530 s = _fscache_invalidate_object(object, event);
57531 fscache_stat_d(&fscache_n_cop_invalidate_object);
57532 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
57533 {
57534 _enter("{OBJ%x},%d", object->debug_id, event);
57535
57536 - fscache_stat(&fscache_n_updates_run);
57537 + fscache_stat_unchecked(&fscache_n_updates_run);
57538 fscache_stat(&fscache_n_cop_update_object);
57539 object->cache->ops->update_object(object);
57540 fscache_stat_d(&fscache_n_cop_update_object);
57541 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
57542 index 318071a..379938b 100644
57543 --- a/fs/fscache/operation.c
57544 +++ b/fs/fscache/operation.c
57545 @@ -17,7 +17,7 @@
57546 #include <linux/slab.h>
57547 #include "internal.h"
57548
57549 -atomic_t fscache_op_debug_id;
57550 +atomic_unchecked_t fscache_op_debug_id;
57551 EXPORT_SYMBOL(fscache_op_debug_id);
57552
57553 /**
57554 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
57555 ASSERTCMP(atomic_read(&op->usage), >, 0);
57556 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
57557
57558 - fscache_stat(&fscache_n_op_enqueue);
57559 + fscache_stat_unchecked(&fscache_n_op_enqueue);
57560 switch (op->flags & FSCACHE_OP_TYPE) {
57561 case FSCACHE_OP_ASYNC:
57562 _debug("queue async");
57563 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
57564 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
57565 if (op->processor)
57566 fscache_enqueue_operation(op);
57567 - fscache_stat(&fscache_n_op_run);
57568 + fscache_stat_unchecked(&fscache_n_op_run);
57569 }
57570
57571 /*
57572 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
57573 if (object->n_in_progress > 0) {
57574 atomic_inc(&op->usage);
57575 list_add_tail(&op->pend_link, &object->pending_ops);
57576 - fscache_stat(&fscache_n_op_pend);
57577 + fscache_stat_unchecked(&fscache_n_op_pend);
57578 } else if (!list_empty(&object->pending_ops)) {
57579 atomic_inc(&op->usage);
57580 list_add_tail(&op->pend_link, &object->pending_ops);
57581 - fscache_stat(&fscache_n_op_pend);
57582 + fscache_stat_unchecked(&fscache_n_op_pend);
57583 fscache_start_operations(object);
57584 } else {
57585 ASSERTCMP(object->n_in_progress, ==, 0);
57586 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
57587 object->n_exclusive++; /* reads and writes must wait */
57588 atomic_inc(&op->usage);
57589 list_add_tail(&op->pend_link, &object->pending_ops);
57590 - fscache_stat(&fscache_n_op_pend);
57591 + fscache_stat_unchecked(&fscache_n_op_pend);
57592 ret = 0;
57593 } else {
57594 /* If we're in any other state, there must have been an I/O
57595 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
57596 if (object->n_exclusive > 0) {
57597 atomic_inc(&op->usage);
57598 list_add_tail(&op->pend_link, &object->pending_ops);
57599 - fscache_stat(&fscache_n_op_pend);
57600 + fscache_stat_unchecked(&fscache_n_op_pend);
57601 } else if (!list_empty(&object->pending_ops)) {
57602 atomic_inc(&op->usage);
57603 list_add_tail(&op->pend_link, &object->pending_ops);
57604 - fscache_stat(&fscache_n_op_pend);
57605 + fscache_stat_unchecked(&fscache_n_op_pend);
57606 fscache_start_operations(object);
57607 } else {
57608 ASSERTCMP(object->n_exclusive, ==, 0);
57609 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
57610 object->n_ops++;
57611 atomic_inc(&op->usage);
57612 list_add_tail(&op->pend_link, &object->pending_ops);
57613 - fscache_stat(&fscache_n_op_pend);
57614 + fscache_stat_unchecked(&fscache_n_op_pend);
57615 ret = 0;
57616 } else if (fscache_object_is_dying(object)) {
57617 - fscache_stat(&fscache_n_op_rejected);
57618 + fscache_stat_unchecked(&fscache_n_op_rejected);
57619 op->state = FSCACHE_OP_ST_CANCELLED;
57620 ret = -ENOBUFS;
57621 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
57622 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
57623 ret = -EBUSY;
57624 if (op->state == FSCACHE_OP_ST_PENDING) {
57625 ASSERT(!list_empty(&op->pend_link));
57626 - fscache_stat(&fscache_n_op_cancelled);
57627 + fscache_stat_unchecked(&fscache_n_op_cancelled);
57628 list_del_init(&op->pend_link);
57629 if (do_cancel)
57630 do_cancel(op);
57631 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
57632 while (!list_empty(&object->pending_ops)) {
57633 op = list_entry(object->pending_ops.next,
57634 struct fscache_operation, pend_link);
57635 - fscache_stat(&fscache_n_op_cancelled);
57636 + fscache_stat_unchecked(&fscache_n_op_cancelled);
57637 list_del_init(&op->pend_link);
57638
57639 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
57640 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
57641 op->state, ==, FSCACHE_OP_ST_CANCELLED);
57642 op->state = FSCACHE_OP_ST_DEAD;
57643
57644 - fscache_stat(&fscache_n_op_release);
57645 + fscache_stat_unchecked(&fscache_n_op_release);
57646
57647 if (op->release) {
57648 op->release(op);
57649 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
57650 * lock, and defer it otherwise */
57651 if (!spin_trylock(&object->lock)) {
57652 _debug("defer put");
57653 - fscache_stat(&fscache_n_op_deferred_release);
57654 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
57655
57656 cache = object->cache;
57657 spin_lock(&cache->op_gc_list_lock);
57658 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
57659
57660 _debug("GC DEFERRED REL OBJ%x OP%x",
57661 object->debug_id, op->debug_id);
57662 - fscache_stat(&fscache_n_op_gc);
57663 + fscache_stat_unchecked(&fscache_n_op_gc);
57664
57665 ASSERTCMP(atomic_read(&op->usage), ==, 0);
57666 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
57667 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
57668 index 73899c1..ae40c58 100644
57669 --- a/fs/fscache/page.c
57670 +++ b/fs/fscache/page.c
57671 @@ -61,7 +61,7 @@ try_again:
57672 val = radix_tree_lookup(&cookie->stores, page->index);
57673 if (!val) {
57674 rcu_read_unlock();
57675 - fscache_stat(&fscache_n_store_vmscan_not_storing);
57676 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
57677 __fscache_uncache_page(cookie, page);
57678 return true;
57679 }
57680 @@ -91,11 +91,11 @@ try_again:
57681 spin_unlock(&cookie->stores_lock);
57682
57683 if (xpage) {
57684 - fscache_stat(&fscache_n_store_vmscan_cancelled);
57685 - fscache_stat(&fscache_n_store_radix_deletes);
57686 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
57687 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
57688 ASSERTCMP(xpage, ==, page);
57689 } else {
57690 - fscache_stat(&fscache_n_store_vmscan_gone);
57691 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
57692 }
57693
57694 wake_up_bit(&cookie->flags, 0);
57695 @@ -110,11 +110,11 @@ page_busy:
57696 * sleeping on memory allocation, so we may need to impose a timeout
57697 * too. */
57698 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
57699 - fscache_stat(&fscache_n_store_vmscan_busy);
57700 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
57701 return false;
57702 }
57703
57704 - fscache_stat(&fscache_n_store_vmscan_wait);
57705 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
57706 __fscache_wait_on_page_write(cookie, page);
57707 gfp &= ~__GFP_WAIT;
57708 goto try_again;
57709 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
57710 FSCACHE_COOKIE_STORING_TAG);
57711 if (!radix_tree_tag_get(&cookie->stores, page->index,
57712 FSCACHE_COOKIE_PENDING_TAG)) {
57713 - fscache_stat(&fscache_n_store_radix_deletes);
57714 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
57715 xpage = radix_tree_delete(&cookie->stores, page->index);
57716 }
57717 spin_unlock(&cookie->stores_lock);
57718 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
57719
57720 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
57721
57722 - fscache_stat(&fscache_n_attr_changed_calls);
57723 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
57724
57725 if (fscache_object_is_active(object) &&
57726 fscache_use_cookie(object)) {
57727 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57728
57729 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57730
57731 - fscache_stat(&fscache_n_attr_changed);
57732 + fscache_stat_unchecked(&fscache_n_attr_changed);
57733
57734 op = kzalloc(sizeof(*op), GFP_KERNEL);
57735 if (!op) {
57736 - fscache_stat(&fscache_n_attr_changed_nomem);
57737 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
57738 _leave(" = -ENOMEM");
57739 return -ENOMEM;
57740 }
57741 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57742 if (fscache_submit_exclusive_op(object, op) < 0)
57743 goto nobufs;
57744 spin_unlock(&cookie->lock);
57745 - fscache_stat(&fscache_n_attr_changed_ok);
57746 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
57747 fscache_put_operation(op);
57748 _leave(" = 0");
57749 return 0;
57750 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57751 nobufs:
57752 spin_unlock(&cookie->lock);
57753 kfree(op);
57754 - fscache_stat(&fscache_n_attr_changed_nobufs);
57755 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
57756 _leave(" = %d", -ENOBUFS);
57757 return -ENOBUFS;
57758 }
57759 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
57760 /* allocate a retrieval operation and attempt to submit it */
57761 op = kzalloc(sizeof(*op), GFP_NOIO);
57762 if (!op) {
57763 - fscache_stat(&fscache_n_retrievals_nomem);
57764 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57765 return NULL;
57766 }
57767
57768 @@ -289,13 +289,13 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
57769 return 0;
57770 }
57771
57772 - fscache_stat(&fscache_n_retrievals_wait);
57773 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
57774
57775 jif = jiffies;
57776 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
57777 fscache_wait_bit_interruptible,
57778 TASK_INTERRUPTIBLE) != 0) {
57779 - fscache_stat(&fscache_n_retrievals_intr);
57780 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57781 _leave(" = -ERESTARTSYS");
57782 return -ERESTARTSYS;
57783 }
57784 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
57785 */
57786 int fscache_wait_for_operation_activation(struct fscache_object *object,
57787 struct fscache_operation *op,
57788 - atomic_t *stat_op_waits,
57789 - atomic_t *stat_object_dead,
57790 + atomic_unchecked_t *stat_op_waits,
57791 + atomic_unchecked_t *stat_object_dead,
57792 void (*do_cancel)(struct fscache_operation *))
57793 {
57794 int ret;
57795 @@ -335,7 +335,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
57796
57797 _debug(">>> WT");
57798 if (stat_op_waits)
57799 - fscache_stat(stat_op_waits);
57800 + fscache_stat_unchecked(stat_op_waits);
57801 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
57802 fscache_wait_bit_interruptible,
57803 TASK_INTERRUPTIBLE) != 0) {
57804 @@ -353,7 +353,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
57805 check_if_dead:
57806 if (op->state == FSCACHE_OP_ST_CANCELLED) {
57807 if (stat_object_dead)
57808 - fscache_stat(stat_object_dead);
57809 + fscache_stat_unchecked(stat_object_dead);
57810 _leave(" = -ENOBUFS [cancelled]");
57811 return -ENOBUFS;
57812 }
57813 @@ -361,7 +361,7 @@ check_if_dead:
57814 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->state);
57815 fscache_cancel_op(op, do_cancel);
57816 if (stat_object_dead)
57817 - fscache_stat(stat_object_dead);
57818 + fscache_stat_unchecked(stat_object_dead);
57819 return -ENOBUFS;
57820 }
57821 return 0;
57822 @@ -388,7 +388,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57823
57824 _enter("%p,%p,,,", cookie, page);
57825
57826 - fscache_stat(&fscache_n_retrievals);
57827 + fscache_stat_unchecked(&fscache_n_retrievals);
57828
57829 if (hlist_empty(&cookie->backing_objects))
57830 goto nobufs;
57831 @@ -428,7 +428,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57832 goto nobufs_unlock_dec;
57833 spin_unlock(&cookie->lock);
57834
57835 - fscache_stat(&fscache_n_retrieval_ops);
57836 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57837
57838 /* pin the netfs read context in case we need to do the actual netfs
57839 * read because we've encountered a cache read failure */
57840 @@ -459,15 +459,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57841
57842 error:
57843 if (ret == -ENOMEM)
57844 - fscache_stat(&fscache_n_retrievals_nomem);
57845 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57846 else if (ret == -ERESTARTSYS)
57847 - fscache_stat(&fscache_n_retrievals_intr);
57848 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57849 else if (ret == -ENODATA)
57850 - fscache_stat(&fscache_n_retrievals_nodata);
57851 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57852 else if (ret < 0)
57853 - fscache_stat(&fscache_n_retrievals_nobufs);
57854 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57855 else
57856 - fscache_stat(&fscache_n_retrievals_ok);
57857 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57858
57859 fscache_put_retrieval(op);
57860 _leave(" = %d", ret);
57861 @@ -480,7 +480,7 @@ nobufs_unlock:
57862 atomic_dec(&cookie->n_active);
57863 kfree(op);
57864 nobufs:
57865 - fscache_stat(&fscache_n_retrievals_nobufs);
57866 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57867 _leave(" = -ENOBUFS");
57868 return -ENOBUFS;
57869 }
57870 @@ -518,7 +518,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57871
57872 _enter("%p,,%d,,,", cookie, *nr_pages);
57873
57874 - fscache_stat(&fscache_n_retrievals);
57875 + fscache_stat_unchecked(&fscache_n_retrievals);
57876
57877 if (hlist_empty(&cookie->backing_objects))
57878 goto nobufs;
57879 @@ -554,7 +554,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57880 goto nobufs_unlock_dec;
57881 spin_unlock(&cookie->lock);
57882
57883 - fscache_stat(&fscache_n_retrieval_ops);
57884 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57885
57886 /* pin the netfs read context in case we need to do the actual netfs
57887 * read because we've encountered a cache read failure */
57888 @@ -585,15 +585,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57889
57890 error:
57891 if (ret == -ENOMEM)
57892 - fscache_stat(&fscache_n_retrievals_nomem);
57893 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57894 else if (ret == -ERESTARTSYS)
57895 - fscache_stat(&fscache_n_retrievals_intr);
57896 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57897 else if (ret == -ENODATA)
57898 - fscache_stat(&fscache_n_retrievals_nodata);
57899 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57900 else if (ret < 0)
57901 - fscache_stat(&fscache_n_retrievals_nobufs);
57902 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57903 else
57904 - fscache_stat(&fscache_n_retrievals_ok);
57905 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57906
57907 fscache_put_retrieval(op);
57908 _leave(" = %d", ret);
57909 @@ -606,7 +606,7 @@ nobufs_unlock:
57910 atomic_dec(&cookie->n_active);
57911 kfree(op);
57912 nobufs:
57913 - fscache_stat(&fscache_n_retrievals_nobufs);
57914 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57915 _leave(" = -ENOBUFS");
57916 return -ENOBUFS;
57917 }
57918 @@ -630,7 +630,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57919
57920 _enter("%p,%p,,,", cookie, page);
57921
57922 - fscache_stat(&fscache_n_allocs);
57923 + fscache_stat_unchecked(&fscache_n_allocs);
57924
57925 if (hlist_empty(&cookie->backing_objects))
57926 goto nobufs;
57927 @@ -662,7 +662,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57928 goto nobufs_unlock;
57929 spin_unlock(&cookie->lock);
57930
57931 - fscache_stat(&fscache_n_alloc_ops);
57932 + fscache_stat_unchecked(&fscache_n_alloc_ops);
57933
57934 ret = fscache_wait_for_operation_activation(
57935 object, &op->op,
57936 @@ -679,11 +679,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57937
57938 error:
57939 if (ret == -ERESTARTSYS)
57940 - fscache_stat(&fscache_n_allocs_intr);
57941 + fscache_stat_unchecked(&fscache_n_allocs_intr);
57942 else if (ret < 0)
57943 - fscache_stat(&fscache_n_allocs_nobufs);
57944 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57945 else
57946 - fscache_stat(&fscache_n_allocs_ok);
57947 + fscache_stat_unchecked(&fscache_n_allocs_ok);
57948
57949 fscache_put_retrieval(op);
57950 _leave(" = %d", ret);
57951 @@ -694,7 +694,7 @@ nobufs_unlock:
57952 atomic_dec(&cookie->n_active);
57953 kfree(op);
57954 nobufs:
57955 - fscache_stat(&fscache_n_allocs_nobufs);
57956 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57957 _leave(" = -ENOBUFS");
57958 return -ENOBUFS;
57959 }
57960 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57961
57962 spin_lock(&cookie->stores_lock);
57963
57964 - fscache_stat(&fscache_n_store_calls);
57965 + fscache_stat_unchecked(&fscache_n_store_calls);
57966
57967 /* find a page to store */
57968 page = NULL;
57969 @@ -781,7 +781,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57970 page = results[0];
57971 _debug("gang %d [%lx]", n, page->index);
57972 if (page->index > op->store_limit) {
57973 - fscache_stat(&fscache_n_store_pages_over_limit);
57974 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
57975 goto superseded;
57976 }
57977
57978 @@ -793,7 +793,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57979 spin_unlock(&cookie->stores_lock);
57980 spin_unlock(&object->lock);
57981
57982 - fscache_stat(&fscache_n_store_pages);
57983 + fscache_stat_unchecked(&fscache_n_store_pages);
57984 fscache_stat(&fscache_n_cop_write_page);
57985 ret = object->cache->ops->write_page(op, page);
57986 fscache_stat_d(&fscache_n_cop_write_page);
57987 @@ -896,7 +896,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57988 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57989 ASSERT(PageFsCache(page));
57990
57991 - fscache_stat(&fscache_n_stores);
57992 + fscache_stat_unchecked(&fscache_n_stores);
57993
57994 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
57995 _leave(" = -ENOBUFS [invalidating]");
57996 @@ -954,7 +954,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57997 spin_unlock(&cookie->stores_lock);
57998 spin_unlock(&object->lock);
57999
58000 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
58001 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
58002 op->store_limit = object->store_limit;
58003
58004 atomic_inc(&cookie->n_active);
58005 @@ -963,8 +963,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
58006
58007 spin_unlock(&cookie->lock);
58008 radix_tree_preload_end();
58009 - fscache_stat(&fscache_n_store_ops);
58010 - fscache_stat(&fscache_n_stores_ok);
58011 + fscache_stat_unchecked(&fscache_n_store_ops);
58012 + fscache_stat_unchecked(&fscache_n_stores_ok);
58013
58014 /* the work queue now carries its own ref on the object */
58015 fscache_put_operation(&op->op);
58016 @@ -972,14 +972,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
58017 return 0;
58018
58019 already_queued:
58020 - fscache_stat(&fscache_n_stores_again);
58021 + fscache_stat_unchecked(&fscache_n_stores_again);
58022 already_pending:
58023 spin_unlock(&cookie->stores_lock);
58024 spin_unlock(&object->lock);
58025 spin_unlock(&cookie->lock);
58026 radix_tree_preload_end();
58027 kfree(op);
58028 - fscache_stat(&fscache_n_stores_ok);
58029 + fscache_stat_unchecked(&fscache_n_stores_ok);
58030 _leave(" = 0");
58031 return 0;
58032
58033 @@ -999,14 +999,14 @@ nobufs:
58034 spin_unlock(&cookie->lock);
58035 radix_tree_preload_end();
58036 kfree(op);
58037 - fscache_stat(&fscache_n_stores_nobufs);
58038 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
58039 _leave(" = -ENOBUFS");
58040 return -ENOBUFS;
58041
58042 nomem_free:
58043 kfree(op);
58044 nomem:
58045 - fscache_stat(&fscache_n_stores_oom);
58046 + fscache_stat_unchecked(&fscache_n_stores_oom);
58047 _leave(" = -ENOMEM");
58048 return -ENOMEM;
58049 }
58050 @@ -1024,7 +1024,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
58051 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
58052 ASSERTCMP(page, !=, NULL);
58053
58054 - fscache_stat(&fscache_n_uncaches);
58055 + fscache_stat_unchecked(&fscache_n_uncaches);
58056
58057 /* cache withdrawal may beat us to it */
58058 if (!PageFsCache(page))
58059 @@ -1075,7 +1075,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
58060 struct fscache_cookie *cookie = op->op.object->cookie;
58061
58062 #ifdef CONFIG_FSCACHE_STATS
58063 - atomic_inc(&fscache_n_marks);
58064 + atomic_inc_unchecked(&fscache_n_marks);
58065 #endif
58066
58067 _debug("- mark %p{%lx}", page, page->index);
58068 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
58069 index 40d13c7..ddf52b9 100644
58070 --- a/fs/fscache/stats.c
58071 +++ b/fs/fscache/stats.c
58072 @@ -18,99 +18,99 @@
58073 /*
58074 * operation counters
58075 */
58076 -atomic_t fscache_n_op_pend;
58077 -atomic_t fscache_n_op_run;
58078 -atomic_t fscache_n_op_enqueue;
58079 -atomic_t fscache_n_op_requeue;
58080 -atomic_t fscache_n_op_deferred_release;
58081 -atomic_t fscache_n_op_release;
58082 -atomic_t fscache_n_op_gc;
58083 -atomic_t fscache_n_op_cancelled;
58084 -atomic_t fscache_n_op_rejected;
58085 +atomic_unchecked_t fscache_n_op_pend;
58086 +atomic_unchecked_t fscache_n_op_run;
58087 +atomic_unchecked_t fscache_n_op_enqueue;
58088 +atomic_unchecked_t fscache_n_op_requeue;
58089 +atomic_unchecked_t fscache_n_op_deferred_release;
58090 +atomic_unchecked_t fscache_n_op_release;
58091 +atomic_unchecked_t fscache_n_op_gc;
58092 +atomic_unchecked_t fscache_n_op_cancelled;
58093 +atomic_unchecked_t fscache_n_op_rejected;
58094
58095 -atomic_t fscache_n_attr_changed;
58096 -atomic_t fscache_n_attr_changed_ok;
58097 -atomic_t fscache_n_attr_changed_nobufs;
58098 -atomic_t fscache_n_attr_changed_nomem;
58099 -atomic_t fscache_n_attr_changed_calls;
58100 +atomic_unchecked_t fscache_n_attr_changed;
58101 +atomic_unchecked_t fscache_n_attr_changed_ok;
58102 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
58103 +atomic_unchecked_t fscache_n_attr_changed_nomem;
58104 +atomic_unchecked_t fscache_n_attr_changed_calls;
58105
58106 -atomic_t fscache_n_allocs;
58107 -atomic_t fscache_n_allocs_ok;
58108 -atomic_t fscache_n_allocs_wait;
58109 -atomic_t fscache_n_allocs_nobufs;
58110 -atomic_t fscache_n_allocs_intr;
58111 -atomic_t fscache_n_allocs_object_dead;
58112 -atomic_t fscache_n_alloc_ops;
58113 -atomic_t fscache_n_alloc_op_waits;
58114 +atomic_unchecked_t fscache_n_allocs;
58115 +atomic_unchecked_t fscache_n_allocs_ok;
58116 +atomic_unchecked_t fscache_n_allocs_wait;
58117 +atomic_unchecked_t fscache_n_allocs_nobufs;
58118 +atomic_unchecked_t fscache_n_allocs_intr;
58119 +atomic_unchecked_t fscache_n_allocs_object_dead;
58120 +atomic_unchecked_t fscache_n_alloc_ops;
58121 +atomic_unchecked_t fscache_n_alloc_op_waits;
58122
58123 -atomic_t fscache_n_retrievals;
58124 -atomic_t fscache_n_retrievals_ok;
58125 -atomic_t fscache_n_retrievals_wait;
58126 -atomic_t fscache_n_retrievals_nodata;
58127 -atomic_t fscache_n_retrievals_nobufs;
58128 -atomic_t fscache_n_retrievals_intr;
58129 -atomic_t fscache_n_retrievals_nomem;
58130 -atomic_t fscache_n_retrievals_object_dead;
58131 -atomic_t fscache_n_retrieval_ops;
58132 -atomic_t fscache_n_retrieval_op_waits;
58133 +atomic_unchecked_t fscache_n_retrievals;
58134 +atomic_unchecked_t fscache_n_retrievals_ok;
58135 +atomic_unchecked_t fscache_n_retrievals_wait;
58136 +atomic_unchecked_t fscache_n_retrievals_nodata;
58137 +atomic_unchecked_t fscache_n_retrievals_nobufs;
58138 +atomic_unchecked_t fscache_n_retrievals_intr;
58139 +atomic_unchecked_t fscache_n_retrievals_nomem;
58140 +atomic_unchecked_t fscache_n_retrievals_object_dead;
58141 +atomic_unchecked_t fscache_n_retrieval_ops;
58142 +atomic_unchecked_t fscache_n_retrieval_op_waits;
58143
58144 -atomic_t fscache_n_stores;
58145 -atomic_t fscache_n_stores_ok;
58146 -atomic_t fscache_n_stores_again;
58147 -atomic_t fscache_n_stores_nobufs;
58148 -atomic_t fscache_n_stores_oom;
58149 -atomic_t fscache_n_store_ops;
58150 -atomic_t fscache_n_store_calls;
58151 -atomic_t fscache_n_store_pages;
58152 -atomic_t fscache_n_store_radix_deletes;
58153 -atomic_t fscache_n_store_pages_over_limit;
58154 +atomic_unchecked_t fscache_n_stores;
58155 +atomic_unchecked_t fscache_n_stores_ok;
58156 +atomic_unchecked_t fscache_n_stores_again;
58157 +atomic_unchecked_t fscache_n_stores_nobufs;
58158 +atomic_unchecked_t fscache_n_stores_oom;
58159 +atomic_unchecked_t fscache_n_store_ops;
58160 +atomic_unchecked_t fscache_n_store_calls;
58161 +atomic_unchecked_t fscache_n_store_pages;
58162 +atomic_unchecked_t fscache_n_store_radix_deletes;
58163 +atomic_unchecked_t fscache_n_store_pages_over_limit;
58164
58165 -atomic_t fscache_n_store_vmscan_not_storing;
58166 -atomic_t fscache_n_store_vmscan_gone;
58167 -atomic_t fscache_n_store_vmscan_busy;
58168 -atomic_t fscache_n_store_vmscan_cancelled;
58169 -atomic_t fscache_n_store_vmscan_wait;
58170 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
58171 +atomic_unchecked_t fscache_n_store_vmscan_gone;
58172 +atomic_unchecked_t fscache_n_store_vmscan_busy;
58173 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
58174 +atomic_unchecked_t fscache_n_store_vmscan_wait;
58175
58176 -atomic_t fscache_n_marks;
58177 -atomic_t fscache_n_uncaches;
58178 +atomic_unchecked_t fscache_n_marks;
58179 +atomic_unchecked_t fscache_n_uncaches;
58180
58181 -atomic_t fscache_n_acquires;
58182 -atomic_t fscache_n_acquires_null;
58183 -atomic_t fscache_n_acquires_no_cache;
58184 -atomic_t fscache_n_acquires_ok;
58185 -atomic_t fscache_n_acquires_nobufs;
58186 -atomic_t fscache_n_acquires_oom;
58187 +atomic_unchecked_t fscache_n_acquires;
58188 +atomic_unchecked_t fscache_n_acquires_null;
58189 +atomic_unchecked_t fscache_n_acquires_no_cache;
58190 +atomic_unchecked_t fscache_n_acquires_ok;
58191 +atomic_unchecked_t fscache_n_acquires_nobufs;
58192 +atomic_unchecked_t fscache_n_acquires_oom;
58193
58194 -atomic_t fscache_n_invalidates;
58195 -atomic_t fscache_n_invalidates_run;
58196 +atomic_unchecked_t fscache_n_invalidates;
58197 +atomic_unchecked_t fscache_n_invalidates_run;
58198
58199 -atomic_t fscache_n_updates;
58200 -atomic_t fscache_n_updates_null;
58201 -atomic_t fscache_n_updates_run;
58202 +atomic_unchecked_t fscache_n_updates;
58203 +atomic_unchecked_t fscache_n_updates_null;
58204 +atomic_unchecked_t fscache_n_updates_run;
58205
58206 -atomic_t fscache_n_relinquishes;
58207 -atomic_t fscache_n_relinquishes_null;
58208 -atomic_t fscache_n_relinquishes_waitcrt;
58209 -atomic_t fscache_n_relinquishes_retire;
58210 +atomic_unchecked_t fscache_n_relinquishes;
58211 +atomic_unchecked_t fscache_n_relinquishes_null;
58212 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
58213 +atomic_unchecked_t fscache_n_relinquishes_retire;
58214
58215 -atomic_t fscache_n_cookie_index;
58216 -atomic_t fscache_n_cookie_data;
58217 -atomic_t fscache_n_cookie_special;
58218 +atomic_unchecked_t fscache_n_cookie_index;
58219 +atomic_unchecked_t fscache_n_cookie_data;
58220 +atomic_unchecked_t fscache_n_cookie_special;
58221
58222 -atomic_t fscache_n_object_alloc;
58223 -atomic_t fscache_n_object_no_alloc;
58224 -atomic_t fscache_n_object_lookups;
58225 -atomic_t fscache_n_object_lookups_negative;
58226 -atomic_t fscache_n_object_lookups_positive;
58227 -atomic_t fscache_n_object_lookups_timed_out;
58228 -atomic_t fscache_n_object_created;
58229 -atomic_t fscache_n_object_avail;
58230 -atomic_t fscache_n_object_dead;
58231 +atomic_unchecked_t fscache_n_object_alloc;
58232 +atomic_unchecked_t fscache_n_object_no_alloc;
58233 +atomic_unchecked_t fscache_n_object_lookups;
58234 +atomic_unchecked_t fscache_n_object_lookups_negative;
58235 +atomic_unchecked_t fscache_n_object_lookups_positive;
58236 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
58237 +atomic_unchecked_t fscache_n_object_created;
58238 +atomic_unchecked_t fscache_n_object_avail;
58239 +atomic_unchecked_t fscache_n_object_dead;
58240
58241 -atomic_t fscache_n_checkaux_none;
58242 -atomic_t fscache_n_checkaux_okay;
58243 -atomic_t fscache_n_checkaux_update;
58244 -atomic_t fscache_n_checkaux_obsolete;
58245 +atomic_unchecked_t fscache_n_checkaux_none;
58246 +atomic_unchecked_t fscache_n_checkaux_okay;
58247 +atomic_unchecked_t fscache_n_checkaux_update;
58248 +atomic_unchecked_t fscache_n_checkaux_obsolete;
58249
58250 atomic_t fscache_n_cop_alloc_object;
58251 atomic_t fscache_n_cop_lookup_object;
58252 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
58253 seq_puts(m, "FS-Cache statistics\n");
58254
58255 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
58256 - atomic_read(&fscache_n_cookie_index),
58257 - atomic_read(&fscache_n_cookie_data),
58258 - atomic_read(&fscache_n_cookie_special));
58259 + atomic_read_unchecked(&fscache_n_cookie_index),
58260 + atomic_read_unchecked(&fscache_n_cookie_data),
58261 + atomic_read_unchecked(&fscache_n_cookie_special));
58262
58263 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
58264 - atomic_read(&fscache_n_object_alloc),
58265 - atomic_read(&fscache_n_object_no_alloc),
58266 - atomic_read(&fscache_n_object_avail),
58267 - atomic_read(&fscache_n_object_dead));
58268 + atomic_read_unchecked(&fscache_n_object_alloc),
58269 + atomic_read_unchecked(&fscache_n_object_no_alloc),
58270 + atomic_read_unchecked(&fscache_n_object_avail),
58271 + atomic_read_unchecked(&fscache_n_object_dead));
58272 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
58273 - atomic_read(&fscache_n_checkaux_none),
58274 - atomic_read(&fscache_n_checkaux_okay),
58275 - atomic_read(&fscache_n_checkaux_update),
58276 - atomic_read(&fscache_n_checkaux_obsolete));
58277 + atomic_read_unchecked(&fscache_n_checkaux_none),
58278 + atomic_read_unchecked(&fscache_n_checkaux_okay),
58279 + atomic_read_unchecked(&fscache_n_checkaux_update),
58280 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
58281
58282 seq_printf(m, "Pages : mrk=%u unc=%u\n",
58283 - atomic_read(&fscache_n_marks),
58284 - atomic_read(&fscache_n_uncaches));
58285 + atomic_read_unchecked(&fscache_n_marks),
58286 + atomic_read_unchecked(&fscache_n_uncaches));
58287
58288 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
58289 " oom=%u\n",
58290 - atomic_read(&fscache_n_acquires),
58291 - atomic_read(&fscache_n_acquires_null),
58292 - atomic_read(&fscache_n_acquires_no_cache),
58293 - atomic_read(&fscache_n_acquires_ok),
58294 - atomic_read(&fscache_n_acquires_nobufs),
58295 - atomic_read(&fscache_n_acquires_oom));
58296 + atomic_read_unchecked(&fscache_n_acquires),
58297 + atomic_read_unchecked(&fscache_n_acquires_null),
58298 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
58299 + atomic_read_unchecked(&fscache_n_acquires_ok),
58300 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
58301 + atomic_read_unchecked(&fscache_n_acquires_oom));
58302
58303 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
58304 - atomic_read(&fscache_n_object_lookups),
58305 - atomic_read(&fscache_n_object_lookups_negative),
58306 - atomic_read(&fscache_n_object_lookups_positive),
58307 - atomic_read(&fscache_n_object_created),
58308 - atomic_read(&fscache_n_object_lookups_timed_out));
58309 + atomic_read_unchecked(&fscache_n_object_lookups),
58310 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
58311 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
58312 + atomic_read_unchecked(&fscache_n_object_created),
58313 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
58314
58315 seq_printf(m, "Invals : n=%u run=%u\n",
58316 - atomic_read(&fscache_n_invalidates),
58317 - atomic_read(&fscache_n_invalidates_run));
58318 + atomic_read_unchecked(&fscache_n_invalidates),
58319 + atomic_read_unchecked(&fscache_n_invalidates_run));
58320
58321 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
58322 - atomic_read(&fscache_n_updates),
58323 - atomic_read(&fscache_n_updates_null),
58324 - atomic_read(&fscache_n_updates_run));
58325 + atomic_read_unchecked(&fscache_n_updates),
58326 + atomic_read_unchecked(&fscache_n_updates_null),
58327 + atomic_read_unchecked(&fscache_n_updates_run));
58328
58329 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
58330 - atomic_read(&fscache_n_relinquishes),
58331 - atomic_read(&fscache_n_relinquishes_null),
58332 - atomic_read(&fscache_n_relinquishes_waitcrt),
58333 - atomic_read(&fscache_n_relinquishes_retire));
58334 + atomic_read_unchecked(&fscache_n_relinquishes),
58335 + atomic_read_unchecked(&fscache_n_relinquishes_null),
58336 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
58337 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
58338
58339 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
58340 - atomic_read(&fscache_n_attr_changed),
58341 - atomic_read(&fscache_n_attr_changed_ok),
58342 - atomic_read(&fscache_n_attr_changed_nobufs),
58343 - atomic_read(&fscache_n_attr_changed_nomem),
58344 - atomic_read(&fscache_n_attr_changed_calls));
58345 + atomic_read_unchecked(&fscache_n_attr_changed),
58346 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
58347 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
58348 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
58349 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
58350
58351 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
58352 - atomic_read(&fscache_n_allocs),
58353 - atomic_read(&fscache_n_allocs_ok),
58354 - atomic_read(&fscache_n_allocs_wait),
58355 - atomic_read(&fscache_n_allocs_nobufs),
58356 - atomic_read(&fscache_n_allocs_intr));
58357 + atomic_read_unchecked(&fscache_n_allocs),
58358 + atomic_read_unchecked(&fscache_n_allocs_ok),
58359 + atomic_read_unchecked(&fscache_n_allocs_wait),
58360 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
58361 + atomic_read_unchecked(&fscache_n_allocs_intr));
58362 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
58363 - atomic_read(&fscache_n_alloc_ops),
58364 - atomic_read(&fscache_n_alloc_op_waits),
58365 - atomic_read(&fscache_n_allocs_object_dead));
58366 + atomic_read_unchecked(&fscache_n_alloc_ops),
58367 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
58368 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
58369
58370 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
58371 " int=%u oom=%u\n",
58372 - atomic_read(&fscache_n_retrievals),
58373 - atomic_read(&fscache_n_retrievals_ok),
58374 - atomic_read(&fscache_n_retrievals_wait),
58375 - atomic_read(&fscache_n_retrievals_nodata),
58376 - atomic_read(&fscache_n_retrievals_nobufs),
58377 - atomic_read(&fscache_n_retrievals_intr),
58378 - atomic_read(&fscache_n_retrievals_nomem));
58379 + atomic_read_unchecked(&fscache_n_retrievals),
58380 + atomic_read_unchecked(&fscache_n_retrievals_ok),
58381 + atomic_read_unchecked(&fscache_n_retrievals_wait),
58382 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
58383 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
58384 + atomic_read_unchecked(&fscache_n_retrievals_intr),
58385 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
58386 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
58387 - atomic_read(&fscache_n_retrieval_ops),
58388 - atomic_read(&fscache_n_retrieval_op_waits),
58389 - atomic_read(&fscache_n_retrievals_object_dead));
58390 + atomic_read_unchecked(&fscache_n_retrieval_ops),
58391 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
58392 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
58393
58394 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
58395 - atomic_read(&fscache_n_stores),
58396 - atomic_read(&fscache_n_stores_ok),
58397 - atomic_read(&fscache_n_stores_again),
58398 - atomic_read(&fscache_n_stores_nobufs),
58399 - atomic_read(&fscache_n_stores_oom));
58400 + atomic_read_unchecked(&fscache_n_stores),
58401 + atomic_read_unchecked(&fscache_n_stores_ok),
58402 + atomic_read_unchecked(&fscache_n_stores_again),
58403 + atomic_read_unchecked(&fscache_n_stores_nobufs),
58404 + atomic_read_unchecked(&fscache_n_stores_oom));
58405 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
58406 - atomic_read(&fscache_n_store_ops),
58407 - atomic_read(&fscache_n_store_calls),
58408 - atomic_read(&fscache_n_store_pages),
58409 - atomic_read(&fscache_n_store_radix_deletes),
58410 - atomic_read(&fscache_n_store_pages_over_limit));
58411 + atomic_read_unchecked(&fscache_n_store_ops),
58412 + atomic_read_unchecked(&fscache_n_store_calls),
58413 + atomic_read_unchecked(&fscache_n_store_pages),
58414 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
58415 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
58416
58417 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
58418 - atomic_read(&fscache_n_store_vmscan_not_storing),
58419 - atomic_read(&fscache_n_store_vmscan_gone),
58420 - atomic_read(&fscache_n_store_vmscan_busy),
58421 - atomic_read(&fscache_n_store_vmscan_cancelled),
58422 - atomic_read(&fscache_n_store_vmscan_wait));
58423 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
58424 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
58425 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
58426 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
58427 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
58428
58429 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
58430 - atomic_read(&fscache_n_op_pend),
58431 - atomic_read(&fscache_n_op_run),
58432 - atomic_read(&fscache_n_op_enqueue),
58433 - atomic_read(&fscache_n_op_cancelled),
58434 - atomic_read(&fscache_n_op_rejected));
58435 + atomic_read_unchecked(&fscache_n_op_pend),
58436 + atomic_read_unchecked(&fscache_n_op_run),
58437 + atomic_read_unchecked(&fscache_n_op_enqueue),
58438 + atomic_read_unchecked(&fscache_n_op_cancelled),
58439 + atomic_read_unchecked(&fscache_n_op_rejected));
58440 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
58441 - atomic_read(&fscache_n_op_deferred_release),
58442 - atomic_read(&fscache_n_op_release),
58443 - atomic_read(&fscache_n_op_gc));
58444 + atomic_read_unchecked(&fscache_n_op_deferred_release),
58445 + atomic_read_unchecked(&fscache_n_op_release),
58446 + atomic_read_unchecked(&fscache_n_op_gc));
58447
58448 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
58449 atomic_read(&fscache_n_cop_alloc_object),
58450 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
58451 index adbfd66..4b25822 100644
58452 --- a/fs/fuse/cuse.c
58453 +++ b/fs/fuse/cuse.c
58454 @@ -603,10 +603,12 @@ static int __init cuse_init(void)
58455 INIT_LIST_HEAD(&cuse_conntbl[i]);
58456
58457 /* inherit and extend fuse_dev_operations */
58458 - cuse_channel_fops = fuse_dev_operations;
58459 - cuse_channel_fops.owner = THIS_MODULE;
58460 - cuse_channel_fops.open = cuse_channel_open;
58461 - cuse_channel_fops.release = cuse_channel_release;
58462 + pax_open_kernel();
58463 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
58464 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
58465 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
58466 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
58467 + pax_close_kernel();
58468
58469 cuse_class = class_create(THIS_MODULE, "cuse");
58470 if (IS_ERR(cuse_class))
58471 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
58472 index ef74ad5..c9ac759e 100644
58473 --- a/fs/fuse/dev.c
58474 +++ b/fs/fuse/dev.c
58475 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
58476 ret = 0;
58477 pipe_lock(pipe);
58478
58479 - if (!pipe->readers) {
58480 + if (!atomic_read(&pipe->readers)) {
58481 send_sig(SIGPIPE, current, 0);
58482 if (!ret)
58483 ret = -EPIPE;
58484 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
58485 page_nr++;
58486 ret += buf->len;
58487
58488 - if (pipe->files)
58489 + if (atomic_read(&pipe->files))
58490 do_wakeup = 1;
58491 }
58492
58493 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
58494 index b7989f2..1f72ec4 100644
58495 --- a/fs/fuse/dir.c
58496 +++ b/fs/fuse/dir.c
58497 @@ -1438,7 +1438,7 @@ static char *read_link(struct dentry *dentry)
58498 return link;
58499 }
58500
58501 -static void free_link(char *link)
58502 +static void free_link(const char *link)
58503 {
58504 if (!IS_ERR(link))
58505 free_page((unsigned long) link);
58506 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
58507 index 1298766..c964c60 100644
58508 --- a/fs/gfs2/inode.c
58509 +++ b/fs/gfs2/inode.c
58510 @@ -1515,7 +1515,7 @@ out:
58511
58512 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
58513 {
58514 - char *s = nd_get_link(nd);
58515 + const char *s = nd_get_link(nd);
58516 if (!IS_ERR(s))
58517 kfree(s);
58518 }
58519 diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
58520 index 2543728..14d7bd4 100644
58521 --- a/fs/hostfs/hostfs_kern.c
58522 +++ b/fs/hostfs/hostfs_kern.c
58523 @@ -904,7 +904,7 @@ static void *hostfs_follow_link(struct dentry *dentry, struct nameidata *nd)
58524
58525 static void hostfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
58526 {
58527 - char *s = nd_get_link(nd);
58528 + const char *s = nd_get_link(nd);
58529 if (!IS_ERR(s))
58530 __putname(s);
58531 }
58532 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
58533 index d19b30a..ef89c36 100644
58534 --- a/fs/hugetlbfs/inode.c
58535 +++ b/fs/hugetlbfs/inode.c
58536 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
58537 struct mm_struct *mm = current->mm;
58538 struct vm_area_struct *vma;
58539 struct hstate *h = hstate_file(file);
58540 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
58541 struct vm_unmapped_area_info info;
58542
58543 if (len & ~huge_page_mask(h))
58544 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
58545 return addr;
58546 }
58547
58548 +#ifdef CONFIG_PAX_RANDMMAP
58549 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
58550 +#endif
58551 +
58552 if (addr) {
58553 addr = ALIGN(addr, huge_page_size(h));
58554 vma = find_vma(mm, addr);
58555 - if (TASK_SIZE - len >= addr &&
58556 - (!vma || addr + len <= vma->vm_start))
58557 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
58558 return addr;
58559 }
58560
58561 info.flags = 0;
58562 info.length = len;
58563 info.low_limit = TASK_UNMAPPED_BASE;
58564 +
58565 +#ifdef CONFIG_PAX_RANDMMAP
58566 + if (mm->pax_flags & MF_PAX_RANDMMAP)
58567 + info.low_limit += mm->delta_mmap;
58568 +#endif
58569 +
58570 info.high_limit = TASK_SIZE;
58571 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
58572 info.align_offset = 0;
58573 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
58574 };
58575 MODULE_ALIAS_FS("hugetlbfs");
58576
58577 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58578 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58579
58580 static int can_do_hugetlb_shm(void)
58581 {
58582 diff --git a/fs/inode.c b/fs/inode.c
58583 index b33ba8e..3c79a47 100644
58584 --- a/fs/inode.c
58585 +++ b/fs/inode.c
58586 @@ -849,8 +849,8 @@ unsigned int get_next_ino(void)
58587
58588 #ifdef CONFIG_SMP
58589 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
58590 - static atomic_t shared_last_ino;
58591 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
58592 + static atomic_unchecked_t shared_last_ino;
58593 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
58594
58595 res = next - LAST_INO_BATCH;
58596 }
58597 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
58598 index 4a6cf28..d3a29d3 100644
58599 --- a/fs/jffs2/erase.c
58600 +++ b/fs/jffs2/erase.c
58601 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
58602 struct jffs2_unknown_node marker = {
58603 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
58604 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
58605 - .totlen = cpu_to_je32(c->cleanmarker_size)
58606 + .totlen = cpu_to_je32(c->cleanmarker_size),
58607 + .hdr_crc = cpu_to_je32(0)
58608 };
58609
58610 jffs2_prealloc_raw_node_refs(c, jeb, 1);
58611 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
58612 index a6597d6..41b30ec 100644
58613 --- a/fs/jffs2/wbuf.c
58614 +++ b/fs/jffs2/wbuf.c
58615 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
58616 {
58617 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
58618 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
58619 - .totlen = constant_cpu_to_je32(8)
58620 + .totlen = constant_cpu_to_je32(8),
58621 + .hdr_crc = constant_cpu_to_je32(0)
58622 };
58623
58624 /*
58625 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
58626 index 6669aa2..36b033d 100644
58627 --- a/fs/jfs/super.c
58628 +++ b/fs/jfs/super.c
58629 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
58630
58631 jfs_inode_cachep =
58632 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
58633 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
58634 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
58635 init_once);
58636 if (jfs_inode_cachep == NULL)
58637 return -ENOMEM;
58638 diff --git a/fs/libfs.c b/fs/libfs.c
58639 index 193e0c2..7404665 100644
58640 --- a/fs/libfs.c
58641 +++ b/fs/libfs.c
58642 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
58643
58644 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
58645 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
58646 + char d_name[sizeof(next->d_iname)];
58647 + const unsigned char *name;
58648 +
58649 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
58650 if (!simple_positive(next)) {
58651 spin_unlock(&next->d_lock);
58652 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
58653
58654 spin_unlock(&next->d_lock);
58655 spin_unlock(&dentry->d_lock);
58656 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
58657 + name = next->d_name.name;
58658 + if (name == next->d_iname) {
58659 + memcpy(d_name, name, next->d_name.len);
58660 + name = d_name;
58661 + }
58662 + if (!dir_emit(ctx, name, next->d_name.len,
58663 next->d_inode->i_ino, dt_type(next->d_inode)))
58664 return 0;
58665 spin_lock(&dentry->d_lock);
58666 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
58667 index acd3947..1f896e2 100644
58668 --- a/fs/lockd/clntproc.c
58669 +++ b/fs/lockd/clntproc.c
58670 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
58671 /*
58672 * Cookie counter for NLM requests
58673 */
58674 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
58675 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
58676
58677 void nlmclnt_next_cookie(struct nlm_cookie *c)
58678 {
58679 - u32 cookie = atomic_inc_return(&nlm_cookie);
58680 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
58681
58682 memcpy(c->data, &cookie, 4);
58683 c->len=4;
58684 diff --git a/fs/locks.c b/fs/locks.c
58685 index b27a300..4156d0b 100644
58686 --- a/fs/locks.c
58687 +++ b/fs/locks.c
58688 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
58689 return;
58690
58691 if (filp->f_op && filp->f_op->flock) {
58692 - struct file_lock fl = {
58693 + struct file_lock flock = {
58694 .fl_pid = current->tgid,
58695 .fl_file = filp,
58696 .fl_flags = FL_FLOCK,
58697 .fl_type = F_UNLCK,
58698 .fl_end = OFFSET_MAX,
58699 };
58700 - filp->f_op->flock(filp, F_SETLKW, &fl);
58701 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
58702 - fl.fl_ops->fl_release_private(&fl);
58703 + filp->f_op->flock(filp, F_SETLKW, &flock);
58704 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
58705 + flock.fl_ops->fl_release_private(&flock);
58706 }
58707
58708 spin_lock(&inode->i_lock);
58709 diff --git a/fs/namei.c b/fs/namei.c
58710 index 23ac50f..c6757a5 100644
58711 --- a/fs/namei.c
58712 +++ b/fs/namei.c
58713 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
58714 if (ret != -EACCES)
58715 return ret;
58716
58717 +#ifdef CONFIG_GRKERNSEC
58718 + /* we'll block if we have to log due to a denied capability use */
58719 + if (mask & MAY_NOT_BLOCK)
58720 + return -ECHILD;
58721 +#endif
58722 +
58723 if (S_ISDIR(inode->i_mode)) {
58724 /* DACs are overridable for directories */
58725 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
58726 - return 0;
58727 if (!(mask & MAY_WRITE))
58728 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
58729 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
58730 + inode_capable(inode, CAP_DAC_READ_SEARCH))
58731 return 0;
58732 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
58733 + return 0;
58734 return -EACCES;
58735 }
58736 /*
58737 + * Searching includes executable on directories, else just read.
58738 + */
58739 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
58740 + if (mask == MAY_READ)
58741 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
58742 + inode_capable(inode, CAP_DAC_READ_SEARCH))
58743 + return 0;
58744 +
58745 + /*
58746 * Read/write DACs are always overridable.
58747 * Executable DACs are overridable when there is
58748 * at least one exec bit set.
58749 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
58750 if (inode_capable(inode, CAP_DAC_OVERRIDE))
58751 return 0;
58752
58753 - /*
58754 - * Searching includes executable on directories, else just read.
58755 - */
58756 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
58757 - if (mask == MAY_READ)
58758 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
58759 - return 0;
58760 -
58761 return -EACCES;
58762 }
58763
58764 @@ -821,7 +829,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
58765 {
58766 struct dentry *dentry = link->dentry;
58767 int error;
58768 - char *s;
58769 + const char *s;
58770
58771 BUG_ON(nd->flags & LOOKUP_RCU);
58772
58773 @@ -842,6 +850,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
58774 if (error)
58775 goto out_put_nd_path;
58776
58777 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
58778 + dentry->d_inode, dentry, nd->path.mnt)) {
58779 + error = -EACCES;
58780 + goto out_put_nd_path;
58781 + }
58782 +
58783 nd->last_type = LAST_BIND;
58784 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
58785 error = PTR_ERR(*p);
58786 @@ -1602,6 +1616,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
58787 if (res)
58788 break;
58789 res = walk_component(nd, path, LOOKUP_FOLLOW);
58790 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
58791 + res = -EACCES;
58792 put_link(nd, &link, cookie);
58793 } while (res > 0);
58794
58795 @@ -1700,7 +1716,7 @@ EXPORT_SYMBOL(full_name_hash);
58796 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
58797 {
58798 unsigned long a, b, adata, bdata, mask, hash, len;
58799 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
58800 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
58801
58802 hash = a = 0;
58803 len = -sizeof(unsigned long);
58804 @@ -1981,6 +1997,8 @@ static int path_lookupat(int dfd, const char *name,
58805 if (err)
58806 break;
58807 err = lookup_last(nd, &path);
58808 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
58809 + err = -EACCES;
58810 put_link(nd, &link, cookie);
58811 }
58812 }
58813 @@ -1988,6 +2006,13 @@ static int path_lookupat(int dfd, const char *name,
58814 if (!err)
58815 err = complete_walk(nd);
58816
58817 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
58818 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58819 + path_put(&nd->path);
58820 + err = -ENOENT;
58821 + }
58822 + }
58823 +
58824 if (!err && nd->flags & LOOKUP_DIRECTORY) {
58825 if (!can_lookup(nd->inode)) {
58826 path_put(&nd->path);
58827 @@ -2015,8 +2040,15 @@ static int filename_lookup(int dfd, struct filename *name,
58828 retval = path_lookupat(dfd, name->name,
58829 flags | LOOKUP_REVAL, nd);
58830
58831 - if (likely(!retval))
58832 + if (likely(!retval)) {
58833 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
58834 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
58835 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
58836 + path_put(&nd->path);
58837 + return -ENOENT;
58838 + }
58839 + }
58840 + }
58841 return retval;
58842 }
58843
58844 @@ -2587,6 +2619,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
58845 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
58846 return -EPERM;
58847
58848 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
58849 + return -EPERM;
58850 + if (gr_handle_rawio(inode))
58851 + return -EPERM;
58852 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
58853 + return -EACCES;
58854 +
58855 return 0;
58856 }
58857
58858 @@ -2818,7 +2857,7 @@ looked_up:
58859 * cleared otherwise prior to returning.
58860 */
58861 static int lookup_open(struct nameidata *nd, struct path *path,
58862 - struct file *file,
58863 + struct path *link, struct file *file,
58864 const struct open_flags *op,
58865 bool got_write, int *opened)
58866 {
58867 @@ -2853,6 +2892,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58868 /* Negative dentry, just create the file */
58869 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
58870 umode_t mode = op->mode;
58871 +
58872 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
58873 + error = -EACCES;
58874 + goto out_dput;
58875 + }
58876 +
58877 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
58878 + error = -EACCES;
58879 + goto out_dput;
58880 + }
58881 +
58882 if (!IS_POSIXACL(dir->d_inode))
58883 mode &= ~current_umask();
58884 /*
58885 @@ -2874,6 +2924,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58886 nd->flags & LOOKUP_EXCL);
58887 if (error)
58888 goto out_dput;
58889 + else
58890 + gr_handle_create(dentry, nd->path.mnt);
58891 }
58892 out_no_open:
58893 path->dentry = dentry;
58894 @@ -2888,7 +2940,7 @@ out_dput:
58895 /*
58896 * Handle the last step of open()
58897 */
58898 -static int do_last(struct nameidata *nd, struct path *path,
58899 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
58900 struct file *file, const struct open_flags *op,
58901 int *opened, struct filename *name)
58902 {
58903 @@ -2938,6 +2990,15 @@ static int do_last(struct nameidata *nd, struct path *path,
58904 if (error)
58905 return error;
58906
58907 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
58908 + error = -ENOENT;
58909 + goto out;
58910 + }
58911 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58912 + error = -EACCES;
58913 + goto out;
58914 + }
58915 +
58916 audit_inode(name, dir, LOOKUP_PARENT);
58917 error = -EISDIR;
58918 /* trailing slashes? */
58919 @@ -2957,7 +3018,7 @@ retry_lookup:
58920 */
58921 }
58922 mutex_lock(&dir->d_inode->i_mutex);
58923 - error = lookup_open(nd, path, file, op, got_write, opened);
58924 + error = lookup_open(nd, path, link, file, op, got_write, opened);
58925 mutex_unlock(&dir->d_inode->i_mutex);
58926
58927 if (error <= 0) {
58928 @@ -2981,11 +3042,28 @@ retry_lookup:
58929 goto finish_open_created;
58930 }
58931
58932 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
58933 + error = -ENOENT;
58934 + goto exit_dput;
58935 + }
58936 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
58937 + error = -EACCES;
58938 + goto exit_dput;
58939 + }
58940 +
58941 /*
58942 * create/update audit record if it already exists.
58943 */
58944 - if (path->dentry->d_inode)
58945 + if (path->dentry->d_inode) {
58946 + /* only check if O_CREAT is specified, all other checks need to go
58947 + into may_open */
58948 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
58949 + error = -EACCES;
58950 + goto exit_dput;
58951 + }
58952 +
58953 audit_inode(name, path->dentry, 0);
58954 + }
58955
58956 /*
58957 * If atomic_open() acquired write access it is dropped now due to
58958 @@ -3026,6 +3104,11 @@ finish_lookup:
58959 }
58960 }
58961 BUG_ON(inode != path->dentry->d_inode);
58962 + /* if we're resolving a symlink to another symlink */
58963 + if (link && gr_handle_symlink_owner(link, inode)) {
58964 + error = -EACCES;
58965 + goto out;
58966 + }
58967 return 1;
58968 }
58969
58970 @@ -3035,7 +3118,6 @@ finish_lookup:
58971 save_parent.dentry = nd->path.dentry;
58972 save_parent.mnt = mntget(path->mnt);
58973 nd->path.dentry = path->dentry;
58974 -
58975 }
58976 nd->inode = inode;
58977 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
58978 @@ -3045,7 +3127,18 @@ finish_open:
58979 path_put(&save_parent);
58980 return error;
58981 }
58982 +
58983 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58984 + error = -ENOENT;
58985 + goto out;
58986 + }
58987 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58988 + error = -EACCES;
58989 + goto out;
58990 + }
58991 +
58992 audit_inode(name, nd->path.dentry, 0);
58993 +
58994 error = -EISDIR;
58995 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
58996 goto out;
58997 @@ -3208,7 +3301,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
58998 if (unlikely(error))
58999 goto out;
59000
59001 - error = do_last(nd, &path, file, op, &opened, pathname);
59002 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
59003 while (unlikely(error > 0)) { /* trailing symlink */
59004 struct path link = path;
59005 void *cookie;
59006 @@ -3226,7 +3319,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
59007 error = follow_link(&link, nd, &cookie);
59008 if (unlikely(error))
59009 break;
59010 - error = do_last(nd, &path, file, op, &opened, pathname);
59011 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
59012 put_link(nd, &link, cookie);
59013 }
59014 out:
59015 @@ -3326,8 +3419,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
59016 goto unlock;
59017
59018 error = -EEXIST;
59019 - if (dentry->d_inode)
59020 + if (dentry->d_inode) {
59021 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
59022 + error = -ENOENT;
59023 + }
59024 goto fail;
59025 + }
59026 /*
59027 * Special case - lookup gave negative, but... we had foo/bar/
59028 * From the vfs_mknod() POV we just have a negative dentry -
59029 @@ -3379,6 +3476,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
59030 }
59031 EXPORT_SYMBOL(user_path_create);
59032
59033 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
59034 +{
59035 + struct filename *tmp = getname(pathname);
59036 + struct dentry *res;
59037 + if (IS_ERR(tmp))
59038 + return ERR_CAST(tmp);
59039 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
59040 + if (IS_ERR(res))
59041 + putname(tmp);
59042 + else
59043 + *to = tmp;
59044 + return res;
59045 +}
59046 +
59047 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
59048 {
59049 int error = may_create(dir, dentry);
59050 @@ -3441,6 +3552,17 @@ retry:
59051
59052 if (!IS_POSIXACL(path.dentry->d_inode))
59053 mode &= ~current_umask();
59054 +
59055 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
59056 + error = -EPERM;
59057 + goto out;
59058 + }
59059 +
59060 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
59061 + error = -EACCES;
59062 + goto out;
59063 + }
59064 +
59065 error = security_path_mknod(&path, dentry, mode, dev);
59066 if (error)
59067 goto out;
59068 @@ -3457,6 +3579,8 @@ retry:
59069 break;
59070 }
59071 out:
59072 + if (!error)
59073 + gr_handle_create(dentry, path.mnt);
59074 done_path_create(&path, dentry);
59075 if (retry_estale(error, lookup_flags)) {
59076 lookup_flags |= LOOKUP_REVAL;
59077 @@ -3509,9 +3633,16 @@ retry:
59078
59079 if (!IS_POSIXACL(path.dentry->d_inode))
59080 mode &= ~current_umask();
59081 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
59082 + error = -EACCES;
59083 + goto out;
59084 + }
59085 error = security_path_mkdir(&path, dentry, mode);
59086 if (!error)
59087 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
59088 + if (!error)
59089 + gr_handle_create(dentry, path.mnt);
59090 +out:
59091 done_path_create(&path, dentry);
59092 if (retry_estale(error, lookup_flags)) {
59093 lookup_flags |= LOOKUP_REVAL;
59094 @@ -3592,6 +3723,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
59095 struct filename *name;
59096 struct dentry *dentry;
59097 struct nameidata nd;
59098 + ino_t saved_ino = 0;
59099 + dev_t saved_dev = 0;
59100 unsigned int lookup_flags = 0;
59101 retry:
59102 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
59103 @@ -3624,10 +3757,21 @@ retry:
59104 error = -ENOENT;
59105 goto exit3;
59106 }
59107 +
59108 + saved_ino = dentry->d_inode->i_ino;
59109 + saved_dev = gr_get_dev_from_dentry(dentry);
59110 +
59111 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
59112 + error = -EACCES;
59113 + goto exit3;
59114 + }
59115 +
59116 error = security_path_rmdir(&nd.path, dentry);
59117 if (error)
59118 goto exit3;
59119 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
59120 + if (!error && (saved_dev || saved_ino))
59121 + gr_handle_delete(saved_ino, saved_dev);
59122 exit3:
59123 dput(dentry);
59124 exit2:
59125 @@ -3693,6 +3837,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
59126 struct dentry *dentry;
59127 struct nameidata nd;
59128 struct inode *inode = NULL;
59129 + ino_t saved_ino = 0;
59130 + dev_t saved_dev = 0;
59131 unsigned int lookup_flags = 0;
59132 retry:
59133 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
59134 @@ -3719,10 +3865,22 @@ retry:
59135 if (!inode)
59136 goto slashes;
59137 ihold(inode);
59138 +
59139 + if (inode->i_nlink <= 1) {
59140 + saved_ino = inode->i_ino;
59141 + saved_dev = gr_get_dev_from_dentry(dentry);
59142 + }
59143 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
59144 + error = -EACCES;
59145 + goto exit2;
59146 + }
59147 +
59148 error = security_path_unlink(&nd.path, dentry);
59149 if (error)
59150 goto exit2;
59151 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
59152 + if (!error && (saved_ino || saved_dev))
59153 + gr_handle_delete(saved_ino, saved_dev);
59154 exit2:
59155 dput(dentry);
59156 }
59157 @@ -3800,9 +3958,17 @@ retry:
59158 if (IS_ERR(dentry))
59159 goto out_putname;
59160
59161 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
59162 + error = -EACCES;
59163 + goto out;
59164 + }
59165 +
59166 error = security_path_symlink(&path, dentry, from->name);
59167 if (!error)
59168 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
59169 + if (!error)
59170 + gr_handle_create(dentry, path.mnt);
59171 +out:
59172 done_path_create(&path, dentry);
59173 if (retry_estale(error, lookup_flags)) {
59174 lookup_flags |= LOOKUP_REVAL;
59175 @@ -3882,6 +4048,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
59176 {
59177 struct dentry *new_dentry;
59178 struct path old_path, new_path;
59179 + struct filename *to = NULL;
59180 int how = 0;
59181 int error;
59182
59183 @@ -3905,7 +4072,7 @@ retry:
59184 if (error)
59185 return error;
59186
59187 - new_dentry = user_path_create(newdfd, newname, &new_path,
59188 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
59189 (how & LOOKUP_REVAL));
59190 error = PTR_ERR(new_dentry);
59191 if (IS_ERR(new_dentry))
59192 @@ -3917,11 +4084,28 @@ retry:
59193 error = may_linkat(&old_path);
59194 if (unlikely(error))
59195 goto out_dput;
59196 +
59197 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
59198 + old_path.dentry->d_inode,
59199 + old_path.dentry->d_inode->i_mode, to)) {
59200 + error = -EACCES;
59201 + goto out_dput;
59202 + }
59203 +
59204 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
59205 + old_path.dentry, old_path.mnt, to)) {
59206 + error = -EACCES;
59207 + goto out_dput;
59208 + }
59209 +
59210 error = security_path_link(old_path.dentry, &new_path, new_dentry);
59211 if (error)
59212 goto out_dput;
59213 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
59214 + if (!error)
59215 + gr_handle_create(new_dentry, new_path.mnt);
59216 out_dput:
59217 + putname(to);
59218 done_path_create(&new_path, new_dentry);
59219 if (retry_estale(error, how)) {
59220 how |= LOOKUP_REVAL;
59221 @@ -4167,12 +4351,21 @@ retry:
59222 if (new_dentry == trap)
59223 goto exit5;
59224
59225 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
59226 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
59227 + to);
59228 + if (error)
59229 + goto exit5;
59230 +
59231 error = security_path_rename(&oldnd.path, old_dentry,
59232 &newnd.path, new_dentry);
59233 if (error)
59234 goto exit5;
59235 error = vfs_rename(old_dir->d_inode, old_dentry,
59236 new_dir->d_inode, new_dentry);
59237 + if (!error)
59238 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
59239 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
59240 exit5:
59241 dput(new_dentry);
59242 exit4:
59243 @@ -4204,6 +4397,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
59244
59245 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
59246 {
59247 + char tmpbuf[64];
59248 + const char *newlink;
59249 int len;
59250
59251 len = PTR_ERR(link);
59252 @@ -4213,7 +4408,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
59253 len = strlen(link);
59254 if (len > (unsigned) buflen)
59255 len = buflen;
59256 - if (copy_to_user(buffer, link, len))
59257 +
59258 + if (len < sizeof(tmpbuf)) {
59259 + memcpy(tmpbuf, link, len);
59260 + newlink = tmpbuf;
59261 + } else
59262 + newlink = link;
59263 +
59264 + if (copy_to_user(buffer, newlink, len))
59265 len = -EFAULT;
59266 out:
59267 return len;
59268 diff --git a/fs/namespace.c b/fs/namespace.c
59269 index da5c494..a755a54 100644
59270 --- a/fs/namespace.c
59271 +++ b/fs/namespace.c
59272 @@ -1268,6 +1268,9 @@ static int do_umount(struct mount *mnt, int flags)
59273 if (!(sb->s_flags & MS_RDONLY))
59274 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
59275 up_write(&sb->s_umount);
59276 +
59277 + gr_log_remount(mnt->mnt_devname, retval);
59278 +
59279 return retval;
59280 }
59281
59282 @@ -1286,6 +1289,9 @@ static int do_umount(struct mount *mnt, int flags)
59283 }
59284 br_write_unlock(&vfsmount_lock);
59285 namespace_unlock();
59286 +
59287 + gr_log_unmount(mnt->mnt_devname, retval);
59288 +
59289 return retval;
59290 }
59291
59292 @@ -1305,7 +1311,7 @@ static inline bool may_mount(void)
59293 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
59294 */
59295
59296 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
59297 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
59298 {
59299 struct path path;
59300 struct mount *mnt;
59301 @@ -1347,7 +1353,7 @@ out:
59302 /*
59303 * The 2.0 compatible umount. No flags.
59304 */
59305 -SYSCALL_DEFINE1(oldumount, char __user *, name)
59306 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
59307 {
59308 return sys_umount(name, 0);
59309 }
59310 @@ -2358,6 +2364,16 @@ long do_mount(const char *dev_name, const char *dir_name,
59311 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
59312 MS_STRICTATIME);
59313
59314 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
59315 + retval = -EPERM;
59316 + goto dput_out;
59317 + }
59318 +
59319 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
59320 + retval = -EPERM;
59321 + goto dput_out;
59322 + }
59323 +
59324 if (flags & MS_REMOUNT)
59325 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
59326 data_page);
59327 @@ -2372,6 +2388,9 @@ long do_mount(const char *dev_name, const char *dir_name,
59328 dev_name, data_page);
59329 dput_out:
59330 path_put(&path);
59331 +
59332 + gr_log_mount(dev_name, dir_name, retval);
59333 +
59334 return retval;
59335 }
59336
59337 @@ -2389,7 +2408,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
59338 * number incrementing at 10Ghz will take 12,427 years to wrap which
59339 * is effectively never, so we can ignore the possibility.
59340 */
59341 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
59342 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
59343
59344 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
59345 {
59346 @@ -2404,7 +2423,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
59347 kfree(new_ns);
59348 return ERR_PTR(ret);
59349 }
59350 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
59351 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
59352 atomic_set(&new_ns->count, 1);
59353 new_ns->root = NULL;
59354 INIT_LIST_HEAD(&new_ns->list);
59355 @@ -2418,7 +2437,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
59356 * Allocate a new namespace structure and populate it with contents
59357 * copied from the namespace of the passed in task structure.
59358 */
59359 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
59360 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
59361 struct user_namespace *user_ns, struct fs_struct *fs)
59362 {
59363 struct mnt_namespace *new_ns;
59364 @@ -2549,8 +2568,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
59365 }
59366 EXPORT_SYMBOL(mount_subtree);
59367
59368 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
59369 - char __user *, type, unsigned long, flags, void __user *, data)
59370 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
59371 + const char __user *, type, unsigned long, flags, void __user *, data)
59372 {
59373 int ret;
59374 char *kernel_type;
59375 @@ -2663,6 +2682,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
59376 if (error)
59377 goto out2;
59378
59379 + if (gr_handle_chroot_pivot()) {
59380 + error = -EPERM;
59381 + goto out2;
59382 + }
59383 +
59384 get_fs_root(current->fs, &root);
59385 old_mp = lock_mount(&old);
59386 error = PTR_ERR(old_mp);
59387 @@ -2932,7 +2956,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
59388 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
59389 return -EPERM;
59390
59391 - if (fs->users != 1)
59392 + if (atomic_read(&fs->users) != 1)
59393 return -EINVAL;
59394
59395 get_mnt_ns(mnt_ns);
59396 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
59397 index f4ccfe6..a5cf064 100644
59398 --- a/fs/nfs/callback_xdr.c
59399 +++ b/fs/nfs/callback_xdr.c
59400 @@ -51,7 +51,7 @@ struct callback_op {
59401 callback_decode_arg_t decode_args;
59402 callback_encode_res_t encode_res;
59403 long res_maxsize;
59404 -};
59405 +} __do_const;
59406
59407 static struct callback_op callback_ops[];
59408
59409 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
59410 index eda8879..bfc6837 100644
59411 --- a/fs/nfs/inode.c
59412 +++ b/fs/nfs/inode.c
59413 @@ -1150,16 +1150,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
59414 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
59415 }
59416
59417 -static atomic_long_t nfs_attr_generation_counter;
59418 +static atomic_long_unchecked_t nfs_attr_generation_counter;
59419
59420 static unsigned long nfs_read_attr_generation_counter(void)
59421 {
59422 - return atomic_long_read(&nfs_attr_generation_counter);
59423 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
59424 }
59425
59426 unsigned long nfs_inc_attr_generation_counter(void)
59427 {
59428 - return atomic_long_inc_return(&nfs_attr_generation_counter);
59429 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
59430 }
59431
59432 void nfs_fattr_init(struct nfs_fattr *fattr)
59433 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
59434 index 419572f..5414a23 100644
59435 --- a/fs/nfsd/nfs4proc.c
59436 +++ b/fs/nfsd/nfs4proc.c
59437 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
59438 nfsd4op_rsize op_rsize_bop;
59439 stateid_getter op_get_currentstateid;
59440 stateid_setter op_set_currentstateid;
59441 -};
59442 +} __do_const;
59443
59444 static struct nfsd4_operation nfsd4_ops[];
59445
59446 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
59447 index ecc735e..79b2d31 100644
59448 --- a/fs/nfsd/nfs4xdr.c
59449 +++ b/fs/nfsd/nfs4xdr.c
59450 @@ -1500,7 +1500,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
59451
59452 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
59453
59454 -static nfsd4_dec nfsd4_dec_ops[] = {
59455 +static const nfsd4_dec nfsd4_dec_ops[] = {
59456 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
59457 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
59458 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
59459 @@ -1540,7 +1540,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
59460 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
59461 };
59462
59463 -static nfsd4_dec nfsd41_dec_ops[] = {
59464 +static const nfsd4_dec nfsd41_dec_ops[] = {
59465 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
59466 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
59467 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
59468 @@ -1602,7 +1602,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
59469 };
59470
59471 struct nfsd4_minorversion_ops {
59472 - nfsd4_dec *decoders;
59473 + const nfsd4_dec *decoders;
59474 int nops;
59475 };
59476
59477 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
59478 index b6af150..f6ec5e3 100644
59479 --- a/fs/nfsd/nfscache.c
59480 +++ b/fs/nfsd/nfscache.c
59481 @@ -547,14 +547,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
59482 {
59483 struct svc_cacherep *rp = rqstp->rq_cacherep;
59484 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
59485 - int len;
59486 + long len;
59487 size_t bufsize = 0;
59488
59489 if (!rp)
59490 return;
59491
59492 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
59493 - len >>= 2;
59494 + if (statp) {
59495 + len = (char*)statp - (char*)resv->iov_base;
59496 + len = resv->iov_len - len;
59497 + len >>= 2;
59498 + }
59499
59500 /* Don't cache excessive amounts of data and XDR failures */
59501 if (!statp || len > (256 >> 2)) {
59502 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
59503 index 72cb28e..5b5f87d 100644
59504 --- a/fs/nfsd/vfs.c
59505 +++ b/fs/nfsd/vfs.c
59506 @@ -993,7 +993,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
59507 } else {
59508 oldfs = get_fs();
59509 set_fs(KERNEL_DS);
59510 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
59511 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
59512 set_fs(oldfs);
59513 }
59514
59515 @@ -1080,7 +1080,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
59516
59517 /* Write the data. */
59518 oldfs = get_fs(); set_fs(KERNEL_DS);
59519 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
59520 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
59521 set_fs(oldfs);
59522 if (host_err < 0)
59523 goto out_nfserr;
59524 @@ -1626,7 +1626,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
59525 */
59526
59527 oldfs = get_fs(); set_fs(KERNEL_DS);
59528 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
59529 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
59530 set_fs(oldfs);
59531
59532 if (host_err < 0)
59533 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
59534 index fea6bd5..8ee9d81 100644
59535 --- a/fs/nls/nls_base.c
59536 +++ b/fs/nls/nls_base.c
59537 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
59538
59539 int register_nls(struct nls_table * nls)
59540 {
59541 - struct nls_table ** tmp = &tables;
59542 + struct nls_table *tmp = tables;
59543
59544 if (nls->next)
59545 return -EBUSY;
59546
59547 spin_lock(&nls_lock);
59548 - while (*tmp) {
59549 - if (nls == *tmp) {
59550 + while (tmp) {
59551 + if (nls == tmp) {
59552 spin_unlock(&nls_lock);
59553 return -EBUSY;
59554 }
59555 - tmp = &(*tmp)->next;
59556 + tmp = tmp->next;
59557 }
59558 - nls->next = tables;
59559 + pax_open_kernel();
59560 + *(struct nls_table **)&nls->next = tables;
59561 + pax_close_kernel();
59562 tables = nls;
59563 spin_unlock(&nls_lock);
59564 return 0;
59565 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
59566
59567 int unregister_nls(struct nls_table * nls)
59568 {
59569 - struct nls_table ** tmp = &tables;
59570 + struct nls_table * const * tmp = &tables;
59571
59572 spin_lock(&nls_lock);
59573 while (*tmp) {
59574 if (nls == *tmp) {
59575 - *tmp = nls->next;
59576 + pax_open_kernel();
59577 + *(struct nls_table **)tmp = nls->next;
59578 + pax_close_kernel();
59579 spin_unlock(&nls_lock);
59580 return 0;
59581 }
59582 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
59583 index 7424929..35f6be5 100644
59584 --- a/fs/nls/nls_euc-jp.c
59585 +++ b/fs/nls/nls_euc-jp.c
59586 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
59587 p_nls = load_nls("cp932");
59588
59589 if (p_nls) {
59590 - table.charset2upper = p_nls->charset2upper;
59591 - table.charset2lower = p_nls->charset2lower;
59592 + pax_open_kernel();
59593 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
59594 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
59595 + pax_close_kernel();
59596 return register_nls(&table);
59597 }
59598
59599 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
59600 index e7bc1d7..06bd4bb 100644
59601 --- a/fs/nls/nls_koi8-ru.c
59602 +++ b/fs/nls/nls_koi8-ru.c
59603 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
59604 p_nls = load_nls("koi8-u");
59605
59606 if (p_nls) {
59607 - table.charset2upper = p_nls->charset2upper;
59608 - table.charset2lower = p_nls->charset2lower;
59609 + pax_open_kernel();
59610 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
59611 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
59612 + pax_close_kernel();
59613 return register_nls(&table);
59614 }
59615
59616 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
59617 index e44cb64..4807084 100644
59618 --- a/fs/notify/fanotify/fanotify_user.c
59619 +++ b/fs/notify/fanotify/fanotify_user.c
59620 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
59621
59622 fd = fanotify_event_metadata.fd;
59623 ret = -EFAULT;
59624 - if (copy_to_user(buf, &fanotify_event_metadata,
59625 - fanotify_event_metadata.event_len))
59626 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
59627 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
59628 goto out_close_fd;
59629
59630 ret = prepare_for_access_response(group, event, fd);
59631 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
59632 index 7b51b05..5ea5ef6 100644
59633 --- a/fs/notify/notification.c
59634 +++ b/fs/notify/notification.c
59635 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
59636 * get set to 0 so it will never get 'freed'
59637 */
59638 static struct fsnotify_event *q_overflow_event;
59639 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59640 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59641
59642 /**
59643 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
59644 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59645 */
59646 u32 fsnotify_get_cookie(void)
59647 {
59648 - return atomic_inc_return(&fsnotify_sync_cookie);
59649 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
59650 }
59651 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
59652
59653 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
59654 index 9e38daf..5727cae 100644
59655 --- a/fs/ntfs/dir.c
59656 +++ b/fs/ntfs/dir.c
59657 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
59658 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
59659 ~(s64)(ndir->itype.index.block_size - 1)));
59660 /* Bounds checks. */
59661 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
59662 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
59663 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
59664 "inode 0x%lx or driver bug.", vdir->i_ino);
59665 goto err_out;
59666 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
59667 index ea4ba9d..1e13d34 100644
59668 --- a/fs/ntfs/file.c
59669 +++ b/fs/ntfs/file.c
59670 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
59671 char *addr;
59672 size_t total = 0;
59673 unsigned len;
59674 - int left;
59675 + unsigned left;
59676
59677 do {
59678 len = PAGE_CACHE_SIZE - ofs;
59679 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
59680 index 82650d5..db37dcf 100644
59681 --- a/fs/ntfs/super.c
59682 +++ b/fs/ntfs/super.c
59683 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59684 if (!silent)
59685 ntfs_error(sb, "Primary boot sector is invalid.");
59686 } else if (!silent)
59687 - ntfs_error(sb, read_err_str, "primary");
59688 + ntfs_error(sb, read_err_str, "%s", "primary");
59689 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
59690 if (bh_primary)
59691 brelse(bh_primary);
59692 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59693 goto hotfix_primary_boot_sector;
59694 brelse(bh_backup);
59695 } else if (!silent)
59696 - ntfs_error(sb, read_err_str, "backup");
59697 + ntfs_error(sb, read_err_str, "%s", "backup");
59698 /* Try to read NT3.51- backup boot sector. */
59699 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
59700 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
59701 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59702 "sector.");
59703 brelse(bh_backup);
59704 } else if (!silent)
59705 - ntfs_error(sb, read_err_str, "backup");
59706 + ntfs_error(sb, read_err_str, "%s", "backup");
59707 /* We failed. Cleanup and return. */
59708 if (bh_primary)
59709 brelse(bh_primary);
59710 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
59711 index cd5496b..26a1055 100644
59712 --- a/fs/ocfs2/localalloc.c
59713 +++ b/fs/ocfs2/localalloc.c
59714 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
59715 goto bail;
59716 }
59717
59718 - atomic_inc(&osb->alloc_stats.moves);
59719 + atomic_inc_unchecked(&osb->alloc_stats.moves);
59720
59721 bail:
59722 if (handle)
59723 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
59724 index 3a90347..c40bef8 100644
59725 --- a/fs/ocfs2/ocfs2.h
59726 +++ b/fs/ocfs2/ocfs2.h
59727 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
59728
59729 struct ocfs2_alloc_stats
59730 {
59731 - atomic_t moves;
59732 - atomic_t local_data;
59733 - atomic_t bitmap_data;
59734 - atomic_t bg_allocs;
59735 - atomic_t bg_extends;
59736 + atomic_unchecked_t moves;
59737 + atomic_unchecked_t local_data;
59738 + atomic_unchecked_t bitmap_data;
59739 + atomic_unchecked_t bg_allocs;
59740 + atomic_unchecked_t bg_extends;
59741 };
59742
59743 enum ocfs2_local_alloc_state
59744 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
59745 index 5397c07..54afc55 100644
59746 --- a/fs/ocfs2/suballoc.c
59747 +++ b/fs/ocfs2/suballoc.c
59748 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
59749 mlog_errno(status);
59750 goto bail;
59751 }
59752 - atomic_inc(&osb->alloc_stats.bg_extends);
59753 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
59754
59755 /* You should never ask for this much metadata */
59756 BUG_ON(bits_wanted >
59757 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
59758 mlog_errno(status);
59759 goto bail;
59760 }
59761 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59762 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59763
59764 *suballoc_loc = res.sr_bg_blkno;
59765 *suballoc_bit_start = res.sr_bit_offset;
59766 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
59767 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
59768 res->sr_bits);
59769
59770 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59771 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59772
59773 BUG_ON(res->sr_bits != 1);
59774
59775 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
59776 mlog_errno(status);
59777 goto bail;
59778 }
59779 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59780 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59781
59782 BUG_ON(res.sr_bits != 1);
59783
59784 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
59785 cluster_start,
59786 num_clusters);
59787 if (!status)
59788 - atomic_inc(&osb->alloc_stats.local_data);
59789 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
59790 } else {
59791 if (min_clusters > (osb->bitmap_cpg - 1)) {
59792 /* The only paths asking for contiguousness
59793 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
59794 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
59795 res.sr_bg_blkno,
59796 res.sr_bit_offset);
59797 - atomic_inc(&osb->alloc_stats.bitmap_data);
59798 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
59799 *num_clusters = res.sr_bits;
59800 }
59801 }
59802 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
59803 index d4e81e4..ad89f5f 100644
59804 --- a/fs/ocfs2/super.c
59805 +++ b/fs/ocfs2/super.c
59806 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
59807 "%10s => GlobalAllocs: %d LocalAllocs: %d "
59808 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
59809 "Stats",
59810 - atomic_read(&osb->alloc_stats.bitmap_data),
59811 - atomic_read(&osb->alloc_stats.local_data),
59812 - atomic_read(&osb->alloc_stats.bg_allocs),
59813 - atomic_read(&osb->alloc_stats.moves),
59814 - atomic_read(&osb->alloc_stats.bg_extends));
59815 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
59816 + atomic_read_unchecked(&osb->alloc_stats.local_data),
59817 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
59818 + atomic_read_unchecked(&osb->alloc_stats.moves),
59819 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
59820
59821 out += snprintf(buf + out, len - out,
59822 "%10s => State: %u Descriptor: %llu Size: %u bits "
59823 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
59824 spin_lock_init(&osb->osb_xattr_lock);
59825 ocfs2_init_steal_slots(osb);
59826
59827 - atomic_set(&osb->alloc_stats.moves, 0);
59828 - atomic_set(&osb->alloc_stats.local_data, 0);
59829 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
59830 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
59831 - atomic_set(&osb->alloc_stats.bg_extends, 0);
59832 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
59833 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
59834 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
59835 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
59836 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
59837
59838 /* Copy the blockcheck stats from the superblock probe */
59839 osb->osb_ecc_stats = *stats;
59840 diff --git a/fs/open.c b/fs/open.c
59841 index d420331..2dbb3fd 100644
59842 --- a/fs/open.c
59843 +++ b/fs/open.c
59844 @@ -32,6 +32,8 @@
59845 #include <linux/dnotify.h>
59846 #include <linux/compat.h>
59847
59848 +#define CREATE_TRACE_POINTS
59849 +#include <trace/events/fs.h>
59850 #include "internal.h"
59851
59852 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
59853 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
59854 error = locks_verify_truncate(inode, NULL, length);
59855 if (!error)
59856 error = security_path_truncate(path);
59857 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
59858 + error = -EACCES;
59859 if (!error)
59860 error = do_truncate(path->dentry, length, 0, NULL);
59861
59862 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
59863 error = locks_verify_truncate(inode, f.file, length);
59864 if (!error)
59865 error = security_path_truncate(&f.file->f_path);
59866 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
59867 + error = -EACCES;
59868 if (!error)
59869 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
59870 sb_end_write(inode->i_sb);
59871 @@ -360,6 +366,9 @@ retry:
59872 if (__mnt_is_readonly(path.mnt))
59873 res = -EROFS;
59874
59875 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
59876 + res = -EACCES;
59877 +
59878 out_path_release:
59879 path_put(&path);
59880 if (retry_estale(res, lookup_flags)) {
59881 @@ -391,6 +400,8 @@ retry:
59882 if (error)
59883 goto dput_and_out;
59884
59885 + gr_log_chdir(path.dentry, path.mnt);
59886 +
59887 set_fs_pwd(current->fs, &path);
59888
59889 dput_and_out:
59890 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
59891 goto out_putf;
59892
59893 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
59894 +
59895 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
59896 + error = -EPERM;
59897 +
59898 + if (!error)
59899 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
59900 +
59901 if (!error)
59902 set_fs_pwd(current->fs, &f.file->f_path);
59903 out_putf:
59904 @@ -449,7 +467,13 @@ retry:
59905 if (error)
59906 goto dput_and_out;
59907
59908 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
59909 + goto dput_and_out;
59910 +
59911 set_fs_root(current->fs, &path);
59912 +
59913 + gr_handle_chroot_chdir(&path);
59914 +
59915 error = 0;
59916 dput_and_out:
59917 path_put(&path);
59918 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
59919 if (error)
59920 return error;
59921 mutex_lock(&inode->i_mutex);
59922 +
59923 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
59924 + error = -EACCES;
59925 + goto out_unlock;
59926 + }
59927 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
59928 + error = -EACCES;
59929 + goto out_unlock;
59930 + }
59931 +
59932 error = security_path_chmod(path, mode);
59933 if (error)
59934 goto out_unlock;
59935 @@ -530,6 +564,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
59936 uid = make_kuid(current_user_ns(), user);
59937 gid = make_kgid(current_user_ns(), group);
59938
59939 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
59940 + return -EACCES;
59941 +
59942 newattrs.ia_valid = ATTR_CTIME;
59943 if (user != (uid_t) -1) {
59944 if (!uid_valid(uid))
59945 @@ -974,6 +1011,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
59946 } else {
59947 fsnotify_open(f);
59948 fd_install(fd, f);
59949 + trace_do_sys_open(tmp->name, flags, mode);
59950 }
59951 }
59952 putname(tmp);
59953 diff --git a/fs/pipe.c b/fs/pipe.c
59954 index 0e0752e..7cfdd50 100644
59955 --- a/fs/pipe.c
59956 +++ b/fs/pipe.c
59957 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
59958
59959 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
59960 {
59961 - if (pipe->files)
59962 + if (atomic_read(&pipe->files))
59963 mutex_lock_nested(&pipe->mutex, subclass);
59964 }
59965
59966 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
59967
59968 void pipe_unlock(struct pipe_inode_info *pipe)
59969 {
59970 - if (pipe->files)
59971 + if (atomic_read(&pipe->files))
59972 mutex_unlock(&pipe->mutex);
59973 }
59974 EXPORT_SYMBOL(pipe_unlock);
59975 @@ -449,9 +449,9 @@ redo:
59976 }
59977 if (bufs) /* More to do? */
59978 continue;
59979 - if (!pipe->writers)
59980 + if (!atomic_read(&pipe->writers))
59981 break;
59982 - if (!pipe->waiting_writers) {
59983 + if (!atomic_read(&pipe->waiting_writers)) {
59984 /* syscall merging: Usually we must not sleep
59985 * if O_NONBLOCK is set, or if we got some data.
59986 * But if a writer sleeps in kernel space, then
59987 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
59988 ret = 0;
59989 __pipe_lock(pipe);
59990
59991 - if (!pipe->readers) {
59992 + if (!atomic_read(&pipe->readers)) {
59993 send_sig(SIGPIPE, current, 0);
59994 ret = -EPIPE;
59995 goto out;
59996 @@ -562,7 +562,7 @@ redo1:
59997 for (;;) {
59998 int bufs;
59999
60000 - if (!pipe->readers) {
60001 + if (!atomic_read(&pipe->readers)) {
60002 send_sig(SIGPIPE, current, 0);
60003 if (!ret)
60004 ret = -EPIPE;
60005 @@ -653,9 +653,9 @@ redo2:
60006 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
60007 do_wakeup = 0;
60008 }
60009 - pipe->waiting_writers++;
60010 + atomic_inc(&pipe->waiting_writers);
60011 pipe_wait(pipe);
60012 - pipe->waiting_writers--;
60013 + atomic_dec(&pipe->waiting_writers);
60014 }
60015 out:
60016 __pipe_unlock(pipe);
60017 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
60018 mask = 0;
60019 if (filp->f_mode & FMODE_READ) {
60020 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
60021 - if (!pipe->writers && filp->f_version != pipe->w_counter)
60022 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
60023 mask |= POLLHUP;
60024 }
60025
60026 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
60027 * Most Unices do not set POLLERR for FIFOs but on Linux they
60028 * behave exactly like pipes for poll().
60029 */
60030 - if (!pipe->readers)
60031 + if (!atomic_read(&pipe->readers))
60032 mask |= POLLERR;
60033 }
60034
60035 @@ -731,7 +731,7 @@ static void put_pipe_info(struct inode *inode, struct pipe_inode_info *pipe)
60036 int kill = 0;
60037
60038 spin_lock(&inode->i_lock);
60039 - if (!--pipe->files) {
60040 + if (atomic_dec_and_test(&pipe->files)) {
60041 inode->i_pipe = NULL;
60042 kill = 1;
60043 }
60044 @@ -748,11 +748,11 @@ pipe_release(struct inode *inode, struct file *file)
60045
60046 __pipe_lock(pipe);
60047 if (file->f_mode & FMODE_READ)
60048 - pipe->readers--;
60049 + atomic_dec(&pipe->readers);
60050 if (file->f_mode & FMODE_WRITE)
60051 - pipe->writers--;
60052 + atomic_dec(&pipe->writers);
60053
60054 - if (pipe->readers || pipe->writers) {
60055 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
60056 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
60057 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
60058 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
60059 @@ -817,7 +817,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
60060 kfree(pipe);
60061 }
60062
60063 -static struct vfsmount *pipe_mnt __read_mostly;
60064 +struct vfsmount *pipe_mnt __read_mostly;
60065
60066 /*
60067 * pipefs_dname() is called from d_path().
60068 @@ -847,8 +847,9 @@ static struct inode * get_pipe_inode(void)
60069 goto fail_iput;
60070
60071 inode->i_pipe = pipe;
60072 - pipe->files = 2;
60073 - pipe->readers = pipe->writers = 1;
60074 + atomic_set(&pipe->files, 2);
60075 + atomic_set(&pipe->readers, 1);
60076 + atomic_set(&pipe->writers, 1);
60077 inode->i_fop = &pipefifo_fops;
60078
60079 /*
60080 @@ -1027,17 +1028,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
60081 spin_lock(&inode->i_lock);
60082 if (inode->i_pipe) {
60083 pipe = inode->i_pipe;
60084 - pipe->files++;
60085 + atomic_inc(&pipe->files);
60086 spin_unlock(&inode->i_lock);
60087 } else {
60088 spin_unlock(&inode->i_lock);
60089 pipe = alloc_pipe_info();
60090 if (!pipe)
60091 return -ENOMEM;
60092 - pipe->files = 1;
60093 + atomic_set(&pipe->files, 1);
60094 spin_lock(&inode->i_lock);
60095 if (unlikely(inode->i_pipe)) {
60096 - inode->i_pipe->files++;
60097 + atomic_inc(&inode->i_pipe->files);
60098 spin_unlock(&inode->i_lock);
60099 free_pipe_info(pipe);
60100 pipe = inode->i_pipe;
60101 @@ -1062,10 +1063,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
60102 * opened, even when there is no process writing the FIFO.
60103 */
60104 pipe->r_counter++;
60105 - if (pipe->readers++ == 0)
60106 + if (atomic_inc_return(&pipe->readers) == 1)
60107 wake_up_partner(pipe);
60108
60109 - if (!is_pipe && !pipe->writers) {
60110 + if (!is_pipe && !atomic_read(&pipe->writers)) {
60111 if ((filp->f_flags & O_NONBLOCK)) {
60112 /* suppress POLLHUP until we have
60113 * seen a writer */
60114 @@ -1084,14 +1085,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
60115 * errno=ENXIO when there is no process reading the FIFO.
60116 */
60117 ret = -ENXIO;
60118 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
60119 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
60120 goto err;
60121
60122 pipe->w_counter++;
60123 - if (!pipe->writers++)
60124 + if (atomic_inc_return(&pipe->writers) == 1)
60125 wake_up_partner(pipe);
60126
60127 - if (!is_pipe && !pipe->readers) {
60128 + if (!is_pipe && !atomic_read(&pipe->readers)) {
60129 if (wait_for_partner(pipe, &pipe->r_counter))
60130 goto err_wr;
60131 }
60132 @@ -1105,11 +1106,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
60133 * the process can at least talk to itself.
60134 */
60135
60136 - pipe->readers++;
60137 - pipe->writers++;
60138 + atomic_inc(&pipe->readers);
60139 + atomic_inc(&pipe->writers);
60140 pipe->r_counter++;
60141 pipe->w_counter++;
60142 - if (pipe->readers == 1 || pipe->writers == 1)
60143 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
60144 wake_up_partner(pipe);
60145 break;
60146
60147 @@ -1123,13 +1124,13 @@ static int fifo_open(struct inode *inode, struct file *filp)
60148 return 0;
60149
60150 err_rd:
60151 - if (!--pipe->readers)
60152 + if (atomic_dec_and_test(&pipe->readers))
60153 wake_up_interruptible(&pipe->wait);
60154 ret = -ERESTARTSYS;
60155 goto err;
60156
60157 err_wr:
60158 - if (!--pipe->writers)
60159 + if (atomic_dec_and_test(&pipe->writers))
60160 wake_up_interruptible(&pipe->wait);
60161 ret = -ERESTARTSYS;
60162 goto err;
60163 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
60164 index 15af622..0e9f4467 100644
60165 --- a/fs/proc/Kconfig
60166 +++ b/fs/proc/Kconfig
60167 @@ -30,12 +30,12 @@ config PROC_FS
60168
60169 config PROC_KCORE
60170 bool "/proc/kcore support" if !ARM
60171 - depends on PROC_FS && MMU
60172 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
60173
60174 config PROC_VMCORE
60175 bool "/proc/vmcore support"
60176 - depends on PROC_FS && CRASH_DUMP
60177 - default y
60178 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
60179 + default n
60180 help
60181 Exports the dump image of crashed kernel in ELF format.
60182
60183 @@ -59,8 +59,8 @@ config PROC_SYSCTL
60184 limited in memory.
60185
60186 config PROC_PAGE_MONITOR
60187 - default y
60188 - depends on PROC_FS && MMU
60189 + default n
60190 + depends on PROC_FS && MMU && !GRKERNSEC
60191 bool "Enable /proc page monitoring" if EXPERT
60192 help
60193 Various /proc files exist to monitor process memory utilization:
60194 diff --git a/fs/proc/array.c b/fs/proc/array.c
60195 index cbd0f1b..adec3f0 100644
60196 --- a/fs/proc/array.c
60197 +++ b/fs/proc/array.c
60198 @@ -60,6 +60,7 @@
60199 #include <linux/tty.h>
60200 #include <linux/string.h>
60201 #include <linux/mman.h>
60202 +#include <linux/grsecurity.h>
60203 #include <linux/proc_fs.h>
60204 #include <linux/ioport.h>
60205 #include <linux/uaccess.h>
60206 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
60207 seq_putc(m, '\n');
60208 }
60209
60210 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
60211 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
60212 +{
60213 + if (p->mm)
60214 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
60215 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
60216 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
60217 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
60218 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
60219 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
60220 + else
60221 + seq_printf(m, "PaX:\t-----\n");
60222 +}
60223 +#endif
60224 +
60225 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
60226 struct pid *pid, struct task_struct *task)
60227 {
60228 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
60229 task_cpus_allowed(m, task);
60230 cpuset_task_status_allowed(m, task);
60231 task_context_switch_counts(m, task);
60232 +
60233 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
60234 + task_pax(m, task);
60235 +#endif
60236 +
60237 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
60238 + task_grsec_rbac(m, task);
60239 +#endif
60240 +
60241 return 0;
60242 }
60243
60244 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60245 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60246 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60247 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60248 +#endif
60249 +
60250 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60251 struct pid *pid, struct task_struct *task, int whole)
60252 {
60253 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60254 char tcomm[sizeof(task->comm)];
60255 unsigned long flags;
60256
60257 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60258 + if (current->exec_id != m->exec_id) {
60259 + gr_log_badprocpid("stat");
60260 + return 0;
60261 + }
60262 +#endif
60263 +
60264 state = *get_task_state(task);
60265 vsize = eip = esp = 0;
60266 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
60267 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60268 gtime = task_gtime(task);
60269 }
60270
60271 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60272 + if (PAX_RAND_FLAGS(mm)) {
60273 + eip = 0;
60274 + esp = 0;
60275 + wchan = 0;
60276 + }
60277 +#endif
60278 +#ifdef CONFIG_GRKERNSEC_HIDESYM
60279 + wchan = 0;
60280 + eip =0;
60281 + esp =0;
60282 +#endif
60283 +
60284 /* scale priority and nice values from timeslices to -20..20 */
60285 /* to make it look like a "normal" Unix priority/nice value */
60286 priority = task_prio(task);
60287 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60288 seq_put_decimal_ull(m, ' ', vsize);
60289 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
60290 seq_put_decimal_ull(m, ' ', rsslim);
60291 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60292 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
60293 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
60294 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
60295 +#else
60296 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
60297 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
60298 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
60299 +#endif
60300 seq_put_decimal_ull(m, ' ', esp);
60301 seq_put_decimal_ull(m, ' ', eip);
60302 /* The signal information here is obsolete.
60303 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60304 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
60305 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
60306
60307 - if (mm && permitted) {
60308 + if (mm && permitted
60309 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60310 + && !PAX_RAND_FLAGS(mm)
60311 +#endif
60312 + ) {
60313 seq_put_decimal_ull(m, ' ', mm->start_data);
60314 seq_put_decimal_ull(m, ' ', mm->end_data);
60315 seq_put_decimal_ull(m, ' ', mm->start_brk);
60316 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
60317 struct pid *pid, struct task_struct *task)
60318 {
60319 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
60320 - struct mm_struct *mm = get_task_mm(task);
60321 + struct mm_struct *mm;
60322
60323 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60324 + if (current->exec_id != m->exec_id) {
60325 + gr_log_badprocpid("statm");
60326 + return 0;
60327 + }
60328 +#endif
60329 + mm = get_task_mm(task);
60330 if (mm) {
60331 size = task_statm(mm, &shared, &text, &data, &resident);
60332 mmput(mm);
60333 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
60334 return 0;
60335 }
60336
60337 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60338 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
60339 +{
60340 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
60341 +}
60342 +#endif
60343 +
60344 #ifdef CONFIG_CHECKPOINT_RESTORE
60345 static struct pid *
60346 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
60347 diff --git a/fs/proc/base.c b/fs/proc/base.c
60348 index 1485e38..8ad4236 100644
60349 --- a/fs/proc/base.c
60350 +++ b/fs/proc/base.c
60351 @@ -113,6 +113,14 @@ struct pid_entry {
60352 union proc_op op;
60353 };
60354
60355 +struct getdents_callback {
60356 + struct linux_dirent __user * current_dir;
60357 + struct linux_dirent __user * previous;
60358 + struct file * file;
60359 + int count;
60360 + int error;
60361 +};
60362 +
60363 #define NOD(NAME, MODE, IOP, FOP, OP) { \
60364 .name = (NAME), \
60365 .len = sizeof(NAME) - 1, \
60366 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
60367 if (!mm->arg_end)
60368 goto out_mm; /* Shh! No looking before we're done */
60369
60370 + if (gr_acl_handle_procpidmem(task))
60371 + goto out_mm;
60372 +
60373 len = mm->arg_end - mm->arg_start;
60374
60375 if (len > PAGE_SIZE)
60376 @@ -237,12 +248,28 @@ out:
60377 return res;
60378 }
60379
60380 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60381 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60382 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60383 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60384 +#endif
60385 +
60386 static int proc_pid_auxv(struct task_struct *task, char *buffer)
60387 {
60388 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
60389 int res = PTR_ERR(mm);
60390 if (mm && !IS_ERR(mm)) {
60391 unsigned int nwords = 0;
60392 +
60393 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60394 + /* allow if we're currently ptracing this task */
60395 + if (PAX_RAND_FLAGS(mm) &&
60396 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
60397 + mmput(mm);
60398 + return 0;
60399 + }
60400 +#endif
60401 +
60402 do {
60403 nwords += 2;
60404 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
60405 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
60406 }
60407
60408
60409 -#ifdef CONFIG_KALLSYMS
60410 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60411 /*
60412 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
60413 * Returns the resolved symbol. If that fails, simply return the address.
60414 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
60415 mutex_unlock(&task->signal->cred_guard_mutex);
60416 }
60417
60418 -#ifdef CONFIG_STACKTRACE
60419 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60420
60421 #define MAX_STACK_TRACE_DEPTH 64
60422
60423 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
60424 return count;
60425 }
60426
60427 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60428 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60429 static int proc_pid_syscall(struct task_struct *task, char *buffer)
60430 {
60431 long nr;
60432 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
60433 /************************************************************************/
60434
60435 /* permission checks */
60436 -static int proc_fd_access_allowed(struct inode *inode)
60437 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
60438 {
60439 struct task_struct *task;
60440 int allowed = 0;
60441 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
60442 */
60443 task = get_proc_task(inode);
60444 if (task) {
60445 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
60446 + if (log)
60447 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
60448 + else
60449 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
60450 put_task_struct(task);
60451 }
60452 return allowed;
60453 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
60454 struct task_struct *task,
60455 int hide_pid_min)
60456 {
60457 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60458 + return false;
60459 +
60460 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60461 + rcu_read_lock();
60462 + {
60463 + const struct cred *tmpcred = current_cred();
60464 + const struct cred *cred = __task_cred(task);
60465 +
60466 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
60467 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60468 + || in_group_p(grsec_proc_gid)
60469 +#endif
60470 + ) {
60471 + rcu_read_unlock();
60472 + return true;
60473 + }
60474 + }
60475 + rcu_read_unlock();
60476 +
60477 + if (!pid->hide_pid)
60478 + return false;
60479 +#endif
60480 +
60481 if (pid->hide_pid < hide_pid_min)
60482 return true;
60483 if (in_group_p(pid->pid_gid))
60484 return true;
60485 +
60486 return ptrace_may_access(task, PTRACE_MODE_READ);
60487 }
60488
60489 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
60490 put_task_struct(task);
60491
60492 if (!has_perms) {
60493 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60494 + {
60495 +#else
60496 if (pid->hide_pid == 2) {
60497 +#endif
60498 /*
60499 * Let's make getdents(), stat(), and open()
60500 * consistent with each other. If a process
60501 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
60502 if (!task)
60503 return -ESRCH;
60504
60505 + if (gr_acl_handle_procpidmem(task)) {
60506 + put_task_struct(task);
60507 + return -EPERM;
60508 + }
60509 +
60510 mm = mm_access(task, mode);
60511 put_task_struct(task);
60512
60513 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
60514
60515 file->private_data = mm;
60516
60517 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60518 + file->f_version = current->exec_id;
60519 +#endif
60520 +
60521 return 0;
60522 }
60523
60524 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
60525 ssize_t copied;
60526 char *page;
60527
60528 +#ifdef CONFIG_GRKERNSEC
60529 + if (write)
60530 + return -EPERM;
60531 +#endif
60532 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60533 + if (file->f_version != current->exec_id) {
60534 + gr_log_badprocpid("mem");
60535 + return 0;
60536 + }
60537 +#endif
60538 +
60539 if (!mm)
60540 return 0;
60541
60542 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
60543 goto free;
60544
60545 while (count > 0) {
60546 - int this_len = min_t(int, count, PAGE_SIZE);
60547 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
60548
60549 if (write && copy_from_user(page, buf, this_len)) {
60550 copied = -EFAULT;
60551 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
60552 if (!mm)
60553 return 0;
60554
60555 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60556 + if (file->f_version != current->exec_id) {
60557 + gr_log_badprocpid("environ");
60558 + return 0;
60559 + }
60560 +#endif
60561 +
60562 page = (char *)__get_free_page(GFP_TEMPORARY);
60563 if (!page)
60564 return -ENOMEM;
60565 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
60566 goto free;
60567 while (count > 0) {
60568 size_t this_len, max_len;
60569 - int retval;
60570 + ssize_t retval;
60571
60572 if (src >= (mm->env_end - mm->env_start))
60573 break;
60574 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
60575 int error = -EACCES;
60576
60577 /* Are we allowed to snoop on the tasks file descriptors? */
60578 - if (!proc_fd_access_allowed(inode))
60579 + if (!proc_fd_access_allowed(inode, 0))
60580 goto out;
60581
60582 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
60583 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
60584 struct path path;
60585
60586 /* Are we allowed to snoop on the tasks file descriptors? */
60587 - if (!proc_fd_access_allowed(inode))
60588 - goto out;
60589 + /* logging this is needed for learning on chromium to work properly,
60590 + but we don't want to flood the logs from 'ps' which does a readlink
60591 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
60592 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
60593 + */
60594 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
60595 + if (!proc_fd_access_allowed(inode,0))
60596 + goto out;
60597 + } else {
60598 + if (!proc_fd_access_allowed(inode,1))
60599 + goto out;
60600 + }
60601
60602 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
60603 if (error)
60604 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
60605 rcu_read_lock();
60606 cred = __task_cred(task);
60607 inode->i_uid = cred->euid;
60608 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60609 + inode->i_gid = grsec_proc_gid;
60610 +#else
60611 inode->i_gid = cred->egid;
60612 +#endif
60613 rcu_read_unlock();
60614 }
60615 security_task_to_inode(task, inode);
60616 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
60617 return -ENOENT;
60618 }
60619 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
60620 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60621 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
60622 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60623 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
60624 +#endif
60625 task_dumpable(task)) {
60626 cred = __task_cred(task);
60627 stat->uid = cred->euid;
60628 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60629 + stat->gid = grsec_proc_gid;
60630 +#else
60631 stat->gid = cred->egid;
60632 +#endif
60633 }
60634 }
60635 rcu_read_unlock();
60636 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
60637
60638 if (task) {
60639 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
60640 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60641 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
60642 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60643 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
60644 +#endif
60645 task_dumpable(task)) {
60646 rcu_read_lock();
60647 cred = __task_cred(task);
60648 inode->i_uid = cred->euid;
60649 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60650 + inode->i_gid = grsec_proc_gid;
60651 +#else
60652 inode->i_gid = cred->egid;
60653 +#endif
60654 rcu_read_unlock();
60655 } else {
60656 inode->i_uid = GLOBAL_ROOT_UID;
60657 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
60658 if (!task)
60659 goto out_no_task;
60660
60661 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60662 + goto out;
60663 +
60664 /*
60665 * Yes, it does not scale. And it should not. Don't add
60666 * new entries into /proc/<tgid>/ without very good reasons.
60667 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
60668 if (!task)
60669 return -ENOENT;
60670
60671 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60672 + goto out;
60673 +
60674 if (!dir_emit_dots(file, ctx))
60675 goto out;
60676
60677 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
60678 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
60679 #endif
60680 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
60681 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60682 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60683 INF("syscall", S_IRUGO, proc_pid_syscall),
60684 #endif
60685 INF("cmdline", S_IRUGO, proc_pid_cmdline),
60686 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
60687 #ifdef CONFIG_SECURITY
60688 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
60689 #endif
60690 -#ifdef CONFIG_KALLSYMS
60691 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60692 INF("wchan", S_IRUGO, proc_pid_wchan),
60693 #endif
60694 -#ifdef CONFIG_STACKTRACE
60695 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60696 ONE("stack", S_IRUGO, proc_pid_stack),
60697 #endif
60698 #ifdef CONFIG_SCHEDSTATS
60699 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
60700 #ifdef CONFIG_HARDWALL
60701 INF("hardwall", S_IRUGO, proc_pid_hardwall),
60702 #endif
60703 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60704 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
60705 +#endif
60706 #ifdef CONFIG_USER_NS
60707 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
60708 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
60709 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
60710 if (!inode)
60711 goto out;
60712
60713 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60714 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
60715 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60716 + inode->i_gid = grsec_proc_gid;
60717 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
60718 +#else
60719 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
60720 +#endif
60721 inode->i_op = &proc_tgid_base_inode_operations;
60722 inode->i_fop = &proc_tgid_base_operations;
60723 inode->i_flags|=S_IMMUTABLE;
60724 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
60725 if (!task)
60726 goto out;
60727
60728 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60729 + goto out_put_task;
60730 +
60731 result = proc_pid_instantiate(dir, dentry, task, NULL);
60732 +out_put_task:
60733 put_task_struct(task);
60734 out:
60735 return ERR_PTR(result);
60736 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
60737 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
60738 #endif
60739 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
60740 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60741 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60742 INF("syscall", S_IRUGO, proc_pid_syscall),
60743 #endif
60744 INF("cmdline", S_IRUGO, proc_pid_cmdline),
60745 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
60746 #ifdef CONFIG_SECURITY
60747 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
60748 #endif
60749 -#ifdef CONFIG_KALLSYMS
60750 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60751 INF("wchan", S_IRUGO, proc_pid_wchan),
60752 #endif
60753 -#ifdef CONFIG_STACKTRACE
60754 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60755 ONE("stack", S_IRUGO, proc_pid_stack),
60756 #endif
60757 #ifdef CONFIG_SCHEDSTATS
60758 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
60759 index 82676e3..5f8518a 100644
60760 --- a/fs/proc/cmdline.c
60761 +++ b/fs/proc/cmdline.c
60762 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
60763
60764 static int __init proc_cmdline_init(void)
60765 {
60766 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60767 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
60768 +#else
60769 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
60770 +#endif
60771 return 0;
60772 }
60773 module_init(proc_cmdline_init);
60774 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
60775 index b143471..bb105e5 100644
60776 --- a/fs/proc/devices.c
60777 +++ b/fs/proc/devices.c
60778 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
60779
60780 static int __init proc_devices_init(void)
60781 {
60782 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60783 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
60784 +#else
60785 proc_create("devices", 0, NULL, &proc_devinfo_operations);
60786 +#endif
60787 return 0;
60788 }
60789 module_init(proc_devices_init);
60790 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
60791 index 985ea88..d118a0a 100644
60792 --- a/fs/proc/fd.c
60793 +++ b/fs/proc/fd.c
60794 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
60795 if (!task)
60796 return -ENOENT;
60797
60798 - files = get_files_struct(task);
60799 + if (!gr_acl_handle_procpidmem(task))
60800 + files = get_files_struct(task);
60801 put_task_struct(task);
60802
60803 if (files) {
60804 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
60805 */
60806 int proc_fd_permission(struct inode *inode, int mask)
60807 {
60808 + struct task_struct *task;
60809 int rv = generic_permission(inode, mask);
60810 - if (rv == 0)
60811 - return 0;
60812 +
60813 if (task_tgid(current) == proc_pid(inode))
60814 rv = 0;
60815 +
60816 + task = get_proc_task(inode);
60817 + if (task == NULL)
60818 + return rv;
60819 +
60820 + if (gr_acl_handle_procpidmem(task))
60821 + rv = -EACCES;
60822 +
60823 + put_task_struct(task);
60824 +
60825 return rv;
60826 }
60827
60828 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
60829 index 8eaa1ba..cc6ff42 100644
60830 --- a/fs/proc/inode.c
60831 +++ b/fs/proc/inode.c
60832 @@ -23,11 +23,17 @@
60833 #include <linux/slab.h>
60834 #include <linux/mount.h>
60835 #include <linux/magic.h>
60836 +#include <linux/grsecurity.h>
60837
60838 #include <asm/uaccess.h>
60839
60840 #include "internal.h"
60841
60842 +#ifdef CONFIG_PROC_SYSCTL
60843 +extern const struct inode_operations proc_sys_inode_operations;
60844 +extern const struct inode_operations proc_sys_dir_operations;
60845 +#endif
60846 +
60847 static void proc_evict_inode(struct inode *inode)
60848 {
60849 struct proc_dir_entry *de;
60850 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
60851 ns = PROC_I(inode)->ns.ns;
60852 if (ns_ops && ns)
60853 ns_ops->put(ns);
60854 +
60855 +#ifdef CONFIG_PROC_SYSCTL
60856 + if (inode->i_op == &proc_sys_inode_operations ||
60857 + inode->i_op == &proc_sys_dir_operations)
60858 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
60859 +#endif
60860 +
60861 }
60862
60863 static struct kmem_cache * proc_inode_cachep;
60864 @@ -405,7 +418,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
60865 if (de->mode) {
60866 inode->i_mode = de->mode;
60867 inode->i_uid = de->uid;
60868 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60869 + inode->i_gid = grsec_proc_gid;
60870 +#else
60871 inode->i_gid = de->gid;
60872 +#endif
60873 }
60874 if (de->size)
60875 inode->i_size = de->size;
60876 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
60877 index 651d09a..60c73ae 100644
60878 --- a/fs/proc/internal.h
60879 +++ b/fs/proc/internal.h
60880 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
60881 struct pid *, struct task_struct *);
60882 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
60883 struct pid *, struct task_struct *);
60884 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60885 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
60886 +#endif
60887
60888 /*
60889 * base.c
60890 diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c
60891 index 05029c0..7ea1987 100644
60892 --- a/fs/proc/interrupts.c
60893 +++ b/fs/proc/interrupts.c
60894 @@ -47,7 +47,11 @@ static const struct file_operations proc_interrupts_operations = {
60895
60896 static int __init proc_interrupts_init(void)
60897 {
60898 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60899 + proc_create_grsec("interrupts", 0, NULL, &proc_interrupts_operations);
60900 +#else
60901 proc_create("interrupts", 0, NULL, &proc_interrupts_operations);
60902 +#endif
60903 return 0;
60904 }
60905 module_init(proc_interrupts_init);
60906 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
60907 index 06ea155..9a798c7 100644
60908 --- a/fs/proc/kcore.c
60909 +++ b/fs/proc/kcore.c
60910 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60911 * the addresses in the elf_phdr on our list.
60912 */
60913 start = kc_offset_to_vaddr(*fpos - elf_buflen);
60914 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
60915 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
60916 + if (tsz > buflen)
60917 tsz = buflen;
60918 -
60919 +
60920 while (buflen) {
60921 struct kcore_list *m;
60922
60923 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60924 kfree(elf_buf);
60925 } else {
60926 if (kern_addr_valid(start)) {
60927 - unsigned long n;
60928 + char *elf_buf;
60929 + mm_segment_t oldfs;
60930
60931 - n = copy_to_user(buffer, (char *)start, tsz);
60932 - /*
60933 - * We cannot distinguish between fault on source
60934 - * and fault on destination. When this happens
60935 - * we clear too and hope it will trigger the
60936 - * EFAULT again.
60937 - */
60938 - if (n) {
60939 - if (clear_user(buffer + tsz - n,
60940 - n))
60941 + elf_buf = kmalloc(tsz, GFP_KERNEL);
60942 + if (!elf_buf)
60943 + return -ENOMEM;
60944 + oldfs = get_fs();
60945 + set_fs(KERNEL_DS);
60946 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
60947 + set_fs(oldfs);
60948 + if (copy_to_user(buffer, elf_buf, tsz)) {
60949 + kfree(elf_buf);
60950 return -EFAULT;
60951 + }
60952 }
60953 + set_fs(oldfs);
60954 + kfree(elf_buf);
60955 } else {
60956 if (clear_user(buffer, tsz))
60957 return -EFAULT;
60958 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60959
60960 static int open_kcore(struct inode *inode, struct file *filp)
60961 {
60962 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
60963 + return -EPERM;
60964 +#endif
60965 if (!capable(CAP_SYS_RAWIO))
60966 return -EPERM;
60967 if (kcore_need_update)
60968 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
60969 index 59d85d6..ac6fc05 100644
60970 --- a/fs/proc/meminfo.c
60971 +++ b/fs/proc/meminfo.c
60972 @@ -153,7 +153,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
60973 vmi.used >> 10,
60974 vmi.largest_chunk >> 10
60975 #ifdef CONFIG_MEMORY_FAILURE
60976 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
60977 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
60978 #endif
60979 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
60980 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
60981 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
60982 index ccfd99b..1b7e255 100644
60983 --- a/fs/proc/nommu.c
60984 +++ b/fs/proc/nommu.c
60985 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
60986 if (len < 1)
60987 len = 1;
60988 seq_printf(m, "%*c", len, ' ');
60989 - seq_path(m, &file->f_path, "");
60990 + seq_path(m, &file->f_path, "\n\\");
60991 }
60992
60993 seq_putc(m, '\n');
60994 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
60995 index 4677bb7..408e936 100644
60996 --- a/fs/proc/proc_net.c
60997 +++ b/fs/proc/proc_net.c
60998 @@ -23,6 +23,7 @@
60999 #include <linux/nsproxy.h>
61000 #include <net/net_namespace.h>
61001 #include <linux/seq_file.h>
61002 +#include <linux/grsecurity.h>
61003
61004 #include "internal.h"
61005
61006 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
61007 struct task_struct *task;
61008 struct nsproxy *ns;
61009 struct net *net = NULL;
61010 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61011 + const struct cred *cred = current_cred();
61012 +#endif
61013 +
61014 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61015 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
61016 + return net;
61017 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61018 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
61019 + return net;
61020 +#endif
61021
61022 rcu_read_lock();
61023 task = pid_task(proc_pid(dir), PIDTYPE_PID);
61024 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
61025 index 7129046..6914844 100644
61026 --- a/fs/proc/proc_sysctl.c
61027 +++ b/fs/proc/proc_sysctl.c
61028 @@ -11,13 +11,21 @@
61029 #include <linux/namei.h>
61030 #include <linux/mm.h>
61031 #include <linux/module.h>
61032 +#include <linux/nsproxy.h>
61033 +#ifdef CONFIG_GRKERNSEC
61034 +#include <net/net_namespace.h>
61035 +#endif
61036 #include "internal.h"
61037
61038 +extern int gr_handle_chroot_sysctl(const int op);
61039 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
61040 + const int op);
61041 +
61042 static const struct dentry_operations proc_sys_dentry_operations;
61043 static const struct file_operations proc_sys_file_operations;
61044 -static const struct inode_operations proc_sys_inode_operations;
61045 +const struct inode_operations proc_sys_inode_operations;
61046 static const struct file_operations proc_sys_dir_file_operations;
61047 -static const struct inode_operations proc_sys_dir_operations;
61048 +const struct inode_operations proc_sys_dir_operations;
61049
61050 void proc_sys_poll_notify(struct ctl_table_poll *poll)
61051 {
61052 @@ -467,6 +475,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
61053
61054 err = NULL;
61055 d_set_d_op(dentry, &proc_sys_dentry_operations);
61056 +
61057 + gr_handle_proc_create(dentry, inode);
61058 +
61059 d_add(dentry, inode);
61060
61061 out:
61062 @@ -482,6 +493,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
61063 struct inode *inode = file_inode(filp);
61064 struct ctl_table_header *head = grab_header(inode);
61065 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
61066 + int op = write ? MAY_WRITE : MAY_READ;
61067 ssize_t error;
61068 size_t res;
61069
61070 @@ -493,7 +505,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
61071 * and won't be until we finish.
61072 */
61073 error = -EPERM;
61074 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
61075 + if (sysctl_perm(head, table, op))
61076 goto out;
61077
61078 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
61079 @@ -501,6 +513,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
61080 if (!table->proc_handler)
61081 goto out;
61082
61083 +#ifdef CONFIG_GRKERNSEC
61084 + error = -EPERM;
61085 + if (gr_handle_chroot_sysctl(op))
61086 + goto out;
61087 + dget(filp->f_path.dentry);
61088 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
61089 + dput(filp->f_path.dentry);
61090 + goto out;
61091 + }
61092 + dput(filp->f_path.dentry);
61093 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
61094 + goto out;
61095 + if (write) {
61096 + if (current->nsproxy->net_ns != table->extra2) {
61097 + if (!capable(CAP_SYS_ADMIN))
61098 + goto out;
61099 + } else if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
61100 + goto out;
61101 + }
61102 +#endif
61103 +
61104 /* careful: calling conventions are nasty here */
61105 res = count;
61106 error = table->proc_handler(table, write, buf, &res, ppos);
61107 @@ -598,6 +631,9 @@ static bool proc_sys_fill_cache(struct file *file,
61108 return false;
61109 } else {
61110 d_set_d_op(child, &proc_sys_dentry_operations);
61111 +
61112 + gr_handle_proc_create(child, inode);
61113 +
61114 d_add(child, inode);
61115 }
61116 } else {
61117 @@ -641,6 +677,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
61118 if ((*pos)++ < ctx->pos)
61119 return true;
61120
61121 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
61122 + return 0;
61123 +
61124 if (unlikely(S_ISLNK(table->mode)))
61125 res = proc_sys_link_fill_cache(file, ctx, head, table);
61126 else
61127 @@ -734,6 +773,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
61128 if (IS_ERR(head))
61129 return PTR_ERR(head);
61130
61131 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
61132 + return -ENOENT;
61133 +
61134 generic_fillattr(inode, stat);
61135 if (table)
61136 stat->mode = (stat->mode & S_IFMT) | table->mode;
61137 @@ -756,13 +798,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
61138 .llseek = generic_file_llseek,
61139 };
61140
61141 -static const struct inode_operations proc_sys_inode_operations = {
61142 +const struct inode_operations proc_sys_inode_operations = {
61143 .permission = proc_sys_permission,
61144 .setattr = proc_sys_setattr,
61145 .getattr = proc_sys_getattr,
61146 };
61147
61148 -static const struct inode_operations proc_sys_dir_operations = {
61149 +const struct inode_operations proc_sys_dir_operations = {
61150 .lookup = proc_sys_lookup,
61151 .permission = proc_sys_permission,
61152 .setattr = proc_sys_setattr,
61153 @@ -839,7 +881,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
61154 static struct ctl_dir *new_dir(struct ctl_table_set *set,
61155 const char *name, int namelen)
61156 {
61157 - struct ctl_table *table;
61158 + ctl_table_no_const *table;
61159 struct ctl_dir *new;
61160 struct ctl_node *node;
61161 char *new_name;
61162 @@ -851,7 +893,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
61163 return NULL;
61164
61165 node = (struct ctl_node *)(new + 1);
61166 - table = (struct ctl_table *)(node + 1);
61167 + table = (ctl_table_no_const *)(node + 1);
61168 new_name = (char *)(table + 2);
61169 memcpy(new_name, name, namelen);
61170 new_name[namelen] = '\0';
61171 @@ -1020,7 +1062,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
61172 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
61173 struct ctl_table_root *link_root)
61174 {
61175 - struct ctl_table *link_table, *entry, *link;
61176 + ctl_table_no_const *link_table, *link;
61177 + struct ctl_table *entry;
61178 struct ctl_table_header *links;
61179 struct ctl_node *node;
61180 char *link_name;
61181 @@ -1043,7 +1086,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
61182 return NULL;
61183
61184 node = (struct ctl_node *)(links + 1);
61185 - link_table = (struct ctl_table *)(node + nr_entries);
61186 + link_table = (ctl_table_no_const *)(node + nr_entries);
61187 link_name = (char *)&link_table[nr_entries + 1];
61188
61189 for (link = link_table, entry = table; entry->procname; link++, entry++) {
61190 @@ -1291,8 +1334,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61191 struct ctl_table_header ***subheader, struct ctl_table_set *set,
61192 struct ctl_table *table)
61193 {
61194 - struct ctl_table *ctl_table_arg = NULL;
61195 - struct ctl_table *entry, *files;
61196 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
61197 + struct ctl_table *entry;
61198 int nr_files = 0;
61199 int nr_dirs = 0;
61200 int err = -ENOMEM;
61201 @@ -1304,10 +1347,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61202 nr_files++;
61203 }
61204
61205 - files = table;
61206 /* If there are mixed files and directories we need a new table */
61207 if (nr_dirs && nr_files) {
61208 - struct ctl_table *new;
61209 + ctl_table_no_const *new;
61210 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
61211 GFP_KERNEL);
61212 if (!files)
61213 @@ -1325,7 +1367,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61214 /* Register everything except a directory full of subdirectories */
61215 if (nr_files || !nr_dirs) {
61216 struct ctl_table_header *header;
61217 - header = __register_sysctl_table(set, path, files);
61218 + header = __register_sysctl_table(set, path, files ? files : table);
61219 if (!header) {
61220 kfree(ctl_table_arg);
61221 goto out;
61222 diff --git a/fs/proc/root.c b/fs/proc/root.c
61223 index 87dbcbe..55e1b4d 100644
61224 --- a/fs/proc/root.c
61225 +++ b/fs/proc/root.c
61226 @@ -186,7 +186,15 @@ void __init proc_root_init(void)
61227 #ifdef CONFIG_PROC_DEVICETREE
61228 proc_device_tree_init();
61229 #endif
61230 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
61231 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61232 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
61233 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61234 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
61235 +#endif
61236 +#else
61237 proc_mkdir("bus", NULL);
61238 +#endif
61239 proc_sys_init();
61240 }
61241
61242 diff --git a/fs/proc/self.c b/fs/proc/self.c
61243 index 6b6a993..807cccc 100644
61244 --- a/fs/proc/self.c
61245 +++ b/fs/proc/self.c
61246 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
61247 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
61248 void *cookie)
61249 {
61250 - char *s = nd_get_link(nd);
61251 + const char *s = nd_get_link(nd);
61252 if (!IS_ERR(s))
61253 kfree(s);
61254 }
61255 diff --git a/fs/proc/stat.c b/fs/proc/stat.c
61256 index 1cf86c0..0ee1ca5 100644
61257 --- a/fs/proc/stat.c
61258 +++ b/fs/proc/stat.c
61259 @@ -11,6 +11,7 @@
61260 #include <linux/irqnr.h>
61261 #include <asm/cputime.h>
61262 #include <linux/tick.h>
61263 +#include <linux/grsecurity.h>
61264
61265 #ifndef arch_irq_stat_cpu
61266 #define arch_irq_stat_cpu(cpu) 0
61267 @@ -87,6 +88,18 @@ static int show_stat(struct seq_file *p, void *v)
61268 u64 sum_softirq = 0;
61269 unsigned int per_softirq_sums[NR_SOFTIRQS] = {0};
61270 struct timespec boottime;
61271 + int unrestricted = 1;
61272 +
61273 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
61274 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61275 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)
61276 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
61277 + && !in_group_p(grsec_proc_gid)
61278 +#endif
61279 + )
61280 + unrestricted = 0;
61281 +#endif
61282 +#endif
61283
61284 user = nice = system = idle = iowait =
61285 irq = softirq = steal = 0;
61286 @@ -94,6 +107,7 @@ static int show_stat(struct seq_file *p, void *v)
61287 getboottime(&boottime);
61288 jif = boottime.tv_sec;
61289
61290 + if (unrestricted) {
61291 for_each_possible_cpu(i) {
61292 user += kcpustat_cpu(i).cpustat[CPUTIME_USER];
61293 nice += kcpustat_cpu(i).cpustat[CPUTIME_NICE];
61294 @@ -116,6 +130,7 @@ static int show_stat(struct seq_file *p, void *v)
61295 }
61296 }
61297 sum += arch_irq_stat();
61298 + }
61299
61300 seq_puts(p, "cpu ");
61301 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(user));
61302 @@ -131,6 +146,7 @@ static int show_stat(struct seq_file *p, void *v)
61303 seq_putc(p, '\n');
61304
61305 for_each_online_cpu(i) {
61306 + if (unrestricted) {
61307 /* Copy values here to work around gcc-2.95.3, gcc-2.96 */
61308 user = kcpustat_cpu(i).cpustat[CPUTIME_USER];
61309 nice = kcpustat_cpu(i).cpustat[CPUTIME_NICE];
61310 @@ -142,6 +158,7 @@ static int show_stat(struct seq_file *p, void *v)
61311 steal = kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
61312 guest = kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
61313 guest_nice = kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
61314 + }
61315 seq_printf(p, "cpu%d", i);
61316 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(user));
61317 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(nice));
61318 @@ -159,7 +176,7 @@ static int show_stat(struct seq_file *p, void *v)
61319
61320 /* sum again ? it could be updated? */
61321 for_each_irq_nr(j)
61322 - seq_put_decimal_ull(p, ' ', kstat_irqs(j));
61323 + seq_put_decimal_ull(p, ' ', unrestricted ? kstat_irqs(j) : 0ULL);
61324
61325 seq_printf(p,
61326 "\nctxt %llu\n"
61327 @@ -167,11 +184,11 @@ static int show_stat(struct seq_file *p, void *v)
61328 "processes %lu\n"
61329 "procs_running %lu\n"
61330 "procs_blocked %lu\n",
61331 - nr_context_switches(),
61332 + unrestricted ? nr_context_switches() : 0ULL,
61333 (unsigned long)jif,
61334 - total_forks,
61335 - nr_running(),
61336 - nr_iowait());
61337 + unrestricted ? total_forks : 0UL,
61338 + unrestricted ? nr_running() : 0UL,
61339 + unrestricted ? nr_iowait() : 0UL);
61340
61341 seq_printf(p, "softirq %llu", (unsigned long long)sum_softirq);
61342
61343 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
61344 index 390bdab..83c1e8a 100644
61345 --- a/fs/proc/task_mmu.c
61346 +++ b/fs/proc/task_mmu.c
61347 @@ -12,12 +12,19 @@
61348 #include <linux/swap.h>
61349 #include <linux/swapops.h>
61350 #include <linux/mmu_notifier.h>
61351 +#include <linux/grsecurity.h>
61352
61353 #include <asm/elf.h>
61354 #include <asm/uaccess.h>
61355 #include <asm/tlbflush.h>
61356 #include "internal.h"
61357
61358 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61359 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
61360 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
61361 + _mm->pax_flags & MF_PAX_SEGMEXEC))
61362 +#endif
61363 +
61364 void task_mem(struct seq_file *m, struct mm_struct *mm)
61365 {
61366 unsigned long data, text, lib, swap;
61367 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61368 "VmExe:\t%8lu kB\n"
61369 "VmLib:\t%8lu kB\n"
61370 "VmPTE:\t%8lu kB\n"
61371 - "VmSwap:\t%8lu kB\n",
61372 - hiwater_vm << (PAGE_SHIFT-10),
61373 + "VmSwap:\t%8lu kB\n"
61374 +
61375 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
61376 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
61377 +#endif
61378 +
61379 + ,hiwater_vm << (PAGE_SHIFT-10),
61380 total_vm << (PAGE_SHIFT-10),
61381 mm->locked_vm << (PAGE_SHIFT-10),
61382 mm->pinned_vm << (PAGE_SHIFT-10),
61383 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61384 data << (PAGE_SHIFT-10),
61385 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
61386 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
61387 - swap << (PAGE_SHIFT-10));
61388 + swap << (PAGE_SHIFT-10)
61389 +
61390 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
61391 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61392 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
61393 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
61394 +#else
61395 + , mm->context.user_cs_base
61396 + , mm->context.user_cs_limit
61397 +#endif
61398 +#endif
61399 +
61400 + );
61401 }
61402
61403 unsigned long task_vsize(struct mm_struct *mm)
61404 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61405 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
61406 }
61407
61408 - /* We don't show the stack guard page in /proc/maps */
61409 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61410 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
61411 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
61412 +#else
61413 start = vma->vm_start;
61414 - if (stack_guard_page_start(vma, start))
61415 - start += PAGE_SIZE;
61416 end = vma->vm_end;
61417 - if (stack_guard_page_end(vma, end))
61418 - end -= PAGE_SIZE;
61419 +#endif
61420
61421 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
61422 start,
61423 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61424 flags & VM_WRITE ? 'w' : '-',
61425 flags & VM_EXEC ? 'x' : '-',
61426 flags & VM_MAYSHARE ? 's' : 'p',
61427 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61428 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
61429 +#else
61430 pgoff,
61431 +#endif
61432 MAJOR(dev), MINOR(dev), ino, &len);
61433
61434 /*
61435 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61436 */
61437 if (file) {
61438 pad_len_spaces(m, len);
61439 - seq_path(m, &file->f_path, "\n");
61440 + seq_path(m, &file->f_path, "\n\\");
61441 goto done;
61442 }
61443
61444 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61445 * Thread stack in /proc/PID/task/TID/maps or
61446 * the main process stack.
61447 */
61448 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
61449 - vma->vm_end >= mm->start_stack)) {
61450 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
61451 + (vma->vm_start <= mm->start_stack &&
61452 + vma->vm_end >= mm->start_stack)) {
61453 name = "[stack]";
61454 } else {
61455 /* Thread stack in /proc/PID/maps */
61456 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
61457 struct proc_maps_private *priv = m->private;
61458 struct task_struct *task = priv->task;
61459
61460 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61461 + if (current->exec_id != m->exec_id) {
61462 + gr_log_badprocpid("maps");
61463 + return 0;
61464 + }
61465 +#endif
61466 +
61467 show_map_vma(m, vma, is_pid);
61468
61469 if (m->count < m->size) /* vma is copied successfully */
61470 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
61471 .private = &mss,
61472 };
61473
61474 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61475 + if (current->exec_id != m->exec_id) {
61476 + gr_log_badprocpid("smaps");
61477 + return 0;
61478 + }
61479 +#endif
61480 memset(&mss, 0, sizeof mss);
61481 - mss.vma = vma;
61482 - /* mmap_sem is held in m_start */
61483 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
61484 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
61485 -
61486 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61487 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
61488 +#endif
61489 + mss.vma = vma;
61490 + /* mmap_sem is held in m_start */
61491 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
61492 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
61493 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61494 + }
61495 +#endif
61496 show_map_vma(m, vma, is_pid);
61497
61498 seq_printf(m,
61499 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
61500 "KernelPageSize: %8lu kB\n"
61501 "MMUPageSize: %8lu kB\n"
61502 "Locked: %8lu kB\n",
61503 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61504 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
61505 +#else
61506 (vma->vm_end - vma->vm_start) >> 10,
61507 +#endif
61508 mss.resident >> 10,
61509 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
61510 mss.shared_clean >> 10,
61511 @@ -1390,6 +1441,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
61512 int n;
61513 char buffer[50];
61514
61515 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61516 + if (current->exec_id != m->exec_id) {
61517 + gr_log_badprocpid("numa_maps");
61518 + return 0;
61519 + }
61520 +#endif
61521 +
61522 if (!mm)
61523 return 0;
61524
61525 @@ -1409,11 +1467,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
61526 if (n < 0)
61527 return n;
61528
61529 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61530 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
61531 +#else
61532 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
61533 +#endif
61534
61535 if (file) {
61536 seq_printf(m, " file=");
61537 - seq_path(m, &file->f_path, "\n\t= ");
61538 + seq_path(m, &file->f_path, "\n\t\\= ");
61539 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
61540 seq_printf(m, " heap");
61541 } else {
61542 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
61543 index 56123a6..5a2f6ec 100644
61544 --- a/fs/proc/task_nommu.c
61545 +++ b/fs/proc/task_nommu.c
61546 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61547 else
61548 bytes += kobjsize(mm);
61549
61550 - if (current->fs && current->fs->users > 1)
61551 + if (current->fs && atomic_read(&current->fs->users) > 1)
61552 sbytes += kobjsize(current->fs);
61553 else
61554 bytes += kobjsize(current->fs);
61555 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
61556
61557 if (file) {
61558 pad_len_spaces(m, len);
61559 - seq_path(m, &file->f_path, "");
61560 + seq_path(m, &file->f_path, "\n\\");
61561 } else if (mm) {
61562 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
61563
61564 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
61565 index 9100d69..f1f9fc9 100644
61566 --- a/fs/proc/vmcore.c
61567 +++ b/fs/proc/vmcore.c
61568 @@ -105,9 +105,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
61569 nr_bytes = count;
61570
61571 /* If pfn is not ram, return zeros for sparse dump files */
61572 - if (pfn_is_ram(pfn) == 0)
61573 - memset(buf, 0, nr_bytes);
61574 - else {
61575 + if (pfn_is_ram(pfn) == 0) {
61576 + if (userbuf) {
61577 + if (clear_user((char __force_user *)buf, nr_bytes))
61578 + return -EFAULT;
61579 + } else
61580 + memset(buf, 0, nr_bytes);
61581 + } else {
61582 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
61583 offset, userbuf);
61584 if (tmp < 0)
61585 @@ -233,7 +237,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
61586 if (*fpos < m->offset + m->size) {
61587 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
61588 start = m->paddr + *fpos - m->offset;
61589 - tmp = read_from_oldmem(buffer, tsz, &start, userbuf);
61590 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, userbuf);
61591 if (tmp < 0)
61592 return tmp;
61593 buflen -= tsz;
61594 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
61595 index b00fcc9..e0c6381 100644
61596 --- a/fs/qnx6/qnx6.h
61597 +++ b/fs/qnx6/qnx6.h
61598 @@ -74,7 +74,7 @@ enum {
61599 BYTESEX_BE,
61600 };
61601
61602 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
61603 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
61604 {
61605 if (sbi->s_bytesex == BYTESEX_LE)
61606 return le64_to_cpu((__force __le64)n);
61607 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
61608 return (__force __fs64)cpu_to_be64(n);
61609 }
61610
61611 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
61612 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
61613 {
61614 if (sbi->s_bytesex == BYTESEX_LE)
61615 return le32_to_cpu((__force __le32)n);
61616 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
61617 index 16e8abb..2dcf914 100644
61618 --- a/fs/quota/netlink.c
61619 +++ b/fs/quota/netlink.c
61620 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
61621 void quota_send_warning(struct kqid qid, dev_t dev,
61622 const char warntype)
61623 {
61624 - static atomic_t seq;
61625 + static atomic_unchecked_t seq;
61626 struct sk_buff *skb;
61627 void *msg_head;
61628 int ret;
61629 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
61630 "VFS: Not enough memory to send quota warning.\n");
61631 return;
61632 }
61633 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
61634 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
61635 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
61636 if (!msg_head) {
61637 printk(KERN_ERR
61638 diff --git a/fs/read_write.c b/fs/read_write.c
61639 index e3cd280..a378473 100644
61640 --- a/fs/read_write.c
61641 +++ b/fs/read_write.c
61642 @@ -438,7 +438,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
61643
61644 old_fs = get_fs();
61645 set_fs(get_ds());
61646 - p = (__force const char __user *)buf;
61647 + p = (const char __force_user *)buf;
61648 if (count > MAX_RW_COUNT)
61649 count = MAX_RW_COUNT;
61650 if (file->f_op->write)
61651 diff --git a/fs/readdir.c b/fs/readdir.c
61652 index 93d71e5..6a14be8 100644
61653 --- a/fs/readdir.c
61654 +++ b/fs/readdir.c
61655 @@ -17,6 +17,7 @@
61656 #include <linux/security.h>
61657 #include <linux/syscalls.h>
61658 #include <linux/unistd.h>
61659 +#include <linux/namei.h>
61660
61661 #include <asm/uaccess.h>
61662
61663 @@ -69,6 +70,7 @@ struct old_linux_dirent {
61664 struct readdir_callback {
61665 struct dir_context ctx;
61666 struct old_linux_dirent __user * dirent;
61667 + struct file * file;
61668 int result;
61669 };
61670
61671 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
61672 buf->result = -EOVERFLOW;
61673 return -EOVERFLOW;
61674 }
61675 +
61676 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61677 + return 0;
61678 +
61679 buf->result++;
61680 dirent = buf->dirent;
61681 if (!access_ok(VERIFY_WRITE, dirent,
61682 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
61683 if (!f.file)
61684 return -EBADF;
61685
61686 + buf.file = f.file;
61687 error = iterate_dir(f.file, &buf.ctx);
61688 if (buf.result)
61689 error = buf.result;
61690 @@ -142,6 +149,7 @@ struct getdents_callback {
61691 struct dir_context ctx;
61692 struct linux_dirent __user * current_dir;
61693 struct linux_dirent __user * previous;
61694 + struct file * file;
61695 int count;
61696 int error;
61697 };
61698 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
61699 buf->error = -EOVERFLOW;
61700 return -EOVERFLOW;
61701 }
61702 +
61703 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61704 + return 0;
61705 +
61706 dirent = buf->previous;
61707 if (dirent) {
61708 if (__put_user(offset, &dirent->d_off))
61709 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
61710 if (!f.file)
61711 return -EBADF;
61712
61713 + buf.file = f.file;
61714 error = iterate_dir(f.file, &buf.ctx);
61715 if (error >= 0)
61716 error = buf.error;
61717 @@ -226,6 +239,7 @@ struct getdents_callback64 {
61718 struct dir_context ctx;
61719 struct linux_dirent64 __user * current_dir;
61720 struct linux_dirent64 __user * previous;
61721 + struct file *file;
61722 int count;
61723 int error;
61724 };
61725 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
61726 buf->error = -EINVAL; /* only used if we fail.. */
61727 if (reclen > buf->count)
61728 return -EINVAL;
61729 +
61730 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61731 + return 0;
61732 +
61733 dirent = buf->previous;
61734 if (dirent) {
61735 if (__put_user(offset, &dirent->d_off))
61736 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
61737 if (!f.file)
61738 return -EBADF;
61739
61740 + buf.file = f.file;
61741 error = iterate_dir(f.file, &buf.ctx);
61742 if (error >= 0)
61743 error = buf.error;
61744 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
61745 index 2b7882b..1c5ef48 100644
61746 --- a/fs/reiserfs/do_balan.c
61747 +++ b/fs/reiserfs/do_balan.c
61748 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
61749 return;
61750 }
61751
61752 - atomic_inc(&(fs_generation(tb->tb_sb)));
61753 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
61754 do_balance_starts(tb);
61755
61756 /* balance leaf returns 0 except if combining L R and S into
61757 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
61758 index a958444..42b2323 100644
61759 --- a/fs/reiserfs/procfs.c
61760 +++ b/fs/reiserfs/procfs.c
61761 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
61762 "SMALL_TAILS " : "NO_TAILS ",
61763 replay_only(sb) ? "REPLAY_ONLY " : "",
61764 convert_reiserfs(sb) ? "CONV " : "",
61765 - atomic_read(&r->s_generation_counter),
61766 + atomic_read_unchecked(&r->s_generation_counter),
61767 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
61768 SF(s_do_balance), SF(s_unneeded_left_neighbor),
61769 SF(s_good_search_by_key_reada), SF(s_bmaps),
61770 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
61771 index f8adaee..0eeeeca 100644
61772 --- a/fs/reiserfs/reiserfs.h
61773 +++ b/fs/reiserfs/reiserfs.h
61774 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
61775 /* Comment? -Hans */
61776 wait_queue_head_t s_wait;
61777 /* To be obsoleted soon by per buffer seals.. -Hans */
61778 - atomic_t s_generation_counter; // increased by one every time the
61779 + atomic_unchecked_t s_generation_counter; // increased by one every time the
61780 // tree gets re-balanced
61781 unsigned long s_properties; /* File system properties. Currently holds
61782 on-disk FS format */
61783 @@ -1982,7 +1982,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
61784 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
61785
61786 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
61787 -#define get_generation(s) atomic_read (&fs_generation(s))
61788 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
61789 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
61790 #define __fs_changed(gen,s) (gen != get_generation (s))
61791 #define fs_changed(gen,s) \
61792 diff --git a/fs/select.c b/fs/select.c
61793 index dfd5cb1..1754d57 100644
61794 --- a/fs/select.c
61795 +++ b/fs/select.c
61796 @@ -20,6 +20,7 @@
61797 #include <linux/export.h>
61798 #include <linux/slab.h>
61799 #include <linux/poll.h>
61800 +#include <linux/security.h>
61801 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
61802 #include <linux/file.h>
61803 #include <linux/fdtable.h>
61804 @@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
61805 struct poll_list *walk = head;
61806 unsigned long todo = nfds;
61807
61808 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
61809 if (nfds > rlimit(RLIMIT_NOFILE))
61810 return -EINVAL;
61811
61812 diff --git a/fs/seq_file.c b/fs/seq_file.c
61813 index a290157..ec3211a 100644
61814 --- a/fs/seq_file.c
61815 +++ b/fs/seq_file.c
61816 @@ -10,6 +10,7 @@
61817 #include <linux/seq_file.h>
61818 #include <linux/slab.h>
61819 #include <linux/cred.h>
61820 +#include <linux/sched.h>
61821
61822 #include <asm/uaccess.h>
61823 #include <asm/page.h>
61824 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
61825 #ifdef CONFIG_USER_NS
61826 p->user_ns = file->f_cred->user_ns;
61827 #endif
61828 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61829 + p->exec_id = current->exec_id;
61830 +#endif
61831
61832 /*
61833 * Wrappers around seq_open(e.g. swaps_open) need to be
61834 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
61835 return 0;
61836 }
61837 if (!m->buf) {
61838 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
61839 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
61840 if (!m->buf)
61841 return -ENOMEM;
61842 }
61843 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
61844 Eoverflow:
61845 m->op->stop(m, p);
61846 kfree(m->buf);
61847 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
61848 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
61849 return !m->buf ? -ENOMEM : -EAGAIN;
61850 }
61851
61852 @@ -152,7 +156,7 @@ Eoverflow:
61853 ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61854 {
61855 struct seq_file *m = file->private_data;
61856 - size_t copied = 0;
61857 + ssize_t copied = 0;
61858 loff_t pos;
61859 size_t n;
61860 void *p;
61861 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61862
61863 /* grab buffer if we didn't have one */
61864 if (!m->buf) {
61865 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
61866 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
61867 if (!m->buf)
61868 goto Enomem;
61869 }
61870 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61871 goto Fill;
61872 m->op->stop(m, p);
61873 kfree(m->buf);
61874 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
61875 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
61876 if (!m->buf)
61877 goto Enomem;
61878 m->count = 0;
61879 @@ -583,7 +587,7 @@ static void single_stop(struct seq_file *p, void *v)
61880 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
61881 void *data)
61882 {
61883 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
61884 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
61885 int res = -ENOMEM;
61886
61887 if (op) {
61888 diff --git a/fs/splice.c b/fs/splice.c
61889 index 3b7ee65..87fc2e4 100644
61890 --- a/fs/splice.c
61891 +++ b/fs/splice.c
61892 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61893 pipe_lock(pipe);
61894
61895 for (;;) {
61896 - if (!pipe->readers) {
61897 + if (!atomic_read(&pipe->readers)) {
61898 send_sig(SIGPIPE, current, 0);
61899 if (!ret)
61900 ret = -EPIPE;
61901 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61902 page_nr++;
61903 ret += buf->len;
61904
61905 - if (pipe->files)
61906 + if (atomic_read(&pipe->files))
61907 do_wakeup = 1;
61908
61909 if (!--spd->nr_pages)
61910 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61911 do_wakeup = 0;
61912 }
61913
61914 - pipe->waiting_writers++;
61915 + atomic_inc(&pipe->waiting_writers);
61916 pipe_wait(pipe);
61917 - pipe->waiting_writers--;
61918 + atomic_dec(&pipe->waiting_writers);
61919 }
61920
61921 pipe_unlock(pipe);
61922 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
61923 old_fs = get_fs();
61924 set_fs(get_ds());
61925 /* The cast to a user pointer is valid due to the set_fs() */
61926 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
61927 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
61928 set_fs(old_fs);
61929
61930 return res;
61931 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
61932 old_fs = get_fs();
61933 set_fs(get_ds());
61934 /* The cast to a user pointer is valid due to the set_fs() */
61935 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
61936 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
61937 set_fs(old_fs);
61938
61939 return res;
61940 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
61941 goto err;
61942
61943 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
61944 - vec[i].iov_base = (void __user *) page_address(page);
61945 + vec[i].iov_base = (void __force_user *) page_address(page);
61946 vec[i].iov_len = this_len;
61947 spd.pages[i] = page;
61948 spd.nr_pages++;
61949 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
61950 ops->release(pipe, buf);
61951 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
61952 pipe->nrbufs--;
61953 - if (pipe->files)
61954 + if (atomic_read(&pipe->files))
61955 sd->need_wakeup = true;
61956 }
61957
61958 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
61959 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
61960 {
61961 while (!pipe->nrbufs) {
61962 - if (!pipe->writers)
61963 + if (!atomic_read(&pipe->writers))
61964 return 0;
61965
61966 - if (!pipe->waiting_writers && sd->num_spliced)
61967 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
61968 return 0;
61969
61970 if (sd->flags & SPLICE_F_NONBLOCK)
61971 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
61972 * out of the pipe right after the splice_to_pipe(). So set
61973 * PIPE_READERS appropriately.
61974 */
61975 - pipe->readers = 1;
61976 + atomic_set(&pipe->readers, 1);
61977
61978 current->splice_pipe = pipe;
61979 }
61980 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
61981
61982 partial[buffers].offset = off;
61983 partial[buffers].len = plen;
61984 + partial[buffers].private = 0;
61985
61986 off = 0;
61987 len -= plen;
61988 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61989 ret = -ERESTARTSYS;
61990 break;
61991 }
61992 - if (!pipe->writers)
61993 + if (!atomic_read(&pipe->writers))
61994 break;
61995 - if (!pipe->waiting_writers) {
61996 + if (!atomic_read(&pipe->waiting_writers)) {
61997 if (flags & SPLICE_F_NONBLOCK) {
61998 ret = -EAGAIN;
61999 break;
62000 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
62001 pipe_lock(pipe);
62002
62003 while (pipe->nrbufs >= pipe->buffers) {
62004 - if (!pipe->readers) {
62005 + if (!atomic_read(&pipe->readers)) {
62006 send_sig(SIGPIPE, current, 0);
62007 ret = -EPIPE;
62008 break;
62009 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
62010 ret = -ERESTARTSYS;
62011 break;
62012 }
62013 - pipe->waiting_writers++;
62014 + atomic_inc(&pipe->waiting_writers);
62015 pipe_wait(pipe);
62016 - pipe->waiting_writers--;
62017 + atomic_dec(&pipe->waiting_writers);
62018 }
62019
62020 pipe_unlock(pipe);
62021 @@ -1862,14 +1863,14 @@ retry:
62022 pipe_double_lock(ipipe, opipe);
62023
62024 do {
62025 - if (!opipe->readers) {
62026 + if (!atomic_read(&opipe->readers)) {
62027 send_sig(SIGPIPE, current, 0);
62028 if (!ret)
62029 ret = -EPIPE;
62030 break;
62031 }
62032
62033 - if (!ipipe->nrbufs && !ipipe->writers)
62034 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
62035 break;
62036
62037 /*
62038 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
62039 pipe_double_lock(ipipe, opipe);
62040
62041 do {
62042 - if (!opipe->readers) {
62043 + if (!atomic_read(&opipe->readers)) {
62044 send_sig(SIGPIPE, current, 0);
62045 if (!ret)
62046 ret = -EPIPE;
62047 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
62048 * return EAGAIN if we have the potential of some data in the
62049 * future, otherwise just return 0
62050 */
62051 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
62052 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
62053 ret = -EAGAIN;
62054
62055 pipe_unlock(ipipe);
62056 diff --git a/fs/stat.c b/fs/stat.c
62057 index ae0c3ce..9ee641c 100644
62058 --- a/fs/stat.c
62059 +++ b/fs/stat.c
62060 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
62061 stat->gid = inode->i_gid;
62062 stat->rdev = inode->i_rdev;
62063 stat->size = i_size_read(inode);
62064 - stat->atime = inode->i_atime;
62065 - stat->mtime = inode->i_mtime;
62066 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
62067 + stat->atime = inode->i_ctime;
62068 + stat->mtime = inode->i_ctime;
62069 + } else {
62070 + stat->atime = inode->i_atime;
62071 + stat->mtime = inode->i_mtime;
62072 + }
62073 stat->ctime = inode->i_ctime;
62074 stat->blksize = (1 << inode->i_blkbits);
62075 stat->blocks = inode->i_blocks;
62076 @@ -52,9 +57,16 @@ EXPORT_SYMBOL(generic_fillattr);
62077 int vfs_getattr_nosec(struct path *path, struct kstat *stat)
62078 {
62079 struct inode *inode = path->dentry->d_inode;
62080 + int retval;
62081
62082 - if (inode->i_op->getattr)
62083 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
62084 + if (inode->i_op->getattr) {
62085 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
62086 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
62087 + stat->atime = stat->ctime;
62088 + stat->mtime = stat->ctime;
62089 + }
62090 + return retval;
62091 + }
62092
62093 generic_fillattr(inode, stat);
62094 return 0;
62095 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
62096 index c590cab..6dfd6fc 100644
62097 --- a/fs/sysfs/bin.c
62098 +++ b/fs/sysfs/bin.c
62099 @@ -234,13 +234,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
62100 return ret;
62101 }
62102
62103 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
62104 - void *buf, int len, int write)
62105 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
62106 + void *buf, size_t len, int write)
62107 {
62108 struct file *file = vma->vm_file;
62109 struct bin_buffer *bb = file->private_data;
62110 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
62111 - int ret;
62112 + ssize_t ret;
62113
62114 if (!bb->vm_ops)
62115 return -EINVAL;
62116 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
62117 index 4d83ced..049dc45 100644
62118 --- a/fs/sysfs/dir.c
62119 +++ b/fs/sysfs/dir.c
62120 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
62121 *
62122 * Returns 31 bit hash of ns + name (so it fits in an off_t )
62123 */
62124 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
62125 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
62126 {
62127 unsigned long hash = init_name_hash();
62128 unsigned int len = strlen(name);
62129 @@ -675,6 +675,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
62130 struct sysfs_dirent *sd;
62131 int rc;
62132
62133 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
62134 + const char *parent_name = parent_sd->s_name;
62135 +
62136 + mode = S_IFDIR | S_IRWXU;
62137 +
62138 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
62139 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
62140 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
62141 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
62142 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
62143 +#endif
62144 +
62145 /* allocate */
62146 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
62147 if (!sd)
62148 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
62149 index 15ef5eb..e474372 100644
62150 --- a/fs/sysfs/file.c
62151 +++ b/fs/sysfs/file.c
62152 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
62153
62154 struct sysfs_open_dirent {
62155 atomic_t refcnt;
62156 - atomic_t event;
62157 + atomic_unchecked_t event;
62158 wait_queue_head_t poll;
62159 struct list_head buffers; /* goes through sysfs_buffer.list */
62160 };
62161 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry *dentry, struct sysfs_buffer *buffer)
62162 if (!sysfs_get_active(attr_sd))
62163 return -ENODEV;
62164
62165 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
62166 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
62167 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
62168
62169 sysfs_put_active(attr_sd);
62170 @@ -284,7 +284,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
62171 return -ENOMEM;
62172
62173 atomic_set(&new_od->refcnt, 0);
62174 - atomic_set(&new_od->event, 1);
62175 + atomic_set_unchecked(&new_od->event, 1);
62176 init_waitqueue_head(&new_od->poll);
62177 INIT_LIST_HEAD(&new_od->buffers);
62178 goto retry;
62179 @@ -430,7 +430,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
62180
62181 sysfs_put_active(attr_sd);
62182
62183 - if (buffer->event != atomic_read(&od->event))
62184 + if (buffer->event != atomic_read_unchecked(&od->event))
62185 goto trigger;
62186
62187 return DEFAULT_POLLMASK;
62188 @@ -450,7 +450,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
62189 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
62190 od = sd->s_attr.open;
62191 if (od) {
62192 - atomic_inc(&od->event);
62193 + atomic_inc_unchecked(&od->event);
62194 wake_up_interruptible(&od->poll);
62195 }
62196 }
62197 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
62198 index 2dd4507..62a215a 100644
62199 --- a/fs/sysfs/symlink.c
62200 +++ b/fs/sysfs/symlink.c
62201 @@ -308,7 +308,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
62202 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd,
62203 void *cookie)
62204 {
62205 - char *page = nd_get_link(nd);
62206 + const char *page = nd_get_link(nd);
62207 if (!IS_ERR(page))
62208 free_page((unsigned long)page);
62209 }
62210 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
62211 index 69d4889..a810bd4 100644
62212 --- a/fs/sysv/sysv.h
62213 +++ b/fs/sysv/sysv.h
62214 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
62215 #endif
62216 }
62217
62218 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
62219 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
62220 {
62221 if (sbi->s_bytesex == BYTESEX_PDP)
62222 return PDP_swab((__force __u32)n);
62223 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
62224 index e18b988..f1d4ad0f 100644
62225 --- a/fs/ubifs/io.c
62226 +++ b/fs/ubifs/io.c
62227 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
62228 return err;
62229 }
62230
62231 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
62232 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
62233 {
62234 int err;
62235
62236 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
62237 index c175b4d..8f36a16 100644
62238 --- a/fs/udf/misc.c
62239 +++ b/fs/udf/misc.c
62240 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
62241
62242 u8 udf_tag_checksum(const struct tag *t)
62243 {
62244 - u8 *data = (u8 *)t;
62245 + const u8 *data = (const u8 *)t;
62246 u8 checksum = 0;
62247 int i;
62248 for (i = 0; i < sizeof(struct tag); ++i)
62249 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
62250 index 8d974c4..b82f6ec 100644
62251 --- a/fs/ufs/swab.h
62252 +++ b/fs/ufs/swab.h
62253 @@ -22,7 +22,7 @@ enum {
62254 BYTESEX_BE
62255 };
62256
62257 -static inline u64
62258 +static inline u64 __intentional_overflow(-1)
62259 fs64_to_cpu(struct super_block *sbp, __fs64 n)
62260 {
62261 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
62262 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
62263 return (__force __fs64)cpu_to_be64(n);
62264 }
62265
62266 -static inline u32
62267 +static inline u32 __intentional_overflow(-1)
62268 fs32_to_cpu(struct super_block *sbp, __fs32 n)
62269 {
62270 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
62271 diff --git a/fs/utimes.c b/fs/utimes.c
62272 index f4fb7ec..3fe03c0 100644
62273 --- a/fs/utimes.c
62274 +++ b/fs/utimes.c
62275 @@ -1,6 +1,7 @@
62276 #include <linux/compiler.h>
62277 #include <linux/file.h>
62278 #include <linux/fs.h>
62279 +#include <linux/security.h>
62280 #include <linux/linkage.h>
62281 #include <linux/mount.h>
62282 #include <linux/namei.h>
62283 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
62284 goto mnt_drop_write_and_out;
62285 }
62286 }
62287 +
62288 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
62289 + error = -EACCES;
62290 + goto mnt_drop_write_and_out;
62291 + }
62292 +
62293 mutex_lock(&inode->i_mutex);
62294 error = notify_change(path->dentry, &newattrs);
62295 mutex_unlock(&inode->i_mutex);
62296 diff --git a/fs/xattr.c b/fs/xattr.c
62297 index 3377dff..f394815 100644
62298 --- a/fs/xattr.c
62299 +++ b/fs/xattr.c
62300 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
62301 return rc;
62302 }
62303
62304 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
62305 +ssize_t
62306 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
62307 +{
62308 + struct inode *inode = dentry->d_inode;
62309 + ssize_t error;
62310 +
62311 + error = inode_permission(inode, MAY_EXEC);
62312 + if (error)
62313 + return error;
62314 +
62315 + if (inode->i_op->getxattr)
62316 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
62317 + else
62318 + error = -EOPNOTSUPP;
62319 +
62320 + return error;
62321 +}
62322 +EXPORT_SYMBOL(pax_getxattr);
62323 +#endif
62324 +
62325 ssize_t
62326 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
62327 {
62328 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
62329 * Extended attribute SET operations
62330 */
62331 static long
62332 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
62333 +setxattr(struct path *path, const char __user *name, const void __user *value,
62334 size_t size, int flags)
62335 {
62336 int error;
62337 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
62338 posix_acl_fix_xattr_from_user(kvalue, size);
62339 }
62340
62341 - error = vfs_setxattr(d, kname, kvalue, size, flags);
62342 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
62343 + error = -EACCES;
62344 + goto out;
62345 + }
62346 +
62347 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
62348 out:
62349 if (vvalue)
62350 vfree(vvalue);
62351 @@ -377,7 +403,7 @@ retry:
62352 return error;
62353 error = mnt_want_write(path.mnt);
62354 if (!error) {
62355 - error = setxattr(path.dentry, name, value, size, flags);
62356 + error = setxattr(&path, name, value, size, flags);
62357 mnt_drop_write(path.mnt);
62358 }
62359 path_put(&path);
62360 @@ -401,7 +427,7 @@ retry:
62361 return error;
62362 error = mnt_want_write(path.mnt);
62363 if (!error) {
62364 - error = setxattr(path.dentry, name, value, size, flags);
62365 + error = setxattr(&path, name, value, size, flags);
62366 mnt_drop_write(path.mnt);
62367 }
62368 path_put(&path);
62369 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
62370 const void __user *,value, size_t, size, int, flags)
62371 {
62372 struct fd f = fdget(fd);
62373 - struct dentry *dentry;
62374 int error = -EBADF;
62375
62376 if (!f.file)
62377 return error;
62378 - dentry = f.file->f_path.dentry;
62379 - audit_inode(NULL, dentry, 0);
62380 + audit_inode(NULL, f.file->f_path.dentry, 0);
62381 error = mnt_want_write_file(f.file);
62382 if (!error) {
62383 - error = setxattr(dentry, name, value, size, flags);
62384 + error = setxattr(&f.file->f_path, name, value, size, flags);
62385 mnt_drop_write_file(f.file);
62386 }
62387 fdput(f);
62388 @@ -626,7 +650,7 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
62389 * Extended attribute REMOVE operations
62390 */
62391 static long
62392 -removexattr(struct dentry *d, const char __user *name)
62393 +removexattr(struct path *path, const char __user *name)
62394 {
62395 int error;
62396 char kname[XATTR_NAME_MAX + 1];
62397 @@ -637,7 +661,10 @@ removexattr(struct dentry *d, const char __user *name)
62398 if (error < 0)
62399 return error;
62400
62401 - return vfs_removexattr(d, kname);
62402 + if (!gr_acl_handle_removexattr(path->dentry, path->mnt))
62403 + return -EACCES;
62404 +
62405 + return vfs_removexattr(path->dentry, kname);
62406 }
62407
62408 SYSCALL_DEFINE2(removexattr, const char __user *, pathname,
62409 @@ -652,7 +679,7 @@ retry:
62410 return error;
62411 error = mnt_want_write(path.mnt);
62412 if (!error) {
62413 - error = removexattr(path.dentry, name);
62414 + error = removexattr(&path, name);
62415 mnt_drop_write(path.mnt);
62416 }
62417 path_put(&path);
62418 @@ -675,7 +702,7 @@ retry:
62419 return error;
62420 error = mnt_want_write(path.mnt);
62421 if (!error) {
62422 - error = removexattr(path.dentry, name);
62423 + error = removexattr(&path, name);
62424 mnt_drop_write(path.mnt);
62425 }
62426 path_put(&path);
62427 @@ -689,16 +716,16 @@ retry:
62428 SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
62429 {
62430 struct fd f = fdget(fd);
62431 - struct dentry *dentry;
62432 + struct path *path;
62433 int error = -EBADF;
62434
62435 if (!f.file)
62436 return error;
62437 - dentry = f.file->f_path.dentry;
62438 - audit_inode(NULL, dentry, 0);
62439 + path = &f.file->f_path;
62440 + audit_inode(NULL, path->dentry, 0);
62441 error = mnt_want_write_file(f.file);
62442 if (!error) {
62443 - error = removexattr(dentry, name);
62444 + error = removexattr(path, name);
62445 mnt_drop_write_file(f.file);
62446 }
62447 fdput(f);
62448 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
62449 index 9fbea87..6b19972 100644
62450 --- a/fs/xattr_acl.c
62451 +++ b/fs/xattr_acl.c
62452 @@ -76,8 +76,8 @@ struct posix_acl *
62453 posix_acl_from_xattr(struct user_namespace *user_ns,
62454 const void *value, size_t size)
62455 {
62456 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
62457 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
62458 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
62459 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
62460 int count;
62461 struct posix_acl *acl;
62462 struct posix_acl_entry *acl_e;
62463 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
62464 index f47e65c..e7125d9 100644
62465 --- a/fs/xfs/xfs_bmap.c
62466 +++ b/fs/xfs/xfs_bmap.c
62467 @@ -586,7 +586,7 @@ xfs_bmap_validate_ret(
62468
62469 #else
62470 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
62471 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
62472 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
62473 #endif /* DEBUG */
62474
62475 /*
62476 diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
62477 index 8f84153..7ce60d0 100644
62478 --- a/fs/xfs/xfs_dir2_readdir.c
62479 +++ b/fs/xfs/xfs_dir2_readdir.c
62480 @@ -160,7 +160,12 @@ xfs_dir2_sf_getdents(
62481 ino = xfs_dir3_sfe_get_ino(mp, sfp, sfep);
62482 filetype = xfs_dir3_sfe_get_ftype(mp, sfp, sfep);
62483 ctx->pos = off & 0x7fffffff;
62484 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
62485 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
62486 + char name[sfep->namelen];
62487 + memcpy(name, sfep->name, sfep->namelen);
62488 + if (!dir_emit(ctx, name, sfep->namelen, ino, xfs_dir3_get_dtype(mp, filetype)))
62489 + return 0;
62490 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
62491 xfs_dir3_get_dtype(mp, filetype)))
62492 return 0;
62493 sfep = xfs_dir3_sf_nextentry(mp, sfp, sfep);
62494 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
62495 index 8c8ef24..689f742 100644
62496 --- a/fs/xfs/xfs_ioctl.c
62497 +++ b/fs/xfs/xfs_ioctl.c
62498 @@ -127,7 +127,7 @@ xfs_find_handle(
62499 }
62500
62501 error = -EFAULT;
62502 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
62503 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
62504 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
62505 goto out_put;
62506
62507 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
62508 index 2b8952d..a60c6be 100644
62509 --- a/fs/xfs/xfs_iops.c
62510 +++ b/fs/xfs/xfs_iops.c
62511 @@ -401,7 +401,7 @@ xfs_vn_put_link(
62512 struct nameidata *nd,
62513 void *p)
62514 {
62515 - char *s = nd_get_link(nd);
62516 + const char *s = nd_get_link(nd);
62517
62518 if (!IS_ERR(s))
62519 kfree(s);
62520 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
62521 new file mode 100644
62522 index 0000000..5b2538b
62523 --- /dev/null
62524 +++ b/grsecurity/Kconfig
62525 @@ -0,0 +1,1116 @@
62526 +#
62527 +# grecurity configuration
62528 +#
62529 +menu "Memory Protections"
62530 +depends on GRKERNSEC
62531 +
62532 +config GRKERNSEC_KMEM
62533 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
62534 + default y if GRKERNSEC_CONFIG_AUTO
62535 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
62536 + help
62537 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
62538 + be written to or read from to modify or leak the contents of the running
62539 + kernel. /dev/port will also not be allowed to be opened, and support
62540 + for /dev/cpu/*/msr and kexec will be removed. If you have module
62541 + support disabled, enabling this will close up six ways that are
62542 + currently used to insert malicious code into the running kernel.
62543 +
62544 + Even with this feature enabled, we still highly recommend that
62545 + you use the RBAC system, as it is still possible for an attacker to
62546 + modify the running kernel through other more obscure methods.
62547 +
62548 + Enabling this feature will prevent the "cpupower" and "powertop" tools
62549 + from working.
62550 +
62551 + It is highly recommended that you say Y here if you meet all the
62552 + conditions above.
62553 +
62554 +config GRKERNSEC_VM86
62555 + bool "Restrict VM86 mode"
62556 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62557 + depends on X86_32
62558 +
62559 + help
62560 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
62561 + make use of a special execution mode on 32bit x86 processors called
62562 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
62563 + video cards and will still work with this option enabled. The purpose
62564 + of the option is to prevent exploitation of emulation errors in
62565 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
62566 + Nearly all users should be able to enable this option.
62567 +
62568 +config GRKERNSEC_IO
62569 + bool "Disable privileged I/O"
62570 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62571 + depends on X86
62572 + select RTC_CLASS
62573 + select RTC_INTF_DEV
62574 + select RTC_DRV_CMOS
62575 +
62576 + help
62577 + If you say Y here, all ioperm and iopl calls will return an error.
62578 + Ioperm and iopl can be used to modify the running kernel.
62579 + Unfortunately, some programs need this access to operate properly,
62580 + the most notable of which are XFree86 and hwclock. hwclock can be
62581 + remedied by having RTC support in the kernel, so real-time
62582 + clock support is enabled if this option is enabled, to ensure
62583 + that hwclock operates correctly.
62584 +
62585 + If you're using XFree86 or a version of Xorg from 2012 or earlier,
62586 + you may not be able to boot into a graphical environment with this
62587 + option enabled. In this case, you should use the RBAC system instead.
62588 +
62589 +config GRKERNSEC_JIT_HARDEN
62590 + bool "Harden BPF JIT against spray attacks"
62591 + default y if GRKERNSEC_CONFIG_AUTO
62592 + depends on BPF_JIT
62593 + help
62594 + If you say Y here, the native code generated by the kernel's Berkeley
62595 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
62596 + attacks that attempt to fit attacker-beneficial instructions in
62597 + 32bit immediate fields of JIT-generated native instructions. The
62598 + attacker will generally aim to cause an unintended instruction sequence
62599 + of JIT-generated native code to execute by jumping into the middle of
62600 + a generated instruction. This feature effectively randomizes the 32bit
62601 + immediate constants present in the generated code to thwart such attacks.
62602 +
62603 + If you're using KERNEXEC, it's recommended that you enable this option
62604 + to supplement the hardening of the kernel.
62605 +
62606 +config GRKERNSEC_PERF_HARDEN
62607 + bool "Disable unprivileged PERF_EVENTS usage by default"
62608 + default y if GRKERNSEC_CONFIG_AUTO
62609 + depends on PERF_EVENTS
62610 + help
62611 + If you say Y here, the range of acceptable values for the
62612 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
62613 + default to a new value: 3. When the sysctl is set to this value, no
62614 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
62615 +
62616 + Though PERF_EVENTS can be used legitimately for performance monitoring
62617 + and low-level application profiling, it is forced on regardless of
62618 + configuration, has been at fault for several vulnerabilities, and
62619 + creates new opportunities for side channels and other information leaks.
62620 +
62621 + This feature puts PERF_EVENTS into a secure default state and permits
62622 + the administrator to change out of it temporarily if unprivileged
62623 + application profiling is needed.
62624 +
62625 +config GRKERNSEC_RAND_THREADSTACK
62626 + bool "Insert random gaps between thread stacks"
62627 + default y if GRKERNSEC_CONFIG_AUTO
62628 + depends on PAX_RANDMMAP && !PPC
62629 + help
62630 + If you say Y here, a random-sized gap will be enforced between allocated
62631 + thread stacks. Glibc's NPTL and other threading libraries that
62632 + pass MAP_STACK to the kernel for thread stack allocation are supported.
62633 + The implementation currently provides 8 bits of entropy for the gap.
62634 +
62635 + Many distributions do not compile threaded remote services with the
62636 + -fstack-check argument to GCC, causing the variable-sized stack-based
62637 + allocator, alloca(), to not probe the stack on allocation. This
62638 + permits an unbounded alloca() to skip over any guard page and potentially
62639 + modify another thread's stack reliably. An enforced random gap
62640 + reduces the reliability of such an attack and increases the chance
62641 + that such a read/write to another thread's stack instead lands in
62642 + an unmapped area, causing a crash and triggering grsecurity's
62643 + anti-bruteforcing logic.
62644 +
62645 +config GRKERNSEC_PROC_MEMMAP
62646 + bool "Harden ASLR against information leaks and entropy reduction"
62647 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
62648 + depends on PAX_NOEXEC || PAX_ASLR
62649 + help
62650 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
62651 + give no information about the addresses of its mappings if
62652 + PaX features that rely on random addresses are enabled on the task.
62653 + In addition to sanitizing this information and disabling other
62654 + dangerous sources of information, this option causes reads of sensitive
62655 + /proc/<pid> entries where the file descriptor was opened in a different
62656 + task than the one performing the read. Such attempts are logged.
62657 + This option also limits argv/env strings for suid/sgid binaries
62658 + to 512KB to prevent a complete exhaustion of the stack entropy provided
62659 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
62660 + binaries to prevent alternative mmap layouts from being abused.
62661 +
62662 + If you use PaX it is essential that you say Y here as it closes up
62663 + several holes that make full ASLR useless locally.
62664 +
62665 +config GRKERNSEC_BRUTE
62666 + bool "Deter exploit bruteforcing"
62667 + default y if GRKERNSEC_CONFIG_AUTO
62668 + help
62669 + If you say Y here, attempts to bruteforce exploits against forking
62670 + daemons such as apache or sshd, as well as against suid/sgid binaries
62671 + will be deterred. When a child of a forking daemon is killed by PaX
62672 + or crashes due to an illegal instruction or other suspicious signal,
62673 + the parent process will be delayed 30 seconds upon every subsequent
62674 + fork until the administrator is able to assess the situation and
62675 + restart the daemon.
62676 + In the suid/sgid case, the attempt is logged, the user has all their
62677 + existing instances of the suid/sgid binary terminated and will
62678 + be unable to execute any suid/sgid binaries for 15 minutes.
62679 +
62680 + It is recommended that you also enable signal logging in the auditing
62681 + section so that logs are generated when a process triggers a suspicious
62682 + signal.
62683 + If the sysctl option is enabled, a sysctl option with name
62684 + "deter_bruteforce" is created.
62685 +
62686 +
62687 +config GRKERNSEC_MODHARDEN
62688 + bool "Harden module auto-loading"
62689 + default y if GRKERNSEC_CONFIG_AUTO
62690 + depends on MODULES
62691 + help
62692 + If you say Y here, module auto-loading in response to use of some
62693 + feature implemented by an unloaded module will be restricted to
62694 + root users. Enabling this option helps defend against attacks
62695 + by unprivileged users who abuse the auto-loading behavior to
62696 + cause a vulnerable module to load that is then exploited.
62697 +
62698 + If this option prevents a legitimate use of auto-loading for a
62699 + non-root user, the administrator can execute modprobe manually
62700 + with the exact name of the module mentioned in the alert log.
62701 + Alternatively, the administrator can add the module to the list
62702 + of modules loaded at boot by modifying init scripts.
62703 +
62704 + Modification of init scripts will most likely be needed on
62705 + Ubuntu servers with encrypted home directory support enabled,
62706 + as the first non-root user logging in will cause the ecb(aes),
62707 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
62708 +
62709 +config GRKERNSEC_HIDESYM
62710 + bool "Hide kernel symbols"
62711 + default y if GRKERNSEC_CONFIG_AUTO
62712 + select PAX_USERCOPY_SLABS
62713 + help
62714 + If you say Y here, getting information on loaded modules, and
62715 + displaying all kernel symbols through a syscall will be restricted
62716 + to users with CAP_SYS_MODULE. For software compatibility reasons,
62717 + /proc/kallsyms will be restricted to the root user. The RBAC
62718 + system can hide that entry even from root.
62719 +
62720 + This option also prevents leaking of kernel addresses through
62721 + several /proc entries.
62722 +
62723 + Note that this option is only effective provided the following
62724 + conditions are met:
62725 + 1) The kernel using grsecurity is not precompiled by some distribution
62726 + 2) You have also enabled GRKERNSEC_DMESG
62727 + 3) You are using the RBAC system and hiding other files such as your
62728 + kernel image and System.map. Alternatively, enabling this option
62729 + causes the permissions on /boot, /lib/modules, and the kernel
62730 + source directory to change at compile time to prevent
62731 + reading by non-root users.
62732 + If the above conditions are met, this option will aid in providing a
62733 + useful protection against local kernel exploitation of overflows
62734 + and arbitrary read/write vulnerabilities.
62735 +
62736 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
62737 + in addition to this feature.
62738 +
62739 +config GRKERNSEC_KERN_LOCKOUT
62740 + bool "Active kernel exploit response"
62741 + default y if GRKERNSEC_CONFIG_AUTO
62742 + depends on X86 || ARM || PPC || SPARC
62743 + help
62744 + If you say Y here, when a PaX alert is triggered due to suspicious
62745 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
62746 + or an OOPS occurs due to bad memory accesses, instead of just
62747 + terminating the offending process (and potentially allowing
62748 + a subsequent exploit from the same user), we will take one of two
62749 + actions:
62750 + If the user was root, we will panic the system
62751 + If the user was non-root, we will log the attempt, terminate
62752 + all processes owned by the user, then prevent them from creating
62753 + any new processes until the system is restarted
62754 + This deters repeated kernel exploitation/bruteforcing attempts
62755 + and is useful for later forensics.
62756 +
62757 +config GRKERNSEC_OLD_ARM_USERLAND
62758 + bool "Old ARM userland compatibility"
62759 + depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
62760 + help
62761 + If you say Y here, stubs of executable code to perform such operations
62762 + as "compare-exchange" will be placed at fixed locations in the ARM vector
62763 + table. This is unfortunately needed for old ARM userland meant to run
62764 + across a wide range of processors. Without this option enabled,
62765 + the get_tls and data memory barrier stubs will be emulated by the kernel,
62766 + which is enough for Linaro userlands or other userlands designed for v6
62767 + and newer ARM CPUs. It's recommended that you try without this option enabled
62768 + first, and only enable it if your userland does not boot (it will likely fail
62769 + at init time).
62770 +
62771 +endmenu
62772 +menu "Role Based Access Control Options"
62773 +depends on GRKERNSEC
62774 +
62775 +config GRKERNSEC_RBAC_DEBUG
62776 + bool
62777 +
62778 +config GRKERNSEC_NO_RBAC
62779 + bool "Disable RBAC system"
62780 + help
62781 + If you say Y here, the /dev/grsec device will be removed from the kernel,
62782 + preventing the RBAC system from being enabled. You should only say Y
62783 + here if you have no intention of using the RBAC system, so as to prevent
62784 + an attacker with root access from misusing the RBAC system to hide files
62785 + and processes when loadable module support and /dev/[k]mem have been
62786 + locked down.
62787 +
62788 +config GRKERNSEC_ACL_HIDEKERN
62789 + bool "Hide kernel processes"
62790 + help
62791 + If you say Y here, all kernel threads will be hidden to all
62792 + processes but those whose subject has the "view hidden processes"
62793 + flag.
62794 +
62795 +config GRKERNSEC_ACL_MAXTRIES
62796 + int "Maximum tries before password lockout"
62797 + default 3
62798 + help
62799 + This option enforces the maximum number of times a user can attempt
62800 + to authorize themselves with the grsecurity RBAC system before being
62801 + denied the ability to attempt authorization again for a specified time.
62802 + The lower the number, the harder it will be to brute-force a password.
62803 +
62804 +config GRKERNSEC_ACL_TIMEOUT
62805 + int "Time to wait after max password tries, in seconds"
62806 + default 30
62807 + help
62808 + This option specifies the time the user must wait after attempting to
62809 + authorize to the RBAC system with the maximum number of invalid
62810 + passwords. The higher the number, the harder it will be to brute-force
62811 + a password.
62812 +
62813 +endmenu
62814 +menu "Filesystem Protections"
62815 +depends on GRKERNSEC
62816 +
62817 +config GRKERNSEC_PROC
62818 + bool "Proc restrictions"
62819 + default y if GRKERNSEC_CONFIG_AUTO
62820 + help
62821 + If you say Y here, the permissions of the /proc filesystem
62822 + will be altered to enhance system security and privacy. You MUST
62823 + choose either a user only restriction or a user and group restriction.
62824 + Depending upon the option you choose, you can either restrict users to
62825 + see only the processes they themselves run, or choose a group that can
62826 + view all processes and files normally restricted to root if you choose
62827 + the "restrict to user only" option. NOTE: If you're running identd or
62828 + ntpd as a non-root user, you will have to run it as the group you
62829 + specify here.
62830 +
62831 +config GRKERNSEC_PROC_USER
62832 + bool "Restrict /proc to user only"
62833 + depends on GRKERNSEC_PROC
62834 + help
62835 + If you say Y here, non-root users will only be able to view their own
62836 + processes, and restricts them from viewing network-related information,
62837 + and viewing kernel symbol and module information.
62838 +
62839 +config GRKERNSEC_PROC_USERGROUP
62840 + bool "Allow special group"
62841 + default y if GRKERNSEC_CONFIG_AUTO
62842 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
62843 + help
62844 + If you say Y here, you will be able to select a group that will be
62845 + able to view all processes and network-related information. If you've
62846 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
62847 + remain hidden. This option is useful if you want to run identd as
62848 + a non-root user. The group you select may also be chosen at boot time
62849 + via "grsec_proc_gid=" on the kernel commandline.
62850 +
62851 +config GRKERNSEC_PROC_GID
62852 + int "GID for special group"
62853 + depends on GRKERNSEC_PROC_USERGROUP
62854 + default 1001
62855 +
62856 +config GRKERNSEC_PROC_ADD
62857 + bool "Additional restrictions"
62858 + default y if GRKERNSEC_CONFIG_AUTO
62859 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
62860 + help
62861 + If you say Y here, additional restrictions will be placed on
62862 + /proc that keep normal users from viewing device information and
62863 + slabinfo information that could be useful for exploits.
62864 +
62865 +config GRKERNSEC_LINK
62866 + bool "Linking restrictions"
62867 + default y if GRKERNSEC_CONFIG_AUTO
62868 + help
62869 + If you say Y here, /tmp race exploits will be prevented, since users
62870 + will no longer be able to follow symlinks owned by other users in
62871 + world-writable +t directories (e.g. /tmp), unless the owner of the
62872 + symlink is the owner of the directory. users will also not be
62873 + able to hardlink to files they do not own. If the sysctl option is
62874 + enabled, a sysctl option with name "linking_restrictions" is created.
62875 +
62876 +config GRKERNSEC_SYMLINKOWN
62877 + bool "Kernel-enforced SymlinksIfOwnerMatch"
62878 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
62879 + help
62880 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
62881 + that prevents it from being used as a security feature. As Apache
62882 + verifies the symlink by performing a stat() against the target of
62883 + the symlink before it is followed, an attacker can setup a symlink
62884 + to point to a same-owned file, then replace the symlink with one
62885 + that targets another user's file just after Apache "validates" the
62886 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
62887 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
62888 + will be in place for the group you specify. If the sysctl option
62889 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
62890 + created.
62891 +
62892 +config GRKERNSEC_SYMLINKOWN_GID
62893 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
62894 + depends on GRKERNSEC_SYMLINKOWN
62895 + default 1006
62896 + help
62897 + Setting this GID determines what group kernel-enforced
62898 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
62899 + is enabled, a sysctl option with name "symlinkown_gid" is created.
62900 +
62901 +config GRKERNSEC_FIFO
62902 + bool "FIFO restrictions"
62903 + default y if GRKERNSEC_CONFIG_AUTO
62904 + help
62905 + If you say Y here, users will not be able to write to FIFOs they don't
62906 + own in world-writable +t directories (e.g. /tmp), unless the owner of
62907 + the FIFO is the same owner of the directory it's held in. If the sysctl
62908 + option is enabled, a sysctl option with name "fifo_restrictions" is
62909 + created.
62910 +
62911 +config GRKERNSEC_SYSFS_RESTRICT
62912 + bool "Sysfs/debugfs restriction"
62913 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62914 + depends on SYSFS
62915 + help
62916 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
62917 + any filesystem normally mounted under it (e.g. debugfs) will be
62918 + mostly accessible only by root. These filesystems generally provide access
62919 + to hardware and debug information that isn't appropriate for unprivileged
62920 + users of the system. Sysfs and debugfs have also become a large source
62921 + of new vulnerabilities, ranging from infoleaks to local compromise.
62922 + There has been very little oversight with an eye toward security involved
62923 + in adding new exporters of information to these filesystems, so their
62924 + use is discouraged.
62925 + For reasons of compatibility, a few directories have been whitelisted
62926 + for access by non-root users:
62927 + /sys/fs/selinux
62928 + /sys/fs/fuse
62929 + /sys/devices/system/cpu
62930 +
62931 +config GRKERNSEC_ROFS
62932 + bool "Runtime read-only mount protection"
62933 + depends on SYSCTL
62934 + help
62935 + If you say Y here, a sysctl option with name "romount_protect" will
62936 + be created. By setting this option to 1 at runtime, filesystems
62937 + will be protected in the following ways:
62938 + * No new writable mounts will be allowed
62939 + * Existing read-only mounts won't be able to be remounted read/write
62940 + * Write operations will be denied on all block devices
62941 + This option acts independently of grsec_lock: once it is set to 1,
62942 + it cannot be turned off. Therefore, please be mindful of the resulting
62943 + behavior if this option is enabled in an init script on a read-only
62944 + filesystem.
62945 + Also be aware that as with other root-focused features, GRKERNSEC_KMEM
62946 + and GRKERNSEC_IO should be enabled and module loading disabled via
62947 + config or at runtime.
62948 + This feature is mainly intended for secure embedded systems.
62949 +
62950 +
62951 +config GRKERNSEC_DEVICE_SIDECHANNEL
62952 + bool "Eliminate stat/notify-based device sidechannels"
62953 + default y if GRKERNSEC_CONFIG_AUTO
62954 + help
62955 + If you say Y here, timing analyses on block or character
62956 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
62957 + will be thwarted for unprivileged users. If a process without
62958 + CAP_MKNOD stats such a device, the last access and last modify times
62959 + will match the device's create time. No access or modify events
62960 + will be triggered through inotify/dnotify/fanotify for such devices.
62961 + This feature will prevent attacks that may at a minimum
62962 + allow an attacker to determine the administrator's password length.
62963 +
62964 +config GRKERNSEC_CHROOT
62965 + bool "Chroot jail restrictions"
62966 + default y if GRKERNSEC_CONFIG_AUTO
62967 + help
62968 + If you say Y here, you will be able to choose several options that will
62969 + make breaking out of a chrooted jail much more difficult. If you
62970 + encounter no software incompatibilities with the following options, it
62971 + is recommended that you enable each one.
62972 +
62973 +config GRKERNSEC_CHROOT_MOUNT
62974 + bool "Deny mounts"
62975 + default y if GRKERNSEC_CONFIG_AUTO
62976 + depends on GRKERNSEC_CHROOT
62977 + help
62978 + If you say Y here, processes inside a chroot will not be able to
62979 + mount or remount filesystems. If the sysctl option is enabled, a
62980 + sysctl option with name "chroot_deny_mount" is created.
62981 +
62982 +config GRKERNSEC_CHROOT_DOUBLE
62983 + bool "Deny double-chroots"
62984 + default y if GRKERNSEC_CONFIG_AUTO
62985 + depends on GRKERNSEC_CHROOT
62986 + help
62987 + If you say Y here, processes inside a chroot will not be able to chroot
62988 + again outside the chroot. This is a widely used method of breaking
62989 + out of a chroot jail and should not be allowed. If the sysctl
62990 + option is enabled, a sysctl option with name
62991 + "chroot_deny_chroot" is created.
62992 +
62993 +config GRKERNSEC_CHROOT_PIVOT
62994 + bool "Deny pivot_root in chroot"
62995 + default y if GRKERNSEC_CONFIG_AUTO
62996 + depends on GRKERNSEC_CHROOT
62997 + help
62998 + If you say Y here, processes inside a chroot will not be able to use
62999 + a function called pivot_root() that was introduced in Linux 2.3.41. It
63000 + works similar to chroot in that it changes the root filesystem. This
63001 + function could be misused in a chrooted process to attempt to break out
63002 + of the chroot, and therefore should not be allowed. If the sysctl
63003 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
63004 + created.
63005 +
63006 +config GRKERNSEC_CHROOT_CHDIR
63007 + bool "Enforce chdir(\"/\") on all chroots"
63008 + default y if GRKERNSEC_CONFIG_AUTO
63009 + depends on GRKERNSEC_CHROOT
63010 + help
63011 + If you say Y here, the current working directory of all newly-chrooted
63012 + applications will be set to the the root directory of the chroot.
63013 + The man page on chroot(2) states:
63014 + Note that this call does not change the current working
63015 + directory, so that `.' can be outside the tree rooted at
63016 + `/'. In particular, the super-user can escape from a
63017 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
63018 +
63019 + It is recommended that you say Y here, since it's not known to break
63020 + any software. If the sysctl option is enabled, a sysctl option with
63021 + name "chroot_enforce_chdir" is created.
63022 +
63023 +config GRKERNSEC_CHROOT_CHMOD
63024 + bool "Deny (f)chmod +s"
63025 + default y if GRKERNSEC_CONFIG_AUTO
63026 + depends on GRKERNSEC_CHROOT
63027 + help
63028 + If you say Y here, processes inside a chroot will not be able to chmod
63029 + or fchmod files to make them have suid or sgid bits. This protects
63030 + against another published method of breaking a chroot. If the sysctl
63031 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
63032 + created.
63033 +
63034 +config GRKERNSEC_CHROOT_FCHDIR
63035 + bool "Deny fchdir out of chroot"
63036 + default y if GRKERNSEC_CONFIG_AUTO
63037 + depends on GRKERNSEC_CHROOT
63038 + help
63039 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
63040 + to a file descriptor of the chrooting process that points to a directory
63041 + outside the filesystem will be stopped. If the sysctl option
63042 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
63043 +
63044 +config GRKERNSEC_CHROOT_MKNOD
63045 + bool "Deny mknod"
63046 + default y if GRKERNSEC_CONFIG_AUTO
63047 + depends on GRKERNSEC_CHROOT
63048 + help
63049 + If you say Y here, processes inside a chroot will not be allowed to
63050 + mknod. The problem with using mknod inside a chroot is that it
63051 + would allow an attacker to create a device entry that is the same
63052 + as one on the physical root of your system, which could range from
63053 + anything from the console device to a device for your harddrive (which
63054 + they could then use to wipe the drive or steal data). It is recommended
63055 + that you say Y here, unless you run into software incompatibilities.
63056 + If the sysctl option is enabled, a sysctl option with name
63057 + "chroot_deny_mknod" is created.
63058 +
63059 +config GRKERNSEC_CHROOT_SHMAT
63060 + bool "Deny shmat() out of chroot"
63061 + default y if GRKERNSEC_CONFIG_AUTO
63062 + depends on GRKERNSEC_CHROOT
63063 + help
63064 + If you say Y here, processes inside a chroot will not be able to attach
63065 + to shared memory segments that were created outside of the chroot jail.
63066 + It is recommended that you say Y here. If the sysctl option is enabled,
63067 + a sysctl option with name "chroot_deny_shmat" is created.
63068 +
63069 +config GRKERNSEC_CHROOT_UNIX
63070 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
63071 + default y if GRKERNSEC_CONFIG_AUTO
63072 + depends on GRKERNSEC_CHROOT
63073 + help
63074 + If you say Y here, processes inside a chroot will not be able to
63075 + connect to abstract (meaning not belonging to a filesystem) Unix
63076 + domain sockets that were bound outside of a chroot. It is recommended
63077 + that you say Y here. If the sysctl option is enabled, a sysctl option
63078 + with name "chroot_deny_unix" is created.
63079 +
63080 +config GRKERNSEC_CHROOT_FINDTASK
63081 + bool "Protect outside processes"
63082 + default y if GRKERNSEC_CONFIG_AUTO
63083 + depends on GRKERNSEC_CHROOT
63084 + help
63085 + If you say Y here, processes inside a chroot will not be able to
63086 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
63087 + getsid, or view any process outside of the chroot. If the sysctl
63088 + option is enabled, a sysctl option with name "chroot_findtask" is
63089 + created.
63090 +
63091 +config GRKERNSEC_CHROOT_NICE
63092 + bool "Restrict priority changes"
63093 + default y if GRKERNSEC_CONFIG_AUTO
63094 + depends on GRKERNSEC_CHROOT
63095 + help
63096 + If you say Y here, processes inside a chroot will not be able to raise
63097 + the priority of processes in the chroot, or alter the priority of
63098 + processes outside the chroot. This provides more security than simply
63099 + removing CAP_SYS_NICE from the process' capability set. If the
63100 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
63101 + is created.
63102 +
63103 +config GRKERNSEC_CHROOT_SYSCTL
63104 + bool "Deny sysctl writes"
63105 + default y if GRKERNSEC_CONFIG_AUTO
63106 + depends on GRKERNSEC_CHROOT
63107 + help
63108 + If you say Y here, an attacker in a chroot will not be able to
63109 + write to sysctl entries, either by sysctl(2) or through a /proc
63110 + interface. It is strongly recommended that you say Y here. If the
63111 + sysctl option is enabled, a sysctl option with name
63112 + "chroot_deny_sysctl" is created.
63113 +
63114 +config GRKERNSEC_CHROOT_CAPS
63115 + bool "Capability restrictions"
63116 + default y if GRKERNSEC_CONFIG_AUTO
63117 + depends on GRKERNSEC_CHROOT
63118 + help
63119 + If you say Y here, the capabilities on all processes within a
63120 + chroot jail will be lowered to stop module insertion, raw i/o,
63121 + system and net admin tasks, rebooting the system, modifying immutable
63122 + files, modifying IPC owned by another, and changing the system time.
63123 + This is left an option because it can break some apps. Disable this
63124 + if your chrooted apps are having problems performing those kinds of
63125 + tasks. If the sysctl option is enabled, a sysctl option with
63126 + name "chroot_caps" is created.
63127 +
63128 +config GRKERNSEC_CHROOT_INITRD
63129 + bool "Exempt initrd tasks from restrictions"
63130 + default y if GRKERNSEC_CONFIG_AUTO
63131 + depends on GRKERNSEC_CHROOT && BLK_DEV_INITRD
63132 + help
63133 + If you say Y here, tasks started prior to init will be exempted from
63134 + grsecurity's chroot restrictions. This option is mainly meant to
63135 + resolve Plymouth's performing privileged operations unnecessarily
63136 + in a chroot.
63137 +
63138 +endmenu
63139 +menu "Kernel Auditing"
63140 +depends on GRKERNSEC
63141 +
63142 +config GRKERNSEC_AUDIT_GROUP
63143 + bool "Single group for auditing"
63144 + help
63145 + If you say Y here, the exec and chdir logging features will only operate
63146 + on a group you specify. This option is recommended if you only want to
63147 + watch certain users instead of having a large amount of logs from the
63148 + entire system. If the sysctl option is enabled, a sysctl option with
63149 + name "audit_group" is created.
63150 +
63151 +config GRKERNSEC_AUDIT_GID
63152 + int "GID for auditing"
63153 + depends on GRKERNSEC_AUDIT_GROUP
63154 + default 1007
63155 +
63156 +config GRKERNSEC_EXECLOG
63157 + bool "Exec logging"
63158 + help
63159 + If you say Y here, all execve() calls will be logged (since the
63160 + other exec*() calls are frontends to execve(), all execution
63161 + will be logged). Useful for shell-servers that like to keep track
63162 + of their users. If the sysctl option is enabled, a sysctl option with
63163 + name "exec_logging" is created.
63164 + WARNING: This option when enabled will produce a LOT of logs, especially
63165 + on an active system.
63166 +
63167 +config GRKERNSEC_RESLOG
63168 + bool "Resource logging"
63169 + default y if GRKERNSEC_CONFIG_AUTO
63170 + help
63171 + If you say Y here, all attempts to overstep resource limits will
63172 + be logged with the resource name, the requested size, and the current
63173 + limit. It is highly recommended that you say Y here. If the sysctl
63174 + option is enabled, a sysctl option with name "resource_logging" is
63175 + created. If the RBAC system is enabled, the sysctl value is ignored.
63176 +
63177 +config GRKERNSEC_CHROOT_EXECLOG
63178 + bool "Log execs within chroot"
63179 + help
63180 + If you say Y here, all executions inside a chroot jail will be logged
63181 + to syslog. This can cause a large amount of logs if certain
63182 + applications (eg. djb's daemontools) are installed on the system, and
63183 + is therefore left as an option. If the sysctl option is enabled, a
63184 + sysctl option with name "chroot_execlog" is created.
63185 +
63186 +config GRKERNSEC_AUDIT_PTRACE
63187 + bool "Ptrace logging"
63188 + help
63189 + If you say Y here, all attempts to attach to a process via ptrace
63190 + will be logged. If the sysctl option is enabled, a sysctl option
63191 + with name "audit_ptrace" is created.
63192 +
63193 +config GRKERNSEC_AUDIT_CHDIR
63194 + bool "Chdir logging"
63195 + help
63196 + If you say Y here, all chdir() calls will be logged. If the sysctl
63197 + option is enabled, a sysctl option with name "audit_chdir" is created.
63198 +
63199 +config GRKERNSEC_AUDIT_MOUNT
63200 + bool "(Un)Mount logging"
63201 + help
63202 + If you say Y here, all mounts and unmounts will be logged. If the
63203 + sysctl option is enabled, a sysctl option with name "audit_mount" is
63204 + created.
63205 +
63206 +config GRKERNSEC_SIGNAL
63207 + bool "Signal logging"
63208 + default y if GRKERNSEC_CONFIG_AUTO
63209 + help
63210 + If you say Y here, certain important signals will be logged, such as
63211 + SIGSEGV, which will as a result inform you of when a error in a program
63212 + occurred, which in some cases could mean a possible exploit attempt.
63213 + If the sysctl option is enabled, a sysctl option with name
63214 + "signal_logging" is created.
63215 +
63216 +config GRKERNSEC_FORKFAIL
63217 + bool "Fork failure logging"
63218 + help
63219 + If you say Y here, all failed fork() attempts will be logged.
63220 + This could suggest a fork bomb, or someone attempting to overstep
63221 + their process limit. If the sysctl option is enabled, a sysctl option
63222 + with name "forkfail_logging" is created.
63223 +
63224 +config GRKERNSEC_TIME
63225 + bool "Time change logging"
63226 + default y if GRKERNSEC_CONFIG_AUTO
63227 + help
63228 + If you say Y here, any changes of the system clock will be logged.
63229 + If the sysctl option is enabled, a sysctl option with name
63230 + "timechange_logging" is created.
63231 +
63232 +config GRKERNSEC_PROC_IPADDR
63233 + bool "/proc/<pid>/ipaddr support"
63234 + default y if GRKERNSEC_CONFIG_AUTO
63235 + help
63236 + If you say Y here, a new entry will be added to each /proc/<pid>
63237 + directory that contains the IP address of the person using the task.
63238 + The IP is carried across local TCP and AF_UNIX stream sockets.
63239 + This information can be useful for IDS/IPSes to perform remote response
63240 + to a local attack. The entry is readable by only the owner of the
63241 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
63242 + the RBAC system), and thus does not create privacy concerns.
63243 +
63244 +config GRKERNSEC_RWXMAP_LOG
63245 + bool 'Denied RWX mmap/mprotect logging'
63246 + default y if GRKERNSEC_CONFIG_AUTO
63247 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
63248 + help
63249 + If you say Y here, calls to mmap() and mprotect() with explicit
63250 + usage of PROT_WRITE and PROT_EXEC together will be logged when
63251 + denied by the PAX_MPROTECT feature. This feature will also
63252 + log other problematic scenarios that can occur when PAX_MPROTECT
63253 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
63254 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
63255 + is created.
63256 +
63257 +endmenu
63258 +
63259 +menu "Executable Protections"
63260 +depends on GRKERNSEC
63261 +
63262 +config GRKERNSEC_DMESG
63263 + bool "Dmesg(8) restriction"
63264 + default y if GRKERNSEC_CONFIG_AUTO
63265 + help
63266 + If you say Y here, non-root users will not be able to use dmesg(8)
63267 + to view the contents of the kernel's circular log buffer.
63268 + The kernel's log buffer often contains kernel addresses and other
63269 + identifying information useful to an attacker in fingerprinting a
63270 + system for a targeted exploit.
63271 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
63272 + created.
63273 +
63274 +config GRKERNSEC_HARDEN_PTRACE
63275 + bool "Deter ptrace-based process snooping"
63276 + default y if GRKERNSEC_CONFIG_AUTO
63277 + help
63278 + If you say Y here, TTY sniffers and other malicious monitoring
63279 + programs implemented through ptrace will be defeated. If you
63280 + have been using the RBAC system, this option has already been
63281 + enabled for several years for all users, with the ability to make
63282 + fine-grained exceptions.
63283 +
63284 + This option only affects the ability of non-root users to ptrace
63285 + processes that are not a descendent of the ptracing process.
63286 + This means that strace ./binary and gdb ./binary will still work,
63287 + but attaching to arbitrary processes will not. If the sysctl
63288 + option is enabled, a sysctl option with name "harden_ptrace" is
63289 + created.
63290 +
63291 +config GRKERNSEC_PTRACE_READEXEC
63292 + bool "Require read access to ptrace sensitive binaries"
63293 + default y if GRKERNSEC_CONFIG_AUTO
63294 + help
63295 + If you say Y here, unprivileged users will not be able to ptrace unreadable
63296 + binaries. This option is useful in environments that
63297 + remove the read bits (e.g. file mode 4711) from suid binaries to
63298 + prevent infoleaking of their contents. This option adds
63299 + consistency to the use of that file mode, as the binary could normally
63300 + be read out when run without privileges while ptracing.
63301 +
63302 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
63303 + is created.
63304 +
63305 +config GRKERNSEC_SETXID
63306 + bool "Enforce consistent multithreaded privileges"
63307 + default y if GRKERNSEC_CONFIG_AUTO
63308 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
63309 + help
63310 + If you say Y here, a change from a root uid to a non-root uid
63311 + in a multithreaded application will cause the resulting uids,
63312 + gids, supplementary groups, and capabilities in that thread
63313 + to be propagated to the other threads of the process. In most
63314 + cases this is unnecessary, as glibc will emulate this behavior
63315 + on behalf of the application. Other libcs do not act in the
63316 + same way, allowing the other threads of the process to continue
63317 + running with root privileges. If the sysctl option is enabled,
63318 + a sysctl option with name "consistent_setxid" is created.
63319 +
63320 +config GRKERNSEC_HARDEN_IPC
63321 + bool "Disallow access to overly-permissive IPC objects"
63322 + default y if GRKERNSEC_CONFIG_AUTO
63323 + depends on SYSVIPC
63324 + help
63325 + If you say Y here, access to overly-permissive IPC objects (shared
63326 + memory, message queues, and semaphores) will be denied for processes
63327 + given the following criteria beyond normal permission checks:
63328 + 1) If the IPC object is world-accessible and the euid doesn't match
63329 + that of the creator or current uid for the IPC object
63330 + 2) If the IPC object is group-accessible and the egid doesn't
63331 + match that of the creator or current gid for the IPC object
63332 + It's a common error to grant too much permission to these objects,
63333 + with impact ranging from denial of service and information leaking to
63334 + privilege escalation. This feature was developed in response to
63335 + research by Tim Brown:
63336 + http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
63337 + who found hundreds of such insecure usages. Processes with
63338 + CAP_IPC_OWNER are still permitted to access these IPC objects.
63339 + If the sysctl option is enabled, a sysctl option with name
63340 + "harden_ipc" is created.
63341 +
63342 +config GRKERNSEC_TPE
63343 + bool "Trusted Path Execution (TPE)"
63344 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
63345 + help
63346 + If you say Y here, you will be able to choose a gid to add to the
63347 + supplementary groups of users you want to mark as "untrusted."
63348 + These users will not be able to execute any files that are not in
63349 + root-owned directories writable only by root. If the sysctl option
63350 + is enabled, a sysctl option with name "tpe" is created.
63351 +
63352 +config GRKERNSEC_TPE_ALL
63353 + bool "Partially restrict all non-root users"
63354 + depends on GRKERNSEC_TPE
63355 + help
63356 + If you say Y here, all non-root users will be covered under
63357 + a weaker TPE restriction. This is separate from, and in addition to,
63358 + the main TPE options that you have selected elsewhere. Thus, if a
63359 + "trusted" GID is chosen, this restriction applies to even that GID.
63360 + Under this restriction, all non-root users will only be allowed to
63361 + execute files in directories they own that are not group or
63362 + world-writable, or in directories owned by root and writable only by
63363 + root. If the sysctl option is enabled, a sysctl option with name
63364 + "tpe_restrict_all" is created.
63365 +
63366 +config GRKERNSEC_TPE_INVERT
63367 + bool "Invert GID option"
63368 + depends on GRKERNSEC_TPE
63369 + help
63370 + If you say Y here, the group you specify in the TPE configuration will
63371 + decide what group TPE restrictions will be *disabled* for. This
63372 + option is useful if you want TPE restrictions to be applied to most
63373 + users on the system. If the sysctl option is enabled, a sysctl option
63374 + with name "tpe_invert" is created. Unlike other sysctl options, this
63375 + entry will default to on for backward-compatibility.
63376 +
63377 +config GRKERNSEC_TPE_GID
63378 + int
63379 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
63380 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
63381 +
63382 +config GRKERNSEC_TPE_UNTRUSTED_GID
63383 + int "GID for TPE-untrusted users"
63384 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
63385 + default 1005
63386 + help
63387 + Setting this GID determines what group TPE restrictions will be
63388 + *enabled* for. If the sysctl option is enabled, a sysctl option
63389 + with name "tpe_gid" is created.
63390 +
63391 +config GRKERNSEC_TPE_TRUSTED_GID
63392 + int "GID for TPE-trusted users"
63393 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
63394 + default 1005
63395 + help
63396 + Setting this GID determines what group TPE restrictions will be
63397 + *disabled* for. If the sysctl option is enabled, a sysctl option
63398 + with name "tpe_gid" is created.
63399 +
63400 +endmenu
63401 +menu "Network Protections"
63402 +depends on GRKERNSEC
63403 +
63404 +config GRKERNSEC_RANDNET
63405 + bool "Larger entropy pools"
63406 + default y if GRKERNSEC_CONFIG_AUTO
63407 + help
63408 + If you say Y here, the entropy pools used for many features of Linux
63409 + and grsecurity will be doubled in size. Since several grsecurity
63410 + features use additional randomness, it is recommended that you say Y
63411 + here. Saying Y here has a similar effect as modifying
63412 + /proc/sys/kernel/random/poolsize.
63413 +
63414 +config GRKERNSEC_BLACKHOLE
63415 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
63416 + default y if GRKERNSEC_CONFIG_AUTO
63417 + depends on NET
63418 + help
63419 + If you say Y here, neither TCP resets nor ICMP
63420 + destination-unreachable packets will be sent in response to packets
63421 + sent to ports for which no associated listening process exists.
63422 + This feature supports both IPV4 and IPV6 and exempts the
63423 + loopback interface from blackholing. Enabling this feature
63424 + makes a host more resilient to DoS attacks and reduces network
63425 + visibility against scanners.
63426 +
63427 + The blackhole feature as-implemented is equivalent to the FreeBSD
63428 + blackhole feature, as it prevents RST responses to all packets, not
63429 + just SYNs. Under most application behavior this causes no
63430 + problems, but applications (like haproxy) may not close certain
63431 + connections in a way that cleanly terminates them on the remote
63432 + end, leaving the remote host in LAST_ACK state. Because of this
63433 + side-effect and to prevent intentional LAST_ACK DoSes, this
63434 + feature also adds automatic mitigation against such attacks.
63435 + The mitigation drastically reduces the amount of time a socket
63436 + can spend in LAST_ACK state. If you're using haproxy and not
63437 + all servers it connects to have this option enabled, consider
63438 + disabling this feature on the haproxy host.
63439 +
63440 + If the sysctl option is enabled, two sysctl options with names
63441 + "ip_blackhole" and "lastack_retries" will be created.
63442 + While "ip_blackhole" takes the standard zero/non-zero on/off
63443 + toggle, "lastack_retries" uses the same kinds of values as
63444 + "tcp_retries1" and "tcp_retries2". The default value of 4
63445 + prevents a socket from lasting more than 45 seconds in LAST_ACK
63446 + state.
63447 +
63448 +config GRKERNSEC_NO_SIMULT_CONNECT
63449 + bool "Disable TCP Simultaneous Connect"
63450 + default y if GRKERNSEC_CONFIG_AUTO
63451 + depends on NET
63452 + help
63453 + If you say Y here, a feature by Willy Tarreau will be enabled that
63454 + removes a weakness in Linux's strict implementation of TCP that
63455 + allows two clients to connect to each other without either entering
63456 + a listening state. The weakness allows an attacker to easily prevent
63457 + a client from connecting to a known server provided the source port
63458 + for the connection is guessed correctly.
63459 +
63460 + As the weakness could be used to prevent an antivirus or IPS from
63461 + fetching updates, or prevent an SSL gateway from fetching a CRL,
63462 + it should be eliminated by enabling this option. Though Linux is
63463 + one of few operating systems supporting simultaneous connect, it
63464 + has no legitimate use in practice and is rarely supported by firewalls.
63465 +
63466 +config GRKERNSEC_SOCKET
63467 + bool "Socket restrictions"
63468 + depends on NET
63469 + help
63470 + If you say Y here, you will be able to choose from several options.
63471 + If you assign a GID on your system and add it to the supplementary
63472 + groups of users you want to restrict socket access to, this patch
63473 + will perform up to three things, based on the option(s) you choose.
63474 +
63475 +config GRKERNSEC_SOCKET_ALL
63476 + bool "Deny any sockets to group"
63477 + depends on GRKERNSEC_SOCKET
63478 + help
63479 + If you say Y here, you will be able to choose a GID of whose users will
63480 + be unable to connect to other hosts from your machine or run server
63481 + applications from your machine. If the sysctl option is enabled, a
63482 + sysctl option with name "socket_all" is created.
63483 +
63484 +config GRKERNSEC_SOCKET_ALL_GID
63485 + int "GID to deny all sockets for"
63486 + depends on GRKERNSEC_SOCKET_ALL
63487 + default 1004
63488 + help
63489 + Here you can choose the GID to disable socket access for. Remember to
63490 + add the users you want socket access disabled for to the GID
63491 + specified here. If the sysctl option is enabled, a sysctl option
63492 + with name "socket_all_gid" is created.
63493 +
63494 +config GRKERNSEC_SOCKET_CLIENT
63495 + bool "Deny client sockets to group"
63496 + depends on GRKERNSEC_SOCKET
63497 + help
63498 + If you say Y here, you will be able to choose a GID of whose users will
63499 + be unable to connect to other hosts from your machine, but will be
63500 + able to run servers. If this option is enabled, all users in the group
63501 + you specify will have to use passive mode when initiating ftp transfers
63502 + from the shell on your machine. If the sysctl option is enabled, a
63503 + sysctl option with name "socket_client" is created.
63504 +
63505 +config GRKERNSEC_SOCKET_CLIENT_GID
63506 + int "GID to deny client sockets for"
63507 + depends on GRKERNSEC_SOCKET_CLIENT
63508 + default 1003
63509 + help
63510 + Here you can choose the GID to disable client socket access for.
63511 + Remember to add the users you want client socket access disabled for to
63512 + the GID specified here. If the sysctl option is enabled, a sysctl
63513 + option with name "socket_client_gid" is created.
63514 +
63515 +config GRKERNSEC_SOCKET_SERVER
63516 + bool "Deny server sockets to group"
63517 + depends on GRKERNSEC_SOCKET
63518 + help
63519 + If you say Y here, you will be able to choose a GID of whose users will
63520 + be unable to run server applications from your machine. If the sysctl
63521 + option is enabled, a sysctl option with name "socket_server" is created.
63522 +
63523 +config GRKERNSEC_SOCKET_SERVER_GID
63524 + int "GID to deny server sockets for"
63525 + depends on GRKERNSEC_SOCKET_SERVER
63526 + default 1002
63527 + help
63528 + Here you can choose the GID to disable server socket access for.
63529 + Remember to add the users you want server socket access disabled for to
63530 + the GID specified here. If the sysctl option is enabled, a sysctl
63531 + option with name "socket_server_gid" is created.
63532 +
63533 +endmenu
63534 +
63535 +menu "Physical Protections"
63536 +depends on GRKERNSEC
63537 +
63538 +config GRKERNSEC_DENYUSB
63539 + bool "Deny new USB connections after toggle"
63540 + default y if GRKERNSEC_CONFIG_AUTO
63541 + depends on SYSCTL && USB_SUPPORT
63542 + help
63543 + If you say Y here, a new sysctl option with name "deny_new_usb"
63544 + will be created. Setting its value to 1 will prevent any new
63545 + USB devices from being recognized by the OS. Any attempted USB
63546 + device insertion will be logged. This option is intended to be
63547 + used against custom USB devices designed to exploit vulnerabilities
63548 + in various USB device drivers.
63549 +
63550 + For greatest effectiveness, this sysctl should be set after any
63551 + relevant init scripts. This option is safe to enable in distros
63552 + as each user can choose whether or not to toggle the sysctl.
63553 +
63554 +config GRKERNSEC_DENYUSB_FORCE
63555 + bool "Reject all USB devices not connected at boot"
63556 + select USB
63557 + depends on GRKERNSEC_DENYUSB
63558 + help
63559 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
63560 + that doesn't involve a sysctl entry. This option should only be
63561 + enabled if you're sure you want to deny all new USB connections
63562 + at runtime and don't want to modify init scripts. This should not
63563 + be enabled by distros. It forces the core USB code to be built
63564 + into the kernel image so that all devices connected at boot time
63565 + can be recognized and new USB device connections can be prevented
63566 + prior to init running.
63567 +
63568 +endmenu
63569 +
63570 +menu "Sysctl Support"
63571 +depends on GRKERNSEC && SYSCTL
63572 +
63573 +config GRKERNSEC_SYSCTL
63574 + bool "Sysctl support"
63575 + default y if GRKERNSEC_CONFIG_AUTO
63576 + help
63577 + If you say Y here, you will be able to change the options that
63578 + grsecurity runs with at bootup, without having to recompile your
63579 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
63580 + to enable (1) or disable (0) various features. All the sysctl entries
63581 + are mutable until the "grsec_lock" entry is set to a non-zero value.
63582 + All features enabled in the kernel configuration are disabled at boot
63583 + if you do not say Y to the "Turn on features by default" option.
63584 + All options should be set at startup, and the grsec_lock entry should
63585 + be set to a non-zero value after all the options are set.
63586 + *THIS IS EXTREMELY IMPORTANT*
63587 +
63588 +config GRKERNSEC_SYSCTL_DISTRO
63589 + bool "Extra sysctl support for distro makers (READ HELP)"
63590 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
63591 + help
63592 + If you say Y here, additional sysctl options will be created
63593 + for features that affect processes running as root. Therefore,
63594 + it is critical when using this option that the grsec_lock entry be
63595 + enabled after boot. Only distros with prebuilt kernel packages
63596 + with this option enabled that can ensure grsec_lock is enabled
63597 + after boot should use this option.
63598 + *Failure to set grsec_lock after boot makes all grsec features
63599 + this option covers useless*
63600 +
63601 + Currently this option creates the following sysctl entries:
63602 + "Disable Privileged I/O": "disable_priv_io"
63603 +
63604 +config GRKERNSEC_SYSCTL_ON
63605 + bool "Turn on features by default"
63606 + default y if GRKERNSEC_CONFIG_AUTO
63607 + depends on GRKERNSEC_SYSCTL
63608 + help
63609 + If you say Y here, instead of having all features enabled in the
63610 + kernel configuration disabled at boot time, the features will be
63611 + enabled at boot time. It is recommended you say Y here unless
63612 + there is some reason you would want all sysctl-tunable features to
63613 + be disabled by default. As mentioned elsewhere, it is important
63614 + to enable the grsec_lock entry once you have finished modifying
63615 + the sysctl entries.
63616 +
63617 +endmenu
63618 +menu "Logging Options"
63619 +depends on GRKERNSEC
63620 +
63621 +config GRKERNSEC_FLOODTIME
63622 + int "Seconds in between log messages (minimum)"
63623 + default 10
63624 + help
63625 + This option allows you to enforce the number of seconds between
63626 + grsecurity log messages. The default should be suitable for most
63627 + people, however, if you choose to change it, choose a value small enough
63628 + to allow informative logs to be produced, but large enough to
63629 + prevent flooding.
63630 +
63631 +config GRKERNSEC_FLOODBURST
63632 + int "Number of messages in a burst (maximum)"
63633 + default 6
63634 + help
63635 + This option allows you to choose the maximum number of messages allowed
63636 + within the flood time interval you chose in a separate option. The
63637 + default should be suitable for most people, however if you find that
63638 + many of your logs are being interpreted as flooding, you may want to
63639 + raise this value.
63640 +
63641 +endmenu
63642 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
63643 new file mode 100644
63644 index 0000000..85beb79
63645 --- /dev/null
63646 +++ b/grsecurity/Makefile
63647 @@ -0,0 +1,43 @@
63648 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
63649 +# during 2001-2009 it has been completely redesigned by Brad Spengler
63650 +# into an RBAC system
63651 +#
63652 +# All code in this directory and various hooks inserted throughout the kernel
63653 +# are copyright Brad Spengler - Open Source Security, Inc., and released
63654 +# under the GPL v2 or higher
63655 +
63656 +KBUILD_CFLAGS += -Werror
63657 +
63658 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
63659 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
63660 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
63661 + grsec_usb.o grsec_ipc.o
63662 +
63663 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
63664 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
63665 + gracl_learn.o grsec_log.o gracl_policy.o
63666 +ifdef CONFIG_COMPAT
63667 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
63668 +endif
63669 +
63670 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
63671 +
63672 +ifdef CONFIG_NET
63673 +obj-y += grsec_sock.o
63674 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
63675 +endif
63676 +
63677 +ifndef CONFIG_GRKERNSEC
63678 +obj-y += grsec_disabled.o
63679 +endif
63680 +
63681 +ifdef CONFIG_GRKERNSEC_HIDESYM
63682 +extra-y := grsec_hidesym.o
63683 +$(obj)/grsec_hidesym.o:
63684 + @-chmod -f 500 /boot
63685 + @-chmod -f 500 /lib/modules
63686 + @-chmod -f 500 /lib64/modules
63687 + @-chmod -f 500 /lib32/modules
63688 + @-chmod -f 700 .
63689 + @echo ' grsec: protected kernel image paths'
63690 +endif
63691 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
63692 new file mode 100644
63693 index 0000000..90f71ce
63694 --- /dev/null
63695 +++ b/grsecurity/gracl.c
63696 @@ -0,0 +1,2679 @@
63697 +#include <linux/kernel.h>
63698 +#include <linux/module.h>
63699 +#include <linux/sched.h>
63700 +#include <linux/mm.h>
63701 +#include <linux/file.h>
63702 +#include <linux/fs.h>
63703 +#include <linux/namei.h>
63704 +#include <linux/mount.h>
63705 +#include <linux/tty.h>
63706 +#include <linux/proc_fs.h>
63707 +#include <linux/lglock.h>
63708 +#include <linux/slab.h>
63709 +#include <linux/vmalloc.h>
63710 +#include <linux/types.h>
63711 +#include <linux/sysctl.h>
63712 +#include <linux/netdevice.h>
63713 +#include <linux/ptrace.h>
63714 +#include <linux/gracl.h>
63715 +#include <linux/gralloc.h>
63716 +#include <linux/security.h>
63717 +#include <linux/grinternal.h>
63718 +#include <linux/pid_namespace.h>
63719 +#include <linux/stop_machine.h>
63720 +#include <linux/fdtable.h>
63721 +#include <linux/percpu.h>
63722 +#include <linux/lglock.h>
63723 +#include <linux/hugetlb.h>
63724 +#include <linux/posix-timers.h>
63725 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63726 +#include <linux/magic.h>
63727 +#include <linux/pagemap.h>
63728 +#include "../fs/btrfs/async-thread.h"
63729 +#include "../fs/btrfs/ctree.h"
63730 +#include "../fs/btrfs/btrfs_inode.h"
63731 +#endif
63732 +#include "../fs/mount.h"
63733 +
63734 +#include <asm/uaccess.h>
63735 +#include <asm/errno.h>
63736 +#include <asm/mman.h>
63737 +
63738 +#define FOR_EACH_ROLE_START(role) \
63739 + role = running_polstate.role_list; \
63740 + while (role) {
63741 +
63742 +#define FOR_EACH_ROLE_END(role) \
63743 + role = role->prev; \
63744 + }
63745 +
63746 +extern struct lglock vfsmount_lock;
63747 +
63748 +extern struct path gr_real_root;
63749 +
63750 +static struct gr_policy_state running_polstate;
63751 +struct gr_policy_state *polstate = &running_polstate;
63752 +extern struct gr_alloc_state *current_alloc_state;
63753 +
63754 +extern char *gr_shared_page[4];
63755 +DEFINE_RWLOCK(gr_inode_lock);
63756 +
63757 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
63758 +
63759 +#ifdef CONFIG_NET
63760 +extern struct vfsmount *sock_mnt;
63761 +#endif
63762 +
63763 +extern struct vfsmount *pipe_mnt;
63764 +extern struct vfsmount *shm_mnt;
63765 +
63766 +#ifdef CONFIG_HUGETLBFS
63767 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
63768 +#endif
63769 +
63770 +extern u16 acl_sp_role_value;
63771 +extern struct acl_object_label *fakefs_obj_rw;
63772 +extern struct acl_object_label *fakefs_obj_rwx;
63773 +
63774 +int gr_acl_is_enabled(void)
63775 +{
63776 + return (gr_status & GR_READY);
63777 +}
63778 +
63779 +void gr_enable_rbac_system(void)
63780 +{
63781 + pax_open_kernel();
63782 + gr_status |= GR_READY;
63783 + pax_close_kernel();
63784 +}
63785 +
63786 +int gr_rbac_disable(void *unused)
63787 +{
63788 + pax_open_kernel();
63789 + gr_status &= ~GR_READY;
63790 + pax_close_kernel();
63791 +
63792 + return 0;
63793 +}
63794 +
63795 +static inline dev_t __get_dev(const struct dentry *dentry)
63796 +{
63797 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63798 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
63799 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
63800 + else
63801 +#endif
63802 + return dentry->d_sb->s_dev;
63803 +}
63804 +
63805 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
63806 +{
63807 + return __get_dev(dentry);
63808 +}
63809 +
63810 +static char gr_task_roletype_to_char(struct task_struct *task)
63811 +{
63812 + switch (task->role->roletype &
63813 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
63814 + GR_ROLE_SPECIAL)) {
63815 + case GR_ROLE_DEFAULT:
63816 + return 'D';
63817 + case GR_ROLE_USER:
63818 + return 'U';
63819 + case GR_ROLE_GROUP:
63820 + return 'G';
63821 + case GR_ROLE_SPECIAL:
63822 + return 'S';
63823 + }
63824 +
63825 + return 'X';
63826 +}
63827 +
63828 +char gr_roletype_to_char(void)
63829 +{
63830 + return gr_task_roletype_to_char(current);
63831 +}
63832 +
63833 +__inline__ int
63834 +gr_acl_tpe_check(void)
63835 +{
63836 + if (unlikely(!(gr_status & GR_READY)))
63837 + return 0;
63838 + if (current->role->roletype & GR_ROLE_TPE)
63839 + return 1;
63840 + else
63841 + return 0;
63842 +}
63843 +
63844 +int
63845 +gr_handle_rawio(const struct inode *inode)
63846 +{
63847 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63848 + if (inode && (S_ISBLK(inode->i_mode) || (S_ISCHR(inode->i_mode) && imajor(inode) == RAW_MAJOR)) &&
63849 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
63850 + !capable(CAP_SYS_RAWIO))
63851 + return 1;
63852 +#endif
63853 + return 0;
63854 +}
63855 +
63856 +int
63857 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
63858 +{
63859 + if (likely(lena != lenb))
63860 + return 0;
63861 +
63862 + return !memcmp(a, b, lena);
63863 +}
63864 +
63865 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
63866 +{
63867 + *buflen -= namelen;
63868 + if (*buflen < 0)
63869 + return -ENAMETOOLONG;
63870 + *buffer -= namelen;
63871 + memcpy(*buffer, str, namelen);
63872 + return 0;
63873 +}
63874 +
63875 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
63876 +{
63877 + return prepend(buffer, buflen, name->name, name->len);
63878 +}
63879 +
63880 +static int prepend_path(const struct path *path, struct path *root,
63881 + char **buffer, int *buflen)
63882 +{
63883 + struct dentry *dentry = path->dentry;
63884 + struct vfsmount *vfsmnt = path->mnt;
63885 + struct mount *mnt = real_mount(vfsmnt);
63886 + bool slash = false;
63887 + int error = 0;
63888 +
63889 + while (dentry != root->dentry || vfsmnt != root->mnt) {
63890 + struct dentry * parent;
63891 +
63892 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
63893 + /* Global root? */
63894 + if (!mnt_has_parent(mnt)) {
63895 + goto out;
63896 + }
63897 + dentry = mnt->mnt_mountpoint;
63898 + mnt = mnt->mnt_parent;
63899 + vfsmnt = &mnt->mnt;
63900 + continue;
63901 + }
63902 + parent = dentry->d_parent;
63903 + prefetch(parent);
63904 + spin_lock(&dentry->d_lock);
63905 + error = prepend_name(buffer, buflen, &dentry->d_name);
63906 + spin_unlock(&dentry->d_lock);
63907 + if (!error)
63908 + error = prepend(buffer, buflen, "/", 1);
63909 + if (error)
63910 + break;
63911 +
63912 + slash = true;
63913 + dentry = parent;
63914 + }
63915 +
63916 +out:
63917 + if (!error && !slash)
63918 + error = prepend(buffer, buflen, "/", 1);
63919 +
63920 + return error;
63921 +}
63922 +
63923 +/* this must be called with vfsmount_lock and rename_lock held */
63924 +
63925 +static char *__our_d_path(const struct path *path, struct path *root,
63926 + char *buf, int buflen)
63927 +{
63928 + char *res = buf + buflen;
63929 + int error;
63930 +
63931 + prepend(&res, &buflen, "\0", 1);
63932 + error = prepend_path(path, root, &res, &buflen);
63933 + if (error)
63934 + return ERR_PTR(error);
63935 +
63936 + return res;
63937 +}
63938 +
63939 +static char *
63940 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
63941 +{
63942 + char *retval;
63943 +
63944 + retval = __our_d_path(path, root, buf, buflen);
63945 + if (unlikely(IS_ERR(retval)))
63946 + retval = strcpy(buf, "<path too long>");
63947 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
63948 + retval[1] = '\0';
63949 +
63950 + return retval;
63951 +}
63952 +
63953 +static char *
63954 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63955 + char *buf, int buflen)
63956 +{
63957 + struct path path;
63958 + char *res;
63959 +
63960 + path.dentry = (struct dentry *)dentry;
63961 + path.mnt = (struct vfsmount *)vfsmnt;
63962 +
63963 + /* we can use gr_real_root.dentry, gr_real_root.mnt, because this is only called
63964 + by the RBAC system */
63965 + res = gen_full_path(&path, &gr_real_root, buf, buflen);
63966 +
63967 + return res;
63968 +}
63969 +
63970 +static char *
63971 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63972 + char *buf, int buflen)
63973 +{
63974 + char *res;
63975 + struct path path;
63976 + struct path root;
63977 + struct task_struct *reaper = init_pid_ns.child_reaper;
63978 +
63979 + path.dentry = (struct dentry *)dentry;
63980 + path.mnt = (struct vfsmount *)vfsmnt;
63981 +
63982 + /* we can't use gr_real_root.dentry, gr_real_root.mnt, because they belong only to the RBAC system */
63983 + get_fs_root(reaper->fs, &root);
63984 +
63985 + br_read_lock(&vfsmount_lock);
63986 + write_seqlock(&rename_lock);
63987 + res = gen_full_path(&path, &root, buf, buflen);
63988 + write_sequnlock(&rename_lock);
63989 + br_read_unlock(&vfsmount_lock);
63990 +
63991 + path_put(&root);
63992 + return res;
63993 +}
63994 +
63995 +char *
63996 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
63997 +{
63998 + char *ret;
63999 + br_read_lock(&vfsmount_lock);
64000 + write_seqlock(&rename_lock);
64001 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
64002 + PAGE_SIZE);
64003 + write_sequnlock(&rename_lock);
64004 + br_read_unlock(&vfsmount_lock);
64005 + return ret;
64006 +}
64007 +
64008 +static char *
64009 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
64010 +{
64011 + char *ret;
64012 + char *buf;
64013 + int buflen;
64014 +
64015 + br_read_lock(&vfsmount_lock);
64016 + write_seqlock(&rename_lock);
64017 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
64018 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
64019 + buflen = (int)(ret - buf);
64020 + if (buflen >= 5)
64021 + prepend(&ret, &buflen, "/proc", 5);
64022 + else
64023 + ret = strcpy(buf, "<path too long>");
64024 + write_sequnlock(&rename_lock);
64025 + br_read_unlock(&vfsmount_lock);
64026 + return ret;
64027 +}
64028 +
64029 +char *
64030 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
64031 +{
64032 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
64033 + PAGE_SIZE);
64034 +}
64035 +
64036 +char *
64037 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
64038 +{
64039 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
64040 + PAGE_SIZE);
64041 +}
64042 +
64043 +char *
64044 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
64045 +{
64046 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
64047 + PAGE_SIZE);
64048 +}
64049 +
64050 +char *
64051 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
64052 +{
64053 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
64054 + PAGE_SIZE);
64055 +}
64056 +
64057 +char *
64058 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
64059 +{
64060 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
64061 + PAGE_SIZE);
64062 +}
64063 +
64064 +__inline__ __u32
64065 +to_gr_audit(const __u32 reqmode)
64066 +{
64067 + /* masks off auditable permission flags, then shifts them to create
64068 + auditing flags, and adds the special case of append auditing if
64069 + we're requesting write */
64070 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
64071 +}
64072 +
64073 +struct acl_role_label *
64074 +__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid,
64075 + const gid_t gid)
64076 +{
64077 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, state->acl_role_set.r_size);
64078 + struct acl_role_label *match;
64079 + struct role_allowed_ip *ipp;
64080 + unsigned int x;
64081 + u32 curr_ip = task->signal->saved_ip;
64082 +
64083 + match = state->acl_role_set.r_hash[index];
64084 +
64085 + while (match) {
64086 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
64087 + for (x = 0; x < match->domain_child_num; x++) {
64088 + if (match->domain_children[x] == uid)
64089 + goto found;
64090 + }
64091 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
64092 + break;
64093 + match = match->next;
64094 + }
64095 +found:
64096 + if (match == NULL) {
64097 + try_group:
64098 + index = gr_rhash(gid, GR_ROLE_GROUP, state->acl_role_set.r_size);
64099 + match = state->acl_role_set.r_hash[index];
64100 +
64101 + while (match) {
64102 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
64103 + for (x = 0; x < match->domain_child_num; x++) {
64104 + if (match->domain_children[x] == gid)
64105 + goto found2;
64106 + }
64107 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
64108 + break;
64109 + match = match->next;
64110 + }
64111 +found2:
64112 + if (match == NULL)
64113 + match = state->default_role;
64114 + if (match->allowed_ips == NULL)
64115 + return match;
64116 + else {
64117 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
64118 + if (likely
64119 + ((ntohl(curr_ip) & ipp->netmask) ==
64120 + (ntohl(ipp->addr) & ipp->netmask)))
64121 + return match;
64122 + }
64123 + match = state->default_role;
64124 + }
64125 + } else if (match->allowed_ips == NULL) {
64126 + return match;
64127 + } else {
64128 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
64129 + if (likely
64130 + ((ntohl(curr_ip) & ipp->netmask) ==
64131 + (ntohl(ipp->addr) & ipp->netmask)))
64132 + return match;
64133 + }
64134 + goto try_group;
64135 + }
64136 +
64137 + return match;
64138 +}
64139 +
64140 +static struct acl_role_label *
64141 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
64142 + const gid_t gid)
64143 +{
64144 + return __lookup_acl_role_label(&running_polstate, task, uid, gid);
64145 +}
64146 +
64147 +struct acl_subject_label *
64148 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
64149 + const struct acl_role_label *role)
64150 +{
64151 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
64152 + struct acl_subject_label *match;
64153 +
64154 + match = role->subj_hash[index];
64155 +
64156 + while (match && (match->inode != ino || match->device != dev ||
64157 + (match->mode & GR_DELETED))) {
64158 + match = match->next;
64159 + }
64160 +
64161 + if (match && !(match->mode & GR_DELETED))
64162 + return match;
64163 + else
64164 + return NULL;
64165 +}
64166 +
64167 +struct acl_subject_label *
64168 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
64169 + const struct acl_role_label *role)
64170 +{
64171 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
64172 + struct acl_subject_label *match;
64173 +
64174 + match = role->subj_hash[index];
64175 +
64176 + while (match && (match->inode != ino || match->device != dev ||
64177 + !(match->mode & GR_DELETED))) {
64178 + match = match->next;
64179 + }
64180 +
64181 + if (match && (match->mode & GR_DELETED))
64182 + return match;
64183 + else
64184 + return NULL;
64185 +}
64186 +
64187 +static struct acl_object_label *
64188 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
64189 + const struct acl_subject_label *subj)
64190 +{
64191 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
64192 + struct acl_object_label *match;
64193 +
64194 + match = subj->obj_hash[index];
64195 +
64196 + while (match && (match->inode != ino || match->device != dev ||
64197 + (match->mode & GR_DELETED))) {
64198 + match = match->next;
64199 + }
64200 +
64201 + if (match && !(match->mode & GR_DELETED))
64202 + return match;
64203 + else
64204 + return NULL;
64205 +}
64206 +
64207 +static struct acl_object_label *
64208 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
64209 + const struct acl_subject_label *subj)
64210 +{
64211 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
64212 + struct acl_object_label *match;
64213 +
64214 + match = subj->obj_hash[index];
64215 +
64216 + while (match && (match->inode != ino || match->device != dev ||
64217 + !(match->mode & GR_DELETED))) {
64218 + match = match->next;
64219 + }
64220 +
64221 + if (match && (match->mode & GR_DELETED))
64222 + return match;
64223 +
64224 + match = subj->obj_hash[index];
64225 +
64226 + while (match && (match->inode != ino || match->device != dev ||
64227 + (match->mode & GR_DELETED))) {
64228 + match = match->next;
64229 + }
64230 +
64231 + if (match && !(match->mode & GR_DELETED))
64232 + return match;
64233 + else
64234 + return NULL;
64235 +}
64236 +
64237 +struct name_entry *
64238 +__lookup_name_entry(const struct gr_policy_state *state, const char *name)
64239 +{
64240 + unsigned int len = strlen(name);
64241 + unsigned int key = full_name_hash(name, len);
64242 + unsigned int index = key % state->name_set.n_size;
64243 + struct name_entry *match;
64244 +
64245 + match = state->name_set.n_hash[index];
64246 +
64247 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
64248 + match = match->next;
64249 +
64250 + return match;
64251 +}
64252 +
64253 +static struct name_entry *
64254 +lookup_name_entry(const char *name)
64255 +{
64256 + return __lookup_name_entry(&running_polstate, name);
64257 +}
64258 +
64259 +static struct name_entry *
64260 +lookup_name_entry_create(const char *name)
64261 +{
64262 + unsigned int len = strlen(name);
64263 + unsigned int key = full_name_hash(name, len);
64264 + unsigned int index = key % running_polstate.name_set.n_size;
64265 + struct name_entry *match;
64266 +
64267 + match = running_polstate.name_set.n_hash[index];
64268 +
64269 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
64270 + !match->deleted))
64271 + match = match->next;
64272 +
64273 + if (match && match->deleted)
64274 + return match;
64275 +
64276 + match = running_polstate.name_set.n_hash[index];
64277 +
64278 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
64279 + match->deleted))
64280 + match = match->next;
64281 +
64282 + if (match && !match->deleted)
64283 + return match;
64284 + else
64285 + return NULL;
64286 +}
64287 +
64288 +static struct inodev_entry *
64289 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
64290 +{
64291 + unsigned int index = gr_fhash(ino, dev, running_polstate.inodev_set.i_size);
64292 + struct inodev_entry *match;
64293 +
64294 + match = running_polstate.inodev_set.i_hash[index];
64295 +
64296 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
64297 + match = match->next;
64298 +
64299 + return match;
64300 +}
64301 +
64302 +void
64303 +__insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry)
64304 +{
64305 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
64306 + state->inodev_set.i_size);
64307 + struct inodev_entry **curr;
64308 +
64309 + entry->prev = NULL;
64310 +
64311 + curr = &state->inodev_set.i_hash[index];
64312 + if (*curr != NULL)
64313 + (*curr)->prev = entry;
64314 +
64315 + entry->next = *curr;
64316 + *curr = entry;
64317 +
64318 + return;
64319 +}
64320 +
64321 +static void
64322 +insert_inodev_entry(struct inodev_entry *entry)
64323 +{
64324 + __insert_inodev_entry(&running_polstate, entry);
64325 +}
64326 +
64327 +void
64328 +insert_acl_obj_label(struct acl_object_label *obj,
64329 + struct acl_subject_label *subj)
64330 +{
64331 + unsigned int index =
64332 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
64333 + struct acl_object_label **curr;
64334 +
64335 + obj->prev = NULL;
64336 +
64337 + curr = &subj->obj_hash[index];
64338 + if (*curr != NULL)
64339 + (*curr)->prev = obj;
64340 +
64341 + obj->next = *curr;
64342 + *curr = obj;
64343 +
64344 + return;
64345 +}
64346 +
64347 +void
64348 +insert_acl_subj_label(struct acl_subject_label *obj,
64349 + struct acl_role_label *role)
64350 +{
64351 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
64352 + struct acl_subject_label **curr;
64353 +
64354 + obj->prev = NULL;
64355 +
64356 + curr = &role->subj_hash[index];
64357 + if (*curr != NULL)
64358 + (*curr)->prev = obj;
64359 +
64360 + obj->next = *curr;
64361 + *curr = obj;
64362 +
64363 + return;
64364 +}
64365 +
64366 +/* derived from glibc fnmatch() 0: match, 1: no match*/
64367 +
64368 +static int
64369 +glob_match(const char *p, const char *n)
64370 +{
64371 + char c;
64372 +
64373 + while ((c = *p++) != '\0') {
64374 + switch (c) {
64375 + case '?':
64376 + if (*n == '\0')
64377 + return 1;
64378 + else if (*n == '/')
64379 + return 1;
64380 + break;
64381 + case '\\':
64382 + if (*n != c)
64383 + return 1;
64384 + break;
64385 + case '*':
64386 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
64387 + if (*n == '/')
64388 + return 1;
64389 + else if (c == '?') {
64390 + if (*n == '\0')
64391 + return 1;
64392 + else
64393 + ++n;
64394 + }
64395 + }
64396 + if (c == '\0') {
64397 + return 0;
64398 + } else {
64399 + const char *endp;
64400 +
64401 + if ((endp = strchr(n, '/')) == NULL)
64402 + endp = n + strlen(n);
64403 +
64404 + if (c == '[') {
64405 + for (--p; n < endp; ++n)
64406 + if (!glob_match(p, n))
64407 + return 0;
64408 + } else if (c == '/') {
64409 + while (*n != '\0' && *n != '/')
64410 + ++n;
64411 + if (*n == '/' && !glob_match(p, n + 1))
64412 + return 0;
64413 + } else {
64414 + for (--p; n < endp; ++n)
64415 + if (*n == c && !glob_match(p, n))
64416 + return 0;
64417 + }
64418 +
64419 + return 1;
64420 + }
64421 + case '[':
64422 + {
64423 + int not;
64424 + char cold;
64425 +
64426 + if (*n == '\0' || *n == '/')
64427 + return 1;
64428 +
64429 + not = (*p == '!' || *p == '^');
64430 + if (not)
64431 + ++p;
64432 +
64433 + c = *p++;
64434 + for (;;) {
64435 + unsigned char fn = (unsigned char)*n;
64436 +
64437 + if (c == '\0')
64438 + return 1;
64439 + else {
64440 + if (c == fn)
64441 + goto matched;
64442 + cold = c;
64443 + c = *p++;
64444 +
64445 + if (c == '-' && *p != ']') {
64446 + unsigned char cend = *p++;
64447 +
64448 + if (cend == '\0')
64449 + return 1;
64450 +
64451 + if (cold <= fn && fn <= cend)
64452 + goto matched;
64453 +
64454 + c = *p++;
64455 + }
64456 + }
64457 +
64458 + if (c == ']')
64459 + break;
64460 + }
64461 + if (!not)
64462 + return 1;
64463 + break;
64464 + matched:
64465 + while (c != ']') {
64466 + if (c == '\0')
64467 + return 1;
64468 +
64469 + c = *p++;
64470 + }
64471 + if (not)
64472 + return 1;
64473 + }
64474 + break;
64475 + default:
64476 + if (c != *n)
64477 + return 1;
64478 + }
64479 +
64480 + ++n;
64481 + }
64482 +
64483 + if (*n == '\0')
64484 + return 0;
64485 +
64486 + if (*n == '/')
64487 + return 0;
64488 +
64489 + return 1;
64490 +}
64491 +
64492 +static struct acl_object_label *
64493 +chk_glob_label(struct acl_object_label *globbed,
64494 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
64495 +{
64496 + struct acl_object_label *tmp;
64497 +
64498 + if (*path == NULL)
64499 + *path = gr_to_filename_nolock(dentry, mnt);
64500 +
64501 + tmp = globbed;
64502 +
64503 + while (tmp) {
64504 + if (!glob_match(tmp->filename, *path))
64505 + return tmp;
64506 + tmp = tmp->next;
64507 + }
64508 +
64509 + return NULL;
64510 +}
64511 +
64512 +static struct acl_object_label *
64513 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64514 + const ino_t curr_ino, const dev_t curr_dev,
64515 + const struct acl_subject_label *subj, char **path, const int checkglob)
64516 +{
64517 + struct acl_subject_label *tmpsubj;
64518 + struct acl_object_label *retval;
64519 + struct acl_object_label *retval2;
64520 +
64521 + tmpsubj = (struct acl_subject_label *) subj;
64522 + read_lock(&gr_inode_lock);
64523 + do {
64524 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
64525 + if (retval) {
64526 + if (checkglob && retval->globbed) {
64527 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
64528 + if (retval2)
64529 + retval = retval2;
64530 + }
64531 + break;
64532 + }
64533 + } while ((tmpsubj = tmpsubj->parent_subject));
64534 + read_unlock(&gr_inode_lock);
64535 +
64536 + return retval;
64537 +}
64538 +
64539 +static __inline__ struct acl_object_label *
64540 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64541 + struct dentry *curr_dentry,
64542 + const struct acl_subject_label *subj, char **path, const int checkglob)
64543 +{
64544 + int newglob = checkglob;
64545 + ino_t inode;
64546 + dev_t device;
64547 +
64548 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
64549 + as we don't want a / * rule to match instead of the / object
64550 + don't do this for create lookups that call this function though, since they're looking up
64551 + on the parent and thus need globbing checks on all paths
64552 + */
64553 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
64554 + newglob = GR_NO_GLOB;
64555 +
64556 + spin_lock(&curr_dentry->d_lock);
64557 + inode = curr_dentry->d_inode->i_ino;
64558 + device = __get_dev(curr_dentry);
64559 + spin_unlock(&curr_dentry->d_lock);
64560 +
64561 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
64562 +}
64563 +
64564 +#ifdef CONFIG_HUGETLBFS
64565 +static inline bool
64566 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
64567 +{
64568 + int i;
64569 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
64570 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
64571 + return true;
64572 + }
64573 +
64574 + return false;
64575 +}
64576 +#endif
64577 +
64578 +static struct acl_object_label *
64579 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64580 + const struct acl_subject_label *subj, char *path, const int checkglob)
64581 +{
64582 + struct dentry *dentry = (struct dentry *) l_dentry;
64583 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64584 + struct mount *real_mnt = real_mount(mnt);
64585 + struct acl_object_label *retval;
64586 + struct dentry *parent;
64587 +
64588 + br_read_lock(&vfsmount_lock);
64589 + write_seqlock(&rename_lock);
64590 +
64591 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
64592 +#ifdef CONFIG_NET
64593 + mnt == sock_mnt ||
64594 +#endif
64595 +#ifdef CONFIG_HUGETLBFS
64596 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
64597 +#endif
64598 + /* ignore Eric Biederman */
64599 + IS_PRIVATE(l_dentry->d_inode))) {
64600 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
64601 + goto out;
64602 + }
64603 +
64604 + for (;;) {
64605 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
64606 + break;
64607 +
64608 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64609 + if (!mnt_has_parent(real_mnt))
64610 + break;
64611 +
64612 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64613 + if (retval != NULL)
64614 + goto out;
64615 +
64616 + dentry = real_mnt->mnt_mountpoint;
64617 + real_mnt = real_mnt->mnt_parent;
64618 + mnt = &real_mnt->mnt;
64619 + continue;
64620 + }
64621 +
64622 + parent = dentry->d_parent;
64623 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64624 + if (retval != NULL)
64625 + goto out;
64626 +
64627 + dentry = parent;
64628 + }
64629 +
64630 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64631 +
64632 + /* gr_real_root is pinned so we don't have to hold a reference */
64633 + if (retval == NULL)
64634 + retval = full_lookup(l_dentry, l_mnt, gr_real_root.dentry, subj, &path, checkglob);
64635 +out:
64636 + write_sequnlock(&rename_lock);
64637 + br_read_unlock(&vfsmount_lock);
64638 +
64639 + BUG_ON(retval == NULL);
64640 +
64641 + return retval;
64642 +}
64643 +
64644 +static __inline__ struct acl_object_label *
64645 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64646 + const struct acl_subject_label *subj)
64647 +{
64648 + char *path = NULL;
64649 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
64650 +}
64651 +
64652 +static __inline__ struct acl_object_label *
64653 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64654 + const struct acl_subject_label *subj)
64655 +{
64656 + char *path = NULL;
64657 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
64658 +}
64659 +
64660 +static __inline__ struct acl_object_label *
64661 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64662 + const struct acl_subject_label *subj, char *path)
64663 +{
64664 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
64665 +}
64666 +
64667 +struct acl_subject_label *
64668 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64669 + const struct acl_role_label *role)
64670 +{
64671 + struct dentry *dentry = (struct dentry *) l_dentry;
64672 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64673 + struct mount *real_mnt = real_mount(mnt);
64674 + struct acl_subject_label *retval;
64675 + struct dentry *parent;
64676 +
64677 + br_read_lock(&vfsmount_lock);
64678 + write_seqlock(&rename_lock);
64679 +
64680 + for (;;) {
64681 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
64682 + break;
64683 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64684 + if (!mnt_has_parent(real_mnt))
64685 + break;
64686 +
64687 + spin_lock(&dentry->d_lock);
64688 + read_lock(&gr_inode_lock);
64689 + retval =
64690 + lookup_acl_subj_label(dentry->d_inode->i_ino,
64691 + __get_dev(dentry), role);
64692 + read_unlock(&gr_inode_lock);
64693 + spin_unlock(&dentry->d_lock);
64694 + if (retval != NULL)
64695 + goto out;
64696 +
64697 + dentry = real_mnt->mnt_mountpoint;
64698 + real_mnt = real_mnt->mnt_parent;
64699 + mnt = &real_mnt->mnt;
64700 + continue;
64701 + }
64702 +
64703 + spin_lock(&dentry->d_lock);
64704 + read_lock(&gr_inode_lock);
64705 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64706 + __get_dev(dentry), role);
64707 + read_unlock(&gr_inode_lock);
64708 + parent = dentry->d_parent;
64709 + spin_unlock(&dentry->d_lock);
64710 +
64711 + if (retval != NULL)
64712 + goto out;
64713 +
64714 + dentry = parent;
64715 + }
64716 +
64717 + spin_lock(&dentry->d_lock);
64718 + read_lock(&gr_inode_lock);
64719 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64720 + __get_dev(dentry), role);
64721 + read_unlock(&gr_inode_lock);
64722 + spin_unlock(&dentry->d_lock);
64723 +
64724 + if (unlikely(retval == NULL)) {
64725 + /* gr_real_root is pinned, we don't need to hold a reference */
64726 + read_lock(&gr_inode_lock);
64727 + retval = lookup_acl_subj_label(gr_real_root.dentry->d_inode->i_ino,
64728 + __get_dev(gr_real_root.dentry), role);
64729 + read_unlock(&gr_inode_lock);
64730 + }
64731 +out:
64732 + write_sequnlock(&rename_lock);
64733 + br_read_unlock(&vfsmount_lock);
64734 +
64735 + BUG_ON(retval == NULL);
64736 +
64737 + return retval;
64738 +}
64739 +
64740 +void
64741 +assign_special_role(const char *rolename)
64742 +{
64743 + struct acl_object_label *obj;
64744 + struct acl_role_label *r;
64745 + struct acl_role_label *assigned = NULL;
64746 + struct task_struct *tsk;
64747 + struct file *filp;
64748 +
64749 + FOR_EACH_ROLE_START(r)
64750 + if (!strcmp(rolename, r->rolename) &&
64751 + (r->roletype & GR_ROLE_SPECIAL)) {
64752 + assigned = r;
64753 + break;
64754 + }
64755 + FOR_EACH_ROLE_END(r)
64756 +
64757 + if (!assigned)
64758 + return;
64759 +
64760 + read_lock(&tasklist_lock);
64761 + read_lock(&grsec_exec_file_lock);
64762 +
64763 + tsk = current->real_parent;
64764 + if (tsk == NULL)
64765 + goto out_unlock;
64766 +
64767 + filp = tsk->exec_file;
64768 + if (filp == NULL)
64769 + goto out_unlock;
64770 +
64771 + tsk->is_writable = 0;
64772 + tsk->inherited = 0;
64773 +
64774 + tsk->acl_sp_role = 1;
64775 + tsk->acl_role_id = ++acl_sp_role_value;
64776 + tsk->role = assigned;
64777 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
64778 +
64779 + /* ignore additional mmap checks for processes that are writable
64780 + by the default ACL */
64781 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
64782 + if (unlikely(obj->mode & GR_WRITE))
64783 + tsk->is_writable = 1;
64784 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
64785 + if (unlikely(obj->mode & GR_WRITE))
64786 + tsk->is_writable = 1;
64787 +
64788 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64789 + printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename,
64790 + tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
64791 +#endif
64792 +
64793 +out_unlock:
64794 + read_unlock(&grsec_exec_file_lock);
64795 + read_unlock(&tasklist_lock);
64796 + return;
64797 +}
64798 +
64799 +
64800 +static void
64801 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
64802 +{
64803 + struct task_struct *task = current;
64804 + const struct cred *cred = current_cred();
64805 +
64806 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
64807 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64808 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64809 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
64810 +
64811 + return;
64812 +}
64813 +
64814 +static void
64815 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
64816 +{
64817 + struct task_struct *task = current;
64818 + const struct cred *cred = current_cred();
64819 +
64820 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64821 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64822 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64823 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
64824 +
64825 + return;
64826 +}
64827 +
64828 +static void
64829 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
64830 +{
64831 + struct task_struct *task = current;
64832 + const struct cred *cred = current_cred();
64833 +
64834 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64835 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64836 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64837 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
64838 +
64839 + return;
64840 +}
64841 +
64842 +static void
64843 +gr_set_proc_res(struct task_struct *task)
64844 +{
64845 + struct acl_subject_label *proc;
64846 + unsigned short i;
64847 +
64848 + proc = task->acl;
64849 +
64850 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
64851 + return;
64852 +
64853 + for (i = 0; i < RLIM_NLIMITS; i++) {
64854 + if (!(proc->resmask & (1U << i)))
64855 + continue;
64856 +
64857 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
64858 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
64859 +
64860 + if (i == RLIMIT_CPU)
64861 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
64862 + }
64863 +
64864 + return;
64865 +}
64866 +
64867 +/* both of the below must be called with
64868 + rcu_read_lock();
64869 + read_lock(&tasklist_lock);
64870 + read_lock(&grsec_exec_file_lock);
64871 +*/
64872 +
64873 +struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename)
64874 +{
64875 + char *tmpname;
64876 + struct acl_subject_label *tmpsubj;
64877 + struct file *filp;
64878 + struct name_entry *nmatch;
64879 +
64880 + filp = task->exec_file;
64881 + if (filp == NULL)
64882 + return NULL;
64883 +
64884 + /* the following is to apply the correct subject
64885 + on binaries running when the RBAC system
64886 + is enabled, when the binaries have been
64887 + replaced or deleted since their execution
64888 + -----
64889 + when the RBAC system starts, the inode/dev
64890 + from exec_file will be one the RBAC system
64891 + is unaware of. It only knows the inode/dev
64892 + of the present file on disk, or the absence
64893 + of it.
64894 + */
64895 +
64896 + if (filename)
64897 + nmatch = __lookup_name_entry(state, filename);
64898 + else {
64899 + preempt_disable();
64900 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
64901 +
64902 + nmatch = __lookup_name_entry(state, tmpname);
64903 + preempt_enable();
64904 + }
64905 + tmpsubj = NULL;
64906 + if (nmatch) {
64907 + if (nmatch->deleted)
64908 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
64909 + else
64910 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
64911 + }
64912 + /* this also works for the reload case -- if we don't match a potentially inherited subject
64913 + then we fall back to a normal lookup based on the binary's ino/dev
64914 + */
64915 + if (tmpsubj == NULL)
64916 + tmpsubj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, task->role);
64917 +
64918 + return tmpsubj;
64919 +}
64920 +
64921 +static struct acl_subject_label *gr_get_subject_for_task(struct task_struct *task, const char *filename)
64922 +{
64923 + return __gr_get_subject_for_task(&running_polstate, task, filename);
64924 +}
64925 +
64926 +void __gr_apply_subject_to_task(const struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj)
64927 +{
64928 + struct acl_object_label *obj;
64929 + struct file *filp;
64930 +
64931 + filp = task->exec_file;
64932 +
64933 + task->acl = subj;
64934 + task->is_writable = 0;
64935 + /* ignore additional mmap checks for processes that are writable
64936 + by the default ACL */
64937 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, state->default_role->root_label);
64938 + if (unlikely(obj->mode & GR_WRITE))
64939 + task->is_writable = 1;
64940 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64941 + if (unlikely(obj->mode & GR_WRITE))
64942 + task->is_writable = 1;
64943 +
64944 + gr_set_proc_res(task);
64945 +
64946 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64947 + 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);
64948 +#endif
64949 +}
64950 +
64951 +static void gr_apply_subject_to_task(struct task_struct *task, struct acl_subject_label *subj)
64952 +{
64953 + __gr_apply_subject_to_task(&running_polstate, task, subj);
64954 +}
64955 +
64956 +__u32
64957 +gr_search_file(const struct dentry * dentry, const __u32 mode,
64958 + const struct vfsmount * mnt)
64959 +{
64960 + __u32 retval = mode;
64961 + struct acl_subject_label *curracl;
64962 + struct acl_object_label *currobj;
64963 +
64964 + if (unlikely(!(gr_status & GR_READY)))
64965 + return (mode & ~GR_AUDITS);
64966 +
64967 + curracl = current->acl;
64968 +
64969 + currobj = chk_obj_label(dentry, mnt, curracl);
64970 + retval = currobj->mode & mode;
64971 +
64972 + /* if we're opening a specified transfer file for writing
64973 + (e.g. /dev/initctl), then transfer our role to init
64974 + */
64975 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
64976 + current->role->roletype & GR_ROLE_PERSIST)) {
64977 + struct task_struct *task = init_pid_ns.child_reaper;
64978 +
64979 + if (task->role != current->role) {
64980 + struct acl_subject_label *subj;
64981 +
64982 + task->acl_sp_role = 0;
64983 + task->acl_role_id = current->acl_role_id;
64984 + task->role = current->role;
64985 + rcu_read_lock();
64986 + read_lock(&grsec_exec_file_lock);
64987 + subj = gr_get_subject_for_task(task, NULL);
64988 + gr_apply_subject_to_task(task, subj);
64989 + read_unlock(&grsec_exec_file_lock);
64990 + rcu_read_unlock();
64991 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
64992 + }
64993 + }
64994 +
64995 + if (unlikely
64996 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
64997 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
64998 + __u32 new_mode = mode;
64999 +
65000 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
65001 +
65002 + retval = new_mode;
65003 +
65004 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
65005 + new_mode |= GR_INHERIT;
65006 +
65007 + if (!(mode & GR_NOLEARN))
65008 + gr_log_learn(dentry, mnt, new_mode);
65009 + }
65010 +
65011 + return retval;
65012 +}
65013 +
65014 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
65015 + const struct dentry *parent,
65016 + const struct vfsmount *mnt)
65017 +{
65018 + struct name_entry *match;
65019 + struct acl_object_label *matchpo;
65020 + struct acl_subject_label *curracl;
65021 + char *path;
65022 +
65023 + if (unlikely(!(gr_status & GR_READY)))
65024 + return NULL;
65025 +
65026 + preempt_disable();
65027 + path = gr_to_filename_rbac(new_dentry, mnt);
65028 + match = lookup_name_entry_create(path);
65029 +
65030 + curracl = current->acl;
65031 +
65032 + if (match) {
65033 + read_lock(&gr_inode_lock);
65034 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
65035 + read_unlock(&gr_inode_lock);
65036 +
65037 + if (matchpo) {
65038 + preempt_enable();
65039 + return matchpo;
65040 + }
65041 + }
65042 +
65043 + // lookup parent
65044 +
65045 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
65046 +
65047 + preempt_enable();
65048 + return matchpo;
65049 +}
65050 +
65051 +__u32
65052 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
65053 + const struct vfsmount * mnt, const __u32 mode)
65054 +{
65055 + struct acl_object_label *matchpo;
65056 + __u32 retval;
65057 +
65058 + if (unlikely(!(gr_status & GR_READY)))
65059 + return (mode & ~GR_AUDITS);
65060 +
65061 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
65062 +
65063 + retval = matchpo->mode & mode;
65064 +
65065 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
65066 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
65067 + __u32 new_mode = mode;
65068 +
65069 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
65070 +
65071 + gr_log_learn(new_dentry, mnt, new_mode);
65072 + return new_mode;
65073 + }
65074 +
65075 + return retval;
65076 +}
65077 +
65078 +__u32
65079 +gr_check_link(const struct dentry * new_dentry,
65080 + const struct dentry * parent_dentry,
65081 + const struct vfsmount * parent_mnt,
65082 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
65083 +{
65084 + struct acl_object_label *obj;
65085 + __u32 oldmode, newmode;
65086 + __u32 needmode;
65087 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
65088 + GR_DELETE | GR_INHERIT;
65089 +
65090 + if (unlikely(!(gr_status & GR_READY)))
65091 + return (GR_CREATE | GR_LINK);
65092 +
65093 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
65094 + oldmode = obj->mode;
65095 +
65096 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
65097 + newmode = obj->mode;
65098 +
65099 + needmode = newmode & checkmodes;
65100 +
65101 + // old name for hardlink must have at least the permissions of the new name
65102 + if ((oldmode & needmode) != needmode)
65103 + goto bad;
65104 +
65105 + // if old name had restrictions/auditing, make sure the new name does as well
65106 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
65107 +
65108 + // don't allow hardlinking of suid/sgid/fcapped files without permission
65109 + if (is_privileged_binary(old_dentry))
65110 + needmode |= GR_SETID;
65111 +
65112 + if ((newmode & needmode) != needmode)
65113 + goto bad;
65114 +
65115 + // enforce minimum permissions
65116 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
65117 + return newmode;
65118 +bad:
65119 + needmode = oldmode;
65120 + if (is_privileged_binary(old_dentry))
65121 + needmode |= GR_SETID;
65122 +
65123 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
65124 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
65125 + return (GR_CREATE | GR_LINK);
65126 + } else if (newmode & GR_SUPPRESS)
65127 + return GR_SUPPRESS;
65128 + else
65129 + return 0;
65130 +}
65131 +
65132 +int
65133 +gr_check_hidden_task(const struct task_struct *task)
65134 +{
65135 + if (unlikely(!(gr_status & GR_READY)))
65136 + return 0;
65137 +
65138 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
65139 + return 1;
65140 +
65141 + return 0;
65142 +}
65143 +
65144 +int
65145 +gr_check_protected_task(const struct task_struct *task)
65146 +{
65147 + if (unlikely(!(gr_status & GR_READY) || !task))
65148 + return 0;
65149 +
65150 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
65151 + task->acl != current->acl)
65152 + return 1;
65153 +
65154 + return 0;
65155 +}
65156 +
65157 +int
65158 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
65159 +{
65160 + struct task_struct *p;
65161 + int ret = 0;
65162 +
65163 + if (unlikely(!(gr_status & GR_READY) || !pid))
65164 + return ret;
65165 +
65166 + read_lock(&tasklist_lock);
65167 + do_each_pid_task(pid, type, p) {
65168 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
65169 + p->acl != current->acl) {
65170 + ret = 1;
65171 + goto out;
65172 + }
65173 + } while_each_pid_task(pid, type, p);
65174 +out:
65175 + read_unlock(&tasklist_lock);
65176 +
65177 + return ret;
65178 +}
65179 +
65180 +void
65181 +gr_copy_label(struct task_struct *tsk)
65182 +{
65183 + struct task_struct *p = current;
65184 +
65185 + tsk->inherited = p->inherited;
65186 + tsk->acl_sp_role = 0;
65187 + tsk->acl_role_id = p->acl_role_id;
65188 + tsk->acl = p->acl;
65189 + tsk->role = p->role;
65190 + tsk->signal->used_accept = 0;
65191 + tsk->signal->curr_ip = p->signal->curr_ip;
65192 + tsk->signal->saved_ip = p->signal->saved_ip;
65193 + if (p->exec_file)
65194 + get_file(p->exec_file);
65195 + tsk->exec_file = p->exec_file;
65196 + tsk->is_writable = p->is_writable;
65197 + if (unlikely(p->signal->used_accept)) {
65198 + p->signal->curr_ip = 0;
65199 + p->signal->saved_ip = 0;
65200 + }
65201 +
65202 + return;
65203 +}
65204 +
65205 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
65206 +
65207 +int
65208 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
65209 +{
65210 + unsigned int i;
65211 + __u16 num;
65212 + uid_t *uidlist;
65213 + uid_t curuid;
65214 + int realok = 0;
65215 + int effectiveok = 0;
65216 + int fsok = 0;
65217 + uid_t globalreal, globaleffective, globalfs;
65218 +
65219 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
65220 + struct user_struct *user;
65221 +
65222 + if (!uid_valid(real))
65223 + goto skipit;
65224 +
65225 + /* find user based on global namespace */
65226 +
65227 + globalreal = GR_GLOBAL_UID(real);
65228 +
65229 + user = find_user(make_kuid(&init_user_ns, globalreal));
65230 + if (user == NULL)
65231 + goto skipit;
65232 +
65233 + if (gr_process_kernel_setuid_ban(user)) {
65234 + /* for find_user */
65235 + free_uid(user);
65236 + return 1;
65237 + }
65238 +
65239 + /* for find_user */
65240 + free_uid(user);
65241 +
65242 +skipit:
65243 +#endif
65244 +
65245 + if (unlikely(!(gr_status & GR_READY)))
65246 + return 0;
65247 +
65248 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
65249 + gr_log_learn_uid_change(real, effective, fs);
65250 +
65251 + num = current->acl->user_trans_num;
65252 + uidlist = current->acl->user_transitions;
65253 +
65254 + if (uidlist == NULL)
65255 + return 0;
65256 +
65257 + if (!uid_valid(real)) {
65258 + realok = 1;
65259 + globalreal = (uid_t)-1;
65260 + } else {
65261 + globalreal = GR_GLOBAL_UID(real);
65262 + }
65263 + if (!uid_valid(effective)) {
65264 + effectiveok = 1;
65265 + globaleffective = (uid_t)-1;
65266 + } else {
65267 + globaleffective = GR_GLOBAL_UID(effective);
65268 + }
65269 + if (!uid_valid(fs)) {
65270 + fsok = 1;
65271 + globalfs = (uid_t)-1;
65272 + } else {
65273 + globalfs = GR_GLOBAL_UID(fs);
65274 + }
65275 +
65276 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
65277 + for (i = 0; i < num; i++) {
65278 + curuid = uidlist[i];
65279 + if (globalreal == curuid)
65280 + realok = 1;
65281 + if (globaleffective == curuid)
65282 + effectiveok = 1;
65283 + if (globalfs == curuid)
65284 + fsok = 1;
65285 + }
65286 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
65287 + for (i = 0; i < num; i++) {
65288 + curuid = uidlist[i];
65289 + if (globalreal == curuid)
65290 + break;
65291 + if (globaleffective == curuid)
65292 + break;
65293 + if (globalfs == curuid)
65294 + break;
65295 + }
65296 + /* not in deny list */
65297 + if (i == num) {
65298 + realok = 1;
65299 + effectiveok = 1;
65300 + fsok = 1;
65301 + }
65302 + }
65303 +
65304 + if (realok && effectiveok && fsok)
65305 + return 0;
65306 + else {
65307 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
65308 + return 1;
65309 + }
65310 +}
65311 +
65312 +int
65313 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
65314 +{
65315 + unsigned int i;
65316 + __u16 num;
65317 + gid_t *gidlist;
65318 + gid_t curgid;
65319 + int realok = 0;
65320 + int effectiveok = 0;
65321 + int fsok = 0;
65322 + gid_t globalreal, globaleffective, globalfs;
65323 +
65324 + if (unlikely(!(gr_status & GR_READY)))
65325 + return 0;
65326 +
65327 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
65328 + gr_log_learn_gid_change(real, effective, fs);
65329 +
65330 + num = current->acl->group_trans_num;
65331 + gidlist = current->acl->group_transitions;
65332 +
65333 + if (gidlist == NULL)
65334 + return 0;
65335 +
65336 + if (!gid_valid(real)) {
65337 + realok = 1;
65338 + globalreal = (gid_t)-1;
65339 + } else {
65340 + globalreal = GR_GLOBAL_GID(real);
65341 + }
65342 + if (!gid_valid(effective)) {
65343 + effectiveok = 1;
65344 + globaleffective = (gid_t)-1;
65345 + } else {
65346 + globaleffective = GR_GLOBAL_GID(effective);
65347 + }
65348 + if (!gid_valid(fs)) {
65349 + fsok = 1;
65350 + globalfs = (gid_t)-1;
65351 + } else {
65352 + globalfs = GR_GLOBAL_GID(fs);
65353 + }
65354 +
65355 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
65356 + for (i = 0; i < num; i++) {
65357 + curgid = gidlist[i];
65358 + if (globalreal == curgid)
65359 + realok = 1;
65360 + if (globaleffective == curgid)
65361 + effectiveok = 1;
65362 + if (globalfs == curgid)
65363 + fsok = 1;
65364 + }
65365 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
65366 + for (i = 0; i < num; i++) {
65367 + curgid = gidlist[i];
65368 + if (globalreal == curgid)
65369 + break;
65370 + if (globaleffective == curgid)
65371 + break;
65372 + if (globalfs == curgid)
65373 + break;
65374 + }
65375 + /* not in deny list */
65376 + if (i == num) {
65377 + realok = 1;
65378 + effectiveok = 1;
65379 + fsok = 1;
65380 + }
65381 + }
65382 +
65383 + if (realok && effectiveok && fsok)
65384 + return 0;
65385 + else {
65386 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
65387 + return 1;
65388 + }
65389 +}
65390 +
65391 +extern int gr_acl_is_capable(const int cap);
65392 +
65393 +void
65394 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
65395 +{
65396 + struct acl_role_label *role = task->role;
65397 + struct acl_subject_label *subj = NULL;
65398 + struct acl_object_label *obj;
65399 + struct file *filp;
65400 + uid_t uid;
65401 + gid_t gid;
65402 +
65403 + if (unlikely(!(gr_status & GR_READY)))
65404 + return;
65405 +
65406 + uid = GR_GLOBAL_UID(kuid);
65407 + gid = GR_GLOBAL_GID(kgid);
65408 +
65409 + filp = task->exec_file;
65410 +
65411 + /* kernel process, we'll give them the kernel role */
65412 + if (unlikely(!filp)) {
65413 + task->role = running_polstate.kernel_role;
65414 + task->acl = running_polstate.kernel_role->root_label;
65415 + return;
65416 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL)) {
65417 + /* save the current ip at time of role lookup so that the proper
65418 + IP will be learned for role_allowed_ip */
65419 + task->signal->saved_ip = task->signal->curr_ip;
65420 + role = lookup_acl_role_label(task, uid, gid);
65421 + }
65422 +
65423 + /* don't change the role if we're not a privileged process */
65424 + if (role && task->role != role &&
65425 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
65426 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
65427 + return;
65428 +
65429 + /* perform subject lookup in possibly new role
65430 + we can use this result below in the case where role == task->role
65431 + */
65432 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
65433 +
65434 + /* if we changed uid/gid, but result in the same role
65435 + and are using inheritance, don't lose the inherited subject
65436 + if current subject is other than what normal lookup
65437 + would result in, we arrived via inheritance, don't
65438 + lose subject
65439 + */
65440 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
65441 + (subj == task->acl)))
65442 + task->acl = subj;
65443 +
65444 + /* leave task->inherited unaffected */
65445 +
65446 + task->role = role;
65447 +
65448 + task->is_writable = 0;
65449 +
65450 + /* ignore additional mmap checks for processes that are writable
65451 + by the default ACL */
65452 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
65453 + if (unlikely(obj->mode & GR_WRITE))
65454 + task->is_writable = 1;
65455 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
65456 + if (unlikely(obj->mode & GR_WRITE))
65457 + task->is_writable = 1;
65458 +
65459 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65460 + 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);
65461 +#endif
65462 +
65463 + gr_set_proc_res(task);
65464 +
65465 + return;
65466 +}
65467 +
65468 +int
65469 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
65470 + const int unsafe_flags)
65471 +{
65472 + struct task_struct *task = current;
65473 + struct acl_subject_label *newacl;
65474 + struct acl_object_label *obj;
65475 + __u32 retmode;
65476 +
65477 + if (unlikely(!(gr_status & GR_READY)))
65478 + return 0;
65479 +
65480 + newacl = chk_subj_label(dentry, mnt, task->role);
65481 +
65482 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
65483 + did an exec
65484 + */
65485 + rcu_read_lock();
65486 + read_lock(&tasklist_lock);
65487 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
65488 + (task->parent->acl->mode & GR_POVERRIDE))) {
65489 + read_unlock(&tasklist_lock);
65490 + rcu_read_unlock();
65491 + goto skip_check;
65492 + }
65493 + read_unlock(&tasklist_lock);
65494 + rcu_read_unlock();
65495 +
65496 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
65497 + !(task->role->roletype & GR_ROLE_GOD) &&
65498 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
65499 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
65500 + if (unsafe_flags & LSM_UNSAFE_SHARE)
65501 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
65502 + else
65503 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
65504 + return -EACCES;
65505 + }
65506 +
65507 +skip_check:
65508 +
65509 + obj = chk_obj_label(dentry, mnt, task->acl);
65510 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
65511 +
65512 + if (!(task->acl->mode & GR_INHERITLEARN) &&
65513 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
65514 + if (obj->nested)
65515 + task->acl = obj->nested;
65516 + else
65517 + task->acl = newacl;
65518 + task->inherited = 0;
65519 + } else {
65520 + task->inherited = 1;
65521 + if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
65522 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
65523 + }
65524 +
65525 + task->is_writable = 0;
65526 +
65527 + /* ignore additional mmap checks for processes that are writable
65528 + by the default ACL */
65529 + obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
65530 + if (unlikely(obj->mode & GR_WRITE))
65531 + task->is_writable = 1;
65532 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
65533 + if (unlikely(obj->mode & GR_WRITE))
65534 + task->is_writable = 1;
65535 +
65536 + gr_set_proc_res(task);
65537 +
65538 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65539 + 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);
65540 +#endif
65541 + return 0;
65542 +}
65543 +
65544 +/* always called with valid inodev ptr */
65545 +static void
65546 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
65547 +{
65548 + struct acl_object_label *matchpo;
65549 + struct acl_subject_label *matchps;
65550 + struct acl_subject_label *subj;
65551 + struct acl_role_label *role;
65552 + unsigned int x;
65553 +
65554 + FOR_EACH_ROLE_START(role)
65555 + FOR_EACH_SUBJECT_START(role, subj, x)
65556 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
65557 + matchpo->mode |= GR_DELETED;
65558 + FOR_EACH_SUBJECT_END(subj,x)
65559 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65560 + /* nested subjects aren't in the role's subj_hash table */
65561 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
65562 + matchpo->mode |= GR_DELETED;
65563 + FOR_EACH_NESTED_SUBJECT_END(subj)
65564 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
65565 + matchps->mode |= GR_DELETED;
65566 + FOR_EACH_ROLE_END(role)
65567 +
65568 + inodev->nentry->deleted = 1;
65569 +
65570 + return;
65571 +}
65572 +
65573 +void
65574 +gr_handle_delete(const ino_t ino, const dev_t dev)
65575 +{
65576 + struct inodev_entry *inodev;
65577 +
65578 + if (unlikely(!(gr_status & GR_READY)))
65579 + return;
65580 +
65581 + write_lock(&gr_inode_lock);
65582 + inodev = lookup_inodev_entry(ino, dev);
65583 + if (inodev != NULL)
65584 + do_handle_delete(inodev, ino, dev);
65585 + write_unlock(&gr_inode_lock);
65586 +
65587 + return;
65588 +}
65589 +
65590 +static void
65591 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
65592 + const ino_t newinode, const dev_t newdevice,
65593 + struct acl_subject_label *subj)
65594 +{
65595 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
65596 + struct acl_object_label *match;
65597 +
65598 + match = subj->obj_hash[index];
65599 +
65600 + while (match && (match->inode != oldinode ||
65601 + match->device != olddevice ||
65602 + !(match->mode & GR_DELETED)))
65603 + match = match->next;
65604 +
65605 + if (match && (match->inode == oldinode)
65606 + && (match->device == olddevice)
65607 + && (match->mode & GR_DELETED)) {
65608 + if (match->prev == NULL) {
65609 + subj->obj_hash[index] = match->next;
65610 + if (match->next != NULL)
65611 + match->next->prev = NULL;
65612 + } else {
65613 + match->prev->next = match->next;
65614 + if (match->next != NULL)
65615 + match->next->prev = match->prev;
65616 + }
65617 + match->prev = NULL;
65618 + match->next = NULL;
65619 + match->inode = newinode;
65620 + match->device = newdevice;
65621 + match->mode &= ~GR_DELETED;
65622 +
65623 + insert_acl_obj_label(match, subj);
65624 + }
65625 +
65626 + return;
65627 +}
65628 +
65629 +static void
65630 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
65631 + const ino_t newinode, const dev_t newdevice,
65632 + struct acl_role_label *role)
65633 +{
65634 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
65635 + struct acl_subject_label *match;
65636 +
65637 + match = role->subj_hash[index];
65638 +
65639 + while (match && (match->inode != oldinode ||
65640 + match->device != olddevice ||
65641 + !(match->mode & GR_DELETED)))
65642 + match = match->next;
65643 +
65644 + if (match && (match->inode == oldinode)
65645 + && (match->device == olddevice)
65646 + && (match->mode & GR_DELETED)) {
65647 + if (match->prev == NULL) {
65648 + role->subj_hash[index] = match->next;
65649 + if (match->next != NULL)
65650 + match->next->prev = NULL;
65651 + } else {
65652 + match->prev->next = match->next;
65653 + if (match->next != NULL)
65654 + match->next->prev = match->prev;
65655 + }
65656 + match->prev = NULL;
65657 + match->next = NULL;
65658 + match->inode = newinode;
65659 + match->device = newdevice;
65660 + match->mode &= ~GR_DELETED;
65661 +
65662 + insert_acl_subj_label(match, role);
65663 + }
65664 +
65665 + return;
65666 +}
65667 +
65668 +static void
65669 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
65670 + const ino_t newinode, const dev_t newdevice)
65671 +{
65672 + unsigned int index = gr_fhash(oldinode, olddevice, running_polstate.inodev_set.i_size);
65673 + struct inodev_entry *match;
65674 +
65675 + match = running_polstate.inodev_set.i_hash[index];
65676 +
65677 + while (match && (match->nentry->inode != oldinode ||
65678 + match->nentry->device != olddevice || !match->nentry->deleted))
65679 + match = match->next;
65680 +
65681 + if (match && (match->nentry->inode == oldinode)
65682 + && (match->nentry->device == olddevice) &&
65683 + match->nentry->deleted) {
65684 + if (match->prev == NULL) {
65685 + running_polstate.inodev_set.i_hash[index] = match->next;
65686 + if (match->next != NULL)
65687 + match->next->prev = NULL;
65688 + } else {
65689 + match->prev->next = match->next;
65690 + if (match->next != NULL)
65691 + match->next->prev = match->prev;
65692 + }
65693 + match->prev = NULL;
65694 + match->next = NULL;
65695 + match->nentry->inode = newinode;
65696 + match->nentry->device = newdevice;
65697 + match->nentry->deleted = 0;
65698 +
65699 + insert_inodev_entry(match);
65700 + }
65701 +
65702 + return;
65703 +}
65704 +
65705 +static void
65706 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
65707 +{
65708 + struct acl_subject_label *subj;
65709 + struct acl_role_label *role;
65710 + unsigned int x;
65711 +
65712 + FOR_EACH_ROLE_START(role)
65713 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
65714 +
65715 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65716 + if ((subj->inode == ino) && (subj->device == dev)) {
65717 + subj->inode = ino;
65718 + subj->device = dev;
65719 + }
65720 + /* nested subjects aren't in the role's subj_hash table */
65721 + update_acl_obj_label(matchn->inode, matchn->device,
65722 + ino, dev, subj);
65723 + FOR_EACH_NESTED_SUBJECT_END(subj)
65724 + FOR_EACH_SUBJECT_START(role, subj, x)
65725 + update_acl_obj_label(matchn->inode, matchn->device,
65726 + ino, dev, subj);
65727 + FOR_EACH_SUBJECT_END(subj,x)
65728 + FOR_EACH_ROLE_END(role)
65729 +
65730 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
65731 +
65732 + return;
65733 +}
65734 +
65735 +static void
65736 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
65737 + const struct vfsmount *mnt)
65738 +{
65739 + ino_t ino = dentry->d_inode->i_ino;
65740 + dev_t dev = __get_dev(dentry);
65741 +
65742 + __do_handle_create(matchn, ino, dev);
65743 +
65744 + return;
65745 +}
65746 +
65747 +void
65748 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
65749 +{
65750 + struct name_entry *matchn;
65751 +
65752 + if (unlikely(!(gr_status & GR_READY)))
65753 + return;
65754 +
65755 + preempt_disable();
65756 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
65757 +
65758 + if (unlikely((unsigned long)matchn)) {
65759 + write_lock(&gr_inode_lock);
65760 + do_handle_create(matchn, dentry, mnt);
65761 + write_unlock(&gr_inode_lock);
65762 + }
65763 + preempt_enable();
65764 +
65765 + return;
65766 +}
65767 +
65768 +void
65769 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
65770 +{
65771 + struct name_entry *matchn;
65772 +
65773 + if (unlikely(!(gr_status & GR_READY)))
65774 + return;
65775 +
65776 + preempt_disable();
65777 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
65778 +
65779 + if (unlikely((unsigned long)matchn)) {
65780 + write_lock(&gr_inode_lock);
65781 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
65782 + write_unlock(&gr_inode_lock);
65783 + }
65784 + preempt_enable();
65785 +
65786 + return;
65787 +}
65788 +
65789 +void
65790 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
65791 + struct dentry *old_dentry,
65792 + struct dentry *new_dentry,
65793 + struct vfsmount *mnt, const __u8 replace)
65794 +{
65795 + struct name_entry *matchn;
65796 + struct inodev_entry *inodev;
65797 + struct inode *inode = new_dentry->d_inode;
65798 + ino_t old_ino = old_dentry->d_inode->i_ino;
65799 + dev_t old_dev = __get_dev(old_dentry);
65800 +
65801 + /* vfs_rename swaps the name and parent link for old_dentry and
65802 + new_dentry
65803 + at this point, old_dentry has the new name, parent link, and inode
65804 + for the renamed file
65805 + if a file is being replaced by a rename, new_dentry has the inode
65806 + and name for the replaced file
65807 + */
65808 +
65809 + if (unlikely(!(gr_status & GR_READY)))
65810 + return;
65811 +
65812 + preempt_disable();
65813 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
65814 +
65815 + /* we wouldn't have to check d_inode if it weren't for
65816 + NFS silly-renaming
65817 + */
65818 +
65819 + write_lock(&gr_inode_lock);
65820 + if (unlikely(replace && inode)) {
65821 + ino_t new_ino = inode->i_ino;
65822 + dev_t new_dev = __get_dev(new_dentry);
65823 +
65824 + inodev = lookup_inodev_entry(new_ino, new_dev);
65825 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
65826 + do_handle_delete(inodev, new_ino, new_dev);
65827 + }
65828 +
65829 + inodev = lookup_inodev_entry(old_ino, old_dev);
65830 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
65831 + do_handle_delete(inodev, old_ino, old_dev);
65832 +
65833 + if (unlikely((unsigned long)matchn))
65834 + do_handle_create(matchn, old_dentry, mnt);
65835 +
65836 + write_unlock(&gr_inode_lock);
65837 + preempt_enable();
65838 +
65839 + return;
65840 +}
65841 +
65842 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
65843 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
65844 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
65845 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
65846 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
65847 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
65848 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
65849 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
65850 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
65851 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
65852 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
65853 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
65854 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
65855 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
65856 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
65857 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
65858 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
65859 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
65860 +};
65861 +
65862 +void
65863 +gr_learn_resource(const struct task_struct *task,
65864 + const int res, const unsigned long wanted, const int gt)
65865 +{
65866 + struct acl_subject_label *acl;
65867 + const struct cred *cred;
65868 +
65869 + if (unlikely((gr_status & GR_READY) &&
65870 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
65871 + goto skip_reslog;
65872 +
65873 + gr_log_resource(task, res, wanted, gt);
65874 +skip_reslog:
65875 +
65876 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
65877 + return;
65878 +
65879 + acl = task->acl;
65880 +
65881 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
65882 + !(acl->resmask & (1U << (unsigned short) res))))
65883 + return;
65884 +
65885 + if (wanted >= acl->res[res].rlim_cur) {
65886 + unsigned long res_add;
65887 +
65888 + res_add = wanted + res_learn_bumps[res];
65889 +
65890 + acl->res[res].rlim_cur = res_add;
65891 +
65892 + if (wanted > acl->res[res].rlim_max)
65893 + acl->res[res].rlim_max = res_add;
65894 +
65895 + /* only log the subject filename, since resource logging is supported for
65896 + single-subject learning only */
65897 + rcu_read_lock();
65898 + cred = __task_cred(task);
65899 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65900 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
65901 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
65902 + "", (unsigned long) res, &task->signal->saved_ip);
65903 + rcu_read_unlock();
65904 + }
65905 +
65906 + return;
65907 +}
65908 +EXPORT_SYMBOL(gr_learn_resource);
65909 +#endif
65910 +
65911 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
65912 +void
65913 +pax_set_initial_flags(struct linux_binprm *bprm)
65914 +{
65915 + struct task_struct *task = current;
65916 + struct acl_subject_label *proc;
65917 + unsigned long flags;
65918 +
65919 + if (unlikely(!(gr_status & GR_READY)))
65920 + return;
65921 +
65922 + flags = pax_get_flags(task);
65923 +
65924 + proc = task->acl;
65925 +
65926 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
65927 + flags &= ~MF_PAX_PAGEEXEC;
65928 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
65929 + flags &= ~MF_PAX_SEGMEXEC;
65930 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
65931 + flags &= ~MF_PAX_RANDMMAP;
65932 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
65933 + flags &= ~MF_PAX_EMUTRAMP;
65934 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
65935 + flags &= ~MF_PAX_MPROTECT;
65936 +
65937 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
65938 + flags |= MF_PAX_PAGEEXEC;
65939 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
65940 + flags |= MF_PAX_SEGMEXEC;
65941 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
65942 + flags |= MF_PAX_RANDMMAP;
65943 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
65944 + flags |= MF_PAX_EMUTRAMP;
65945 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
65946 + flags |= MF_PAX_MPROTECT;
65947 +
65948 + pax_set_flags(task, flags);
65949 +
65950 + return;
65951 +}
65952 +#endif
65953 +
65954 +int
65955 +gr_handle_proc_ptrace(struct task_struct *task)
65956 +{
65957 + struct file *filp;
65958 + struct task_struct *tmp = task;
65959 + struct task_struct *curtemp = current;
65960 + __u32 retmode;
65961 +
65962 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65963 + if (unlikely(!(gr_status & GR_READY)))
65964 + return 0;
65965 +#endif
65966 +
65967 + read_lock(&tasklist_lock);
65968 + read_lock(&grsec_exec_file_lock);
65969 + filp = task->exec_file;
65970 +
65971 + while (task_pid_nr(tmp) > 0) {
65972 + if (tmp == curtemp)
65973 + break;
65974 + tmp = tmp->real_parent;
65975 + }
65976 +
65977 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65978 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
65979 + read_unlock(&grsec_exec_file_lock);
65980 + read_unlock(&tasklist_lock);
65981 + return 1;
65982 + }
65983 +
65984 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65985 + if (!(gr_status & GR_READY)) {
65986 + read_unlock(&grsec_exec_file_lock);
65987 + read_unlock(&tasklist_lock);
65988 + return 0;
65989 + }
65990 +#endif
65991 +
65992 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
65993 + read_unlock(&grsec_exec_file_lock);
65994 + read_unlock(&tasklist_lock);
65995 +
65996 + if (retmode & GR_NOPTRACE)
65997 + return 1;
65998 +
65999 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
66000 + && (current->acl != task->acl || (current->acl != current->role->root_label
66001 + && task_pid_nr(current) != task_pid_nr(task))))
66002 + return 1;
66003 +
66004 + return 0;
66005 +}
66006 +
66007 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
66008 +{
66009 + if (unlikely(!(gr_status & GR_READY)))
66010 + return;
66011 +
66012 + if (!(current->role->roletype & GR_ROLE_GOD))
66013 + return;
66014 +
66015 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
66016 + p->role->rolename, gr_task_roletype_to_char(p),
66017 + p->acl->filename);
66018 +}
66019 +
66020 +int
66021 +gr_handle_ptrace(struct task_struct *task, const long request)
66022 +{
66023 + struct task_struct *tmp = task;
66024 + struct task_struct *curtemp = current;
66025 + __u32 retmode;
66026 +
66027 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
66028 + if (unlikely(!(gr_status & GR_READY)))
66029 + return 0;
66030 +#endif
66031 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
66032 + read_lock(&tasklist_lock);
66033 + while (task_pid_nr(tmp) > 0) {
66034 + if (tmp == curtemp)
66035 + break;
66036 + tmp = tmp->real_parent;
66037 + }
66038 +
66039 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
66040 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
66041 + read_unlock(&tasklist_lock);
66042 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66043 + return 1;
66044 + }
66045 + read_unlock(&tasklist_lock);
66046 + }
66047 +
66048 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66049 + if (!(gr_status & GR_READY))
66050 + return 0;
66051 +#endif
66052 +
66053 + read_lock(&grsec_exec_file_lock);
66054 + if (unlikely(!task->exec_file)) {
66055 + read_unlock(&grsec_exec_file_lock);
66056 + return 0;
66057 + }
66058 +
66059 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
66060 + read_unlock(&grsec_exec_file_lock);
66061 +
66062 + if (retmode & GR_NOPTRACE) {
66063 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66064 + return 1;
66065 + }
66066 +
66067 + if (retmode & GR_PTRACERD) {
66068 + switch (request) {
66069 + case PTRACE_SEIZE:
66070 + case PTRACE_POKETEXT:
66071 + case PTRACE_POKEDATA:
66072 + case PTRACE_POKEUSR:
66073 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
66074 + case PTRACE_SETREGS:
66075 + case PTRACE_SETFPREGS:
66076 +#endif
66077 +#ifdef CONFIG_X86
66078 + case PTRACE_SETFPXREGS:
66079 +#endif
66080 +#ifdef CONFIG_ALTIVEC
66081 + case PTRACE_SETVRREGS:
66082 +#endif
66083 + return 1;
66084 + default:
66085 + return 0;
66086 + }
66087 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
66088 + !(current->role->roletype & GR_ROLE_GOD) &&
66089 + (current->acl != task->acl)) {
66090 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66091 + return 1;
66092 + }
66093 +
66094 + return 0;
66095 +}
66096 +
66097 +static int is_writable_mmap(const struct file *filp)
66098 +{
66099 + struct task_struct *task = current;
66100 + struct acl_object_label *obj, *obj2;
66101 +
66102 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
66103 + !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))) {
66104 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
66105 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
66106 + task->role->root_label);
66107 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
66108 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
66109 + return 1;
66110 + }
66111 + }
66112 + return 0;
66113 +}
66114 +
66115 +int
66116 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
66117 +{
66118 + __u32 mode;
66119 +
66120 + if (unlikely(!file || !(prot & PROT_EXEC)))
66121 + return 1;
66122 +
66123 + if (is_writable_mmap(file))
66124 + return 0;
66125 +
66126 + mode =
66127 + gr_search_file(file->f_path.dentry,
66128 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66129 + file->f_path.mnt);
66130 +
66131 + if (!gr_tpe_allow(file))
66132 + return 0;
66133 +
66134 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66135 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66136 + return 0;
66137 + } else if (unlikely(!(mode & GR_EXEC))) {
66138 + return 0;
66139 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66140 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66141 + return 1;
66142 + }
66143 +
66144 + return 1;
66145 +}
66146 +
66147 +int
66148 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
66149 +{
66150 + __u32 mode;
66151 +
66152 + if (unlikely(!file || !(prot & PROT_EXEC)))
66153 + return 1;
66154 +
66155 + if (is_writable_mmap(file))
66156 + return 0;
66157 +
66158 + mode =
66159 + gr_search_file(file->f_path.dentry,
66160 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66161 + file->f_path.mnt);
66162 +
66163 + if (!gr_tpe_allow(file))
66164 + return 0;
66165 +
66166 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66167 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66168 + return 0;
66169 + } else if (unlikely(!(mode & GR_EXEC))) {
66170 + return 0;
66171 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66172 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66173 + return 1;
66174 + }
66175 +
66176 + return 1;
66177 +}
66178 +
66179 +void
66180 +gr_acl_handle_psacct(struct task_struct *task, const long code)
66181 +{
66182 + unsigned long runtime;
66183 + unsigned long cputime;
66184 + unsigned int wday, cday;
66185 + __u8 whr, chr;
66186 + __u8 wmin, cmin;
66187 + __u8 wsec, csec;
66188 + struct timespec timeval;
66189 +
66190 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
66191 + !(task->acl->mode & GR_PROCACCT)))
66192 + return;
66193 +
66194 + do_posix_clock_monotonic_gettime(&timeval);
66195 + runtime = timeval.tv_sec - task->start_time.tv_sec;
66196 + wday = runtime / (3600 * 24);
66197 + runtime -= wday * (3600 * 24);
66198 + whr = runtime / 3600;
66199 + runtime -= whr * 3600;
66200 + wmin = runtime / 60;
66201 + runtime -= wmin * 60;
66202 + wsec = runtime;
66203 +
66204 + cputime = (task->utime + task->stime) / HZ;
66205 + cday = cputime / (3600 * 24);
66206 + cputime -= cday * (3600 * 24);
66207 + chr = cputime / 3600;
66208 + cputime -= chr * 3600;
66209 + cmin = cputime / 60;
66210 + cputime -= cmin * 60;
66211 + csec = cputime;
66212 +
66213 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
66214 +
66215 + return;
66216 +}
66217 +
66218 +#ifdef CONFIG_TASKSTATS
66219 +int gr_is_taskstats_denied(int pid)
66220 +{
66221 + struct task_struct *task;
66222 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66223 + const struct cred *cred;
66224 +#endif
66225 + int ret = 0;
66226 +
66227 + /* restrict taskstats viewing to un-chrooted root users
66228 + who have the 'view' subject flag if the RBAC system is enabled
66229 + */
66230 +
66231 + rcu_read_lock();
66232 + read_lock(&tasklist_lock);
66233 + task = find_task_by_vpid(pid);
66234 + if (task) {
66235 +#ifdef CONFIG_GRKERNSEC_CHROOT
66236 + if (proc_is_chrooted(task))
66237 + ret = -EACCES;
66238 +#endif
66239 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66240 + cred = __task_cred(task);
66241 +#ifdef CONFIG_GRKERNSEC_PROC_USER
66242 + if (gr_is_global_nonroot(cred->uid))
66243 + ret = -EACCES;
66244 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66245 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
66246 + ret = -EACCES;
66247 +#endif
66248 +#endif
66249 + if (gr_status & GR_READY) {
66250 + if (!(task->acl->mode & GR_VIEW))
66251 + ret = -EACCES;
66252 + }
66253 + } else
66254 + ret = -ENOENT;
66255 +
66256 + read_unlock(&tasklist_lock);
66257 + rcu_read_unlock();
66258 +
66259 + return ret;
66260 +}
66261 +#endif
66262 +
66263 +/* AUXV entries are filled via a descendant of search_binary_handler
66264 + after we've already applied the subject for the target
66265 +*/
66266 +int gr_acl_enable_at_secure(void)
66267 +{
66268 + if (unlikely(!(gr_status & GR_READY)))
66269 + return 0;
66270 +
66271 + if (current->acl->mode & GR_ATSECURE)
66272 + return 1;
66273 +
66274 + return 0;
66275 +}
66276 +
66277 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
66278 +{
66279 + struct task_struct *task = current;
66280 + struct dentry *dentry = file->f_path.dentry;
66281 + struct vfsmount *mnt = file->f_path.mnt;
66282 + struct acl_object_label *obj, *tmp;
66283 + struct acl_subject_label *subj;
66284 + unsigned int bufsize;
66285 + int is_not_root;
66286 + char *path;
66287 + dev_t dev = __get_dev(dentry);
66288 +
66289 + if (unlikely(!(gr_status & GR_READY)))
66290 + return 1;
66291 +
66292 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
66293 + return 1;
66294 +
66295 + /* ignore Eric Biederman */
66296 + if (IS_PRIVATE(dentry->d_inode))
66297 + return 1;
66298 +
66299 + subj = task->acl;
66300 + read_lock(&gr_inode_lock);
66301 + do {
66302 + obj = lookup_acl_obj_label(ino, dev, subj);
66303 + if (obj != NULL) {
66304 + read_unlock(&gr_inode_lock);
66305 + return (obj->mode & GR_FIND) ? 1 : 0;
66306 + }
66307 + } while ((subj = subj->parent_subject));
66308 + read_unlock(&gr_inode_lock);
66309 +
66310 + /* this is purely an optimization since we're looking for an object
66311 + for the directory we're doing a readdir on
66312 + if it's possible for any globbed object to match the entry we're
66313 + filling into the directory, then the object we find here will be
66314 + an anchor point with attached globbed objects
66315 + */
66316 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
66317 + if (obj->globbed == NULL)
66318 + return (obj->mode & GR_FIND) ? 1 : 0;
66319 +
66320 + is_not_root = ((obj->filename[0] == '/') &&
66321 + (obj->filename[1] == '\0')) ? 0 : 1;
66322 + bufsize = PAGE_SIZE - namelen - is_not_root;
66323 +
66324 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
66325 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
66326 + return 1;
66327 +
66328 + preempt_disable();
66329 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
66330 + bufsize);
66331 +
66332 + bufsize = strlen(path);
66333 +
66334 + /* if base is "/", don't append an additional slash */
66335 + if (is_not_root)
66336 + *(path + bufsize) = '/';
66337 + memcpy(path + bufsize + is_not_root, name, namelen);
66338 + *(path + bufsize + namelen + is_not_root) = '\0';
66339 +
66340 + tmp = obj->globbed;
66341 + while (tmp) {
66342 + if (!glob_match(tmp->filename, path)) {
66343 + preempt_enable();
66344 + return (tmp->mode & GR_FIND) ? 1 : 0;
66345 + }
66346 + tmp = tmp->next;
66347 + }
66348 + preempt_enable();
66349 + return (obj->mode & GR_FIND) ? 1 : 0;
66350 +}
66351 +
66352 +void gr_put_exec_file(struct task_struct *task)
66353 +{
66354 + struct file *filp;
66355 +
66356 + write_lock(&grsec_exec_file_lock);
66357 + filp = task->exec_file;
66358 + task->exec_file = NULL;
66359 + write_unlock(&grsec_exec_file_lock);
66360 +
66361 + if (filp)
66362 + fput(filp);
66363 +
66364 + return;
66365 +}
66366 +
66367 +
66368 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
66369 +EXPORT_SYMBOL(gr_acl_is_enabled);
66370 +#endif
66371 +#ifdef CONFIG_SECURITY
66372 +EXPORT_SYMBOL(gr_check_user_change);
66373 +EXPORT_SYMBOL(gr_check_group_change);
66374 +#endif
66375 +
66376 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
66377 new file mode 100644
66378 index 0000000..18ffbbd
66379 --- /dev/null
66380 +++ b/grsecurity/gracl_alloc.c
66381 @@ -0,0 +1,105 @@
66382 +#include <linux/kernel.h>
66383 +#include <linux/mm.h>
66384 +#include <linux/slab.h>
66385 +#include <linux/vmalloc.h>
66386 +#include <linux/gracl.h>
66387 +#include <linux/grsecurity.h>
66388 +
66389 +static struct gr_alloc_state __current_alloc_state = { 1, 1, NULL };
66390 +struct gr_alloc_state *current_alloc_state = &__current_alloc_state;
66391 +
66392 +static __inline__ int
66393 +alloc_pop(void)
66394 +{
66395 + if (current_alloc_state->alloc_stack_next == 1)
66396 + return 0;
66397 +
66398 + kfree(current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 2]);
66399 +
66400 + current_alloc_state->alloc_stack_next--;
66401 +
66402 + return 1;
66403 +}
66404 +
66405 +static __inline__ int
66406 +alloc_push(void *buf)
66407 +{
66408 + if (current_alloc_state->alloc_stack_next >= current_alloc_state->alloc_stack_size)
66409 + return 1;
66410 +
66411 + current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 1] = buf;
66412 +
66413 + current_alloc_state->alloc_stack_next++;
66414 +
66415 + return 0;
66416 +}
66417 +
66418 +void *
66419 +acl_alloc(unsigned long len)
66420 +{
66421 + void *ret = NULL;
66422 +
66423 + if (!len || len > PAGE_SIZE)
66424 + goto out;
66425 +
66426 + ret = kmalloc(len, GFP_KERNEL);
66427 +
66428 + if (ret) {
66429 + if (alloc_push(ret)) {
66430 + kfree(ret);
66431 + ret = NULL;
66432 + }
66433 + }
66434 +
66435 +out:
66436 + return ret;
66437 +}
66438 +
66439 +void *
66440 +acl_alloc_num(unsigned long num, unsigned long len)
66441 +{
66442 + if (!len || (num > (PAGE_SIZE / len)))
66443 + return NULL;
66444 +
66445 + return acl_alloc(num * len);
66446 +}
66447 +
66448 +void
66449 +acl_free_all(void)
66450 +{
66451 + if (!current_alloc_state->alloc_stack)
66452 + return;
66453 +
66454 + while (alloc_pop()) ;
66455 +
66456 + if (current_alloc_state->alloc_stack) {
66457 + if ((current_alloc_state->alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
66458 + kfree(current_alloc_state->alloc_stack);
66459 + else
66460 + vfree(current_alloc_state->alloc_stack);
66461 + }
66462 +
66463 + current_alloc_state->alloc_stack = NULL;
66464 + current_alloc_state->alloc_stack_size = 1;
66465 + current_alloc_state->alloc_stack_next = 1;
66466 +
66467 + return;
66468 +}
66469 +
66470 +int
66471 +acl_alloc_stack_init(unsigned long size)
66472 +{
66473 + if ((size * sizeof (void *)) <= PAGE_SIZE)
66474 + current_alloc_state->alloc_stack =
66475 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
66476 + else
66477 + current_alloc_state->alloc_stack = (void **) vmalloc(size * sizeof (void *));
66478 +
66479 + current_alloc_state->alloc_stack_size = size;
66480 + current_alloc_state->alloc_stack_next = 1;
66481 +
66482 + if (!current_alloc_state->alloc_stack)
66483 + return 0;
66484 + else
66485 + return 1;
66486 +}
66487 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
66488 new file mode 100644
66489 index 0000000..bdd51ea
66490 --- /dev/null
66491 +++ b/grsecurity/gracl_cap.c
66492 @@ -0,0 +1,110 @@
66493 +#include <linux/kernel.h>
66494 +#include <linux/module.h>
66495 +#include <linux/sched.h>
66496 +#include <linux/gracl.h>
66497 +#include <linux/grsecurity.h>
66498 +#include <linux/grinternal.h>
66499 +
66500 +extern const char *captab_log[];
66501 +extern int captab_log_entries;
66502 +
66503 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
66504 +{
66505 + struct acl_subject_label *curracl;
66506 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66507 + kernel_cap_t cap_audit = __cap_empty_set;
66508 +
66509 + if (!gr_acl_is_enabled())
66510 + return 1;
66511 +
66512 + curracl = task->acl;
66513 +
66514 + cap_drop = curracl->cap_lower;
66515 + cap_mask = curracl->cap_mask;
66516 + cap_audit = curracl->cap_invert_audit;
66517 +
66518 + while ((curracl = curracl->parent_subject)) {
66519 + /* if the cap isn't specified in the current computed mask but is specified in the
66520 + current level subject, and is lowered in the current level subject, then add
66521 + it to the set of dropped capabilities
66522 + otherwise, add the current level subject's mask to the current computed mask
66523 + */
66524 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66525 + cap_raise(cap_mask, cap);
66526 + if (cap_raised(curracl->cap_lower, cap))
66527 + cap_raise(cap_drop, cap);
66528 + if (cap_raised(curracl->cap_invert_audit, cap))
66529 + cap_raise(cap_audit, cap);
66530 + }
66531 + }
66532 +
66533 + if (!cap_raised(cap_drop, cap)) {
66534 + if (cap_raised(cap_audit, cap))
66535 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
66536 + return 1;
66537 + }
66538 +
66539 + curracl = task->acl;
66540 +
66541 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
66542 + && cap_raised(cred->cap_effective, cap)) {
66543 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
66544 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
66545 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
66546 + gr_to_filename(task->exec_file->f_path.dentry,
66547 + task->exec_file->f_path.mnt) : curracl->filename,
66548 + curracl->filename, 0UL,
66549 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
66550 + return 1;
66551 + }
66552 +
66553 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
66554 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
66555 +
66556 + return 0;
66557 +}
66558 +
66559 +int
66560 +gr_acl_is_capable(const int cap)
66561 +{
66562 + return gr_task_acl_is_capable(current, current_cred(), cap);
66563 +}
66564 +
66565 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
66566 +{
66567 + struct acl_subject_label *curracl;
66568 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66569 +
66570 + if (!gr_acl_is_enabled())
66571 + return 1;
66572 +
66573 + curracl = task->acl;
66574 +
66575 + cap_drop = curracl->cap_lower;
66576 + cap_mask = curracl->cap_mask;
66577 +
66578 + while ((curracl = curracl->parent_subject)) {
66579 + /* if the cap isn't specified in the current computed mask but is specified in the
66580 + current level subject, and is lowered in the current level subject, then add
66581 + it to the set of dropped capabilities
66582 + otherwise, add the current level subject's mask to the current computed mask
66583 + */
66584 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66585 + cap_raise(cap_mask, cap);
66586 + if (cap_raised(curracl->cap_lower, cap))
66587 + cap_raise(cap_drop, cap);
66588 + }
66589 + }
66590 +
66591 + if (!cap_raised(cap_drop, cap))
66592 + return 1;
66593 +
66594 + return 0;
66595 +}
66596 +
66597 +int
66598 +gr_acl_is_capable_nolog(const int cap)
66599 +{
66600 + return gr_task_acl_is_capable_nolog(current, cap);
66601 +}
66602 +
66603 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
66604 new file mode 100644
66605 index 0000000..ca25605
66606 --- /dev/null
66607 +++ b/grsecurity/gracl_compat.c
66608 @@ -0,0 +1,270 @@
66609 +#include <linux/kernel.h>
66610 +#include <linux/gracl.h>
66611 +#include <linux/compat.h>
66612 +#include <linux/gracl_compat.h>
66613 +
66614 +#include <asm/uaccess.h>
66615 +
66616 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
66617 +{
66618 + struct gr_arg_wrapper_compat uwrapcompat;
66619 +
66620 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
66621 + return -EFAULT;
66622 +
66623 + if (((uwrapcompat.version != GRSECURITY_VERSION) &&
66624 + (uwrapcompat.version != 0x2901)) ||
66625 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
66626 + return -EINVAL;
66627 +
66628 + uwrap->arg = compat_ptr(uwrapcompat.arg);
66629 + uwrap->version = uwrapcompat.version;
66630 + uwrap->size = sizeof(struct gr_arg);
66631 +
66632 + return 0;
66633 +}
66634 +
66635 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
66636 +{
66637 + struct gr_arg_compat argcompat;
66638 +
66639 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
66640 + return -EFAULT;
66641 +
66642 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
66643 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
66644 + arg->role_db.num_roles = argcompat.role_db.num_roles;
66645 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
66646 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
66647 + arg->role_db.num_objects = argcompat.role_db.num_objects;
66648 +
66649 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
66650 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
66651 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
66652 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
66653 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
66654 + arg->segv_device = argcompat.segv_device;
66655 + arg->segv_inode = argcompat.segv_inode;
66656 + arg->segv_uid = argcompat.segv_uid;
66657 + arg->num_sprole_pws = argcompat.num_sprole_pws;
66658 + arg->mode = argcompat.mode;
66659 +
66660 + return 0;
66661 +}
66662 +
66663 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
66664 +{
66665 + struct acl_object_label_compat objcompat;
66666 +
66667 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
66668 + return -EFAULT;
66669 +
66670 + obj->filename = compat_ptr(objcompat.filename);
66671 + obj->inode = objcompat.inode;
66672 + obj->device = objcompat.device;
66673 + obj->mode = objcompat.mode;
66674 +
66675 + obj->nested = compat_ptr(objcompat.nested);
66676 + obj->globbed = compat_ptr(objcompat.globbed);
66677 +
66678 + obj->prev = compat_ptr(objcompat.prev);
66679 + obj->next = compat_ptr(objcompat.next);
66680 +
66681 + return 0;
66682 +}
66683 +
66684 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
66685 +{
66686 + unsigned int i;
66687 + struct acl_subject_label_compat subjcompat;
66688 +
66689 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
66690 + return -EFAULT;
66691 +
66692 + subj->filename = compat_ptr(subjcompat.filename);
66693 + subj->inode = subjcompat.inode;
66694 + subj->device = subjcompat.device;
66695 + subj->mode = subjcompat.mode;
66696 + subj->cap_mask = subjcompat.cap_mask;
66697 + subj->cap_lower = subjcompat.cap_lower;
66698 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
66699 +
66700 + for (i = 0; i < GR_NLIMITS; i++) {
66701 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
66702 + subj->res[i].rlim_cur = RLIM_INFINITY;
66703 + else
66704 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
66705 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
66706 + subj->res[i].rlim_max = RLIM_INFINITY;
66707 + else
66708 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
66709 + }
66710 + subj->resmask = subjcompat.resmask;
66711 +
66712 + subj->user_trans_type = subjcompat.user_trans_type;
66713 + subj->group_trans_type = subjcompat.group_trans_type;
66714 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
66715 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
66716 + subj->user_trans_num = subjcompat.user_trans_num;
66717 + subj->group_trans_num = subjcompat.group_trans_num;
66718 +
66719 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
66720 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
66721 + subj->ip_type = subjcompat.ip_type;
66722 + subj->ips = compat_ptr(subjcompat.ips);
66723 + subj->ip_num = subjcompat.ip_num;
66724 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
66725 +
66726 + subj->crashes = subjcompat.crashes;
66727 + subj->expires = subjcompat.expires;
66728 +
66729 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
66730 + subj->hash = compat_ptr(subjcompat.hash);
66731 + subj->prev = compat_ptr(subjcompat.prev);
66732 + subj->next = compat_ptr(subjcompat.next);
66733 +
66734 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
66735 + subj->obj_hash_size = subjcompat.obj_hash_size;
66736 + subj->pax_flags = subjcompat.pax_flags;
66737 +
66738 + return 0;
66739 +}
66740 +
66741 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
66742 +{
66743 + struct acl_role_label_compat rolecompat;
66744 +
66745 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
66746 + return -EFAULT;
66747 +
66748 + role->rolename = compat_ptr(rolecompat.rolename);
66749 + role->uidgid = rolecompat.uidgid;
66750 + role->roletype = rolecompat.roletype;
66751 +
66752 + role->auth_attempts = rolecompat.auth_attempts;
66753 + role->expires = rolecompat.expires;
66754 +
66755 + role->root_label = compat_ptr(rolecompat.root_label);
66756 + role->hash = compat_ptr(rolecompat.hash);
66757 +
66758 + role->prev = compat_ptr(rolecompat.prev);
66759 + role->next = compat_ptr(rolecompat.next);
66760 +
66761 + role->transitions = compat_ptr(rolecompat.transitions);
66762 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
66763 + role->domain_children = compat_ptr(rolecompat.domain_children);
66764 + role->domain_child_num = rolecompat.domain_child_num;
66765 +
66766 + role->umask = rolecompat.umask;
66767 +
66768 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
66769 + role->subj_hash_size = rolecompat.subj_hash_size;
66770 +
66771 + return 0;
66772 +}
66773 +
66774 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
66775 +{
66776 + struct role_allowed_ip_compat roleip_compat;
66777 +
66778 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
66779 + return -EFAULT;
66780 +
66781 + roleip->addr = roleip_compat.addr;
66782 + roleip->netmask = roleip_compat.netmask;
66783 +
66784 + roleip->prev = compat_ptr(roleip_compat.prev);
66785 + roleip->next = compat_ptr(roleip_compat.next);
66786 +
66787 + return 0;
66788 +}
66789 +
66790 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
66791 +{
66792 + struct role_transition_compat trans_compat;
66793 +
66794 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
66795 + return -EFAULT;
66796 +
66797 + trans->rolename = compat_ptr(trans_compat.rolename);
66798 +
66799 + trans->prev = compat_ptr(trans_compat.prev);
66800 + trans->next = compat_ptr(trans_compat.next);
66801 +
66802 + return 0;
66803 +
66804 +}
66805 +
66806 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
66807 +{
66808 + struct gr_hash_struct_compat hash_compat;
66809 +
66810 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
66811 + return -EFAULT;
66812 +
66813 + hash->table = compat_ptr(hash_compat.table);
66814 + hash->nametable = compat_ptr(hash_compat.nametable);
66815 + hash->first = compat_ptr(hash_compat.first);
66816 +
66817 + hash->table_size = hash_compat.table_size;
66818 + hash->used_size = hash_compat.used_size;
66819 +
66820 + hash->type = hash_compat.type;
66821 +
66822 + return 0;
66823 +}
66824 +
66825 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
66826 +{
66827 + compat_uptr_t ptrcompat;
66828 +
66829 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
66830 + return -EFAULT;
66831 +
66832 + *(void **)ptr = compat_ptr(ptrcompat);
66833 +
66834 + return 0;
66835 +}
66836 +
66837 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
66838 +{
66839 + struct acl_ip_label_compat ip_compat;
66840 +
66841 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
66842 + return -EFAULT;
66843 +
66844 + ip->iface = compat_ptr(ip_compat.iface);
66845 + ip->addr = ip_compat.addr;
66846 + ip->netmask = ip_compat.netmask;
66847 + ip->low = ip_compat.low;
66848 + ip->high = ip_compat.high;
66849 + ip->mode = ip_compat.mode;
66850 + ip->type = ip_compat.type;
66851 +
66852 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
66853 +
66854 + ip->prev = compat_ptr(ip_compat.prev);
66855 + ip->next = compat_ptr(ip_compat.next);
66856 +
66857 + return 0;
66858 +}
66859 +
66860 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
66861 +{
66862 + struct sprole_pw_compat pw_compat;
66863 +
66864 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
66865 + return -EFAULT;
66866 +
66867 + pw->rolename = compat_ptr(pw_compat.rolename);
66868 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
66869 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
66870 +
66871 + return 0;
66872 +}
66873 +
66874 +size_t get_gr_arg_wrapper_size_compat(void)
66875 +{
66876 + return sizeof(struct gr_arg_wrapper_compat);
66877 +}
66878 +
66879 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
66880 new file mode 100644
66881 index 0000000..deb6f3b
66882 --- /dev/null
66883 +++ b/grsecurity/gracl_fs.c
66884 @@ -0,0 +1,437 @@
66885 +#include <linux/kernel.h>
66886 +#include <linux/sched.h>
66887 +#include <linux/types.h>
66888 +#include <linux/fs.h>
66889 +#include <linux/file.h>
66890 +#include <linux/stat.h>
66891 +#include <linux/grsecurity.h>
66892 +#include <linux/grinternal.h>
66893 +#include <linux/gracl.h>
66894 +
66895 +umode_t
66896 +gr_acl_umask(void)
66897 +{
66898 + if (unlikely(!gr_acl_is_enabled()))
66899 + return 0;
66900 +
66901 + return current->role->umask;
66902 +}
66903 +
66904 +__u32
66905 +gr_acl_handle_hidden_file(const struct dentry * dentry,
66906 + const struct vfsmount * mnt)
66907 +{
66908 + __u32 mode;
66909 +
66910 + if (unlikely(!dentry->d_inode))
66911 + return GR_FIND;
66912 +
66913 + mode =
66914 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
66915 +
66916 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
66917 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66918 + return mode;
66919 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
66920 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66921 + return 0;
66922 + } else if (unlikely(!(mode & GR_FIND)))
66923 + return 0;
66924 +
66925 + return GR_FIND;
66926 +}
66927 +
66928 +__u32
66929 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
66930 + int acc_mode)
66931 +{
66932 + __u32 reqmode = GR_FIND;
66933 + __u32 mode;
66934 +
66935 + if (unlikely(!dentry->d_inode))
66936 + return reqmode;
66937 +
66938 + if (acc_mode & MAY_APPEND)
66939 + reqmode |= GR_APPEND;
66940 + else if (acc_mode & MAY_WRITE)
66941 + reqmode |= GR_WRITE;
66942 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
66943 + reqmode |= GR_READ;
66944 +
66945 + mode =
66946 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66947 + mnt);
66948 +
66949 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66950 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66951 + reqmode & GR_READ ? " reading" : "",
66952 + reqmode & GR_WRITE ? " writing" : reqmode &
66953 + GR_APPEND ? " appending" : "");
66954 + return reqmode;
66955 + } else
66956 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66957 + {
66958 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66959 + reqmode & GR_READ ? " reading" : "",
66960 + reqmode & GR_WRITE ? " writing" : reqmode &
66961 + GR_APPEND ? " appending" : "");
66962 + return 0;
66963 + } else if (unlikely((mode & reqmode) != reqmode))
66964 + return 0;
66965 +
66966 + return reqmode;
66967 +}
66968 +
66969 +__u32
66970 +gr_acl_handle_creat(const struct dentry * dentry,
66971 + const struct dentry * p_dentry,
66972 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
66973 + const int imode)
66974 +{
66975 + __u32 reqmode = GR_WRITE | GR_CREATE;
66976 + __u32 mode;
66977 +
66978 + if (acc_mode & MAY_APPEND)
66979 + reqmode |= GR_APPEND;
66980 + // if a directory was required or the directory already exists, then
66981 + // don't count this open as a read
66982 + if ((acc_mode & MAY_READ) &&
66983 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
66984 + reqmode |= GR_READ;
66985 + if ((open_flags & O_CREAT) &&
66986 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
66987 + reqmode |= GR_SETID;
66988 +
66989 + mode =
66990 + gr_check_create(dentry, p_dentry, p_mnt,
66991 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
66992 +
66993 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66994 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66995 + reqmode & GR_READ ? " reading" : "",
66996 + reqmode & GR_WRITE ? " writing" : reqmode &
66997 + GR_APPEND ? " appending" : "");
66998 + return reqmode;
66999 + } else
67000 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67001 + {
67002 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
67003 + reqmode & GR_READ ? " reading" : "",
67004 + reqmode & GR_WRITE ? " writing" : reqmode &
67005 + GR_APPEND ? " appending" : "");
67006 + return 0;
67007 + } else if (unlikely((mode & reqmode) != reqmode))
67008 + return 0;
67009 +
67010 + return reqmode;
67011 +}
67012 +
67013 +__u32
67014 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
67015 + const int fmode)
67016 +{
67017 + __u32 mode, reqmode = GR_FIND;
67018 +
67019 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
67020 + reqmode |= GR_EXEC;
67021 + if (fmode & S_IWOTH)
67022 + reqmode |= GR_WRITE;
67023 + if (fmode & S_IROTH)
67024 + reqmode |= GR_READ;
67025 +
67026 + mode =
67027 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
67028 + mnt);
67029 +
67030 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67031 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67032 + reqmode & GR_READ ? " reading" : "",
67033 + reqmode & GR_WRITE ? " writing" : "",
67034 + reqmode & GR_EXEC ? " executing" : "");
67035 + return reqmode;
67036 + } else
67037 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67038 + {
67039 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67040 + reqmode & GR_READ ? " reading" : "",
67041 + reqmode & GR_WRITE ? " writing" : "",
67042 + reqmode & GR_EXEC ? " executing" : "");
67043 + return 0;
67044 + } else if (unlikely((mode & reqmode) != reqmode))
67045 + return 0;
67046 +
67047 + return reqmode;
67048 +}
67049 +
67050 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
67051 +{
67052 + __u32 mode;
67053 +
67054 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
67055 +
67056 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67057 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
67058 + return mode;
67059 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67060 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
67061 + return 0;
67062 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67063 + return 0;
67064 +
67065 + return (reqmode);
67066 +}
67067 +
67068 +__u32
67069 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
67070 +{
67071 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
67072 +}
67073 +
67074 +__u32
67075 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
67076 +{
67077 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
67078 +}
67079 +
67080 +__u32
67081 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
67082 +{
67083 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
67084 +}
67085 +
67086 +__u32
67087 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
67088 +{
67089 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
67090 +}
67091 +
67092 +__u32
67093 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
67094 + umode_t *modeptr)
67095 +{
67096 + umode_t mode;
67097 +
67098 + *modeptr &= ~gr_acl_umask();
67099 + mode = *modeptr;
67100 +
67101 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
67102 + return 1;
67103 +
67104 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
67105 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
67106 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
67107 + GR_CHMOD_ACL_MSG);
67108 + } else {
67109 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
67110 + }
67111 +}
67112 +
67113 +__u32
67114 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
67115 +{
67116 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
67117 +}
67118 +
67119 +__u32
67120 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
67121 +{
67122 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
67123 +}
67124 +
67125 +__u32
67126 +gr_acl_handle_removexattr(const struct dentry *dentry, const struct vfsmount *mnt)
67127 +{
67128 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_REMOVEXATTR_ACL_MSG);
67129 +}
67130 +
67131 +__u32
67132 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
67133 +{
67134 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
67135 +}
67136 +
67137 +__u32
67138 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
67139 +{
67140 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
67141 + GR_UNIXCONNECT_ACL_MSG);
67142 +}
67143 +
67144 +/* hardlinks require at minimum create and link permission,
67145 + any additional privilege required is based on the
67146 + privilege of the file being linked to
67147 +*/
67148 +__u32
67149 +gr_acl_handle_link(const struct dentry * new_dentry,
67150 + const struct dentry * parent_dentry,
67151 + const struct vfsmount * parent_mnt,
67152 + const struct dentry * old_dentry,
67153 + const struct vfsmount * old_mnt, const struct filename *to)
67154 +{
67155 + __u32 mode;
67156 + __u32 needmode = GR_CREATE | GR_LINK;
67157 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
67158 +
67159 + mode =
67160 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
67161 + old_mnt);
67162 +
67163 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
67164 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67165 + return mode;
67166 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67167 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67168 + return 0;
67169 + } else if (unlikely((mode & needmode) != needmode))
67170 + return 0;
67171 +
67172 + return 1;
67173 +}
67174 +
67175 +__u32
67176 +gr_acl_handle_symlink(const struct dentry * new_dentry,
67177 + const struct dentry * parent_dentry,
67178 + const struct vfsmount * parent_mnt, const struct filename *from)
67179 +{
67180 + __u32 needmode = GR_WRITE | GR_CREATE;
67181 + __u32 mode;
67182 +
67183 + mode =
67184 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
67185 + GR_CREATE | GR_AUDIT_CREATE |
67186 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
67187 +
67188 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
67189 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67190 + return mode;
67191 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67192 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67193 + return 0;
67194 + } else if (unlikely((mode & needmode) != needmode))
67195 + return 0;
67196 +
67197 + return (GR_WRITE | GR_CREATE);
67198 +}
67199 +
67200 +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)
67201 +{
67202 + __u32 mode;
67203 +
67204 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67205 +
67206 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67207 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
67208 + return mode;
67209 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67210 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
67211 + return 0;
67212 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67213 + return 0;
67214 +
67215 + return (reqmode);
67216 +}
67217 +
67218 +__u32
67219 +gr_acl_handle_mknod(const struct dentry * new_dentry,
67220 + const struct dentry * parent_dentry,
67221 + const struct vfsmount * parent_mnt,
67222 + const int mode)
67223 +{
67224 + __u32 reqmode = GR_WRITE | GR_CREATE;
67225 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67226 + reqmode |= GR_SETID;
67227 +
67228 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67229 + reqmode, GR_MKNOD_ACL_MSG);
67230 +}
67231 +
67232 +__u32
67233 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
67234 + const struct dentry *parent_dentry,
67235 + const struct vfsmount *parent_mnt)
67236 +{
67237 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67238 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
67239 +}
67240 +
67241 +#define RENAME_CHECK_SUCCESS(old, new) \
67242 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
67243 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
67244 +
67245 +int
67246 +gr_acl_handle_rename(struct dentry *new_dentry,
67247 + struct dentry *parent_dentry,
67248 + const struct vfsmount *parent_mnt,
67249 + struct dentry *old_dentry,
67250 + struct inode *old_parent_inode,
67251 + struct vfsmount *old_mnt, const struct filename *newname)
67252 +{
67253 + __u32 comp1, comp2;
67254 + int error = 0;
67255 +
67256 + if (unlikely(!gr_acl_is_enabled()))
67257 + return 0;
67258 +
67259 + if (!new_dentry->d_inode) {
67260 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
67261 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
67262 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
67263 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
67264 + GR_DELETE | GR_AUDIT_DELETE |
67265 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67266 + GR_SUPPRESS, old_mnt);
67267 + } else {
67268 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
67269 + GR_CREATE | GR_DELETE |
67270 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
67271 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67272 + GR_SUPPRESS, parent_mnt);
67273 + comp2 =
67274 + gr_search_file(old_dentry,
67275 + GR_READ | GR_WRITE | GR_AUDIT_READ |
67276 + GR_DELETE | GR_AUDIT_DELETE |
67277 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
67278 + }
67279 +
67280 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
67281 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
67282 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67283 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
67284 + && !(comp2 & GR_SUPPRESS)) {
67285 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67286 + error = -EACCES;
67287 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
67288 + error = -EACCES;
67289 +
67290 + return error;
67291 +}
67292 +
67293 +void
67294 +gr_acl_handle_exit(void)
67295 +{
67296 + u16 id;
67297 + char *rolename;
67298 +
67299 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
67300 + !(current->role->roletype & GR_ROLE_PERSIST))) {
67301 + id = current->acl_role_id;
67302 + rolename = current->role->rolename;
67303 + gr_set_acls(1);
67304 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
67305 + }
67306 +
67307 + gr_put_exec_file(current);
67308 + return;
67309 +}
67310 +
67311 +int
67312 +gr_acl_handle_procpidmem(const struct task_struct *task)
67313 +{
67314 + if (unlikely(!gr_acl_is_enabled()))
67315 + return 0;
67316 +
67317 + if (task != current && task->acl->mode & GR_PROTPROCFD)
67318 + return -EACCES;
67319 +
67320 + return 0;
67321 +}
67322 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
67323 new file mode 100644
67324 index 0000000..f056b81
67325 --- /dev/null
67326 +++ b/grsecurity/gracl_ip.c
67327 @@ -0,0 +1,386 @@
67328 +#include <linux/kernel.h>
67329 +#include <asm/uaccess.h>
67330 +#include <asm/errno.h>
67331 +#include <net/sock.h>
67332 +#include <linux/file.h>
67333 +#include <linux/fs.h>
67334 +#include <linux/net.h>
67335 +#include <linux/in.h>
67336 +#include <linux/skbuff.h>
67337 +#include <linux/ip.h>
67338 +#include <linux/udp.h>
67339 +#include <linux/types.h>
67340 +#include <linux/sched.h>
67341 +#include <linux/netdevice.h>
67342 +#include <linux/inetdevice.h>
67343 +#include <linux/gracl.h>
67344 +#include <linux/grsecurity.h>
67345 +#include <linux/grinternal.h>
67346 +
67347 +#define GR_BIND 0x01
67348 +#define GR_CONNECT 0x02
67349 +#define GR_INVERT 0x04
67350 +#define GR_BINDOVERRIDE 0x08
67351 +#define GR_CONNECTOVERRIDE 0x10
67352 +#define GR_SOCK_FAMILY 0x20
67353 +
67354 +static const char * gr_protocols[IPPROTO_MAX] = {
67355 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
67356 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
67357 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
67358 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
67359 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
67360 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
67361 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
67362 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
67363 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
67364 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
67365 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
67366 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
67367 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
67368 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
67369 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
67370 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
67371 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
67372 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
67373 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
67374 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
67375 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
67376 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
67377 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
67378 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
67379 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
67380 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
67381 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
67382 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
67383 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
67384 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
67385 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
67386 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
67387 + };
67388 +
67389 +static const char * gr_socktypes[SOCK_MAX] = {
67390 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
67391 + "unknown:7", "unknown:8", "unknown:9", "packet"
67392 + };
67393 +
67394 +static const char * gr_sockfamilies[AF_MAX+1] = {
67395 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
67396 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
67397 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
67398 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
67399 + };
67400 +
67401 +const char *
67402 +gr_proto_to_name(unsigned char proto)
67403 +{
67404 + return gr_protocols[proto];
67405 +}
67406 +
67407 +const char *
67408 +gr_socktype_to_name(unsigned char type)
67409 +{
67410 + return gr_socktypes[type];
67411 +}
67412 +
67413 +const char *
67414 +gr_sockfamily_to_name(unsigned char family)
67415 +{
67416 + return gr_sockfamilies[family];
67417 +}
67418 +
67419 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
67420 +
67421 +int
67422 +gr_search_socket(const int domain, const int type, const int protocol)
67423 +{
67424 + struct acl_subject_label *curr;
67425 + const struct cred *cred = current_cred();
67426 +
67427 + if (unlikely(!gr_acl_is_enabled()))
67428 + goto exit;
67429 +
67430 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
67431 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
67432 + goto exit; // let the kernel handle it
67433 +
67434 + curr = current->acl;
67435 +
67436 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
67437 + /* the family is allowed, if this is PF_INET allow it only if
67438 + the extra sock type/protocol checks pass */
67439 + if (domain == PF_INET)
67440 + goto inet_check;
67441 + goto exit;
67442 + } else {
67443 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67444 + __u32 fakeip = 0;
67445 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67446 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67447 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67448 + gr_to_filename(current->exec_file->f_path.dentry,
67449 + current->exec_file->f_path.mnt) :
67450 + curr->filename, curr->filename,
67451 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
67452 + &current->signal->saved_ip);
67453 + goto exit;
67454 + }
67455 + goto exit_fail;
67456 + }
67457 +
67458 +inet_check:
67459 + /* the rest of this checking is for IPv4 only */
67460 + if (!curr->ips)
67461 + goto exit;
67462 +
67463 + if ((curr->ip_type & (1U << type)) &&
67464 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
67465 + goto exit;
67466 +
67467 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67468 + /* we don't place acls on raw sockets , and sometimes
67469 + dgram/ip sockets are opened for ioctl and not
67470 + bind/connect, so we'll fake a bind learn log */
67471 + if (type == SOCK_RAW || type == SOCK_PACKET) {
67472 + __u32 fakeip = 0;
67473 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67474 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67475 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67476 + gr_to_filename(current->exec_file->f_path.dentry,
67477 + current->exec_file->f_path.mnt) :
67478 + curr->filename, curr->filename,
67479 + &fakeip, 0, type,
67480 + protocol, GR_CONNECT, &current->signal->saved_ip);
67481 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
67482 + __u32 fakeip = 0;
67483 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67484 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67485 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67486 + gr_to_filename(current->exec_file->f_path.dentry,
67487 + current->exec_file->f_path.mnt) :
67488 + curr->filename, curr->filename,
67489 + &fakeip, 0, type,
67490 + protocol, GR_BIND, &current->signal->saved_ip);
67491 + }
67492 + /* we'll log when they use connect or bind */
67493 + goto exit;
67494 + }
67495 +
67496 +exit_fail:
67497 + if (domain == PF_INET)
67498 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
67499 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
67500 + else if (rcu_access_pointer(net_families[domain]) != NULL)
67501 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
67502 + gr_socktype_to_name(type), protocol);
67503 +
67504 + return 0;
67505 +exit:
67506 + return 1;
67507 +}
67508 +
67509 +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)
67510 +{
67511 + if ((ip->mode & mode) &&
67512 + (ip_port >= ip->low) &&
67513 + (ip_port <= ip->high) &&
67514 + ((ntohl(ip_addr) & our_netmask) ==
67515 + (ntohl(our_addr) & our_netmask))
67516 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
67517 + && (ip->type & (1U << type))) {
67518 + if (ip->mode & GR_INVERT)
67519 + return 2; // specifically denied
67520 + else
67521 + return 1; // allowed
67522 + }
67523 +
67524 + return 0; // not specifically allowed, may continue parsing
67525 +}
67526 +
67527 +static int
67528 +gr_search_connectbind(const int full_mode, struct sock *sk,
67529 + struct sockaddr_in *addr, const int type)
67530 +{
67531 + char iface[IFNAMSIZ] = {0};
67532 + struct acl_subject_label *curr;
67533 + struct acl_ip_label *ip;
67534 + struct inet_sock *isk;
67535 + struct net_device *dev;
67536 + struct in_device *idev;
67537 + unsigned long i;
67538 + int ret;
67539 + int mode = full_mode & (GR_BIND | GR_CONNECT);
67540 + __u32 ip_addr = 0;
67541 + __u32 our_addr;
67542 + __u32 our_netmask;
67543 + char *p;
67544 + __u16 ip_port = 0;
67545 + const struct cred *cred = current_cred();
67546 +
67547 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
67548 + return 0;
67549 +
67550 + curr = current->acl;
67551 + isk = inet_sk(sk);
67552 +
67553 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
67554 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
67555 + addr->sin_addr.s_addr = curr->inaddr_any_override;
67556 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
67557 + struct sockaddr_in saddr;
67558 + int err;
67559 +
67560 + saddr.sin_family = AF_INET;
67561 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
67562 + saddr.sin_port = isk->inet_sport;
67563 +
67564 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67565 + if (err)
67566 + return err;
67567 +
67568 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67569 + if (err)
67570 + return err;
67571 + }
67572 +
67573 + if (!curr->ips)
67574 + return 0;
67575 +
67576 + ip_addr = addr->sin_addr.s_addr;
67577 + ip_port = ntohs(addr->sin_port);
67578 +
67579 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67580 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67581 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67582 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67583 + gr_to_filename(current->exec_file->f_path.dentry,
67584 + current->exec_file->f_path.mnt) :
67585 + curr->filename, curr->filename,
67586 + &ip_addr, ip_port, type,
67587 + sk->sk_protocol, mode, &current->signal->saved_ip);
67588 + return 0;
67589 + }
67590 +
67591 + for (i = 0; i < curr->ip_num; i++) {
67592 + ip = *(curr->ips + i);
67593 + if (ip->iface != NULL) {
67594 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
67595 + p = strchr(iface, ':');
67596 + if (p != NULL)
67597 + *p = '\0';
67598 + dev = dev_get_by_name(sock_net(sk), iface);
67599 + if (dev == NULL)
67600 + continue;
67601 + idev = in_dev_get(dev);
67602 + if (idev == NULL) {
67603 + dev_put(dev);
67604 + continue;
67605 + }
67606 + rcu_read_lock();
67607 + for_ifa(idev) {
67608 + if (!strcmp(ip->iface, ifa->ifa_label)) {
67609 + our_addr = ifa->ifa_address;
67610 + our_netmask = 0xffffffff;
67611 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67612 + if (ret == 1) {
67613 + rcu_read_unlock();
67614 + in_dev_put(idev);
67615 + dev_put(dev);
67616 + return 0;
67617 + } else if (ret == 2) {
67618 + rcu_read_unlock();
67619 + in_dev_put(idev);
67620 + dev_put(dev);
67621 + goto denied;
67622 + }
67623 + }
67624 + } endfor_ifa(idev);
67625 + rcu_read_unlock();
67626 + in_dev_put(idev);
67627 + dev_put(dev);
67628 + } else {
67629 + our_addr = ip->addr;
67630 + our_netmask = ip->netmask;
67631 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67632 + if (ret == 1)
67633 + return 0;
67634 + else if (ret == 2)
67635 + goto denied;
67636 + }
67637 + }
67638 +
67639 +denied:
67640 + if (mode == GR_BIND)
67641 + 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));
67642 + else if (mode == GR_CONNECT)
67643 + 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));
67644 +
67645 + return -EACCES;
67646 +}
67647 +
67648 +int
67649 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
67650 +{
67651 + /* always allow disconnection of dgram sockets with connect */
67652 + if (addr->sin_family == AF_UNSPEC)
67653 + return 0;
67654 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
67655 +}
67656 +
67657 +int
67658 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
67659 +{
67660 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
67661 +}
67662 +
67663 +int gr_search_listen(struct socket *sock)
67664 +{
67665 + struct sock *sk = sock->sk;
67666 + struct sockaddr_in addr;
67667 +
67668 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67669 + addr.sin_port = inet_sk(sk)->inet_sport;
67670 +
67671 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67672 +}
67673 +
67674 +int gr_search_accept(struct socket *sock)
67675 +{
67676 + struct sock *sk = sock->sk;
67677 + struct sockaddr_in addr;
67678 +
67679 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67680 + addr.sin_port = inet_sk(sk)->inet_sport;
67681 +
67682 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67683 +}
67684 +
67685 +int
67686 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
67687 +{
67688 + if (addr)
67689 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
67690 + else {
67691 + struct sockaddr_in sin;
67692 + const struct inet_sock *inet = inet_sk(sk);
67693 +
67694 + sin.sin_addr.s_addr = inet->inet_daddr;
67695 + sin.sin_port = inet->inet_dport;
67696 +
67697 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67698 + }
67699 +}
67700 +
67701 +int
67702 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
67703 +{
67704 + struct sockaddr_in sin;
67705 +
67706 + if (unlikely(skb->len < sizeof (struct udphdr)))
67707 + return 0; // skip this packet
67708 +
67709 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
67710 + sin.sin_port = udp_hdr(skb)->source;
67711 +
67712 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67713 +}
67714 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
67715 new file mode 100644
67716 index 0000000..25f54ef
67717 --- /dev/null
67718 +++ b/grsecurity/gracl_learn.c
67719 @@ -0,0 +1,207 @@
67720 +#include <linux/kernel.h>
67721 +#include <linux/mm.h>
67722 +#include <linux/sched.h>
67723 +#include <linux/poll.h>
67724 +#include <linux/string.h>
67725 +#include <linux/file.h>
67726 +#include <linux/types.h>
67727 +#include <linux/vmalloc.h>
67728 +#include <linux/grinternal.h>
67729 +
67730 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
67731 + size_t count, loff_t *ppos);
67732 +extern int gr_acl_is_enabled(void);
67733 +
67734 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
67735 +static int gr_learn_attached;
67736 +
67737 +/* use a 512k buffer */
67738 +#define LEARN_BUFFER_SIZE (512 * 1024)
67739 +
67740 +static DEFINE_SPINLOCK(gr_learn_lock);
67741 +static DEFINE_MUTEX(gr_learn_user_mutex);
67742 +
67743 +/* we need to maintain two buffers, so that the kernel context of grlearn
67744 + uses a semaphore around the userspace copying, and the other kernel contexts
67745 + use a spinlock when copying into the buffer, since they cannot sleep
67746 +*/
67747 +static char *learn_buffer;
67748 +static char *learn_buffer_user;
67749 +static int learn_buffer_len;
67750 +static int learn_buffer_user_len;
67751 +
67752 +static ssize_t
67753 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
67754 +{
67755 + DECLARE_WAITQUEUE(wait, current);
67756 + ssize_t retval = 0;
67757 +
67758 + add_wait_queue(&learn_wait, &wait);
67759 + set_current_state(TASK_INTERRUPTIBLE);
67760 + do {
67761 + mutex_lock(&gr_learn_user_mutex);
67762 + spin_lock(&gr_learn_lock);
67763 + if (learn_buffer_len)
67764 + break;
67765 + spin_unlock(&gr_learn_lock);
67766 + mutex_unlock(&gr_learn_user_mutex);
67767 + if (file->f_flags & O_NONBLOCK) {
67768 + retval = -EAGAIN;
67769 + goto out;
67770 + }
67771 + if (signal_pending(current)) {
67772 + retval = -ERESTARTSYS;
67773 + goto out;
67774 + }
67775 +
67776 + schedule();
67777 + } while (1);
67778 +
67779 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
67780 + learn_buffer_user_len = learn_buffer_len;
67781 + retval = learn_buffer_len;
67782 + learn_buffer_len = 0;
67783 +
67784 + spin_unlock(&gr_learn_lock);
67785 +
67786 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
67787 + retval = -EFAULT;
67788 +
67789 + mutex_unlock(&gr_learn_user_mutex);
67790 +out:
67791 + set_current_state(TASK_RUNNING);
67792 + remove_wait_queue(&learn_wait, &wait);
67793 + return retval;
67794 +}
67795 +
67796 +static unsigned int
67797 +poll_learn(struct file * file, poll_table * wait)
67798 +{
67799 + poll_wait(file, &learn_wait, wait);
67800 +
67801 + if (learn_buffer_len)
67802 + return (POLLIN | POLLRDNORM);
67803 +
67804 + return 0;
67805 +}
67806 +
67807 +void
67808 +gr_clear_learn_entries(void)
67809 +{
67810 + char *tmp;
67811 +
67812 + mutex_lock(&gr_learn_user_mutex);
67813 + spin_lock(&gr_learn_lock);
67814 + tmp = learn_buffer;
67815 + learn_buffer = NULL;
67816 + spin_unlock(&gr_learn_lock);
67817 + if (tmp)
67818 + vfree(tmp);
67819 + if (learn_buffer_user != NULL) {
67820 + vfree(learn_buffer_user);
67821 + learn_buffer_user = NULL;
67822 + }
67823 + learn_buffer_len = 0;
67824 + mutex_unlock(&gr_learn_user_mutex);
67825 +
67826 + return;
67827 +}
67828 +
67829 +void
67830 +gr_add_learn_entry(const char *fmt, ...)
67831 +{
67832 + va_list args;
67833 + unsigned int len;
67834 +
67835 + if (!gr_learn_attached)
67836 + return;
67837 +
67838 + spin_lock(&gr_learn_lock);
67839 +
67840 + /* leave a gap at the end so we know when it's "full" but don't have to
67841 + compute the exact length of the string we're trying to append
67842 + */
67843 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
67844 + spin_unlock(&gr_learn_lock);
67845 + wake_up_interruptible(&learn_wait);
67846 + return;
67847 + }
67848 + if (learn_buffer == NULL) {
67849 + spin_unlock(&gr_learn_lock);
67850 + return;
67851 + }
67852 +
67853 + va_start(args, fmt);
67854 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
67855 + va_end(args);
67856 +
67857 + learn_buffer_len += len + 1;
67858 +
67859 + spin_unlock(&gr_learn_lock);
67860 + wake_up_interruptible(&learn_wait);
67861 +
67862 + return;
67863 +}
67864 +
67865 +static int
67866 +open_learn(struct inode *inode, struct file *file)
67867 +{
67868 + if (file->f_mode & FMODE_READ && gr_learn_attached)
67869 + return -EBUSY;
67870 + if (file->f_mode & FMODE_READ) {
67871 + int retval = 0;
67872 + mutex_lock(&gr_learn_user_mutex);
67873 + if (learn_buffer == NULL)
67874 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
67875 + if (learn_buffer_user == NULL)
67876 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
67877 + if (learn_buffer == NULL) {
67878 + retval = -ENOMEM;
67879 + goto out_error;
67880 + }
67881 + if (learn_buffer_user == NULL) {
67882 + retval = -ENOMEM;
67883 + goto out_error;
67884 + }
67885 + learn_buffer_len = 0;
67886 + learn_buffer_user_len = 0;
67887 + gr_learn_attached = 1;
67888 +out_error:
67889 + mutex_unlock(&gr_learn_user_mutex);
67890 + return retval;
67891 + }
67892 + return 0;
67893 +}
67894 +
67895 +static int
67896 +close_learn(struct inode *inode, struct file *file)
67897 +{
67898 + if (file->f_mode & FMODE_READ) {
67899 + char *tmp = NULL;
67900 + mutex_lock(&gr_learn_user_mutex);
67901 + spin_lock(&gr_learn_lock);
67902 + tmp = learn_buffer;
67903 + learn_buffer = NULL;
67904 + spin_unlock(&gr_learn_lock);
67905 + if (tmp)
67906 + vfree(tmp);
67907 + if (learn_buffer_user != NULL) {
67908 + vfree(learn_buffer_user);
67909 + learn_buffer_user = NULL;
67910 + }
67911 + learn_buffer_len = 0;
67912 + learn_buffer_user_len = 0;
67913 + gr_learn_attached = 0;
67914 + mutex_unlock(&gr_learn_user_mutex);
67915 + }
67916 +
67917 + return 0;
67918 +}
67919 +
67920 +const struct file_operations grsec_fops = {
67921 + .read = read_learn,
67922 + .write = write_grsec_handler,
67923 + .open = open_learn,
67924 + .release = close_learn,
67925 + .poll = poll_learn,
67926 +};
67927 diff --git a/grsecurity/gracl_policy.c b/grsecurity/gracl_policy.c
67928 new file mode 100644
67929 index 0000000..361a099
67930 --- /dev/null
67931 +++ b/grsecurity/gracl_policy.c
67932 @@ -0,0 +1,1782 @@
67933 +#include <linux/kernel.h>
67934 +#include <linux/module.h>
67935 +#include <linux/sched.h>
67936 +#include <linux/mm.h>
67937 +#include <linux/file.h>
67938 +#include <linux/fs.h>
67939 +#include <linux/namei.h>
67940 +#include <linux/mount.h>
67941 +#include <linux/tty.h>
67942 +#include <linux/proc_fs.h>
67943 +#include <linux/lglock.h>
67944 +#include <linux/slab.h>
67945 +#include <linux/vmalloc.h>
67946 +#include <linux/types.h>
67947 +#include <linux/sysctl.h>
67948 +#include <linux/netdevice.h>
67949 +#include <linux/ptrace.h>
67950 +#include <linux/gracl.h>
67951 +#include <linux/gralloc.h>
67952 +#include <linux/security.h>
67953 +#include <linux/grinternal.h>
67954 +#include <linux/pid_namespace.h>
67955 +#include <linux/stop_machine.h>
67956 +#include <linux/fdtable.h>
67957 +#include <linux/percpu.h>
67958 +#include <linux/lglock.h>
67959 +#include <linux/hugetlb.h>
67960 +#include <linux/posix-timers.h>
67961 +#include "../fs/mount.h"
67962 +
67963 +#include <asm/uaccess.h>
67964 +#include <asm/errno.h>
67965 +#include <asm/mman.h>
67966 +
67967 +extern struct gr_policy_state *polstate;
67968 +
67969 +#define FOR_EACH_ROLE_START(role) \
67970 + role = polstate->role_list; \
67971 + while (role) {
67972 +
67973 +#define FOR_EACH_ROLE_END(role) \
67974 + role = role->prev; \
67975 + }
67976 +
67977 +struct path gr_real_root;
67978 +
67979 +extern struct gr_alloc_state *current_alloc_state;
67980 +
67981 +u16 acl_sp_role_value;
67982 +
67983 +static DEFINE_MUTEX(gr_dev_mutex);
67984 +
67985 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
67986 +extern void gr_clear_learn_entries(void);
67987 +
67988 +static struct gr_arg gr_usermode;
67989 +static unsigned char gr_system_salt[GR_SALT_LEN];
67990 +static unsigned char gr_system_sum[GR_SHA_LEN];
67991 +
67992 +static unsigned int gr_auth_attempts = 0;
67993 +static unsigned long gr_auth_expires = 0UL;
67994 +
67995 +struct acl_object_label *fakefs_obj_rw;
67996 +struct acl_object_label *fakefs_obj_rwx;
67997 +
67998 +extern int gr_init_uidset(void);
67999 +extern void gr_free_uidset(void);
68000 +extern void gr_remove_uid(uid_t uid);
68001 +extern int gr_find_uid(uid_t uid);
68002 +
68003 +extern struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename);
68004 +extern void __gr_apply_subject_to_task(struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj);
68005 +extern int gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb);
68006 +extern void __insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry);
68007 +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);
68008 +extern void insert_acl_obj_label(struct acl_object_label *obj, struct acl_subject_label *subj);
68009 +extern void insert_acl_subj_label(struct acl_subject_label *obj, struct acl_role_label *role);
68010 +extern struct name_entry * __lookup_name_entry(const struct gr_policy_state *state, const char *name);
68011 +extern char *gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt);
68012 +extern struct acl_subject_label *lookup_acl_subj_label(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
68013 +extern struct acl_subject_label *lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
68014 +extern void assign_special_role(const char *rolename);
68015 +extern struct acl_subject_label *chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt, const struct acl_role_label *role);
68016 +extern int gr_rbac_disable(void *unused);
68017 +extern void gr_enable_rbac_system(void);
68018 +
68019 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
68020 +{
68021 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
68022 + return -EFAULT;
68023 +
68024 + return 0;
68025 +}
68026 +
68027 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
68028 +{
68029 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
68030 + return -EFAULT;
68031 +
68032 + return 0;
68033 +}
68034 +
68035 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
68036 +{
68037 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
68038 + return -EFAULT;
68039 +
68040 + return 0;
68041 +}
68042 +
68043 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
68044 +{
68045 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
68046 + return -EFAULT;
68047 +
68048 + return 0;
68049 +}
68050 +
68051 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
68052 +{
68053 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
68054 + return -EFAULT;
68055 +
68056 + return 0;
68057 +}
68058 +
68059 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
68060 +{
68061 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
68062 + return -EFAULT;
68063 +
68064 + return 0;
68065 +}
68066 +
68067 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
68068 +{
68069 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
68070 + return -EFAULT;
68071 +
68072 + return 0;
68073 +}
68074 +
68075 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
68076 +{
68077 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
68078 + return -EFAULT;
68079 +
68080 + return 0;
68081 +}
68082 +
68083 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
68084 +{
68085 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
68086 + return -EFAULT;
68087 +
68088 + return 0;
68089 +}
68090 +
68091 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
68092 +{
68093 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
68094 + return -EFAULT;
68095 +
68096 + if (((uwrap->version != GRSECURITY_VERSION) &&
68097 + (uwrap->version != 0x2901)) ||
68098 + (uwrap->size != sizeof(struct gr_arg)))
68099 + return -EINVAL;
68100 +
68101 + return 0;
68102 +}
68103 +
68104 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
68105 +{
68106 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
68107 + return -EFAULT;
68108 +
68109 + return 0;
68110 +}
68111 +
68112 +static size_t get_gr_arg_wrapper_size_normal(void)
68113 +{
68114 + return sizeof(struct gr_arg_wrapper);
68115 +}
68116 +
68117 +#ifdef CONFIG_COMPAT
68118 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
68119 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
68120 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
68121 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
68122 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
68123 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
68124 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
68125 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
68126 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
68127 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
68128 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
68129 +extern size_t get_gr_arg_wrapper_size_compat(void);
68130 +
68131 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
68132 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
68133 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
68134 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
68135 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
68136 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
68137 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
68138 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
68139 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
68140 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
68141 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
68142 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
68143 +
68144 +#else
68145 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
68146 +#define copy_gr_arg copy_gr_arg_normal
68147 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
68148 +#define copy_acl_object_label copy_acl_object_label_normal
68149 +#define copy_acl_subject_label copy_acl_subject_label_normal
68150 +#define copy_acl_role_label copy_acl_role_label_normal
68151 +#define copy_acl_ip_label copy_acl_ip_label_normal
68152 +#define copy_pointer_from_array copy_pointer_from_array_normal
68153 +#define copy_sprole_pw copy_sprole_pw_normal
68154 +#define copy_role_transition copy_role_transition_normal
68155 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
68156 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
68157 +#endif
68158 +
68159 +static struct acl_subject_label *
68160 +lookup_subject_map(const struct acl_subject_label *userp)
68161 +{
68162 + unsigned int index = gr_shash(userp, polstate->subj_map_set.s_size);
68163 + struct subject_map *match;
68164 +
68165 + match = polstate->subj_map_set.s_hash[index];
68166 +
68167 + while (match && match->user != userp)
68168 + match = match->next;
68169 +
68170 + if (match != NULL)
68171 + return match->kernel;
68172 + else
68173 + return NULL;
68174 +}
68175 +
68176 +static void
68177 +insert_subj_map_entry(struct subject_map *subjmap)
68178 +{
68179 + unsigned int index = gr_shash(subjmap->user, polstate->subj_map_set.s_size);
68180 + struct subject_map **curr;
68181 +
68182 + subjmap->prev = NULL;
68183 +
68184 + curr = &polstate->subj_map_set.s_hash[index];
68185 + if (*curr != NULL)
68186 + (*curr)->prev = subjmap;
68187 +
68188 + subjmap->next = *curr;
68189 + *curr = subjmap;
68190 +
68191 + return;
68192 +}
68193 +
68194 +static void
68195 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
68196 +{
68197 + unsigned int index =
68198 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), polstate->acl_role_set.r_size);
68199 + struct acl_role_label **curr;
68200 + struct acl_role_label *tmp, *tmp2;
68201 +
68202 + curr = &polstate->acl_role_set.r_hash[index];
68203 +
68204 + /* simple case, slot is empty, just set it to our role */
68205 + if (*curr == NULL) {
68206 + *curr = role;
68207 + } else {
68208 + /* example:
68209 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
68210 + 2 -> 3
68211 + */
68212 + /* first check to see if we can already be reached via this slot */
68213 + tmp = *curr;
68214 + while (tmp && tmp != role)
68215 + tmp = tmp->next;
68216 + if (tmp == role) {
68217 + /* we don't need to add ourselves to this slot's chain */
68218 + return;
68219 + }
68220 + /* we need to add ourselves to this chain, two cases */
68221 + if (role->next == NULL) {
68222 + /* simple case, append the current chain to our role */
68223 + role->next = *curr;
68224 + *curr = role;
68225 + } else {
68226 + /* 1 -> 2 -> 3 -> 4
68227 + 2 -> 3 -> 4
68228 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
68229 + */
68230 + /* trickier case: walk our role's chain until we find
68231 + the role for the start of the current slot's chain */
68232 + tmp = role;
68233 + tmp2 = *curr;
68234 + while (tmp->next && tmp->next != tmp2)
68235 + tmp = tmp->next;
68236 + if (tmp->next == tmp2) {
68237 + /* from example above, we found 3, so just
68238 + replace this slot's chain with ours */
68239 + *curr = role;
68240 + } else {
68241 + /* we didn't find a subset of our role's chain
68242 + in the current slot's chain, so append their
68243 + chain to ours, and set us as the first role in
68244 + the slot's chain
68245 +
68246 + we could fold this case with the case above,
68247 + but making it explicit for clarity
68248 + */
68249 + tmp->next = tmp2;
68250 + *curr = role;
68251 + }
68252 + }
68253 + }
68254 +
68255 + return;
68256 +}
68257 +
68258 +static void
68259 +insert_acl_role_label(struct acl_role_label *role)
68260 +{
68261 + int i;
68262 +
68263 + if (polstate->role_list == NULL) {
68264 + polstate->role_list = role;
68265 + role->prev = NULL;
68266 + } else {
68267 + role->prev = polstate->role_list;
68268 + polstate->role_list = role;
68269 + }
68270 +
68271 + /* used for hash chains */
68272 + role->next = NULL;
68273 +
68274 + if (role->roletype & GR_ROLE_DOMAIN) {
68275 + for (i = 0; i < role->domain_child_num; i++)
68276 + __insert_acl_role_label(role, role->domain_children[i]);
68277 + } else
68278 + __insert_acl_role_label(role, role->uidgid);
68279 +}
68280 +
68281 +static int
68282 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
68283 +{
68284 + struct name_entry **curr, *nentry;
68285 + struct inodev_entry *ientry;
68286 + unsigned int len = strlen(name);
68287 + unsigned int key = full_name_hash(name, len);
68288 + unsigned int index = key % polstate->name_set.n_size;
68289 +
68290 + curr = &polstate->name_set.n_hash[index];
68291 +
68292 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
68293 + curr = &((*curr)->next);
68294 +
68295 + if (*curr != NULL)
68296 + return 1;
68297 +
68298 + nentry = acl_alloc(sizeof (struct name_entry));
68299 + if (nentry == NULL)
68300 + return 0;
68301 + ientry = acl_alloc(sizeof (struct inodev_entry));
68302 + if (ientry == NULL)
68303 + return 0;
68304 + ientry->nentry = nentry;
68305 +
68306 + nentry->key = key;
68307 + nentry->name = name;
68308 + nentry->inode = inode;
68309 + nentry->device = device;
68310 + nentry->len = len;
68311 + nentry->deleted = deleted;
68312 +
68313 + nentry->prev = NULL;
68314 + curr = &polstate->name_set.n_hash[index];
68315 + if (*curr != NULL)
68316 + (*curr)->prev = nentry;
68317 + nentry->next = *curr;
68318 + *curr = nentry;
68319 +
68320 + /* insert us into the table searchable by inode/dev */
68321 + __insert_inodev_entry(polstate, ientry);
68322 +
68323 + return 1;
68324 +}
68325 +
68326 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
68327 +
68328 +static void *
68329 +create_table(__u32 * len, int elementsize)
68330 +{
68331 + unsigned int table_sizes[] = {
68332 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
68333 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
68334 + 4194301, 8388593, 16777213, 33554393, 67108859
68335 + };
68336 + void *newtable = NULL;
68337 + unsigned int pwr = 0;
68338 +
68339 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
68340 + table_sizes[pwr] <= *len)
68341 + pwr++;
68342 +
68343 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
68344 + return newtable;
68345 +
68346 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
68347 + newtable =
68348 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
68349 + else
68350 + newtable = vmalloc(table_sizes[pwr] * elementsize);
68351 +
68352 + *len = table_sizes[pwr];
68353 +
68354 + return newtable;
68355 +}
68356 +
68357 +static int
68358 +init_variables(const struct gr_arg *arg, bool reload)
68359 +{
68360 + struct task_struct *reaper = init_pid_ns.child_reaper;
68361 + unsigned int stacksize;
68362 +
68363 + polstate->subj_map_set.s_size = arg->role_db.num_subjects;
68364 + polstate->acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
68365 + polstate->name_set.n_size = arg->role_db.num_objects;
68366 + polstate->inodev_set.i_size = arg->role_db.num_objects;
68367 +
68368 + if (!polstate->subj_map_set.s_size || !polstate->acl_role_set.r_size ||
68369 + !polstate->name_set.n_size || !polstate->inodev_set.i_size)
68370 + return 1;
68371 +
68372 + if (!reload) {
68373 + if (!gr_init_uidset())
68374 + return 1;
68375 + }
68376 +
68377 + /* set up the stack that holds allocation info */
68378 +
68379 + stacksize = arg->role_db.num_pointers + 5;
68380 +
68381 + if (!acl_alloc_stack_init(stacksize))
68382 + return 1;
68383 +
68384 + if (!reload) {
68385 + /* grab reference for the real root dentry and vfsmount */
68386 + get_fs_root(reaper->fs, &gr_real_root);
68387 +
68388 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
68389 + 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);
68390 +#endif
68391 +
68392 + fakefs_obj_rw = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
68393 + if (fakefs_obj_rw == NULL)
68394 + return 1;
68395 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
68396 +
68397 + fakefs_obj_rwx = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
68398 + if (fakefs_obj_rwx == NULL)
68399 + return 1;
68400 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
68401 + }
68402 +
68403 + polstate->subj_map_set.s_hash =
68404 + (struct subject_map **) create_table(&polstate->subj_map_set.s_size, sizeof(void *));
68405 + polstate->acl_role_set.r_hash =
68406 + (struct acl_role_label **) create_table(&polstate->acl_role_set.r_size, sizeof(void *));
68407 + polstate->name_set.n_hash = (struct name_entry **) create_table(&polstate->name_set.n_size, sizeof(void *));
68408 + polstate->inodev_set.i_hash =
68409 + (struct inodev_entry **) create_table(&polstate->inodev_set.i_size, sizeof(void *));
68410 +
68411 + if (!polstate->subj_map_set.s_hash || !polstate->acl_role_set.r_hash ||
68412 + !polstate->name_set.n_hash || !polstate->inodev_set.i_hash)
68413 + return 1;
68414 +
68415 + memset(polstate->subj_map_set.s_hash, 0,
68416 + sizeof(struct subject_map *) * polstate->subj_map_set.s_size);
68417 + memset(polstate->acl_role_set.r_hash, 0,
68418 + sizeof (struct acl_role_label *) * polstate->acl_role_set.r_size);
68419 + memset(polstate->name_set.n_hash, 0,
68420 + sizeof (struct name_entry *) * polstate->name_set.n_size);
68421 + memset(polstate->inodev_set.i_hash, 0,
68422 + sizeof (struct inodev_entry *) * polstate->inodev_set.i_size);
68423 +
68424 + return 0;
68425 +}
68426 +
68427 +/* free information not needed after startup
68428 + currently contains user->kernel pointer mappings for subjects
68429 +*/
68430 +
68431 +static void
68432 +free_init_variables(void)
68433 +{
68434 + __u32 i;
68435 +
68436 + if (polstate->subj_map_set.s_hash) {
68437 + for (i = 0; i < polstate->subj_map_set.s_size; i++) {
68438 + if (polstate->subj_map_set.s_hash[i]) {
68439 + kfree(polstate->subj_map_set.s_hash[i]);
68440 + polstate->subj_map_set.s_hash[i] = NULL;
68441 + }
68442 + }
68443 +
68444 + if ((polstate->subj_map_set.s_size * sizeof (struct subject_map *)) <=
68445 + PAGE_SIZE)
68446 + kfree(polstate->subj_map_set.s_hash);
68447 + else
68448 + vfree(polstate->subj_map_set.s_hash);
68449 + }
68450 +
68451 + return;
68452 +}
68453 +
68454 +static void
68455 +free_variables(bool reload)
68456 +{
68457 + struct acl_subject_label *s;
68458 + struct acl_role_label *r;
68459 + struct task_struct *task, *task2;
68460 + unsigned int x;
68461 +
68462 + if (!reload) {
68463 + gr_clear_learn_entries();
68464 +
68465 + read_lock(&tasklist_lock);
68466 + do_each_thread(task2, task) {
68467 + task->acl_sp_role = 0;
68468 + task->acl_role_id = 0;
68469 + task->inherited = 0;
68470 + task->acl = NULL;
68471 + task->role = NULL;
68472 + } while_each_thread(task2, task);
68473 + read_unlock(&tasklist_lock);
68474 +
68475 + kfree(fakefs_obj_rw);
68476 + fakefs_obj_rw = NULL;
68477 + kfree(fakefs_obj_rwx);
68478 + fakefs_obj_rwx = NULL;
68479 +
68480 + /* release the reference to the real root dentry and vfsmount */
68481 + path_put(&gr_real_root);
68482 + memset(&gr_real_root, 0, sizeof(gr_real_root));
68483 + }
68484 +
68485 + /* free all object hash tables */
68486 +
68487 + FOR_EACH_ROLE_START(r)
68488 + if (r->subj_hash == NULL)
68489 + goto next_role;
68490 + FOR_EACH_SUBJECT_START(r, s, x)
68491 + if (s->obj_hash == NULL)
68492 + break;
68493 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
68494 + kfree(s->obj_hash);
68495 + else
68496 + vfree(s->obj_hash);
68497 + FOR_EACH_SUBJECT_END(s, x)
68498 + FOR_EACH_NESTED_SUBJECT_START(r, s)
68499 + if (s->obj_hash == NULL)
68500 + break;
68501 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
68502 + kfree(s->obj_hash);
68503 + else
68504 + vfree(s->obj_hash);
68505 + FOR_EACH_NESTED_SUBJECT_END(s)
68506 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
68507 + kfree(r->subj_hash);
68508 + else
68509 + vfree(r->subj_hash);
68510 + r->subj_hash = NULL;
68511 +next_role:
68512 + FOR_EACH_ROLE_END(r)
68513 +
68514 + acl_free_all();
68515 +
68516 + if (polstate->acl_role_set.r_hash) {
68517 + if ((polstate->acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
68518 + PAGE_SIZE)
68519 + kfree(polstate->acl_role_set.r_hash);
68520 + else
68521 + vfree(polstate->acl_role_set.r_hash);
68522 + }
68523 + if (polstate->name_set.n_hash) {
68524 + if ((polstate->name_set.n_size * sizeof (struct name_entry *)) <=
68525 + PAGE_SIZE)
68526 + kfree(polstate->name_set.n_hash);
68527 + else
68528 + vfree(polstate->name_set.n_hash);
68529 + }
68530 +
68531 + if (polstate->inodev_set.i_hash) {
68532 + if ((polstate->inodev_set.i_size * sizeof (struct inodev_entry *)) <=
68533 + PAGE_SIZE)
68534 + kfree(polstate->inodev_set.i_hash);
68535 + else
68536 + vfree(polstate->inodev_set.i_hash);
68537 + }
68538 +
68539 + if (!reload)
68540 + gr_free_uidset();
68541 +
68542 + memset(&polstate->name_set, 0, sizeof (struct name_db));
68543 + memset(&polstate->inodev_set, 0, sizeof (struct inodev_db));
68544 + memset(&polstate->acl_role_set, 0, sizeof (struct acl_role_db));
68545 + memset(&polstate->subj_map_set, 0, sizeof (struct acl_subj_map_db));
68546 +
68547 + polstate->default_role = NULL;
68548 + polstate->kernel_role = NULL;
68549 + polstate->role_list = NULL;
68550 +
68551 + return;
68552 +}
68553 +
68554 +static struct acl_subject_label *
68555 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
68556 +
68557 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
68558 +{
68559 + unsigned int len = strnlen_user(*name, maxlen);
68560 + char *tmp;
68561 +
68562 + if (!len || len >= maxlen)
68563 + return -EINVAL;
68564 +
68565 + if ((tmp = (char *) acl_alloc(len)) == NULL)
68566 + return -ENOMEM;
68567 +
68568 + if (copy_from_user(tmp, *name, len))
68569 + return -EFAULT;
68570 +
68571 + tmp[len-1] = '\0';
68572 + *name = tmp;
68573 +
68574 + return 0;
68575 +}
68576 +
68577 +static int
68578 +copy_user_glob(struct acl_object_label *obj)
68579 +{
68580 + struct acl_object_label *g_tmp, **guser;
68581 + int error;
68582 +
68583 + if (obj->globbed == NULL)
68584 + return 0;
68585 +
68586 + guser = &obj->globbed;
68587 + while (*guser) {
68588 + g_tmp = (struct acl_object_label *)
68589 + acl_alloc(sizeof (struct acl_object_label));
68590 + if (g_tmp == NULL)
68591 + return -ENOMEM;
68592 +
68593 + if (copy_acl_object_label(g_tmp, *guser))
68594 + return -EFAULT;
68595 +
68596 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
68597 + if (error)
68598 + return error;
68599 +
68600 + *guser = g_tmp;
68601 + guser = &(g_tmp->next);
68602 + }
68603 +
68604 + return 0;
68605 +}
68606 +
68607 +static int
68608 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
68609 + struct acl_role_label *role)
68610 +{
68611 + struct acl_object_label *o_tmp;
68612 + int ret;
68613 +
68614 + while (userp) {
68615 + if ((o_tmp = (struct acl_object_label *)
68616 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
68617 + return -ENOMEM;
68618 +
68619 + if (copy_acl_object_label(o_tmp, userp))
68620 + return -EFAULT;
68621 +
68622 + userp = o_tmp->prev;
68623 +
68624 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
68625 + if (ret)
68626 + return ret;
68627 +
68628 + insert_acl_obj_label(o_tmp, subj);
68629 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
68630 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
68631 + return -ENOMEM;
68632 +
68633 + ret = copy_user_glob(o_tmp);
68634 + if (ret)
68635 + return ret;
68636 +
68637 + if (o_tmp->nested) {
68638 + int already_copied;
68639 +
68640 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
68641 + if (IS_ERR(o_tmp->nested))
68642 + return PTR_ERR(o_tmp->nested);
68643 +
68644 + /* insert into nested subject list if we haven't copied this one yet
68645 + to prevent duplicate entries */
68646 + if (!already_copied) {
68647 + o_tmp->nested->next = role->hash->first;
68648 + role->hash->first = o_tmp->nested;
68649 + }
68650 + }
68651 + }
68652 +
68653 + return 0;
68654 +}
68655 +
68656 +static __u32
68657 +count_user_subjs(struct acl_subject_label *userp)
68658 +{
68659 + struct acl_subject_label s_tmp;
68660 + __u32 num = 0;
68661 +
68662 + while (userp) {
68663 + if (copy_acl_subject_label(&s_tmp, userp))
68664 + break;
68665 +
68666 + userp = s_tmp.prev;
68667 + }
68668 +
68669 + return num;
68670 +}
68671 +
68672 +static int
68673 +copy_user_allowedips(struct acl_role_label *rolep)
68674 +{
68675 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
68676 +
68677 + ruserip = rolep->allowed_ips;
68678 +
68679 + while (ruserip) {
68680 + rlast = rtmp;
68681 +
68682 + if ((rtmp = (struct role_allowed_ip *)
68683 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
68684 + return -ENOMEM;
68685 +
68686 + if (copy_role_allowed_ip(rtmp, ruserip))
68687 + return -EFAULT;
68688 +
68689 + ruserip = rtmp->prev;
68690 +
68691 + if (!rlast) {
68692 + rtmp->prev = NULL;
68693 + rolep->allowed_ips = rtmp;
68694 + } else {
68695 + rlast->next = rtmp;
68696 + rtmp->prev = rlast;
68697 + }
68698 +
68699 + if (!ruserip)
68700 + rtmp->next = NULL;
68701 + }
68702 +
68703 + return 0;
68704 +}
68705 +
68706 +static int
68707 +copy_user_transitions(struct acl_role_label *rolep)
68708 +{
68709 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
68710 + int error;
68711 +
68712 + rusertp = rolep->transitions;
68713 +
68714 + while (rusertp) {
68715 + rlast = rtmp;
68716 +
68717 + if ((rtmp = (struct role_transition *)
68718 + acl_alloc(sizeof (struct role_transition))) == NULL)
68719 + return -ENOMEM;
68720 +
68721 + if (copy_role_transition(rtmp, rusertp))
68722 + return -EFAULT;
68723 +
68724 + rusertp = rtmp->prev;
68725 +
68726 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
68727 + if (error)
68728 + return error;
68729 +
68730 + if (!rlast) {
68731 + rtmp->prev = NULL;
68732 + rolep->transitions = rtmp;
68733 + } else {
68734 + rlast->next = rtmp;
68735 + rtmp->prev = rlast;
68736 + }
68737 +
68738 + if (!rusertp)
68739 + rtmp->next = NULL;
68740 + }
68741 +
68742 + return 0;
68743 +}
68744 +
68745 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
68746 +{
68747 + struct acl_object_label o_tmp;
68748 + __u32 num = 0;
68749 +
68750 + while (userp) {
68751 + if (copy_acl_object_label(&o_tmp, userp))
68752 + break;
68753 +
68754 + userp = o_tmp.prev;
68755 + num++;
68756 + }
68757 +
68758 + return num;
68759 +}
68760 +
68761 +static struct acl_subject_label *
68762 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
68763 +{
68764 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
68765 + __u32 num_objs;
68766 + struct acl_ip_label **i_tmp, *i_utmp2;
68767 + struct gr_hash_struct ghash;
68768 + struct subject_map *subjmap;
68769 + unsigned int i_num;
68770 + int err;
68771 +
68772 + if (already_copied != NULL)
68773 + *already_copied = 0;
68774 +
68775 + s_tmp = lookup_subject_map(userp);
68776 +
68777 + /* we've already copied this subject into the kernel, just return
68778 + the reference to it, and don't copy it over again
68779 + */
68780 + if (s_tmp) {
68781 + if (already_copied != NULL)
68782 + *already_copied = 1;
68783 + return(s_tmp);
68784 + }
68785 +
68786 + if ((s_tmp = (struct acl_subject_label *)
68787 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
68788 + return ERR_PTR(-ENOMEM);
68789 +
68790 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
68791 + if (subjmap == NULL)
68792 + return ERR_PTR(-ENOMEM);
68793 +
68794 + subjmap->user = userp;
68795 + subjmap->kernel = s_tmp;
68796 + insert_subj_map_entry(subjmap);
68797 +
68798 + if (copy_acl_subject_label(s_tmp, userp))
68799 + return ERR_PTR(-EFAULT);
68800 +
68801 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
68802 + if (err)
68803 + return ERR_PTR(err);
68804 +
68805 + if (!strcmp(s_tmp->filename, "/"))
68806 + role->root_label = s_tmp;
68807 +
68808 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
68809 + return ERR_PTR(-EFAULT);
68810 +
68811 + /* copy user and group transition tables */
68812 +
68813 + if (s_tmp->user_trans_num) {
68814 + uid_t *uidlist;
68815 +
68816 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
68817 + if (uidlist == NULL)
68818 + return ERR_PTR(-ENOMEM);
68819 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
68820 + return ERR_PTR(-EFAULT);
68821 +
68822 + s_tmp->user_transitions = uidlist;
68823 + }
68824 +
68825 + if (s_tmp->group_trans_num) {
68826 + gid_t *gidlist;
68827 +
68828 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
68829 + if (gidlist == NULL)
68830 + return ERR_PTR(-ENOMEM);
68831 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
68832 + return ERR_PTR(-EFAULT);
68833 +
68834 + s_tmp->group_transitions = gidlist;
68835 + }
68836 +
68837 + /* set up object hash table */
68838 + num_objs = count_user_objs(ghash.first);
68839 +
68840 + s_tmp->obj_hash_size = num_objs;
68841 + s_tmp->obj_hash =
68842 + (struct acl_object_label **)
68843 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
68844 +
68845 + if (!s_tmp->obj_hash)
68846 + return ERR_PTR(-ENOMEM);
68847 +
68848 + memset(s_tmp->obj_hash, 0,
68849 + s_tmp->obj_hash_size *
68850 + sizeof (struct acl_object_label *));
68851 +
68852 + /* add in objects */
68853 + err = copy_user_objs(ghash.first, s_tmp, role);
68854 +
68855 + if (err)
68856 + return ERR_PTR(err);
68857 +
68858 + /* set pointer for parent subject */
68859 + if (s_tmp->parent_subject) {
68860 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
68861 +
68862 + if (IS_ERR(s_tmp2))
68863 + return s_tmp2;
68864 +
68865 + s_tmp->parent_subject = s_tmp2;
68866 + }
68867 +
68868 + /* add in ip acls */
68869 +
68870 + if (!s_tmp->ip_num) {
68871 + s_tmp->ips = NULL;
68872 + goto insert;
68873 + }
68874 +
68875 + i_tmp =
68876 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
68877 + sizeof (struct acl_ip_label *));
68878 +
68879 + if (!i_tmp)
68880 + return ERR_PTR(-ENOMEM);
68881 +
68882 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
68883 + *(i_tmp + i_num) =
68884 + (struct acl_ip_label *)
68885 + acl_alloc(sizeof (struct acl_ip_label));
68886 + if (!*(i_tmp + i_num))
68887 + return ERR_PTR(-ENOMEM);
68888 +
68889 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
68890 + return ERR_PTR(-EFAULT);
68891 +
68892 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
68893 + return ERR_PTR(-EFAULT);
68894 +
68895 + if ((*(i_tmp + i_num))->iface == NULL)
68896 + continue;
68897 +
68898 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
68899 + if (err)
68900 + return ERR_PTR(err);
68901 + }
68902 +
68903 + s_tmp->ips = i_tmp;
68904 +
68905 +insert:
68906 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
68907 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
68908 + return ERR_PTR(-ENOMEM);
68909 +
68910 + return s_tmp;
68911 +}
68912 +
68913 +static int
68914 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
68915 +{
68916 + struct acl_subject_label s_pre;
68917 + struct acl_subject_label * ret;
68918 + int err;
68919 +
68920 + while (userp) {
68921 + if (copy_acl_subject_label(&s_pre, userp))
68922 + return -EFAULT;
68923 +
68924 + ret = do_copy_user_subj(userp, role, NULL);
68925 +
68926 + err = PTR_ERR(ret);
68927 + if (IS_ERR(ret))
68928 + return err;
68929 +
68930 + insert_acl_subj_label(ret, role);
68931 +
68932 + userp = s_pre.prev;
68933 + }
68934 +
68935 + return 0;
68936 +}
68937 +
68938 +static int
68939 +copy_user_acl(struct gr_arg *arg)
68940 +{
68941 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
68942 + struct acl_subject_label *subj_list;
68943 + struct sprole_pw *sptmp;
68944 + struct gr_hash_struct *ghash;
68945 + uid_t *domainlist;
68946 + unsigned int r_num;
68947 + int err = 0;
68948 + __u16 i;
68949 + __u32 num_subjs;
68950 +
68951 + /* we need a default and kernel role */
68952 + if (arg->role_db.num_roles < 2)
68953 + return -EINVAL;
68954 +
68955 + /* copy special role authentication info from userspace */
68956 +
68957 + polstate->num_sprole_pws = arg->num_sprole_pws;
68958 + polstate->acl_special_roles = (struct sprole_pw **) acl_alloc_num(polstate->num_sprole_pws, sizeof(struct sprole_pw *));
68959 +
68960 + if (!polstate->acl_special_roles && polstate->num_sprole_pws)
68961 + return -ENOMEM;
68962 +
68963 + for (i = 0; i < polstate->num_sprole_pws; i++) {
68964 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
68965 + if (!sptmp)
68966 + return -ENOMEM;
68967 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
68968 + return -EFAULT;
68969 +
68970 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
68971 + if (err)
68972 + return err;
68973 +
68974 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
68975 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
68976 +#endif
68977 +
68978 + polstate->acl_special_roles[i] = sptmp;
68979 + }
68980 +
68981 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
68982 +
68983 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
68984 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
68985 +
68986 + if (!r_tmp)
68987 + return -ENOMEM;
68988 +
68989 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
68990 + return -EFAULT;
68991 +
68992 + if (copy_acl_role_label(r_tmp, r_utmp2))
68993 + return -EFAULT;
68994 +
68995 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
68996 + if (err)
68997 + return err;
68998 +
68999 + if (!strcmp(r_tmp->rolename, "default")
69000 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
69001 + polstate->default_role = r_tmp;
69002 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
69003 + polstate->kernel_role = r_tmp;
69004 + }
69005 +
69006 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
69007 + return -ENOMEM;
69008 +
69009 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
69010 + return -EFAULT;
69011 +
69012 + r_tmp->hash = ghash;
69013 +
69014 + num_subjs = count_user_subjs(r_tmp->hash->first);
69015 +
69016 + r_tmp->subj_hash_size = num_subjs;
69017 + r_tmp->subj_hash =
69018 + (struct acl_subject_label **)
69019 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
69020 +
69021 + if (!r_tmp->subj_hash)
69022 + return -ENOMEM;
69023 +
69024 + err = copy_user_allowedips(r_tmp);
69025 + if (err)
69026 + return err;
69027 +
69028 + /* copy domain info */
69029 + if (r_tmp->domain_children != NULL) {
69030 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
69031 + if (domainlist == NULL)
69032 + return -ENOMEM;
69033 +
69034 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
69035 + return -EFAULT;
69036 +
69037 + r_tmp->domain_children = domainlist;
69038 + }
69039 +
69040 + err = copy_user_transitions(r_tmp);
69041 + if (err)
69042 + return err;
69043 +
69044 + memset(r_tmp->subj_hash, 0,
69045 + r_tmp->subj_hash_size *
69046 + sizeof (struct acl_subject_label *));
69047 +
69048 + /* acquire the list of subjects, then NULL out
69049 + the list prior to parsing the subjects for this role,
69050 + as during this parsing the list is replaced with a list
69051 + of *nested* subjects for the role
69052 + */
69053 + subj_list = r_tmp->hash->first;
69054 +
69055 + /* set nested subject list to null */
69056 + r_tmp->hash->first = NULL;
69057 +
69058 + err = copy_user_subjs(subj_list, r_tmp);
69059 +
69060 + if (err)
69061 + return err;
69062 +
69063 + insert_acl_role_label(r_tmp);
69064 + }
69065 +
69066 + if (polstate->default_role == NULL || polstate->kernel_role == NULL)
69067 + return -EINVAL;
69068 +
69069 + return err;
69070 +}
69071 +
69072 +static int gracl_reload_apply_policies(void *reload)
69073 +{
69074 + struct gr_reload_state *reload_state = (struct gr_reload_state *)reload;
69075 + struct task_struct *task, *task2;
69076 + struct acl_role_label *role, *rtmp;
69077 + struct acl_subject_label *subj;
69078 + const struct cred *cred;
69079 + int role_applied;
69080 + int ret = 0;
69081 +
69082 + memcpy(&reload_state->oldpolicy, reload_state->oldpolicy_ptr, sizeof(struct gr_policy_state));
69083 + memcpy(&reload_state->oldalloc, reload_state->oldalloc_ptr, sizeof(struct gr_alloc_state));
69084 +
69085 + /* first make sure we'll be able to apply the new policy cleanly */
69086 + do_each_thread(task2, task) {
69087 + if (task->exec_file == NULL)
69088 + continue;
69089 + role_applied = 0;
69090 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
69091 + /* preserve special roles */
69092 + FOR_EACH_ROLE_START(role)
69093 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
69094 + rtmp = task->role;
69095 + task->role = role;
69096 + role_applied = 1;
69097 + break;
69098 + }
69099 + FOR_EACH_ROLE_END(role)
69100 + }
69101 + if (!role_applied) {
69102 + cred = __task_cred(task);
69103 + rtmp = task->role;
69104 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
69105 + }
69106 + /* this handles non-nested inherited subjects, nested subjects will still
69107 + be dropped currently */
69108 + subj = __gr_get_subject_for_task(polstate, task, task->acl->filename);
69109 + task->tmpacl = __gr_get_subject_for_task(polstate, task, NULL);
69110 + /* change the role back so that we've made no modifications to the policy */
69111 + task->role = rtmp;
69112 +
69113 + if (subj == NULL || task->tmpacl == NULL) {
69114 + ret = -EINVAL;
69115 + goto out;
69116 + }
69117 + } while_each_thread(task2, task);
69118 +
69119 + /* now actually apply the policy */
69120 +
69121 + do_each_thread(task2, task) {
69122 + if (task->exec_file) {
69123 + role_applied = 0;
69124 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
69125 + /* preserve special roles */
69126 + FOR_EACH_ROLE_START(role)
69127 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
69128 + task->role = role;
69129 + role_applied = 1;
69130 + break;
69131 + }
69132 + FOR_EACH_ROLE_END(role)
69133 + }
69134 + if (!role_applied) {
69135 + cred = __task_cred(task);
69136 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
69137 + }
69138 + /* this handles non-nested inherited subjects, nested subjects will still
69139 + be dropped currently */
69140 + if (!reload_state->oldmode && task->inherited)
69141 + subj = __gr_get_subject_for_task(polstate, task, task->acl->filename);
69142 + else {
69143 + /* looked up and tagged to the task previously */
69144 + subj = task->tmpacl;
69145 + }
69146 + /* subj will be non-null */
69147 + __gr_apply_subject_to_task(polstate, task, subj);
69148 + if (reload_state->oldmode) {
69149 + task->acl_role_id = 0;
69150 + task->acl_sp_role = 0;
69151 + task->inherited = 0;
69152 + }
69153 + } else {
69154 + // it's a kernel process
69155 + task->role = polstate->kernel_role;
69156 + task->acl = polstate->kernel_role->root_label;
69157 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
69158 + task->acl->mode &= ~GR_PROCFIND;
69159 +#endif
69160 + }
69161 + } while_each_thread(task2, task);
69162 +
69163 + memcpy(reload_state->oldpolicy_ptr, &reload_state->newpolicy, sizeof(struct gr_policy_state));
69164 + memcpy(reload_state->oldalloc_ptr, &reload_state->newalloc, sizeof(struct gr_alloc_state));
69165 +
69166 +out:
69167 +
69168 + return ret;
69169 +}
69170 +
69171 +static int gracl_reload(struct gr_arg *args, unsigned char oldmode)
69172 +{
69173 + struct gr_reload_state new_reload_state = { };
69174 + int err;
69175 +
69176 + new_reload_state.oldpolicy_ptr = polstate;
69177 + new_reload_state.oldalloc_ptr = current_alloc_state;
69178 + new_reload_state.oldmode = oldmode;
69179 +
69180 + current_alloc_state = &new_reload_state.newalloc;
69181 + polstate = &new_reload_state.newpolicy;
69182 +
69183 + /* everything relevant is now saved off, copy in the new policy */
69184 + if (init_variables(args, true)) {
69185 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
69186 + err = -ENOMEM;
69187 + goto error;
69188 + }
69189 +
69190 + err = copy_user_acl(args);
69191 + free_init_variables();
69192 + if (err)
69193 + goto error;
69194 + /* the new policy is copied in, with the old policy available via saved_state
69195 + first go through applying roles, making sure to preserve special roles
69196 + then apply new subjects, making sure to preserve inherited and nested subjects,
69197 + though currently only inherited subjects will be preserved
69198 + */
69199 + err = stop_machine(gracl_reload_apply_policies, &new_reload_state, NULL);
69200 + if (err)
69201 + goto error;
69202 +
69203 + /* we've now applied the new policy, so restore the old policy state to free it */
69204 + polstate = &new_reload_state.oldpolicy;
69205 + current_alloc_state = &new_reload_state.oldalloc;
69206 + free_variables(true);
69207 +
69208 + /* oldpolicy/oldalloc_ptr point to the new policy/alloc states as they were copied
69209 + to running_polstate/current_alloc_state inside stop_machine
69210 + */
69211 + err = 0;
69212 + goto out;
69213 +error:
69214 + /* on error of loading the new policy, we'll just keep the previous
69215 + policy set around
69216 + */
69217 + free_variables(true);
69218 +
69219 + /* doesn't affect runtime, but maintains consistent state */
69220 +out:
69221 + polstate = new_reload_state.oldpolicy_ptr;
69222 + current_alloc_state = new_reload_state.oldalloc_ptr;
69223 +
69224 + return err;
69225 +}
69226 +
69227 +static int
69228 +gracl_init(struct gr_arg *args)
69229 +{
69230 + int error = 0;
69231 +
69232 + memcpy(&gr_system_salt, args->salt, sizeof(gr_system_salt));
69233 + memcpy(&gr_system_sum, args->sum, sizeof(gr_system_sum));
69234 +
69235 + if (init_variables(args, false)) {
69236 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
69237 + error = -ENOMEM;
69238 + goto out;
69239 + }
69240 +
69241 + error = copy_user_acl(args);
69242 + free_init_variables();
69243 + if (error)
69244 + goto out;
69245 +
69246 + error = gr_set_acls(0);
69247 + if (error)
69248 + goto out;
69249 +
69250 + gr_enable_rbac_system();
69251 +
69252 + return 0;
69253 +
69254 +out:
69255 + free_variables(false);
69256 + return error;
69257 +}
69258 +
69259 +static int
69260 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
69261 + unsigned char **sum)
69262 +{
69263 + struct acl_role_label *r;
69264 + struct role_allowed_ip *ipp;
69265 + struct role_transition *trans;
69266 + unsigned int i;
69267 + int found = 0;
69268 + u32 curr_ip = current->signal->curr_ip;
69269 +
69270 + current->signal->saved_ip = curr_ip;
69271 +
69272 + /* check transition table */
69273 +
69274 + for (trans = current->role->transitions; trans; trans = trans->next) {
69275 + if (!strcmp(rolename, trans->rolename)) {
69276 + found = 1;
69277 + break;
69278 + }
69279 + }
69280 +
69281 + if (!found)
69282 + return 0;
69283 +
69284 + /* handle special roles that do not require authentication
69285 + and check ip */
69286 +
69287 + FOR_EACH_ROLE_START(r)
69288 + if (!strcmp(rolename, r->rolename) &&
69289 + (r->roletype & GR_ROLE_SPECIAL)) {
69290 + found = 0;
69291 + if (r->allowed_ips != NULL) {
69292 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
69293 + if ((ntohl(curr_ip) & ipp->netmask) ==
69294 + (ntohl(ipp->addr) & ipp->netmask))
69295 + found = 1;
69296 + }
69297 + } else
69298 + found = 2;
69299 + if (!found)
69300 + return 0;
69301 +
69302 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
69303 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
69304 + *salt = NULL;
69305 + *sum = NULL;
69306 + return 1;
69307 + }
69308 + }
69309 + FOR_EACH_ROLE_END(r)
69310 +
69311 + for (i = 0; i < polstate->num_sprole_pws; i++) {
69312 + if (!strcmp(rolename, polstate->acl_special_roles[i]->rolename)) {
69313 + *salt = polstate->acl_special_roles[i]->salt;
69314 + *sum = polstate->acl_special_roles[i]->sum;
69315 + return 1;
69316 + }
69317 + }
69318 +
69319 + return 0;
69320 +}
69321 +
69322 +int gr_check_secure_terminal(struct task_struct *task)
69323 +{
69324 + struct task_struct *p, *p2, *p3;
69325 + struct files_struct *files;
69326 + struct fdtable *fdt;
69327 + struct file *our_file = NULL, *file;
69328 + int i;
69329 +
69330 + if (task->signal->tty == NULL)
69331 + return 1;
69332 +
69333 + files = get_files_struct(task);
69334 + if (files != NULL) {
69335 + rcu_read_lock();
69336 + fdt = files_fdtable(files);
69337 + for (i=0; i < fdt->max_fds; i++) {
69338 + file = fcheck_files(files, i);
69339 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
69340 + get_file(file);
69341 + our_file = file;
69342 + }
69343 + }
69344 + rcu_read_unlock();
69345 + put_files_struct(files);
69346 + }
69347 +
69348 + if (our_file == NULL)
69349 + return 1;
69350 +
69351 + read_lock(&tasklist_lock);
69352 + do_each_thread(p2, p) {
69353 + files = get_files_struct(p);
69354 + if (files == NULL ||
69355 + (p->signal && p->signal->tty == task->signal->tty)) {
69356 + if (files != NULL)
69357 + put_files_struct(files);
69358 + continue;
69359 + }
69360 + rcu_read_lock();
69361 + fdt = files_fdtable(files);
69362 + for (i=0; i < fdt->max_fds; i++) {
69363 + file = fcheck_files(files, i);
69364 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
69365 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
69366 + p3 = task;
69367 + while (task_pid_nr(p3) > 0) {
69368 + if (p3 == p)
69369 + break;
69370 + p3 = p3->real_parent;
69371 + }
69372 + if (p3 == p)
69373 + break;
69374 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
69375 + gr_handle_alertkill(p);
69376 + rcu_read_unlock();
69377 + put_files_struct(files);
69378 + read_unlock(&tasklist_lock);
69379 + fput(our_file);
69380 + return 0;
69381 + }
69382 + }
69383 + rcu_read_unlock();
69384 + put_files_struct(files);
69385 + } while_each_thread(p2, p);
69386 + read_unlock(&tasklist_lock);
69387 +
69388 + fput(our_file);
69389 + return 1;
69390 +}
69391 +
69392 +ssize_t
69393 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
69394 +{
69395 + struct gr_arg_wrapper uwrap;
69396 + unsigned char *sprole_salt = NULL;
69397 + unsigned char *sprole_sum = NULL;
69398 + int error = 0;
69399 + int error2 = 0;
69400 + size_t req_count = 0;
69401 + unsigned char oldmode = 0;
69402 +
69403 + mutex_lock(&gr_dev_mutex);
69404 +
69405 + if (gr_acl_is_enabled() && !(current->acl->mode & GR_KERNELAUTH)) {
69406 + error = -EPERM;
69407 + goto out;
69408 + }
69409 +
69410 +#ifdef CONFIG_COMPAT
69411 + pax_open_kernel();
69412 + if (is_compat_task()) {
69413 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
69414 + copy_gr_arg = &copy_gr_arg_compat;
69415 + copy_acl_object_label = &copy_acl_object_label_compat;
69416 + copy_acl_subject_label = &copy_acl_subject_label_compat;
69417 + copy_acl_role_label = &copy_acl_role_label_compat;
69418 + copy_acl_ip_label = &copy_acl_ip_label_compat;
69419 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
69420 + copy_role_transition = &copy_role_transition_compat;
69421 + copy_sprole_pw = &copy_sprole_pw_compat;
69422 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
69423 + copy_pointer_from_array = &copy_pointer_from_array_compat;
69424 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
69425 + } else {
69426 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
69427 + copy_gr_arg = &copy_gr_arg_normal;
69428 + copy_acl_object_label = &copy_acl_object_label_normal;
69429 + copy_acl_subject_label = &copy_acl_subject_label_normal;
69430 + copy_acl_role_label = &copy_acl_role_label_normal;
69431 + copy_acl_ip_label = &copy_acl_ip_label_normal;
69432 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
69433 + copy_role_transition = &copy_role_transition_normal;
69434 + copy_sprole_pw = &copy_sprole_pw_normal;
69435 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
69436 + copy_pointer_from_array = &copy_pointer_from_array_normal;
69437 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
69438 + }
69439 + pax_close_kernel();
69440 +#endif
69441 +
69442 + req_count = get_gr_arg_wrapper_size();
69443 +
69444 + if (count != req_count) {
69445 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
69446 + error = -EINVAL;
69447 + goto out;
69448 + }
69449 +
69450 +
69451 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
69452 + gr_auth_expires = 0;
69453 + gr_auth_attempts = 0;
69454 + }
69455 +
69456 + error = copy_gr_arg_wrapper(buf, &uwrap);
69457 + if (error)
69458 + goto out;
69459 +
69460 + error = copy_gr_arg(uwrap.arg, &gr_usermode);
69461 + if (error)
69462 + goto out;
69463 +
69464 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_SPROLEPAM &&
69465 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
69466 + time_after(gr_auth_expires, get_seconds())) {
69467 + error = -EBUSY;
69468 + goto out;
69469 + }
69470 +
69471 + /* if non-root trying to do anything other than use a special role,
69472 + do not attempt authentication, do not count towards authentication
69473 + locking
69474 + */
69475 +
69476 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_STATUS &&
69477 + gr_usermode.mode != GR_UNSPROLE && gr_usermode.mode != GR_SPROLEPAM &&
69478 + gr_is_global_nonroot(current_uid())) {
69479 + error = -EPERM;
69480 + goto out;
69481 + }
69482 +
69483 + /* ensure pw and special role name are null terminated */
69484 +
69485 + gr_usermode.pw[GR_PW_LEN - 1] = '\0';
69486 + gr_usermode.sp_role[GR_SPROLE_LEN - 1] = '\0';
69487 +
69488 + /* Okay.
69489 + * We have our enough of the argument structure..(we have yet
69490 + * to copy_from_user the tables themselves) . Copy the tables
69491 + * only if we need them, i.e. for loading operations. */
69492 +
69493 + switch (gr_usermode.mode) {
69494 + case GR_STATUS:
69495 + if (gr_acl_is_enabled()) {
69496 + error = 1;
69497 + if (!gr_check_secure_terminal(current))
69498 + error = 3;
69499 + } else
69500 + error = 2;
69501 + goto out;
69502 + case GR_SHUTDOWN:
69503 + if (gr_acl_is_enabled() && !(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
69504 + stop_machine(gr_rbac_disable, NULL, NULL);
69505 + free_variables(false);
69506 + memset(&gr_usermode, 0, sizeof(gr_usermode));
69507 + memset(&gr_system_salt, 0, sizeof(gr_system_salt));
69508 + memset(&gr_system_sum, 0, sizeof(gr_system_sum));
69509 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
69510 + } else if (gr_acl_is_enabled()) {
69511 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
69512 + error = -EPERM;
69513 + } else {
69514 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
69515 + error = -EAGAIN;
69516 + }
69517 + break;
69518 + case GR_ENABLE:
69519 + if (!gr_acl_is_enabled() && !(error2 = gracl_init(&gr_usermode)))
69520 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
69521 + else {
69522 + if (gr_acl_is_enabled())
69523 + error = -EAGAIN;
69524 + else
69525 + error = error2;
69526 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
69527 + }
69528 + break;
69529 + case GR_OLDRELOAD:
69530 + oldmode = 1;
69531 + case GR_RELOAD:
69532 + if (!gr_acl_is_enabled()) {
69533 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
69534 + error = -EAGAIN;
69535 + } else if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
69536 + error2 = gracl_reload(&gr_usermode, oldmode);
69537 + if (!error2)
69538 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
69539 + else {
69540 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
69541 + error = error2;
69542 + }
69543 + } else {
69544 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
69545 + error = -EPERM;
69546 + }
69547 + break;
69548 + case GR_SEGVMOD:
69549 + if (unlikely(!gr_acl_is_enabled())) {
69550 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
69551 + error = -EAGAIN;
69552 + break;
69553 + }
69554 +
69555 + if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
69556 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
69557 + if (gr_usermode.segv_device && gr_usermode.segv_inode) {
69558 + struct acl_subject_label *segvacl;
69559 + segvacl =
69560 + lookup_acl_subj_label(gr_usermode.segv_inode,
69561 + gr_usermode.segv_device,
69562 + current->role);
69563 + if (segvacl) {
69564 + segvacl->crashes = 0;
69565 + segvacl->expires = 0;
69566 + }
69567 + } else if (gr_find_uid(gr_usermode.segv_uid) >= 0) {
69568 + gr_remove_uid(gr_usermode.segv_uid);
69569 + }
69570 + } else {
69571 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
69572 + error = -EPERM;
69573 + }
69574 + break;
69575 + case GR_SPROLE:
69576 + case GR_SPROLEPAM:
69577 + if (unlikely(!gr_acl_is_enabled())) {
69578 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
69579 + error = -EAGAIN;
69580 + break;
69581 + }
69582 +
69583 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
69584 + current->role->expires = 0;
69585 + current->role->auth_attempts = 0;
69586 + }
69587 +
69588 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
69589 + time_after(current->role->expires, get_seconds())) {
69590 + error = -EBUSY;
69591 + goto out;
69592 + }
69593 +
69594 + if (lookup_special_role_auth
69595 + (gr_usermode.mode, gr_usermode.sp_role, &sprole_salt, &sprole_sum)
69596 + && ((!sprole_salt && !sprole_sum)
69597 + || !(chkpw(&gr_usermode, sprole_salt, sprole_sum)))) {
69598 + char *p = "";
69599 + assign_special_role(gr_usermode.sp_role);
69600 + read_lock(&tasklist_lock);
69601 + if (current->real_parent)
69602 + p = current->real_parent->role->rolename;
69603 + read_unlock(&tasklist_lock);
69604 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
69605 + p, acl_sp_role_value);
69606 + } else {
69607 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode.sp_role);
69608 + error = -EPERM;
69609 + if(!(current->role->auth_attempts++))
69610 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
69611 +
69612 + goto out;
69613 + }
69614 + break;
69615 + case GR_UNSPROLE:
69616 + if (unlikely(!gr_acl_is_enabled())) {
69617 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
69618 + error = -EAGAIN;
69619 + break;
69620 + }
69621 +
69622 + if (current->role->roletype & GR_ROLE_SPECIAL) {
69623 + char *p = "";
69624 + int i = 0;
69625 +
69626 + read_lock(&tasklist_lock);
69627 + if (current->real_parent) {
69628 + p = current->real_parent->role->rolename;
69629 + i = current->real_parent->acl_role_id;
69630 + }
69631 + read_unlock(&tasklist_lock);
69632 +
69633 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
69634 + gr_set_acls(1);
69635 + } else {
69636 + error = -EPERM;
69637 + goto out;
69638 + }
69639 + break;
69640 + default:
69641 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode.mode);
69642 + error = -EINVAL;
69643 + break;
69644 + }
69645 +
69646 + if (error != -EPERM)
69647 + goto out;
69648 +
69649 + if(!(gr_auth_attempts++))
69650 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
69651 +
69652 + out:
69653 + mutex_unlock(&gr_dev_mutex);
69654 +
69655 + if (!error)
69656 + error = req_count;
69657 +
69658 + return error;
69659 +}
69660 +
69661 +int
69662 +gr_set_acls(const int type)
69663 +{
69664 + struct task_struct *task, *task2;
69665 + struct acl_role_label *role = current->role;
69666 + struct acl_subject_label *subj;
69667 + __u16 acl_role_id = current->acl_role_id;
69668 + const struct cred *cred;
69669 + int ret;
69670 +
69671 + rcu_read_lock();
69672 + read_lock(&tasklist_lock);
69673 + read_lock(&grsec_exec_file_lock);
69674 + do_each_thread(task2, task) {
69675 + /* check to see if we're called from the exit handler,
69676 + if so, only replace ACLs that have inherited the admin
69677 + ACL */
69678 +
69679 + if (type && (task->role != role ||
69680 + task->acl_role_id != acl_role_id))
69681 + continue;
69682 +
69683 + task->acl_role_id = 0;
69684 + task->acl_sp_role = 0;
69685 + task->inherited = 0;
69686 +
69687 + if (task->exec_file) {
69688 + cred = __task_cred(task);
69689 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
69690 + subj = __gr_get_subject_for_task(polstate, task, NULL);
69691 + if (subj == NULL) {
69692 + ret = -EINVAL;
69693 + read_unlock(&grsec_exec_file_lock);
69694 + read_unlock(&tasklist_lock);
69695 + rcu_read_unlock();
69696 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
69697 + return ret;
69698 + }
69699 + __gr_apply_subject_to_task(polstate, task, subj);
69700 + } else {
69701 + // it's a kernel process
69702 + task->role = polstate->kernel_role;
69703 + task->acl = polstate->kernel_role->root_label;
69704 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
69705 + task->acl->mode &= ~GR_PROCFIND;
69706 +#endif
69707 + }
69708 + } while_each_thread(task2, task);
69709 + read_unlock(&grsec_exec_file_lock);
69710 + read_unlock(&tasklist_lock);
69711 + rcu_read_unlock();
69712 +
69713 + return 0;
69714 +}
69715 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
69716 new file mode 100644
69717 index 0000000..39645c9
69718 --- /dev/null
69719 +++ b/grsecurity/gracl_res.c
69720 @@ -0,0 +1,68 @@
69721 +#include <linux/kernel.h>
69722 +#include <linux/sched.h>
69723 +#include <linux/gracl.h>
69724 +#include <linux/grinternal.h>
69725 +
69726 +static const char *restab_log[] = {
69727 + [RLIMIT_CPU] = "RLIMIT_CPU",
69728 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
69729 + [RLIMIT_DATA] = "RLIMIT_DATA",
69730 + [RLIMIT_STACK] = "RLIMIT_STACK",
69731 + [RLIMIT_CORE] = "RLIMIT_CORE",
69732 + [RLIMIT_RSS] = "RLIMIT_RSS",
69733 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
69734 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
69735 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
69736 + [RLIMIT_AS] = "RLIMIT_AS",
69737 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
69738 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
69739 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
69740 + [RLIMIT_NICE] = "RLIMIT_NICE",
69741 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
69742 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
69743 + [GR_CRASH_RES] = "RLIMIT_CRASH"
69744 +};
69745 +
69746 +void
69747 +gr_log_resource(const struct task_struct *task,
69748 + const int res, const unsigned long wanted, const int gt)
69749 +{
69750 + const struct cred *cred;
69751 + unsigned long rlim;
69752 +
69753 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
69754 + return;
69755 +
69756 + // not yet supported resource
69757 + if (unlikely(!restab_log[res]))
69758 + return;
69759 +
69760 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
69761 + rlim = task_rlimit_max(task, res);
69762 + else
69763 + rlim = task_rlimit(task, res);
69764 +
69765 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
69766 + return;
69767 +
69768 + rcu_read_lock();
69769 + cred = __task_cred(task);
69770 +
69771 + if (res == RLIMIT_NPROC &&
69772 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
69773 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
69774 + goto out_rcu_unlock;
69775 + else if (res == RLIMIT_MEMLOCK &&
69776 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
69777 + goto out_rcu_unlock;
69778 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
69779 + goto out_rcu_unlock;
69780 + rcu_read_unlock();
69781 +
69782 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
69783 +
69784 + return;
69785 +out_rcu_unlock:
69786 + rcu_read_unlock();
69787 + return;
69788 +}
69789 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
69790 new file mode 100644
69791 index 0000000..2040e61
69792 --- /dev/null
69793 +++ b/grsecurity/gracl_segv.c
69794 @@ -0,0 +1,313 @@
69795 +#include <linux/kernel.h>
69796 +#include <linux/mm.h>
69797 +#include <asm/uaccess.h>
69798 +#include <asm/errno.h>
69799 +#include <asm/mman.h>
69800 +#include <net/sock.h>
69801 +#include <linux/file.h>
69802 +#include <linux/fs.h>
69803 +#include <linux/net.h>
69804 +#include <linux/in.h>
69805 +#include <linux/slab.h>
69806 +#include <linux/types.h>
69807 +#include <linux/sched.h>
69808 +#include <linux/timer.h>
69809 +#include <linux/gracl.h>
69810 +#include <linux/grsecurity.h>
69811 +#include <linux/grinternal.h>
69812 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
69813 +#include <linux/magic.h>
69814 +#include <linux/pagemap.h>
69815 +#include "../fs/btrfs/async-thread.h"
69816 +#include "../fs/btrfs/ctree.h"
69817 +#include "../fs/btrfs/btrfs_inode.h"
69818 +#endif
69819 +
69820 +static struct crash_uid *uid_set;
69821 +static unsigned short uid_used;
69822 +static DEFINE_SPINLOCK(gr_uid_lock);
69823 +extern rwlock_t gr_inode_lock;
69824 +extern struct acl_subject_label *
69825 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
69826 + struct acl_role_label *role);
69827 +
69828 +static inline dev_t __get_dev(const struct dentry *dentry)
69829 +{
69830 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
69831 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
69832 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
69833 + else
69834 +#endif
69835 + return dentry->d_sb->s_dev;
69836 +}
69837 +
69838 +int
69839 +gr_init_uidset(void)
69840 +{
69841 + uid_set =
69842 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
69843 + uid_used = 0;
69844 +
69845 + return uid_set ? 1 : 0;
69846 +}
69847 +
69848 +void
69849 +gr_free_uidset(void)
69850 +{
69851 + if (uid_set) {
69852 + struct crash_uid *tmpset;
69853 + spin_lock(&gr_uid_lock);
69854 + tmpset = uid_set;
69855 + uid_set = NULL;
69856 + uid_used = 0;
69857 + spin_unlock(&gr_uid_lock);
69858 + if (tmpset)
69859 + kfree(tmpset);
69860 + }
69861 +
69862 + return;
69863 +}
69864 +
69865 +int
69866 +gr_find_uid(const uid_t uid)
69867 +{
69868 + struct crash_uid *tmp = uid_set;
69869 + uid_t buid;
69870 + int low = 0, high = uid_used - 1, mid;
69871 +
69872 + while (high >= low) {
69873 + mid = (low + high) >> 1;
69874 + buid = tmp[mid].uid;
69875 + if (buid == uid)
69876 + return mid;
69877 + if (buid > uid)
69878 + high = mid - 1;
69879 + if (buid < uid)
69880 + low = mid + 1;
69881 + }
69882 +
69883 + return -1;
69884 +}
69885 +
69886 +static __inline__ void
69887 +gr_insertsort(void)
69888 +{
69889 + unsigned short i, j;
69890 + struct crash_uid index;
69891 +
69892 + for (i = 1; i < uid_used; i++) {
69893 + index = uid_set[i];
69894 + j = i;
69895 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
69896 + uid_set[j] = uid_set[j - 1];
69897 + j--;
69898 + }
69899 + uid_set[j] = index;
69900 + }
69901 +
69902 + return;
69903 +}
69904 +
69905 +static __inline__ void
69906 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
69907 +{
69908 + int loc;
69909 + uid_t uid = GR_GLOBAL_UID(kuid);
69910 +
69911 + if (uid_used == GR_UIDTABLE_MAX)
69912 + return;
69913 +
69914 + loc = gr_find_uid(uid);
69915 +
69916 + if (loc >= 0) {
69917 + uid_set[loc].expires = expires;
69918 + return;
69919 + }
69920 +
69921 + uid_set[uid_used].uid = uid;
69922 + uid_set[uid_used].expires = expires;
69923 + uid_used++;
69924 +
69925 + gr_insertsort();
69926 +
69927 + return;
69928 +}
69929 +
69930 +void
69931 +gr_remove_uid(const unsigned short loc)
69932 +{
69933 + unsigned short i;
69934 +
69935 + for (i = loc + 1; i < uid_used; i++)
69936 + uid_set[i - 1] = uid_set[i];
69937 +
69938 + uid_used--;
69939 +
69940 + return;
69941 +}
69942 +
69943 +int
69944 +gr_check_crash_uid(const kuid_t kuid)
69945 +{
69946 + int loc;
69947 + int ret = 0;
69948 + uid_t uid;
69949 +
69950 + if (unlikely(!gr_acl_is_enabled()))
69951 + return 0;
69952 +
69953 + uid = GR_GLOBAL_UID(kuid);
69954 +
69955 + spin_lock(&gr_uid_lock);
69956 + loc = gr_find_uid(uid);
69957 +
69958 + if (loc < 0)
69959 + goto out_unlock;
69960 +
69961 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
69962 + gr_remove_uid(loc);
69963 + else
69964 + ret = 1;
69965 +
69966 +out_unlock:
69967 + spin_unlock(&gr_uid_lock);
69968 + return ret;
69969 +}
69970 +
69971 +static __inline__ int
69972 +proc_is_setxid(const struct cred *cred)
69973 +{
69974 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
69975 + !uid_eq(cred->uid, cred->fsuid))
69976 + return 1;
69977 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
69978 + !gid_eq(cred->gid, cred->fsgid))
69979 + return 1;
69980 +
69981 + return 0;
69982 +}
69983 +
69984 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
69985 +
69986 +void
69987 +gr_handle_crash(struct task_struct *task, const int sig)
69988 +{
69989 + struct acl_subject_label *curr;
69990 + struct task_struct *tsk, *tsk2;
69991 + const struct cred *cred;
69992 + const struct cred *cred2;
69993 +
69994 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
69995 + return;
69996 +
69997 + if (unlikely(!gr_acl_is_enabled()))
69998 + return;
69999 +
70000 + curr = task->acl;
70001 +
70002 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
70003 + return;
70004 +
70005 + if (time_before_eq(curr->expires, get_seconds())) {
70006 + curr->expires = 0;
70007 + curr->crashes = 0;
70008 + }
70009 +
70010 + curr->crashes++;
70011 +
70012 + if (!curr->expires)
70013 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
70014 +
70015 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
70016 + time_after(curr->expires, get_seconds())) {
70017 + rcu_read_lock();
70018 + cred = __task_cred(task);
70019 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
70020 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
70021 + spin_lock(&gr_uid_lock);
70022 + gr_insert_uid(cred->uid, curr->expires);
70023 + spin_unlock(&gr_uid_lock);
70024 + curr->expires = 0;
70025 + curr->crashes = 0;
70026 + read_lock(&tasklist_lock);
70027 + do_each_thread(tsk2, tsk) {
70028 + cred2 = __task_cred(tsk);
70029 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
70030 + gr_fake_force_sig(SIGKILL, tsk);
70031 + } while_each_thread(tsk2, tsk);
70032 + read_unlock(&tasklist_lock);
70033 + } else {
70034 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
70035 + read_lock(&tasklist_lock);
70036 + read_lock(&grsec_exec_file_lock);
70037 + do_each_thread(tsk2, tsk) {
70038 + if (likely(tsk != task)) {
70039 + // if this thread has the same subject as the one that triggered
70040 + // RES_CRASH and it's the same binary, kill it
70041 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
70042 + gr_fake_force_sig(SIGKILL, tsk);
70043 + }
70044 + } while_each_thread(tsk2, tsk);
70045 + read_unlock(&grsec_exec_file_lock);
70046 + read_unlock(&tasklist_lock);
70047 + }
70048 + rcu_read_unlock();
70049 + }
70050 +
70051 + return;
70052 +}
70053 +
70054 +int
70055 +gr_check_crash_exec(const struct file *filp)
70056 +{
70057 + struct acl_subject_label *curr;
70058 +
70059 + if (unlikely(!gr_acl_is_enabled()))
70060 + return 0;
70061 +
70062 + read_lock(&gr_inode_lock);
70063 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
70064 + __get_dev(filp->f_path.dentry),
70065 + current->role);
70066 + read_unlock(&gr_inode_lock);
70067 +
70068 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
70069 + (!curr->crashes && !curr->expires))
70070 + return 0;
70071 +
70072 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
70073 + time_after(curr->expires, get_seconds()))
70074 + return 1;
70075 + else if (time_before_eq(curr->expires, get_seconds())) {
70076 + curr->crashes = 0;
70077 + curr->expires = 0;
70078 + }
70079 +
70080 + return 0;
70081 +}
70082 +
70083 +void
70084 +gr_handle_alertkill(struct task_struct *task)
70085 +{
70086 + struct acl_subject_label *curracl;
70087 + __u32 curr_ip;
70088 + struct task_struct *p, *p2;
70089 +
70090 + if (unlikely(!gr_acl_is_enabled()))
70091 + return;
70092 +
70093 + curracl = task->acl;
70094 + curr_ip = task->signal->curr_ip;
70095 +
70096 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
70097 + read_lock(&tasklist_lock);
70098 + do_each_thread(p2, p) {
70099 + if (p->signal->curr_ip == curr_ip)
70100 + gr_fake_force_sig(SIGKILL, p);
70101 + } while_each_thread(p2, p);
70102 + read_unlock(&tasklist_lock);
70103 + } else if (curracl->mode & GR_KILLPROC)
70104 + gr_fake_force_sig(SIGKILL, task);
70105 +
70106 + return;
70107 +}
70108 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
70109 new file mode 100644
70110 index 0000000..98011b0
70111 --- /dev/null
70112 +++ b/grsecurity/gracl_shm.c
70113 @@ -0,0 +1,40 @@
70114 +#include <linux/kernel.h>
70115 +#include <linux/mm.h>
70116 +#include <linux/sched.h>
70117 +#include <linux/file.h>
70118 +#include <linux/ipc.h>
70119 +#include <linux/gracl.h>
70120 +#include <linux/grsecurity.h>
70121 +#include <linux/grinternal.h>
70122 +
70123 +int
70124 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
70125 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
70126 +{
70127 + struct task_struct *task;
70128 +
70129 + if (!gr_acl_is_enabled())
70130 + return 1;
70131 +
70132 + rcu_read_lock();
70133 + read_lock(&tasklist_lock);
70134 +
70135 + task = find_task_by_vpid(shm_cprid);
70136 +
70137 + if (unlikely(!task))
70138 + task = find_task_by_vpid(shm_lapid);
70139 +
70140 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
70141 + (task_pid_nr(task) == shm_lapid)) &&
70142 + (task->acl->mode & GR_PROTSHM) &&
70143 + (task->acl != current->acl))) {
70144 + read_unlock(&tasklist_lock);
70145 + rcu_read_unlock();
70146 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
70147 + return 0;
70148 + }
70149 + read_unlock(&tasklist_lock);
70150 + rcu_read_unlock();
70151 +
70152 + return 1;
70153 +}
70154 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
70155 new file mode 100644
70156 index 0000000..bc0be01
70157 --- /dev/null
70158 +++ b/grsecurity/grsec_chdir.c
70159 @@ -0,0 +1,19 @@
70160 +#include <linux/kernel.h>
70161 +#include <linux/sched.h>
70162 +#include <linux/fs.h>
70163 +#include <linux/file.h>
70164 +#include <linux/grsecurity.h>
70165 +#include <linux/grinternal.h>
70166 +
70167 +void
70168 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
70169 +{
70170 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
70171 + if ((grsec_enable_chdir && grsec_enable_group &&
70172 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
70173 + !grsec_enable_group)) {
70174 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
70175 + }
70176 +#endif
70177 + return;
70178 +}
70179 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
70180 new file mode 100644
70181 index 0000000..e10b319
70182 --- /dev/null
70183 +++ b/grsecurity/grsec_chroot.c
70184 @@ -0,0 +1,370 @@
70185 +#include <linux/kernel.h>
70186 +#include <linux/module.h>
70187 +#include <linux/sched.h>
70188 +#include <linux/file.h>
70189 +#include <linux/fs.h>
70190 +#include <linux/mount.h>
70191 +#include <linux/types.h>
70192 +#include "../fs/mount.h"
70193 +#include <linux/grsecurity.h>
70194 +#include <linux/grinternal.h>
70195 +
70196 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
70197 +int gr_init_ran;
70198 +#endif
70199 +
70200 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
70201 +{
70202 +#ifdef CONFIG_GRKERNSEC
70203 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
70204 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
70205 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
70206 + && gr_init_ran
70207 +#endif
70208 + )
70209 + task->gr_is_chrooted = 1;
70210 + else {
70211 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
70212 + if (task_pid_nr(task) == 1 && !gr_init_ran)
70213 + gr_init_ran = 1;
70214 +#endif
70215 + task->gr_is_chrooted = 0;
70216 + }
70217 +
70218 + task->gr_chroot_dentry = path->dentry;
70219 +#endif
70220 + return;
70221 +}
70222 +
70223 +void gr_clear_chroot_entries(struct task_struct *task)
70224 +{
70225 +#ifdef CONFIG_GRKERNSEC
70226 + task->gr_is_chrooted = 0;
70227 + task->gr_chroot_dentry = NULL;
70228 +#endif
70229 + return;
70230 +}
70231 +
70232 +int
70233 +gr_handle_chroot_unix(const pid_t pid)
70234 +{
70235 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
70236 + struct task_struct *p;
70237 +
70238 + if (unlikely(!grsec_enable_chroot_unix))
70239 + return 1;
70240 +
70241 + if (likely(!proc_is_chrooted(current)))
70242 + return 1;
70243 +
70244 + rcu_read_lock();
70245 + read_lock(&tasklist_lock);
70246 + p = find_task_by_vpid_unrestricted(pid);
70247 + if (unlikely(p && !have_same_root(current, p))) {
70248 + read_unlock(&tasklist_lock);
70249 + rcu_read_unlock();
70250 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
70251 + return 0;
70252 + }
70253 + read_unlock(&tasklist_lock);
70254 + rcu_read_unlock();
70255 +#endif
70256 + return 1;
70257 +}
70258 +
70259 +int
70260 +gr_handle_chroot_nice(void)
70261 +{
70262 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
70263 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
70264 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
70265 + return -EPERM;
70266 + }
70267 +#endif
70268 + return 0;
70269 +}
70270 +
70271 +int
70272 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
70273 +{
70274 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
70275 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
70276 + && proc_is_chrooted(current)) {
70277 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
70278 + return -EACCES;
70279 + }
70280 +#endif
70281 + return 0;
70282 +}
70283 +
70284 +int
70285 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
70286 +{
70287 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70288 + struct task_struct *p;
70289 + int ret = 0;
70290 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
70291 + return ret;
70292 +
70293 + read_lock(&tasklist_lock);
70294 + do_each_pid_task(pid, type, p) {
70295 + if (!have_same_root(current, p)) {
70296 + ret = 1;
70297 + goto out;
70298 + }
70299 + } while_each_pid_task(pid, type, p);
70300 +out:
70301 + read_unlock(&tasklist_lock);
70302 + return ret;
70303 +#endif
70304 + return 0;
70305 +}
70306 +
70307 +int
70308 +gr_pid_is_chrooted(struct task_struct *p)
70309 +{
70310 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70311 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
70312 + return 0;
70313 +
70314 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
70315 + !have_same_root(current, p)) {
70316 + return 1;
70317 + }
70318 +#endif
70319 + return 0;
70320 +}
70321 +
70322 +EXPORT_SYMBOL(gr_pid_is_chrooted);
70323 +
70324 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
70325 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
70326 +{
70327 + struct path path, currentroot;
70328 + int ret = 0;
70329 +
70330 + path.dentry = (struct dentry *)u_dentry;
70331 + path.mnt = (struct vfsmount *)u_mnt;
70332 + get_fs_root(current->fs, &currentroot);
70333 + if (path_is_under(&path, &currentroot))
70334 + ret = 1;
70335 + path_put(&currentroot);
70336 +
70337 + return ret;
70338 +}
70339 +#endif
70340 +
70341 +int
70342 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
70343 +{
70344 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
70345 + if (!grsec_enable_chroot_fchdir)
70346 + return 1;
70347 +
70348 + if (!proc_is_chrooted(current))
70349 + return 1;
70350 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
70351 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
70352 + return 0;
70353 + }
70354 +#endif
70355 + return 1;
70356 +}
70357 +
70358 +int
70359 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
70360 + const time_t shm_createtime)
70361 +{
70362 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
70363 + struct task_struct *p;
70364 + time_t starttime;
70365 +
70366 + if (unlikely(!grsec_enable_chroot_shmat))
70367 + return 1;
70368 +
70369 + if (likely(!proc_is_chrooted(current)))
70370 + return 1;
70371 +
70372 + rcu_read_lock();
70373 + read_lock(&tasklist_lock);
70374 +
70375 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
70376 + starttime = p->start_time.tv_sec;
70377 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
70378 + if (have_same_root(current, p)) {
70379 + goto allow;
70380 + } else {
70381 + read_unlock(&tasklist_lock);
70382 + rcu_read_unlock();
70383 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
70384 + return 0;
70385 + }
70386 + }
70387 + /* creator exited, pid reuse, fall through to next check */
70388 + }
70389 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
70390 + if (unlikely(!have_same_root(current, p))) {
70391 + read_unlock(&tasklist_lock);
70392 + rcu_read_unlock();
70393 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
70394 + return 0;
70395 + }
70396 + }
70397 +
70398 +allow:
70399 + read_unlock(&tasklist_lock);
70400 + rcu_read_unlock();
70401 +#endif
70402 + return 1;
70403 +}
70404 +
70405 +void
70406 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
70407 +{
70408 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
70409 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
70410 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
70411 +#endif
70412 + return;
70413 +}
70414 +
70415 +int
70416 +gr_handle_chroot_mknod(const struct dentry *dentry,
70417 + const struct vfsmount *mnt, const int mode)
70418 +{
70419 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
70420 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
70421 + proc_is_chrooted(current)) {
70422 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
70423 + return -EPERM;
70424 + }
70425 +#endif
70426 + return 0;
70427 +}
70428 +
70429 +int
70430 +gr_handle_chroot_mount(const struct dentry *dentry,
70431 + const struct vfsmount *mnt, const char *dev_name)
70432 +{
70433 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
70434 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
70435 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
70436 + return -EPERM;
70437 + }
70438 +#endif
70439 + return 0;
70440 +}
70441 +
70442 +int
70443 +gr_handle_chroot_pivot(void)
70444 +{
70445 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
70446 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
70447 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
70448 + return -EPERM;
70449 + }
70450 +#endif
70451 + return 0;
70452 +}
70453 +
70454 +int
70455 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
70456 +{
70457 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
70458 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
70459 + !gr_is_outside_chroot(dentry, mnt)) {
70460 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
70461 + return -EPERM;
70462 + }
70463 +#endif
70464 + return 0;
70465 +}
70466 +
70467 +extern const char *captab_log[];
70468 +extern int captab_log_entries;
70469 +
70470 +int
70471 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
70472 +{
70473 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70474 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
70475 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
70476 + if (cap_raised(chroot_caps, cap)) {
70477 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
70478 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
70479 + }
70480 + return 0;
70481 + }
70482 + }
70483 +#endif
70484 + return 1;
70485 +}
70486 +
70487 +int
70488 +gr_chroot_is_capable(const int cap)
70489 +{
70490 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70491 + return gr_task_chroot_is_capable(current, current_cred(), cap);
70492 +#endif
70493 + return 1;
70494 +}
70495 +
70496 +int
70497 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
70498 +{
70499 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70500 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
70501 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
70502 + if (cap_raised(chroot_caps, cap)) {
70503 + return 0;
70504 + }
70505 + }
70506 +#endif
70507 + return 1;
70508 +}
70509 +
70510 +int
70511 +gr_chroot_is_capable_nolog(const int cap)
70512 +{
70513 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70514 + return gr_task_chroot_is_capable_nolog(current, cap);
70515 +#endif
70516 + return 1;
70517 +}
70518 +
70519 +int
70520 +gr_handle_chroot_sysctl(const int op)
70521 +{
70522 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
70523 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
70524 + proc_is_chrooted(current))
70525 + return -EACCES;
70526 +#endif
70527 + return 0;
70528 +}
70529 +
70530 +void
70531 +gr_handle_chroot_chdir(const struct path *path)
70532 +{
70533 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
70534 + if (grsec_enable_chroot_chdir)
70535 + set_fs_pwd(current->fs, path);
70536 +#endif
70537 + return;
70538 +}
70539 +
70540 +int
70541 +gr_handle_chroot_chmod(const struct dentry *dentry,
70542 + const struct vfsmount *mnt, const int mode)
70543 +{
70544 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
70545 + /* allow chmod +s on directories, but not files */
70546 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
70547 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
70548 + proc_is_chrooted(current)) {
70549 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
70550 + return -EPERM;
70551 + }
70552 +#endif
70553 + return 0;
70554 +}
70555 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
70556 new file mode 100644
70557 index 0000000..52b3e30
70558 --- /dev/null
70559 +++ b/grsecurity/grsec_disabled.c
70560 @@ -0,0 +1,433 @@
70561 +#include <linux/kernel.h>
70562 +#include <linux/module.h>
70563 +#include <linux/sched.h>
70564 +#include <linux/file.h>
70565 +#include <linux/fs.h>
70566 +#include <linux/kdev_t.h>
70567 +#include <linux/net.h>
70568 +#include <linux/in.h>
70569 +#include <linux/ip.h>
70570 +#include <linux/skbuff.h>
70571 +#include <linux/sysctl.h>
70572 +
70573 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
70574 +void
70575 +pax_set_initial_flags(struct linux_binprm *bprm)
70576 +{
70577 + return;
70578 +}
70579 +#endif
70580 +
70581 +#ifdef CONFIG_SYSCTL
70582 +__u32
70583 +gr_handle_sysctl(const struct ctl_table * table, const int op)
70584 +{
70585 + return 0;
70586 +}
70587 +#endif
70588 +
70589 +#ifdef CONFIG_TASKSTATS
70590 +int gr_is_taskstats_denied(int pid)
70591 +{
70592 + return 0;
70593 +}
70594 +#endif
70595 +
70596 +int
70597 +gr_acl_is_enabled(void)
70598 +{
70599 + return 0;
70600 +}
70601 +
70602 +void
70603 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
70604 +{
70605 + return;
70606 +}
70607 +
70608 +int
70609 +gr_handle_rawio(const struct inode *inode)
70610 +{
70611 + return 0;
70612 +}
70613 +
70614 +void
70615 +gr_acl_handle_psacct(struct task_struct *task, const long code)
70616 +{
70617 + return;
70618 +}
70619 +
70620 +int
70621 +gr_handle_ptrace(struct task_struct *task, const long request)
70622 +{
70623 + return 0;
70624 +}
70625 +
70626 +int
70627 +gr_handle_proc_ptrace(struct task_struct *task)
70628 +{
70629 + return 0;
70630 +}
70631 +
70632 +int
70633 +gr_set_acls(const int type)
70634 +{
70635 + return 0;
70636 +}
70637 +
70638 +int
70639 +gr_check_hidden_task(const struct task_struct *tsk)
70640 +{
70641 + return 0;
70642 +}
70643 +
70644 +int
70645 +gr_check_protected_task(const struct task_struct *task)
70646 +{
70647 + return 0;
70648 +}
70649 +
70650 +int
70651 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
70652 +{
70653 + return 0;
70654 +}
70655 +
70656 +void
70657 +gr_copy_label(struct task_struct *tsk)
70658 +{
70659 + return;
70660 +}
70661 +
70662 +void
70663 +gr_set_pax_flags(struct task_struct *task)
70664 +{
70665 + return;
70666 +}
70667 +
70668 +int
70669 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
70670 + const int unsafe_share)
70671 +{
70672 + return 0;
70673 +}
70674 +
70675 +void
70676 +gr_handle_delete(const ino_t ino, const dev_t dev)
70677 +{
70678 + return;
70679 +}
70680 +
70681 +void
70682 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
70683 +{
70684 + return;
70685 +}
70686 +
70687 +void
70688 +gr_handle_crash(struct task_struct *task, const int sig)
70689 +{
70690 + return;
70691 +}
70692 +
70693 +int
70694 +gr_check_crash_exec(const struct file *filp)
70695 +{
70696 + return 0;
70697 +}
70698 +
70699 +int
70700 +gr_check_crash_uid(const kuid_t uid)
70701 +{
70702 + return 0;
70703 +}
70704 +
70705 +void
70706 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
70707 + struct dentry *old_dentry,
70708 + struct dentry *new_dentry,
70709 + struct vfsmount *mnt, const __u8 replace)
70710 +{
70711 + return;
70712 +}
70713 +
70714 +int
70715 +gr_search_socket(const int family, const int type, const int protocol)
70716 +{
70717 + return 1;
70718 +}
70719 +
70720 +int
70721 +gr_search_connectbind(const int mode, const struct socket *sock,
70722 + const struct sockaddr_in *addr)
70723 +{
70724 + return 0;
70725 +}
70726 +
70727 +void
70728 +gr_handle_alertkill(struct task_struct *task)
70729 +{
70730 + return;
70731 +}
70732 +
70733 +__u32
70734 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
70735 +{
70736 + return 1;
70737 +}
70738 +
70739 +__u32
70740 +gr_acl_handle_hidden_file(const struct dentry * dentry,
70741 + const struct vfsmount * mnt)
70742 +{
70743 + return 1;
70744 +}
70745 +
70746 +__u32
70747 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
70748 + int acc_mode)
70749 +{
70750 + return 1;
70751 +}
70752 +
70753 +__u32
70754 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
70755 +{
70756 + return 1;
70757 +}
70758 +
70759 +__u32
70760 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
70761 +{
70762 + return 1;
70763 +}
70764 +
70765 +int
70766 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
70767 + unsigned int *vm_flags)
70768 +{
70769 + return 1;
70770 +}
70771 +
70772 +__u32
70773 +gr_acl_handle_truncate(const struct dentry * dentry,
70774 + const struct vfsmount * mnt)
70775 +{
70776 + return 1;
70777 +}
70778 +
70779 +__u32
70780 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
70781 +{
70782 + return 1;
70783 +}
70784 +
70785 +__u32
70786 +gr_acl_handle_access(const struct dentry * dentry,
70787 + const struct vfsmount * mnt, const int fmode)
70788 +{
70789 + return 1;
70790 +}
70791 +
70792 +__u32
70793 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
70794 + umode_t *mode)
70795 +{
70796 + return 1;
70797 +}
70798 +
70799 +__u32
70800 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
70801 +{
70802 + return 1;
70803 +}
70804 +
70805 +__u32
70806 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
70807 +{
70808 + return 1;
70809 +}
70810 +
70811 +__u32
70812 +gr_acl_handle_removexattr(const struct dentry * dentry, const struct vfsmount * mnt)
70813 +{
70814 + return 1;
70815 +}
70816 +
70817 +void
70818 +grsecurity_init(void)
70819 +{
70820 + return;
70821 +}
70822 +
70823 +umode_t gr_acl_umask(void)
70824 +{
70825 + return 0;
70826 +}
70827 +
70828 +__u32
70829 +gr_acl_handle_mknod(const struct dentry * new_dentry,
70830 + const struct dentry * parent_dentry,
70831 + const struct vfsmount * parent_mnt,
70832 + const int mode)
70833 +{
70834 + return 1;
70835 +}
70836 +
70837 +__u32
70838 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
70839 + const struct dentry * parent_dentry,
70840 + const struct vfsmount * parent_mnt)
70841 +{
70842 + return 1;
70843 +}
70844 +
70845 +__u32
70846 +gr_acl_handle_symlink(const struct dentry * new_dentry,
70847 + const struct dentry * parent_dentry,
70848 + const struct vfsmount * parent_mnt, const struct filename *from)
70849 +{
70850 + return 1;
70851 +}
70852 +
70853 +__u32
70854 +gr_acl_handle_link(const struct dentry * new_dentry,
70855 + const struct dentry * parent_dentry,
70856 + const struct vfsmount * parent_mnt,
70857 + const struct dentry * old_dentry,
70858 + const struct vfsmount * old_mnt, const struct filename *to)
70859 +{
70860 + return 1;
70861 +}
70862 +
70863 +int
70864 +gr_acl_handle_rename(const struct dentry *new_dentry,
70865 + const struct dentry *parent_dentry,
70866 + const struct vfsmount *parent_mnt,
70867 + const struct dentry *old_dentry,
70868 + const struct inode *old_parent_inode,
70869 + const struct vfsmount *old_mnt, const struct filename *newname)
70870 +{
70871 + return 0;
70872 +}
70873 +
70874 +int
70875 +gr_acl_handle_filldir(const struct file *file, const char *name,
70876 + const int namelen, const ino_t ino)
70877 +{
70878 + return 1;
70879 +}
70880 +
70881 +int
70882 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
70883 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
70884 +{
70885 + return 1;
70886 +}
70887 +
70888 +int
70889 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
70890 +{
70891 + return 0;
70892 +}
70893 +
70894 +int
70895 +gr_search_accept(const struct socket *sock)
70896 +{
70897 + return 0;
70898 +}
70899 +
70900 +int
70901 +gr_search_listen(const struct socket *sock)
70902 +{
70903 + return 0;
70904 +}
70905 +
70906 +int
70907 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
70908 +{
70909 + return 0;
70910 +}
70911 +
70912 +__u32
70913 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
70914 +{
70915 + return 1;
70916 +}
70917 +
70918 +__u32
70919 +gr_acl_handle_creat(const struct dentry * dentry,
70920 + const struct dentry * p_dentry,
70921 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
70922 + const int imode)
70923 +{
70924 + return 1;
70925 +}
70926 +
70927 +void
70928 +gr_acl_handle_exit(void)
70929 +{
70930 + return;
70931 +}
70932 +
70933 +int
70934 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
70935 +{
70936 + return 1;
70937 +}
70938 +
70939 +void
70940 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
70941 +{
70942 + return;
70943 +}
70944 +
70945 +int
70946 +gr_acl_handle_procpidmem(const struct task_struct *task)
70947 +{
70948 + return 0;
70949 +}
70950 +
70951 +int
70952 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
70953 +{
70954 + return 0;
70955 +}
70956 +
70957 +int
70958 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
70959 +{
70960 + return 0;
70961 +}
70962 +
70963 +int
70964 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
70965 +{
70966 + return 0;
70967 +}
70968 +
70969 +int
70970 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
70971 +{
70972 + return 0;
70973 +}
70974 +
70975 +int gr_acl_enable_at_secure(void)
70976 +{
70977 + return 0;
70978 +}
70979 +
70980 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
70981 +{
70982 + return dentry->d_sb->s_dev;
70983 +}
70984 +
70985 +void gr_put_exec_file(struct task_struct *task)
70986 +{
70987 + return;
70988 +}
70989 +
70990 +#ifdef CONFIG_SECURITY
70991 +EXPORT_SYMBOL(gr_check_user_change);
70992 +EXPORT_SYMBOL(gr_check_group_change);
70993 +#endif
70994 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
70995 new file mode 100644
70996 index 0000000..387032b
70997 --- /dev/null
70998 +++ b/grsecurity/grsec_exec.c
70999 @@ -0,0 +1,187 @@
71000 +#include <linux/kernel.h>
71001 +#include <linux/sched.h>
71002 +#include <linux/file.h>
71003 +#include <linux/binfmts.h>
71004 +#include <linux/fs.h>
71005 +#include <linux/types.h>
71006 +#include <linux/grdefs.h>
71007 +#include <linux/grsecurity.h>
71008 +#include <linux/grinternal.h>
71009 +#include <linux/capability.h>
71010 +#include <linux/module.h>
71011 +#include <linux/compat.h>
71012 +
71013 +#include <asm/uaccess.h>
71014 +
71015 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71016 +static char gr_exec_arg_buf[132];
71017 +static DEFINE_MUTEX(gr_exec_arg_mutex);
71018 +#endif
71019 +
71020 +struct user_arg_ptr {
71021 +#ifdef CONFIG_COMPAT
71022 + bool is_compat;
71023 +#endif
71024 + union {
71025 + const char __user *const __user *native;
71026 +#ifdef CONFIG_COMPAT
71027 + const compat_uptr_t __user *compat;
71028 +#endif
71029 + } ptr;
71030 +};
71031 +
71032 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
71033 +
71034 +void
71035 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
71036 +{
71037 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71038 + char *grarg = gr_exec_arg_buf;
71039 + unsigned int i, x, execlen = 0;
71040 + char c;
71041 +
71042 + if (!((grsec_enable_execlog && grsec_enable_group &&
71043 + in_group_p(grsec_audit_gid))
71044 + || (grsec_enable_execlog && !grsec_enable_group)))
71045 + return;
71046 +
71047 + mutex_lock(&gr_exec_arg_mutex);
71048 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
71049 +
71050 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
71051 + const char __user *p;
71052 + unsigned int len;
71053 +
71054 + p = get_user_arg_ptr(argv, i);
71055 + if (IS_ERR(p))
71056 + goto log;
71057 +
71058 + len = strnlen_user(p, 128 - execlen);
71059 + if (len > 128 - execlen)
71060 + len = 128 - execlen;
71061 + else if (len > 0)
71062 + len--;
71063 + if (copy_from_user(grarg + execlen, p, len))
71064 + goto log;
71065 +
71066 + /* rewrite unprintable characters */
71067 + for (x = 0; x < len; x++) {
71068 + c = *(grarg + execlen + x);
71069 + if (c < 32 || c > 126)
71070 + *(grarg + execlen + x) = ' ';
71071 + }
71072 +
71073 + execlen += len;
71074 + *(grarg + execlen) = ' ';
71075 + *(grarg + execlen + 1) = '\0';
71076 + execlen++;
71077 + }
71078 +
71079 + log:
71080 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
71081 + bprm->file->f_path.mnt, grarg);
71082 + mutex_unlock(&gr_exec_arg_mutex);
71083 +#endif
71084 + return;
71085 +}
71086 +
71087 +#ifdef CONFIG_GRKERNSEC
71088 +extern int gr_acl_is_capable(const int cap);
71089 +extern int gr_acl_is_capable_nolog(const int cap);
71090 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
71091 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
71092 +extern int gr_chroot_is_capable(const int cap);
71093 +extern int gr_chroot_is_capable_nolog(const int cap);
71094 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
71095 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
71096 +#endif
71097 +
71098 +const char *captab_log[] = {
71099 + "CAP_CHOWN",
71100 + "CAP_DAC_OVERRIDE",
71101 + "CAP_DAC_READ_SEARCH",
71102 + "CAP_FOWNER",
71103 + "CAP_FSETID",
71104 + "CAP_KILL",
71105 + "CAP_SETGID",
71106 + "CAP_SETUID",
71107 + "CAP_SETPCAP",
71108 + "CAP_LINUX_IMMUTABLE",
71109 + "CAP_NET_BIND_SERVICE",
71110 + "CAP_NET_BROADCAST",
71111 + "CAP_NET_ADMIN",
71112 + "CAP_NET_RAW",
71113 + "CAP_IPC_LOCK",
71114 + "CAP_IPC_OWNER",
71115 + "CAP_SYS_MODULE",
71116 + "CAP_SYS_RAWIO",
71117 + "CAP_SYS_CHROOT",
71118 + "CAP_SYS_PTRACE",
71119 + "CAP_SYS_PACCT",
71120 + "CAP_SYS_ADMIN",
71121 + "CAP_SYS_BOOT",
71122 + "CAP_SYS_NICE",
71123 + "CAP_SYS_RESOURCE",
71124 + "CAP_SYS_TIME",
71125 + "CAP_SYS_TTY_CONFIG",
71126 + "CAP_MKNOD",
71127 + "CAP_LEASE",
71128 + "CAP_AUDIT_WRITE",
71129 + "CAP_AUDIT_CONTROL",
71130 + "CAP_SETFCAP",
71131 + "CAP_MAC_OVERRIDE",
71132 + "CAP_MAC_ADMIN",
71133 + "CAP_SYSLOG",
71134 + "CAP_WAKE_ALARM"
71135 +};
71136 +
71137 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
71138 +
71139 +int gr_is_capable(const int cap)
71140 +{
71141 +#ifdef CONFIG_GRKERNSEC
71142 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
71143 + return 1;
71144 + return 0;
71145 +#else
71146 + return 1;
71147 +#endif
71148 +}
71149 +
71150 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
71151 +{
71152 +#ifdef CONFIG_GRKERNSEC
71153 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
71154 + return 1;
71155 + return 0;
71156 +#else
71157 + return 1;
71158 +#endif
71159 +}
71160 +
71161 +int gr_is_capable_nolog(const int cap)
71162 +{
71163 +#ifdef CONFIG_GRKERNSEC
71164 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
71165 + return 1;
71166 + return 0;
71167 +#else
71168 + return 1;
71169 +#endif
71170 +}
71171 +
71172 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
71173 +{
71174 +#ifdef CONFIG_GRKERNSEC
71175 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
71176 + return 1;
71177 + return 0;
71178 +#else
71179 + return 1;
71180 +#endif
71181 +}
71182 +
71183 +EXPORT_SYMBOL(gr_is_capable);
71184 +EXPORT_SYMBOL(gr_is_capable_nolog);
71185 +EXPORT_SYMBOL(gr_task_is_capable);
71186 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
71187 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
71188 new file mode 100644
71189 index 0000000..06cc6ea
71190 --- /dev/null
71191 +++ b/grsecurity/grsec_fifo.c
71192 @@ -0,0 +1,24 @@
71193 +#include <linux/kernel.h>
71194 +#include <linux/sched.h>
71195 +#include <linux/fs.h>
71196 +#include <linux/file.h>
71197 +#include <linux/grinternal.h>
71198 +
71199 +int
71200 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
71201 + const struct dentry *dir, const int flag, const int acc_mode)
71202 +{
71203 +#ifdef CONFIG_GRKERNSEC_FIFO
71204 + const struct cred *cred = current_cred();
71205 +
71206 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
71207 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
71208 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
71209 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
71210 + if (!inode_permission(dentry->d_inode, acc_mode))
71211 + 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));
71212 + return -EACCES;
71213 + }
71214 +#endif
71215 + return 0;
71216 +}
71217 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
71218 new file mode 100644
71219 index 0000000..8ca18bf
71220 --- /dev/null
71221 +++ b/grsecurity/grsec_fork.c
71222 @@ -0,0 +1,23 @@
71223 +#include <linux/kernel.h>
71224 +#include <linux/sched.h>
71225 +#include <linux/grsecurity.h>
71226 +#include <linux/grinternal.h>
71227 +#include <linux/errno.h>
71228 +
71229 +void
71230 +gr_log_forkfail(const int retval)
71231 +{
71232 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71233 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
71234 + switch (retval) {
71235 + case -EAGAIN:
71236 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
71237 + break;
71238 + case -ENOMEM:
71239 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
71240 + break;
71241 + }
71242 + }
71243 +#endif
71244 + return;
71245 +}
71246 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
71247 new file mode 100644
71248 index 0000000..a88e901
71249 --- /dev/null
71250 +++ b/grsecurity/grsec_init.c
71251 @@ -0,0 +1,272 @@
71252 +#include <linux/kernel.h>
71253 +#include <linux/sched.h>
71254 +#include <linux/mm.h>
71255 +#include <linux/gracl.h>
71256 +#include <linux/slab.h>
71257 +#include <linux/vmalloc.h>
71258 +#include <linux/percpu.h>
71259 +#include <linux/module.h>
71260 +
71261 +int grsec_enable_ptrace_readexec;
71262 +int grsec_enable_setxid;
71263 +int grsec_enable_symlinkown;
71264 +kgid_t grsec_symlinkown_gid;
71265 +int grsec_enable_brute;
71266 +int grsec_enable_link;
71267 +int grsec_enable_dmesg;
71268 +int grsec_enable_harden_ptrace;
71269 +int grsec_enable_harden_ipc;
71270 +int grsec_enable_fifo;
71271 +int grsec_enable_execlog;
71272 +int grsec_enable_signal;
71273 +int grsec_enable_forkfail;
71274 +int grsec_enable_audit_ptrace;
71275 +int grsec_enable_time;
71276 +int grsec_enable_group;
71277 +kgid_t grsec_audit_gid;
71278 +int grsec_enable_chdir;
71279 +int grsec_enable_mount;
71280 +int grsec_enable_rofs;
71281 +int grsec_deny_new_usb;
71282 +int grsec_enable_chroot_findtask;
71283 +int grsec_enable_chroot_mount;
71284 +int grsec_enable_chroot_shmat;
71285 +int grsec_enable_chroot_fchdir;
71286 +int grsec_enable_chroot_double;
71287 +int grsec_enable_chroot_pivot;
71288 +int grsec_enable_chroot_chdir;
71289 +int grsec_enable_chroot_chmod;
71290 +int grsec_enable_chroot_mknod;
71291 +int grsec_enable_chroot_nice;
71292 +int grsec_enable_chroot_execlog;
71293 +int grsec_enable_chroot_caps;
71294 +int grsec_enable_chroot_sysctl;
71295 +int grsec_enable_chroot_unix;
71296 +int grsec_enable_tpe;
71297 +kgid_t grsec_tpe_gid;
71298 +int grsec_enable_blackhole;
71299 +#ifdef CONFIG_IPV6_MODULE
71300 +EXPORT_SYMBOL(grsec_enable_blackhole);
71301 +#endif
71302 +int grsec_lastack_retries;
71303 +int grsec_enable_tpe_all;
71304 +int grsec_enable_tpe_invert;
71305 +int grsec_enable_socket_all;
71306 +kgid_t grsec_socket_all_gid;
71307 +int grsec_enable_socket_client;
71308 +kgid_t grsec_socket_client_gid;
71309 +int grsec_enable_socket_server;
71310 +kgid_t grsec_socket_server_gid;
71311 +int grsec_resource_logging;
71312 +int grsec_disable_privio;
71313 +int grsec_enable_log_rwxmaps;
71314 +int grsec_lock;
71315 +
71316 +DEFINE_SPINLOCK(grsec_alert_lock);
71317 +unsigned long grsec_alert_wtime = 0;
71318 +unsigned long grsec_alert_fyet = 0;
71319 +
71320 +DEFINE_SPINLOCK(grsec_audit_lock);
71321 +
71322 +DEFINE_RWLOCK(grsec_exec_file_lock);
71323 +
71324 +char *gr_shared_page[4];
71325 +
71326 +char *gr_alert_log_fmt;
71327 +char *gr_audit_log_fmt;
71328 +char *gr_alert_log_buf;
71329 +char *gr_audit_log_buf;
71330 +
71331 +void __init
71332 +grsecurity_init(void)
71333 +{
71334 + int j;
71335 + /* create the per-cpu shared pages */
71336 +
71337 +#ifdef CONFIG_X86
71338 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
71339 +#endif
71340 +
71341 + for (j = 0; j < 4; j++) {
71342 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
71343 + if (gr_shared_page[j] == NULL) {
71344 + panic("Unable to allocate grsecurity shared page");
71345 + return;
71346 + }
71347 + }
71348 +
71349 + /* allocate log buffers */
71350 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
71351 + if (!gr_alert_log_fmt) {
71352 + panic("Unable to allocate grsecurity alert log format buffer");
71353 + return;
71354 + }
71355 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
71356 + if (!gr_audit_log_fmt) {
71357 + panic("Unable to allocate grsecurity audit log format buffer");
71358 + return;
71359 + }
71360 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
71361 + if (!gr_alert_log_buf) {
71362 + panic("Unable to allocate grsecurity alert log buffer");
71363 + return;
71364 + }
71365 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
71366 + if (!gr_audit_log_buf) {
71367 + panic("Unable to allocate grsecurity audit log buffer");
71368 + return;
71369 + }
71370 +
71371 +#ifdef CONFIG_GRKERNSEC_IO
71372 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
71373 + grsec_disable_privio = 1;
71374 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
71375 + grsec_disable_privio = 1;
71376 +#else
71377 + grsec_disable_privio = 0;
71378 +#endif
71379 +#endif
71380 +
71381 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71382 + /* for backward compatibility, tpe_invert always defaults to on if
71383 + enabled in the kernel
71384 + */
71385 + grsec_enable_tpe_invert = 1;
71386 +#endif
71387 +
71388 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
71389 +#ifndef CONFIG_GRKERNSEC_SYSCTL
71390 + grsec_lock = 1;
71391 +#endif
71392 +
71393 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71394 + grsec_enable_log_rwxmaps = 1;
71395 +#endif
71396 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
71397 + grsec_enable_group = 1;
71398 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
71399 +#endif
71400 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71401 + grsec_enable_ptrace_readexec = 1;
71402 +#endif
71403 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
71404 + grsec_enable_chdir = 1;
71405 +#endif
71406 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
71407 + grsec_enable_harden_ptrace = 1;
71408 +#endif
71409 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
71410 + grsec_enable_harden_ipc = 1;
71411 +#endif
71412 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71413 + grsec_enable_mount = 1;
71414 +#endif
71415 +#ifdef CONFIG_GRKERNSEC_LINK
71416 + grsec_enable_link = 1;
71417 +#endif
71418 +#ifdef CONFIG_GRKERNSEC_BRUTE
71419 + grsec_enable_brute = 1;
71420 +#endif
71421 +#ifdef CONFIG_GRKERNSEC_DMESG
71422 + grsec_enable_dmesg = 1;
71423 +#endif
71424 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
71425 + grsec_enable_blackhole = 1;
71426 + grsec_lastack_retries = 4;
71427 +#endif
71428 +#ifdef CONFIG_GRKERNSEC_FIFO
71429 + grsec_enable_fifo = 1;
71430 +#endif
71431 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71432 + grsec_enable_execlog = 1;
71433 +#endif
71434 +#ifdef CONFIG_GRKERNSEC_SETXID
71435 + grsec_enable_setxid = 1;
71436 +#endif
71437 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71438 + grsec_enable_signal = 1;
71439 +#endif
71440 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71441 + grsec_enable_forkfail = 1;
71442 +#endif
71443 +#ifdef CONFIG_GRKERNSEC_TIME
71444 + grsec_enable_time = 1;
71445 +#endif
71446 +#ifdef CONFIG_GRKERNSEC_RESLOG
71447 + grsec_resource_logging = 1;
71448 +#endif
71449 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
71450 + grsec_enable_chroot_findtask = 1;
71451 +#endif
71452 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
71453 + grsec_enable_chroot_unix = 1;
71454 +#endif
71455 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
71456 + grsec_enable_chroot_mount = 1;
71457 +#endif
71458 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
71459 + grsec_enable_chroot_fchdir = 1;
71460 +#endif
71461 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
71462 + grsec_enable_chroot_shmat = 1;
71463 +#endif
71464 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71465 + grsec_enable_audit_ptrace = 1;
71466 +#endif
71467 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
71468 + grsec_enable_chroot_double = 1;
71469 +#endif
71470 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
71471 + grsec_enable_chroot_pivot = 1;
71472 +#endif
71473 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
71474 + grsec_enable_chroot_chdir = 1;
71475 +#endif
71476 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
71477 + grsec_enable_chroot_chmod = 1;
71478 +#endif
71479 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
71480 + grsec_enable_chroot_mknod = 1;
71481 +#endif
71482 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
71483 + grsec_enable_chroot_nice = 1;
71484 +#endif
71485 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
71486 + grsec_enable_chroot_execlog = 1;
71487 +#endif
71488 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
71489 + grsec_enable_chroot_caps = 1;
71490 +#endif
71491 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
71492 + grsec_enable_chroot_sysctl = 1;
71493 +#endif
71494 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
71495 + grsec_enable_symlinkown = 1;
71496 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
71497 +#endif
71498 +#ifdef CONFIG_GRKERNSEC_TPE
71499 + grsec_enable_tpe = 1;
71500 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
71501 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71502 + grsec_enable_tpe_all = 1;
71503 +#endif
71504 +#endif
71505 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71506 + grsec_enable_socket_all = 1;
71507 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
71508 +#endif
71509 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71510 + grsec_enable_socket_client = 1;
71511 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
71512 +#endif
71513 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71514 + grsec_enable_socket_server = 1;
71515 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
71516 +#endif
71517 +#endif
71518 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
71519 + grsec_deny_new_usb = 1;
71520 +#endif
71521 +
71522 + return;
71523 +}
71524 diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
71525 new file mode 100644
71526 index 0000000..78d1680
71527 --- /dev/null
71528 +++ b/grsecurity/grsec_ipc.c
71529 @@ -0,0 +1,48 @@
71530 +#include <linux/kernel.h>
71531 +#include <linux/mm.h>
71532 +#include <linux/sched.h>
71533 +#include <linux/file.h>
71534 +#include <linux/ipc.h>
71535 +#include <linux/ipc_namespace.h>
71536 +#include <linux/grsecurity.h>
71537 +#include <linux/grinternal.h>
71538 +
71539 +int
71540 +gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
71541 +{
71542 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
71543 + int write;
71544 + int orig_granted_mode;
71545 + kuid_t euid;
71546 + kgid_t egid;
71547 +
71548 + if (!grsec_enable_harden_ipc)
71549 + return 0;
71550 +
71551 + euid = current_euid();
71552 + egid = current_egid();
71553 +
71554 + write = requested_mode & 00002;
71555 + orig_granted_mode = ipcp->mode;
71556 +
71557 + if (uid_eq(euid, ipcp->cuid) || uid_eq(euid, ipcp->uid))
71558 + orig_granted_mode >>= 6;
71559 + else {
71560 + /* if likely wrong permissions, lock to user */
71561 + if (orig_granted_mode & 0007)
71562 + orig_granted_mode = 0;
71563 + /* otherwise do a egid-only check */
71564 + else if (gid_eq(egid, ipcp->cgid) || gid_eq(egid, ipcp->gid))
71565 + orig_granted_mode >>= 3;
71566 + /* otherwise, no access */
71567 + else
71568 + orig_granted_mode = 0;
71569 + }
71570 + if (!(requested_mode & ~granted_mode & 0007) && (requested_mode & ~orig_granted_mode & 0007) &&
71571 + !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
71572 + gr_log_str_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", GR_GLOBAL_UID(ipcp->cuid));
71573 + return 0;
71574 + }
71575 +#endif
71576 + return 1;
71577 +}
71578 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
71579 new file mode 100644
71580 index 0000000..5e05e20
71581 --- /dev/null
71582 +++ b/grsecurity/grsec_link.c
71583 @@ -0,0 +1,58 @@
71584 +#include <linux/kernel.h>
71585 +#include <linux/sched.h>
71586 +#include <linux/fs.h>
71587 +#include <linux/file.h>
71588 +#include <linux/grinternal.h>
71589 +
71590 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
71591 +{
71592 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
71593 + const struct inode *link_inode = link->dentry->d_inode;
71594 +
71595 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
71596 + /* ignore root-owned links, e.g. /proc/self */
71597 + gr_is_global_nonroot(link_inode->i_uid) && target &&
71598 + !uid_eq(link_inode->i_uid, target->i_uid)) {
71599 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
71600 + return 1;
71601 + }
71602 +#endif
71603 + return 0;
71604 +}
71605 +
71606 +int
71607 +gr_handle_follow_link(const struct inode *parent,
71608 + const struct inode *inode,
71609 + const struct dentry *dentry, const struct vfsmount *mnt)
71610 +{
71611 +#ifdef CONFIG_GRKERNSEC_LINK
71612 + const struct cred *cred = current_cred();
71613 +
71614 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
71615 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
71616 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
71617 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
71618 + return -EACCES;
71619 + }
71620 +#endif
71621 + return 0;
71622 +}
71623 +
71624 +int
71625 +gr_handle_hardlink(const struct dentry *dentry,
71626 + const struct vfsmount *mnt,
71627 + struct inode *inode, const int mode, const struct filename *to)
71628 +{
71629 +#ifdef CONFIG_GRKERNSEC_LINK
71630 + const struct cred *cred = current_cred();
71631 +
71632 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
71633 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
71634 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
71635 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
71636 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
71637 + return -EPERM;
71638 + }
71639 +#endif
71640 + return 0;
71641 +}
71642 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
71643 new file mode 100644
71644 index 0000000..dbe0a6b
71645 --- /dev/null
71646 +++ b/grsecurity/grsec_log.c
71647 @@ -0,0 +1,341 @@
71648 +#include <linux/kernel.h>
71649 +#include <linux/sched.h>
71650 +#include <linux/file.h>
71651 +#include <linux/tty.h>
71652 +#include <linux/fs.h>
71653 +#include <linux/mm.h>
71654 +#include <linux/grinternal.h>
71655 +
71656 +#ifdef CONFIG_TREE_PREEMPT_RCU
71657 +#define DISABLE_PREEMPT() preempt_disable()
71658 +#define ENABLE_PREEMPT() preempt_enable()
71659 +#else
71660 +#define DISABLE_PREEMPT()
71661 +#define ENABLE_PREEMPT()
71662 +#endif
71663 +
71664 +#define BEGIN_LOCKS(x) \
71665 + DISABLE_PREEMPT(); \
71666 + rcu_read_lock(); \
71667 + read_lock(&tasklist_lock); \
71668 + read_lock(&grsec_exec_file_lock); \
71669 + if (x != GR_DO_AUDIT) \
71670 + spin_lock(&grsec_alert_lock); \
71671 + else \
71672 + spin_lock(&grsec_audit_lock)
71673 +
71674 +#define END_LOCKS(x) \
71675 + if (x != GR_DO_AUDIT) \
71676 + spin_unlock(&grsec_alert_lock); \
71677 + else \
71678 + spin_unlock(&grsec_audit_lock); \
71679 + read_unlock(&grsec_exec_file_lock); \
71680 + read_unlock(&tasklist_lock); \
71681 + rcu_read_unlock(); \
71682 + ENABLE_PREEMPT(); \
71683 + if (x == GR_DONT_AUDIT) \
71684 + gr_handle_alertkill(current)
71685 +
71686 +enum {
71687 + FLOODING,
71688 + NO_FLOODING
71689 +};
71690 +
71691 +extern char *gr_alert_log_fmt;
71692 +extern char *gr_audit_log_fmt;
71693 +extern char *gr_alert_log_buf;
71694 +extern char *gr_audit_log_buf;
71695 +
71696 +static int gr_log_start(int audit)
71697 +{
71698 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
71699 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
71700 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71701 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
71702 + unsigned long curr_secs = get_seconds();
71703 +
71704 + if (audit == GR_DO_AUDIT)
71705 + goto set_fmt;
71706 +
71707 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
71708 + grsec_alert_wtime = curr_secs;
71709 + grsec_alert_fyet = 0;
71710 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
71711 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
71712 + grsec_alert_fyet++;
71713 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
71714 + grsec_alert_wtime = curr_secs;
71715 + grsec_alert_fyet++;
71716 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
71717 + return FLOODING;
71718 + }
71719 + else return FLOODING;
71720 +
71721 +set_fmt:
71722 +#endif
71723 + memset(buf, 0, PAGE_SIZE);
71724 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
71725 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
71726 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
71727 + } else if (current->signal->curr_ip) {
71728 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
71729 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
71730 + } else if (gr_acl_is_enabled()) {
71731 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
71732 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
71733 + } else {
71734 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
71735 + strcpy(buf, fmt);
71736 + }
71737 +
71738 + return NO_FLOODING;
71739 +}
71740 +
71741 +static void gr_log_middle(int audit, const char *msg, va_list ap)
71742 + __attribute__ ((format (printf, 2, 0)));
71743 +
71744 +static void gr_log_middle(int audit, const char *msg, va_list ap)
71745 +{
71746 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71747 + unsigned int len = strlen(buf);
71748 +
71749 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
71750 +
71751 + return;
71752 +}
71753 +
71754 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
71755 + __attribute__ ((format (printf, 2, 3)));
71756 +
71757 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
71758 +{
71759 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71760 + unsigned int len = strlen(buf);
71761 + va_list ap;
71762 +
71763 + va_start(ap, msg);
71764 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
71765 + va_end(ap);
71766 +
71767 + return;
71768 +}
71769 +
71770 +static void gr_log_end(int audit, int append_default)
71771 +{
71772 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71773 + if (append_default) {
71774 + struct task_struct *task = current;
71775 + struct task_struct *parent = task->real_parent;
71776 + const struct cred *cred = __task_cred(task);
71777 + const struct cred *pcred = __task_cred(parent);
71778 + unsigned int len = strlen(buf);
71779 +
71780 + 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));
71781 + }
71782 +
71783 + printk("%s\n", buf);
71784 +
71785 + return;
71786 +}
71787 +
71788 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
71789 +{
71790 + int logtype;
71791 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
71792 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
71793 + void *voidptr = NULL;
71794 + int num1 = 0, num2 = 0;
71795 + unsigned long ulong1 = 0, ulong2 = 0;
71796 + struct dentry *dentry = NULL;
71797 + struct vfsmount *mnt = NULL;
71798 + struct file *file = NULL;
71799 + struct task_struct *task = NULL;
71800 + struct vm_area_struct *vma = NULL;
71801 + const struct cred *cred, *pcred;
71802 + va_list ap;
71803 +
71804 + BEGIN_LOCKS(audit);
71805 + logtype = gr_log_start(audit);
71806 + if (logtype == FLOODING) {
71807 + END_LOCKS(audit);
71808 + return;
71809 + }
71810 + va_start(ap, argtypes);
71811 + switch (argtypes) {
71812 + case GR_TTYSNIFF:
71813 + task = va_arg(ap, struct task_struct *);
71814 + 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));
71815 + break;
71816 + case GR_SYSCTL_HIDDEN:
71817 + str1 = va_arg(ap, char *);
71818 + gr_log_middle_varargs(audit, msg, result, str1);
71819 + break;
71820 + case GR_RBAC:
71821 + dentry = va_arg(ap, struct dentry *);
71822 + mnt = va_arg(ap, struct vfsmount *);
71823 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
71824 + break;
71825 + case GR_RBAC_STR:
71826 + dentry = va_arg(ap, struct dentry *);
71827 + mnt = va_arg(ap, struct vfsmount *);
71828 + str1 = va_arg(ap, char *);
71829 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
71830 + break;
71831 + case GR_STR_RBAC:
71832 + str1 = va_arg(ap, char *);
71833 + dentry = va_arg(ap, struct dentry *);
71834 + mnt = va_arg(ap, struct vfsmount *);
71835 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
71836 + break;
71837 + case GR_RBAC_MODE2:
71838 + dentry = va_arg(ap, struct dentry *);
71839 + mnt = va_arg(ap, struct vfsmount *);
71840 + str1 = va_arg(ap, char *);
71841 + str2 = va_arg(ap, char *);
71842 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
71843 + break;
71844 + case GR_RBAC_MODE3:
71845 + dentry = va_arg(ap, struct dentry *);
71846 + mnt = va_arg(ap, struct vfsmount *);
71847 + str1 = va_arg(ap, char *);
71848 + str2 = va_arg(ap, char *);
71849 + str3 = va_arg(ap, char *);
71850 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
71851 + break;
71852 + case GR_FILENAME:
71853 + dentry = va_arg(ap, struct dentry *);
71854 + mnt = va_arg(ap, struct vfsmount *);
71855 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
71856 + break;
71857 + case GR_STR_FILENAME:
71858 + str1 = va_arg(ap, char *);
71859 + dentry = va_arg(ap, struct dentry *);
71860 + mnt = va_arg(ap, struct vfsmount *);
71861 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
71862 + break;
71863 + case GR_FILENAME_STR:
71864 + dentry = va_arg(ap, struct dentry *);
71865 + mnt = va_arg(ap, struct vfsmount *);
71866 + str1 = va_arg(ap, char *);
71867 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
71868 + break;
71869 + case GR_FILENAME_TWO_INT:
71870 + dentry = va_arg(ap, struct dentry *);
71871 + mnt = va_arg(ap, struct vfsmount *);
71872 + num1 = va_arg(ap, int);
71873 + num2 = va_arg(ap, int);
71874 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
71875 + break;
71876 + case GR_FILENAME_TWO_INT_STR:
71877 + dentry = va_arg(ap, struct dentry *);
71878 + mnt = va_arg(ap, struct vfsmount *);
71879 + num1 = va_arg(ap, int);
71880 + num2 = va_arg(ap, int);
71881 + str1 = va_arg(ap, char *);
71882 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
71883 + break;
71884 + case GR_TEXTREL:
71885 + file = va_arg(ap, struct file *);
71886 + ulong1 = va_arg(ap, unsigned long);
71887 + ulong2 = va_arg(ap, unsigned long);
71888 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
71889 + break;
71890 + case GR_PTRACE:
71891 + task = va_arg(ap, struct task_struct *);
71892 + 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));
71893 + break;
71894 + case GR_RESOURCE:
71895 + task = va_arg(ap, struct task_struct *);
71896 + cred = __task_cred(task);
71897 + pcred = __task_cred(task->real_parent);
71898 + ulong1 = va_arg(ap, unsigned long);
71899 + str1 = va_arg(ap, char *);
71900 + ulong2 = va_arg(ap, unsigned long);
71901 + 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));
71902 + break;
71903 + case GR_CAP:
71904 + task = va_arg(ap, struct task_struct *);
71905 + cred = __task_cred(task);
71906 + pcred = __task_cred(task->real_parent);
71907 + str1 = va_arg(ap, char *);
71908 + 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));
71909 + break;
71910 + case GR_SIG:
71911 + str1 = va_arg(ap, char *);
71912 + voidptr = va_arg(ap, void *);
71913 + gr_log_middle_varargs(audit, msg, str1, voidptr);
71914 + break;
71915 + case GR_SIG2:
71916 + task = va_arg(ap, struct task_struct *);
71917 + cred = __task_cred(task);
71918 + pcred = __task_cred(task->real_parent);
71919 + num1 = va_arg(ap, int);
71920 + 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));
71921 + break;
71922 + case GR_CRASH1:
71923 + task = va_arg(ap, struct task_struct *);
71924 + cred = __task_cred(task);
71925 + pcred = __task_cred(task->real_parent);
71926 + ulong1 = va_arg(ap, unsigned long);
71927 + 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);
71928 + break;
71929 + case GR_CRASH2:
71930 + task = va_arg(ap, struct task_struct *);
71931 + cred = __task_cred(task);
71932 + pcred = __task_cred(task->real_parent);
71933 + ulong1 = va_arg(ap, unsigned long);
71934 + 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);
71935 + break;
71936 + case GR_RWXMAP:
71937 + file = va_arg(ap, struct file *);
71938 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
71939 + break;
71940 + case GR_RWXMAPVMA:
71941 + vma = va_arg(ap, struct vm_area_struct *);
71942 + if (vma->vm_file)
71943 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
71944 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
71945 + str1 = "<stack>";
71946 + else if (vma->vm_start <= current->mm->brk &&
71947 + vma->vm_end >= current->mm->start_brk)
71948 + str1 = "<heap>";
71949 + else
71950 + str1 = "<anonymous mapping>";
71951 + gr_log_middle_varargs(audit, msg, str1);
71952 + break;
71953 + case GR_PSACCT:
71954 + {
71955 + unsigned int wday, cday;
71956 + __u8 whr, chr;
71957 + __u8 wmin, cmin;
71958 + __u8 wsec, csec;
71959 + char cur_tty[64] = { 0 };
71960 + char parent_tty[64] = { 0 };
71961 +
71962 + task = va_arg(ap, struct task_struct *);
71963 + wday = va_arg(ap, unsigned int);
71964 + cday = va_arg(ap, unsigned int);
71965 + whr = va_arg(ap, int);
71966 + chr = va_arg(ap, int);
71967 + wmin = va_arg(ap, int);
71968 + cmin = va_arg(ap, int);
71969 + wsec = va_arg(ap, int);
71970 + csec = va_arg(ap, int);
71971 + ulong1 = va_arg(ap, unsigned long);
71972 + cred = __task_cred(task);
71973 + pcred = __task_cred(task->real_parent);
71974 +
71975 + 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));
71976 + }
71977 + break;
71978 + default:
71979 + gr_log_middle(audit, msg, ap);
71980 + }
71981 + va_end(ap);
71982 + // these don't need DEFAULTSECARGS printed on the end
71983 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
71984 + gr_log_end(audit, 0);
71985 + else
71986 + gr_log_end(audit, 1);
71987 + END_LOCKS(audit);
71988 +}
71989 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
71990 new file mode 100644
71991 index 0000000..f536303
71992 --- /dev/null
71993 +++ b/grsecurity/grsec_mem.c
71994 @@ -0,0 +1,40 @@
71995 +#include <linux/kernel.h>
71996 +#include <linux/sched.h>
71997 +#include <linux/mm.h>
71998 +#include <linux/mman.h>
71999 +#include <linux/grinternal.h>
72000 +
72001 +void
72002 +gr_handle_ioperm(void)
72003 +{
72004 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
72005 + return;
72006 +}
72007 +
72008 +void
72009 +gr_handle_iopl(void)
72010 +{
72011 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
72012 + return;
72013 +}
72014 +
72015 +void
72016 +gr_handle_mem_readwrite(u64 from, u64 to)
72017 +{
72018 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
72019 + return;
72020 +}
72021 +
72022 +void
72023 +gr_handle_vm86(void)
72024 +{
72025 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
72026 + return;
72027 +}
72028 +
72029 +void
72030 +gr_log_badprocpid(const char *entry)
72031 +{
72032 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
72033 + return;
72034 +}
72035 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
72036 new file mode 100644
72037 index 0000000..cd9e124
72038 --- /dev/null
72039 +++ b/grsecurity/grsec_mount.c
72040 @@ -0,0 +1,65 @@
72041 +#include <linux/kernel.h>
72042 +#include <linux/sched.h>
72043 +#include <linux/mount.h>
72044 +#include <linux/major.h>
72045 +#include <linux/grsecurity.h>
72046 +#include <linux/grinternal.h>
72047 +
72048 +void
72049 +gr_log_remount(const char *devname, const int retval)
72050 +{
72051 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
72052 + if (grsec_enable_mount && (retval >= 0))
72053 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
72054 +#endif
72055 + return;
72056 +}
72057 +
72058 +void
72059 +gr_log_unmount(const char *devname, const int retval)
72060 +{
72061 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
72062 + if (grsec_enable_mount && (retval >= 0))
72063 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
72064 +#endif
72065 + return;
72066 +}
72067 +
72068 +void
72069 +gr_log_mount(const char *from, const char *to, const int retval)
72070 +{
72071 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
72072 + if (grsec_enable_mount && (retval >= 0))
72073 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
72074 +#endif
72075 + return;
72076 +}
72077 +
72078 +int
72079 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
72080 +{
72081 +#ifdef CONFIG_GRKERNSEC_ROFS
72082 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
72083 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
72084 + return -EPERM;
72085 + } else
72086 + return 0;
72087 +#endif
72088 + return 0;
72089 +}
72090 +
72091 +int
72092 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
72093 +{
72094 +#ifdef CONFIG_GRKERNSEC_ROFS
72095 + struct inode *inode = dentry->d_inode;
72096 +
72097 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
72098 + inode && (S_ISBLK(inode->i_mode) || (S_ISCHR(inode->i_mode) && imajor(inode) == RAW_MAJOR))) {
72099 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
72100 + return -EPERM;
72101 + } else
72102 + return 0;
72103 +#endif
72104 + return 0;
72105 +}
72106 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
72107 new file mode 100644
72108 index 0000000..6ee9d50
72109 --- /dev/null
72110 +++ b/grsecurity/grsec_pax.c
72111 @@ -0,0 +1,45 @@
72112 +#include <linux/kernel.h>
72113 +#include <linux/sched.h>
72114 +#include <linux/mm.h>
72115 +#include <linux/file.h>
72116 +#include <linux/grinternal.h>
72117 +#include <linux/grsecurity.h>
72118 +
72119 +void
72120 +gr_log_textrel(struct vm_area_struct * vma)
72121 +{
72122 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72123 + if (grsec_enable_log_rwxmaps)
72124 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
72125 +#endif
72126 + return;
72127 +}
72128 +
72129 +void gr_log_ptgnustack(struct file *file)
72130 +{
72131 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72132 + if (grsec_enable_log_rwxmaps)
72133 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
72134 +#endif
72135 + return;
72136 +}
72137 +
72138 +void
72139 +gr_log_rwxmmap(struct file *file)
72140 +{
72141 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72142 + if (grsec_enable_log_rwxmaps)
72143 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
72144 +#endif
72145 + return;
72146 +}
72147 +
72148 +void
72149 +gr_log_rwxmprotect(struct vm_area_struct *vma)
72150 +{
72151 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72152 + if (grsec_enable_log_rwxmaps)
72153 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
72154 +#endif
72155 + return;
72156 +}
72157 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
72158 new file mode 100644
72159 index 0000000..f7f29aa
72160 --- /dev/null
72161 +++ b/grsecurity/grsec_ptrace.c
72162 @@ -0,0 +1,30 @@
72163 +#include <linux/kernel.h>
72164 +#include <linux/sched.h>
72165 +#include <linux/grinternal.h>
72166 +#include <linux/security.h>
72167 +
72168 +void
72169 +gr_audit_ptrace(struct task_struct *task)
72170 +{
72171 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
72172 + if (grsec_enable_audit_ptrace)
72173 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
72174 +#endif
72175 + return;
72176 +}
72177 +
72178 +int
72179 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
72180 +{
72181 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
72182 + const struct dentry *dentry = file->f_path.dentry;
72183 + const struct vfsmount *mnt = file->f_path.mnt;
72184 +
72185 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
72186 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
72187 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
72188 + return -EACCES;
72189 + }
72190 +#endif
72191 + return 0;
72192 +}
72193 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
72194 new file mode 100644
72195 index 0000000..3860c7e
72196 --- /dev/null
72197 +++ b/grsecurity/grsec_sig.c
72198 @@ -0,0 +1,236 @@
72199 +#include <linux/kernel.h>
72200 +#include <linux/sched.h>
72201 +#include <linux/fs.h>
72202 +#include <linux/delay.h>
72203 +#include <linux/grsecurity.h>
72204 +#include <linux/grinternal.h>
72205 +#include <linux/hardirq.h>
72206 +
72207 +char *signames[] = {
72208 + [SIGSEGV] = "Segmentation fault",
72209 + [SIGILL] = "Illegal instruction",
72210 + [SIGABRT] = "Abort",
72211 + [SIGBUS] = "Invalid alignment/Bus error"
72212 +};
72213 +
72214 +void
72215 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
72216 +{
72217 +#ifdef CONFIG_GRKERNSEC_SIGNAL
72218 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
72219 + (sig == SIGABRT) || (sig == SIGBUS))) {
72220 + if (task_pid_nr(t) == task_pid_nr(current)) {
72221 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
72222 + } else {
72223 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
72224 + }
72225 + }
72226 +#endif
72227 + return;
72228 +}
72229 +
72230 +int
72231 +gr_handle_signal(const struct task_struct *p, const int sig)
72232 +{
72233 +#ifdef CONFIG_GRKERNSEC
72234 + /* ignore the 0 signal for protected task checks */
72235 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
72236 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
72237 + return -EPERM;
72238 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
72239 + return -EPERM;
72240 + }
72241 +#endif
72242 + return 0;
72243 +}
72244 +
72245 +#ifdef CONFIG_GRKERNSEC
72246 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
72247 +
72248 +int gr_fake_force_sig(int sig, struct task_struct *t)
72249 +{
72250 + unsigned long int flags;
72251 + int ret, blocked, ignored;
72252 + struct k_sigaction *action;
72253 +
72254 + spin_lock_irqsave(&t->sighand->siglock, flags);
72255 + action = &t->sighand->action[sig-1];
72256 + ignored = action->sa.sa_handler == SIG_IGN;
72257 + blocked = sigismember(&t->blocked, sig);
72258 + if (blocked || ignored) {
72259 + action->sa.sa_handler = SIG_DFL;
72260 + if (blocked) {
72261 + sigdelset(&t->blocked, sig);
72262 + recalc_sigpending_and_wake(t);
72263 + }
72264 + }
72265 + if (action->sa.sa_handler == SIG_DFL)
72266 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
72267 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
72268 +
72269 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
72270 +
72271 + return ret;
72272 +}
72273 +#endif
72274 +
72275 +#define GR_USER_BAN_TIME (15 * 60)
72276 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
72277 +
72278 +void gr_handle_brute_attach(int dumpable)
72279 +{
72280 +#ifdef CONFIG_GRKERNSEC_BRUTE
72281 + struct task_struct *p = current;
72282 + kuid_t uid = GLOBAL_ROOT_UID;
72283 + int daemon = 0;
72284 +
72285 + if (!grsec_enable_brute)
72286 + return;
72287 +
72288 + rcu_read_lock();
72289 + read_lock(&tasklist_lock);
72290 + read_lock(&grsec_exec_file_lock);
72291 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
72292 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
72293 + p->real_parent->brute = 1;
72294 + daemon = 1;
72295 + } else {
72296 + const struct cred *cred = __task_cred(p), *cred2;
72297 + struct task_struct *tsk, *tsk2;
72298 +
72299 + if (dumpable != SUID_DUMP_USER && gr_is_global_nonroot(cred->uid)) {
72300 + struct user_struct *user;
72301 +
72302 + uid = cred->uid;
72303 +
72304 + /* this is put upon execution past expiration */
72305 + user = find_user(uid);
72306 + if (user == NULL)
72307 + goto unlock;
72308 + user->suid_banned = 1;
72309 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
72310 + if (user->suid_ban_expires == ~0UL)
72311 + user->suid_ban_expires--;
72312 +
72313 + /* only kill other threads of the same binary, from the same user */
72314 + do_each_thread(tsk2, tsk) {
72315 + cred2 = __task_cred(tsk);
72316 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
72317 + gr_fake_force_sig(SIGKILL, tsk);
72318 + } while_each_thread(tsk2, tsk);
72319 + }
72320 + }
72321 +unlock:
72322 + read_unlock(&grsec_exec_file_lock);
72323 + read_unlock(&tasklist_lock);
72324 + rcu_read_unlock();
72325 +
72326 + if (gr_is_global_nonroot(uid))
72327 + 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);
72328 + else if (daemon)
72329 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
72330 +
72331 +#endif
72332 + return;
72333 +}
72334 +
72335 +void gr_handle_brute_check(void)
72336 +{
72337 +#ifdef CONFIG_GRKERNSEC_BRUTE
72338 + struct task_struct *p = current;
72339 +
72340 + if (unlikely(p->brute)) {
72341 + if (!grsec_enable_brute)
72342 + p->brute = 0;
72343 + else if (time_before(get_seconds(), p->brute_expires))
72344 + msleep(30 * 1000);
72345 + }
72346 +#endif
72347 + return;
72348 +}
72349 +
72350 +void gr_handle_kernel_exploit(void)
72351 +{
72352 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
72353 + const struct cred *cred;
72354 + struct task_struct *tsk, *tsk2;
72355 + struct user_struct *user;
72356 + kuid_t uid;
72357 +
72358 + if (in_irq() || in_serving_softirq() || in_nmi())
72359 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
72360 +
72361 + uid = current_uid();
72362 +
72363 + if (gr_is_global_root(uid))
72364 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
72365 + else {
72366 + /* kill all the processes of this user, hold a reference
72367 + to their creds struct, and prevent them from creating
72368 + another process until system reset
72369 + */
72370 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
72371 + GR_GLOBAL_UID(uid));
72372 + /* we intentionally leak this ref */
72373 + user = get_uid(current->cred->user);
72374 + if (user)
72375 + user->kernel_banned = 1;
72376 +
72377 + /* kill all processes of this user */
72378 + read_lock(&tasklist_lock);
72379 + do_each_thread(tsk2, tsk) {
72380 + cred = __task_cred(tsk);
72381 + if (uid_eq(cred->uid, uid))
72382 + gr_fake_force_sig(SIGKILL, tsk);
72383 + } while_each_thread(tsk2, tsk);
72384 + read_unlock(&tasklist_lock);
72385 + }
72386 +#endif
72387 +}
72388 +
72389 +#ifdef CONFIG_GRKERNSEC_BRUTE
72390 +static bool suid_ban_expired(struct user_struct *user)
72391 +{
72392 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
72393 + user->suid_banned = 0;
72394 + user->suid_ban_expires = 0;
72395 + free_uid(user);
72396 + return true;
72397 + }
72398 +
72399 + return false;
72400 +}
72401 +#endif
72402 +
72403 +int gr_process_kernel_exec_ban(void)
72404 +{
72405 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
72406 + if (unlikely(current->cred->user->kernel_banned))
72407 + return -EPERM;
72408 +#endif
72409 + return 0;
72410 +}
72411 +
72412 +int gr_process_kernel_setuid_ban(struct user_struct *user)
72413 +{
72414 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
72415 + if (unlikely(user->kernel_banned))
72416 + gr_fake_force_sig(SIGKILL, current);
72417 +#endif
72418 + return 0;
72419 +}
72420 +
72421 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
72422 +{
72423 +#ifdef CONFIG_GRKERNSEC_BRUTE
72424 + struct user_struct *user = current->cred->user;
72425 + if (unlikely(user->suid_banned)) {
72426 + if (suid_ban_expired(user))
72427 + return 0;
72428 + /* disallow execution of suid binaries only */
72429 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
72430 + return -EPERM;
72431 + }
72432 +#endif
72433 + return 0;
72434 +}
72435 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
72436 new file mode 100644
72437 index 0000000..4030d57
72438 --- /dev/null
72439 +++ b/grsecurity/grsec_sock.c
72440 @@ -0,0 +1,244 @@
72441 +#include <linux/kernel.h>
72442 +#include <linux/module.h>
72443 +#include <linux/sched.h>
72444 +#include <linux/file.h>
72445 +#include <linux/net.h>
72446 +#include <linux/in.h>
72447 +#include <linux/ip.h>
72448 +#include <net/sock.h>
72449 +#include <net/inet_sock.h>
72450 +#include <linux/grsecurity.h>
72451 +#include <linux/grinternal.h>
72452 +#include <linux/gracl.h>
72453 +
72454 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
72455 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
72456 +
72457 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
72458 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
72459 +
72460 +#ifdef CONFIG_UNIX_MODULE
72461 +EXPORT_SYMBOL(gr_acl_handle_unix);
72462 +EXPORT_SYMBOL(gr_acl_handle_mknod);
72463 +EXPORT_SYMBOL(gr_handle_chroot_unix);
72464 +EXPORT_SYMBOL(gr_handle_create);
72465 +#endif
72466 +
72467 +#ifdef CONFIG_GRKERNSEC
72468 +#define gr_conn_table_size 32749
72469 +struct conn_table_entry {
72470 + struct conn_table_entry *next;
72471 + struct signal_struct *sig;
72472 +};
72473 +
72474 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
72475 +DEFINE_SPINLOCK(gr_conn_table_lock);
72476 +
72477 +extern const char * gr_socktype_to_name(unsigned char type);
72478 +extern const char * gr_proto_to_name(unsigned char proto);
72479 +extern const char * gr_sockfamily_to_name(unsigned char family);
72480 +
72481 +static __inline__ int
72482 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
72483 +{
72484 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
72485 +}
72486 +
72487 +static __inline__ int
72488 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
72489 + __u16 sport, __u16 dport)
72490 +{
72491 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
72492 + sig->gr_sport == sport && sig->gr_dport == dport))
72493 + return 1;
72494 + else
72495 + return 0;
72496 +}
72497 +
72498 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
72499 +{
72500 + struct conn_table_entry **match;
72501 + unsigned int index;
72502 +
72503 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
72504 + sig->gr_sport, sig->gr_dport,
72505 + gr_conn_table_size);
72506 +
72507 + newent->sig = sig;
72508 +
72509 + match = &gr_conn_table[index];
72510 + newent->next = *match;
72511 + *match = newent;
72512 +
72513 + return;
72514 +}
72515 +
72516 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
72517 +{
72518 + struct conn_table_entry *match, *last = NULL;
72519 + unsigned int index;
72520 +
72521 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
72522 + sig->gr_sport, sig->gr_dport,
72523 + gr_conn_table_size);
72524 +
72525 + match = gr_conn_table[index];
72526 + while (match && !conn_match(match->sig,
72527 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
72528 + sig->gr_dport)) {
72529 + last = match;
72530 + match = match->next;
72531 + }
72532 +
72533 + if (match) {
72534 + if (last)
72535 + last->next = match->next;
72536 + else
72537 + gr_conn_table[index] = NULL;
72538 + kfree(match);
72539 + }
72540 +
72541 + return;
72542 +}
72543 +
72544 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
72545 + __u16 sport, __u16 dport)
72546 +{
72547 + struct conn_table_entry *match;
72548 + unsigned int index;
72549 +
72550 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
72551 +
72552 + match = gr_conn_table[index];
72553 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
72554 + match = match->next;
72555 +
72556 + if (match)
72557 + return match->sig;
72558 + else
72559 + return NULL;
72560 +}
72561 +
72562 +#endif
72563 +
72564 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
72565 +{
72566 +#ifdef CONFIG_GRKERNSEC
72567 + struct signal_struct *sig = task->signal;
72568 + struct conn_table_entry *newent;
72569 +
72570 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
72571 + if (newent == NULL)
72572 + return;
72573 + /* no bh lock needed since we are called with bh disabled */
72574 + spin_lock(&gr_conn_table_lock);
72575 + gr_del_task_from_ip_table_nolock(sig);
72576 + sig->gr_saddr = inet->inet_rcv_saddr;
72577 + sig->gr_daddr = inet->inet_daddr;
72578 + sig->gr_sport = inet->inet_sport;
72579 + sig->gr_dport = inet->inet_dport;
72580 + gr_add_to_task_ip_table_nolock(sig, newent);
72581 + spin_unlock(&gr_conn_table_lock);
72582 +#endif
72583 + return;
72584 +}
72585 +
72586 +void gr_del_task_from_ip_table(struct task_struct *task)
72587 +{
72588 +#ifdef CONFIG_GRKERNSEC
72589 + spin_lock_bh(&gr_conn_table_lock);
72590 + gr_del_task_from_ip_table_nolock(task->signal);
72591 + spin_unlock_bh(&gr_conn_table_lock);
72592 +#endif
72593 + return;
72594 +}
72595 +
72596 +void
72597 +gr_attach_curr_ip(const struct sock *sk)
72598 +{
72599 +#ifdef CONFIG_GRKERNSEC
72600 + struct signal_struct *p, *set;
72601 + const struct inet_sock *inet = inet_sk(sk);
72602 +
72603 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
72604 + return;
72605 +
72606 + set = current->signal;
72607 +
72608 + spin_lock_bh(&gr_conn_table_lock);
72609 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
72610 + inet->inet_dport, inet->inet_sport);
72611 + if (unlikely(p != NULL)) {
72612 + set->curr_ip = p->curr_ip;
72613 + set->used_accept = 1;
72614 + gr_del_task_from_ip_table_nolock(p);
72615 + spin_unlock_bh(&gr_conn_table_lock);
72616 + return;
72617 + }
72618 + spin_unlock_bh(&gr_conn_table_lock);
72619 +
72620 + set->curr_ip = inet->inet_daddr;
72621 + set->used_accept = 1;
72622 +#endif
72623 + return;
72624 +}
72625 +
72626 +int
72627 +gr_handle_sock_all(const int family, const int type, const int protocol)
72628 +{
72629 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
72630 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
72631 + (family != AF_UNIX)) {
72632 + if (family == AF_INET)
72633 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
72634 + else
72635 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
72636 + return -EACCES;
72637 + }
72638 +#endif
72639 + return 0;
72640 +}
72641 +
72642 +int
72643 +gr_handle_sock_server(const struct sockaddr *sck)
72644 +{
72645 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72646 + if (grsec_enable_socket_server &&
72647 + in_group_p(grsec_socket_server_gid) &&
72648 + sck && (sck->sa_family != AF_UNIX) &&
72649 + (sck->sa_family != AF_LOCAL)) {
72650 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
72651 + return -EACCES;
72652 + }
72653 +#endif
72654 + return 0;
72655 +}
72656 +
72657 +int
72658 +gr_handle_sock_server_other(const struct sock *sck)
72659 +{
72660 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72661 + if (grsec_enable_socket_server &&
72662 + in_group_p(grsec_socket_server_gid) &&
72663 + sck && (sck->sk_family != AF_UNIX) &&
72664 + (sck->sk_family != AF_LOCAL)) {
72665 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
72666 + return -EACCES;
72667 + }
72668 +#endif
72669 + return 0;
72670 +}
72671 +
72672 +int
72673 +gr_handle_sock_client(const struct sockaddr *sck)
72674 +{
72675 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
72676 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
72677 + sck && (sck->sa_family != AF_UNIX) &&
72678 + (sck->sa_family != AF_LOCAL)) {
72679 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
72680 + return -EACCES;
72681 + }
72682 +#endif
72683 + return 0;
72684 +}
72685 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
72686 new file mode 100644
72687 index 0000000..8159888
72688 --- /dev/null
72689 +++ b/grsecurity/grsec_sysctl.c
72690 @@ -0,0 +1,479 @@
72691 +#include <linux/kernel.h>
72692 +#include <linux/sched.h>
72693 +#include <linux/sysctl.h>
72694 +#include <linux/grsecurity.h>
72695 +#include <linux/grinternal.h>
72696 +
72697 +int
72698 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
72699 +{
72700 +#ifdef CONFIG_GRKERNSEC_SYSCTL
72701 + if (dirname == NULL || name == NULL)
72702 + return 0;
72703 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
72704 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
72705 + return -EACCES;
72706 + }
72707 +#endif
72708 + return 0;
72709 +}
72710 +
72711 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
72712 +static int __maybe_unused __read_only one = 1;
72713 +#endif
72714 +
72715 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
72716 + defined(CONFIG_GRKERNSEC_DENYUSB)
72717 +struct ctl_table grsecurity_table[] = {
72718 +#ifdef CONFIG_GRKERNSEC_SYSCTL
72719 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
72720 +#ifdef CONFIG_GRKERNSEC_IO
72721 + {
72722 + .procname = "disable_priv_io",
72723 + .data = &grsec_disable_privio,
72724 + .maxlen = sizeof(int),
72725 + .mode = 0600,
72726 + .proc_handler = &proc_dointvec,
72727 + },
72728 +#endif
72729 +#endif
72730 +#ifdef CONFIG_GRKERNSEC_LINK
72731 + {
72732 + .procname = "linking_restrictions",
72733 + .data = &grsec_enable_link,
72734 + .maxlen = sizeof(int),
72735 + .mode = 0600,
72736 + .proc_handler = &proc_dointvec,
72737 + },
72738 +#endif
72739 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
72740 + {
72741 + .procname = "enforce_symlinksifowner",
72742 + .data = &grsec_enable_symlinkown,
72743 + .maxlen = sizeof(int),
72744 + .mode = 0600,
72745 + .proc_handler = &proc_dointvec,
72746 + },
72747 + {
72748 + .procname = "symlinkown_gid",
72749 + .data = &grsec_symlinkown_gid,
72750 + .maxlen = sizeof(int),
72751 + .mode = 0600,
72752 + .proc_handler = &proc_dointvec,
72753 + },
72754 +#endif
72755 +#ifdef CONFIG_GRKERNSEC_BRUTE
72756 + {
72757 + .procname = "deter_bruteforce",
72758 + .data = &grsec_enable_brute,
72759 + .maxlen = sizeof(int),
72760 + .mode = 0600,
72761 + .proc_handler = &proc_dointvec,
72762 + },
72763 +#endif
72764 +#ifdef CONFIG_GRKERNSEC_FIFO
72765 + {
72766 + .procname = "fifo_restrictions",
72767 + .data = &grsec_enable_fifo,
72768 + .maxlen = sizeof(int),
72769 + .mode = 0600,
72770 + .proc_handler = &proc_dointvec,
72771 + },
72772 +#endif
72773 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
72774 + {
72775 + .procname = "ptrace_readexec",
72776 + .data = &grsec_enable_ptrace_readexec,
72777 + .maxlen = sizeof(int),
72778 + .mode = 0600,
72779 + .proc_handler = &proc_dointvec,
72780 + },
72781 +#endif
72782 +#ifdef CONFIG_GRKERNSEC_SETXID
72783 + {
72784 + .procname = "consistent_setxid",
72785 + .data = &grsec_enable_setxid,
72786 + .maxlen = sizeof(int),
72787 + .mode = 0600,
72788 + .proc_handler = &proc_dointvec,
72789 + },
72790 +#endif
72791 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
72792 + {
72793 + .procname = "ip_blackhole",
72794 + .data = &grsec_enable_blackhole,
72795 + .maxlen = sizeof(int),
72796 + .mode = 0600,
72797 + .proc_handler = &proc_dointvec,
72798 + },
72799 + {
72800 + .procname = "lastack_retries",
72801 + .data = &grsec_lastack_retries,
72802 + .maxlen = sizeof(int),
72803 + .mode = 0600,
72804 + .proc_handler = &proc_dointvec,
72805 + },
72806 +#endif
72807 +#ifdef CONFIG_GRKERNSEC_EXECLOG
72808 + {
72809 + .procname = "exec_logging",
72810 + .data = &grsec_enable_execlog,
72811 + .maxlen = sizeof(int),
72812 + .mode = 0600,
72813 + .proc_handler = &proc_dointvec,
72814 + },
72815 +#endif
72816 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72817 + {
72818 + .procname = "rwxmap_logging",
72819 + .data = &grsec_enable_log_rwxmaps,
72820 + .maxlen = sizeof(int),
72821 + .mode = 0600,
72822 + .proc_handler = &proc_dointvec,
72823 + },
72824 +#endif
72825 +#ifdef CONFIG_GRKERNSEC_SIGNAL
72826 + {
72827 + .procname = "signal_logging",
72828 + .data = &grsec_enable_signal,
72829 + .maxlen = sizeof(int),
72830 + .mode = 0600,
72831 + .proc_handler = &proc_dointvec,
72832 + },
72833 +#endif
72834 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
72835 + {
72836 + .procname = "forkfail_logging",
72837 + .data = &grsec_enable_forkfail,
72838 + .maxlen = sizeof(int),
72839 + .mode = 0600,
72840 + .proc_handler = &proc_dointvec,
72841 + },
72842 +#endif
72843 +#ifdef CONFIG_GRKERNSEC_TIME
72844 + {
72845 + .procname = "timechange_logging",
72846 + .data = &grsec_enable_time,
72847 + .maxlen = sizeof(int),
72848 + .mode = 0600,
72849 + .proc_handler = &proc_dointvec,
72850 + },
72851 +#endif
72852 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
72853 + {
72854 + .procname = "chroot_deny_shmat",
72855 + .data = &grsec_enable_chroot_shmat,
72856 + .maxlen = sizeof(int),
72857 + .mode = 0600,
72858 + .proc_handler = &proc_dointvec,
72859 + },
72860 +#endif
72861 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
72862 + {
72863 + .procname = "chroot_deny_unix",
72864 + .data = &grsec_enable_chroot_unix,
72865 + .maxlen = sizeof(int),
72866 + .mode = 0600,
72867 + .proc_handler = &proc_dointvec,
72868 + },
72869 +#endif
72870 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
72871 + {
72872 + .procname = "chroot_deny_mount",
72873 + .data = &grsec_enable_chroot_mount,
72874 + .maxlen = sizeof(int),
72875 + .mode = 0600,
72876 + .proc_handler = &proc_dointvec,
72877 + },
72878 +#endif
72879 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
72880 + {
72881 + .procname = "chroot_deny_fchdir",
72882 + .data = &grsec_enable_chroot_fchdir,
72883 + .maxlen = sizeof(int),
72884 + .mode = 0600,
72885 + .proc_handler = &proc_dointvec,
72886 + },
72887 +#endif
72888 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
72889 + {
72890 + .procname = "chroot_deny_chroot",
72891 + .data = &grsec_enable_chroot_double,
72892 + .maxlen = sizeof(int),
72893 + .mode = 0600,
72894 + .proc_handler = &proc_dointvec,
72895 + },
72896 +#endif
72897 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
72898 + {
72899 + .procname = "chroot_deny_pivot",
72900 + .data = &grsec_enable_chroot_pivot,
72901 + .maxlen = sizeof(int),
72902 + .mode = 0600,
72903 + .proc_handler = &proc_dointvec,
72904 + },
72905 +#endif
72906 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
72907 + {
72908 + .procname = "chroot_enforce_chdir",
72909 + .data = &grsec_enable_chroot_chdir,
72910 + .maxlen = sizeof(int),
72911 + .mode = 0600,
72912 + .proc_handler = &proc_dointvec,
72913 + },
72914 +#endif
72915 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
72916 + {
72917 + .procname = "chroot_deny_chmod",
72918 + .data = &grsec_enable_chroot_chmod,
72919 + .maxlen = sizeof(int),
72920 + .mode = 0600,
72921 + .proc_handler = &proc_dointvec,
72922 + },
72923 +#endif
72924 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
72925 + {
72926 + .procname = "chroot_deny_mknod",
72927 + .data = &grsec_enable_chroot_mknod,
72928 + .maxlen = sizeof(int),
72929 + .mode = 0600,
72930 + .proc_handler = &proc_dointvec,
72931 + },
72932 +#endif
72933 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
72934 + {
72935 + .procname = "chroot_restrict_nice",
72936 + .data = &grsec_enable_chroot_nice,
72937 + .maxlen = sizeof(int),
72938 + .mode = 0600,
72939 + .proc_handler = &proc_dointvec,
72940 + },
72941 +#endif
72942 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
72943 + {
72944 + .procname = "chroot_execlog",
72945 + .data = &grsec_enable_chroot_execlog,
72946 + .maxlen = sizeof(int),
72947 + .mode = 0600,
72948 + .proc_handler = &proc_dointvec,
72949 + },
72950 +#endif
72951 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
72952 + {
72953 + .procname = "chroot_caps",
72954 + .data = &grsec_enable_chroot_caps,
72955 + .maxlen = sizeof(int),
72956 + .mode = 0600,
72957 + .proc_handler = &proc_dointvec,
72958 + },
72959 +#endif
72960 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
72961 + {
72962 + .procname = "chroot_deny_sysctl",
72963 + .data = &grsec_enable_chroot_sysctl,
72964 + .maxlen = sizeof(int),
72965 + .mode = 0600,
72966 + .proc_handler = &proc_dointvec,
72967 + },
72968 +#endif
72969 +#ifdef CONFIG_GRKERNSEC_TPE
72970 + {
72971 + .procname = "tpe",
72972 + .data = &grsec_enable_tpe,
72973 + .maxlen = sizeof(int),
72974 + .mode = 0600,
72975 + .proc_handler = &proc_dointvec,
72976 + },
72977 + {
72978 + .procname = "tpe_gid",
72979 + .data = &grsec_tpe_gid,
72980 + .maxlen = sizeof(int),
72981 + .mode = 0600,
72982 + .proc_handler = &proc_dointvec,
72983 + },
72984 +#endif
72985 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
72986 + {
72987 + .procname = "tpe_invert",
72988 + .data = &grsec_enable_tpe_invert,
72989 + .maxlen = sizeof(int),
72990 + .mode = 0600,
72991 + .proc_handler = &proc_dointvec,
72992 + },
72993 +#endif
72994 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
72995 + {
72996 + .procname = "tpe_restrict_all",
72997 + .data = &grsec_enable_tpe_all,
72998 + .maxlen = sizeof(int),
72999 + .mode = 0600,
73000 + .proc_handler = &proc_dointvec,
73001 + },
73002 +#endif
73003 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
73004 + {
73005 + .procname = "socket_all",
73006 + .data = &grsec_enable_socket_all,
73007 + .maxlen = sizeof(int),
73008 + .mode = 0600,
73009 + .proc_handler = &proc_dointvec,
73010 + },
73011 + {
73012 + .procname = "socket_all_gid",
73013 + .data = &grsec_socket_all_gid,
73014 + .maxlen = sizeof(int),
73015 + .mode = 0600,
73016 + .proc_handler = &proc_dointvec,
73017 + },
73018 +#endif
73019 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
73020 + {
73021 + .procname = "socket_client",
73022 + .data = &grsec_enable_socket_client,
73023 + .maxlen = sizeof(int),
73024 + .mode = 0600,
73025 + .proc_handler = &proc_dointvec,
73026 + },
73027 + {
73028 + .procname = "socket_client_gid",
73029 + .data = &grsec_socket_client_gid,
73030 + .maxlen = sizeof(int),
73031 + .mode = 0600,
73032 + .proc_handler = &proc_dointvec,
73033 + },
73034 +#endif
73035 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
73036 + {
73037 + .procname = "socket_server",
73038 + .data = &grsec_enable_socket_server,
73039 + .maxlen = sizeof(int),
73040 + .mode = 0600,
73041 + .proc_handler = &proc_dointvec,
73042 + },
73043 + {
73044 + .procname = "socket_server_gid",
73045 + .data = &grsec_socket_server_gid,
73046 + .maxlen = sizeof(int),
73047 + .mode = 0600,
73048 + .proc_handler = &proc_dointvec,
73049 + },
73050 +#endif
73051 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
73052 + {
73053 + .procname = "audit_group",
73054 + .data = &grsec_enable_group,
73055 + .maxlen = sizeof(int),
73056 + .mode = 0600,
73057 + .proc_handler = &proc_dointvec,
73058 + },
73059 + {
73060 + .procname = "audit_gid",
73061 + .data = &grsec_audit_gid,
73062 + .maxlen = sizeof(int),
73063 + .mode = 0600,
73064 + .proc_handler = &proc_dointvec,
73065 + },
73066 +#endif
73067 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
73068 + {
73069 + .procname = "audit_chdir",
73070 + .data = &grsec_enable_chdir,
73071 + .maxlen = sizeof(int),
73072 + .mode = 0600,
73073 + .proc_handler = &proc_dointvec,
73074 + },
73075 +#endif
73076 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
73077 + {
73078 + .procname = "audit_mount",
73079 + .data = &grsec_enable_mount,
73080 + .maxlen = sizeof(int),
73081 + .mode = 0600,
73082 + .proc_handler = &proc_dointvec,
73083 + },
73084 +#endif
73085 +#ifdef CONFIG_GRKERNSEC_DMESG
73086 + {
73087 + .procname = "dmesg",
73088 + .data = &grsec_enable_dmesg,
73089 + .maxlen = sizeof(int),
73090 + .mode = 0600,
73091 + .proc_handler = &proc_dointvec,
73092 + },
73093 +#endif
73094 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
73095 + {
73096 + .procname = "chroot_findtask",
73097 + .data = &grsec_enable_chroot_findtask,
73098 + .maxlen = sizeof(int),
73099 + .mode = 0600,
73100 + .proc_handler = &proc_dointvec,
73101 + },
73102 +#endif
73103 +#ifdef CONFIG_GRKERNSEC_RESLOG
73104 + {
73105 + .procname = "resource_logging",
73106 + .data = &grsec_resource_logging,
73107 + .maxlen = sizeof(int),
73108 + .mode = 0600,
73109 + .proc_handler = &proc_dointvec,
73110 + },
73111 +#endif
73112 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
73113 + {
73114 + .procname = "audit_ptrace",
73115 + .data = &grsec_enable_audit_ptrace,
73116 + .maxlen = sizeof(int),
73117 + .mode = 0600,
73118 + .proc_handler = &proc_dointvec,
73119 + },
73120 +#endif
73121 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
73122 + {
73123 + .procname = "harden_ptrace",
73124 + .data = &grsec_enable_harden_ptrace,
73125 + .maxlen = sizeof(int),
73126 + .mode = 0600,
73127 + .proc_handler = &proc_dointvec,
73128 + },
73129 +#endif
73130 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
73131 + {
73132 + .procname = "harden_ipc",
73133 + .data = &grsec_enable_harden_ipc,
73134 + .maxlen = sizeof(int),
73135 + .mode = 0600,
73136 + .proc_handler = &proc_dointvec,
73137 + },
73138 +#endif
73139 + {
73140 + .procname = "grsec_lock",
73141 + .data = &grsec_lock,
73142 + .maxlen = sizeof(int),
73143 + .mode = 0600,
73144 + .proc_handler = &proc_dointvec,
73145 + },
73146 +#endif
73147 +#ifdef CONFIG_GRKERNSEC_ROFS
73148 + {
73149 + .procname = "romount_protect",
73150 + .data = &grsec_enable_rofs,
73151 + .maxlen = sizeof(int),
73152 + .mode = 0600,
73153 + .proc_handler = &proc_dointvec_minmax,
73154 + .extra1 = &one,
73155 + .extra2 = &one,
73156 + },
73157 +#endif
73158 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
73159 + {
73160 + .procname = "deny_new_usb",
73161 + .data = &grsec_deny_new_usb,
73162 + .maxlen = sizeof(int),
73163 + .mode = 0600,
73164 + .proc_handler = &proc_dointvec,
73165 + },
73166 +#endif
73167 + { }
73168 +};
73169 +#endif
73170 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
73171 new file mode 100644
73172 index 0000000..0dc13c3
73173 --- /dev/null
73174 +++ b/grsecurity/grsec_time.c
73175 @@ -0,0 +1,16 @@
73176 +#include <linux/kernel.h>
73177 +#include <linux/sched.h>
73178 +#include <linux/grinternal.h>
73179 +#include <linux/module.h>
73180 +
73181 +void
73182 +gr_log_timechange(void)
73183 +{
73184 +#ifdef CONFIG_GRKERNSEC_TIME
73185 + if (grsec_enable_time)
73186 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
73187 +#endif
73188 + return;
73189 +}
73190 +
73191 +EXPORT_SYMBOL(gr_log_timechange);
73192 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
73193 new file mode 100644
73194 index 0000000..ee57dcf
73195 --- /dev/null
73196 +++ b/grsecurity/grsec_tpe.c
73197 @@ -0,0 +1,73 @@
73198 +#include <linux/kernel.h>
73199 +#include <linux/sched.h>
73200 +#include <linux/file.h>
73201 +#include <linux/fs.h>
73202 +#include <linux/grinternal.h>
73203 +
73204 +extern int gr_acl_tpe_check(void);
73205 +
73206 +int
73207 +gr_tpe_allow(const struct file *file)
73208 +{
73209 +#ifdef CONFIG_GRKERNSEC
73210 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
73211 + const struct cred *cred = current_cred();
73212 + char *msg = NULL;
73213 + char *msg2 = NULL;
73214 +
73215 + // never restrict root
73216 + if (gr_is_global_root(cred->uid))
73217 + return 1;
73218 +
73219 + if (grsec_enable_tpe) {
73220 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
73221 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
73222 + msg = "not being in trusted group";
73223 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
73224 + msg = "being in untrusted group";
73225 +#else
73226 + if (in_group_p(grsec_tpe_gid))
73227 + msg = "being in untrusted group";
73228 +#endif
73229 + }
73230 + if (!msg && gr_acl_tpe_check())
73231 + msg = "being in untrusted role";
73232 +
73233 + // not in any affected group/role
73234 + if (!msg)
73235 + goto next_check;
73236 +
73237 + if (gr_is_global_nonroot(inode->i_uid))
73238 + msg2 = "file in non-root-owned directory";
73239 + else if (inode->i_mode & S_IWOTH)
73240 + msg2 = "file in world-writable directory";
73241 + else if (inode->i_mode & S_IWGRP)
73242 + msg2 = "file in group-writable directory";
73243 +
73244 + if (msg && msg2) {
73245 + char fullmsg[70] = {0};
73246 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
73247 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
73248 + return 0;
73249 + }
73250 + msg = NULL;
73251 +next_check:
73252 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
73253 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
73254 + return 1;
73255 +
73256 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
73257 + msg = "directory not owned by user";
73258 + else if (inode->i_mode & S_IWOTH)
73259 + msg = "file in world-writable directory";
73260 + else if (inode->i_mode & S_IWGRP)
73261 + msg = "file in group-writable directory";
73262 +
73263 + if (msg) {
73264 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
73265 + return 0;
73266 + }
73267 +#endif
73268 +#endif
73269 + return 1;
73270 +}
73271 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
73272 new file mode 100644
73273 index 0000000..ae02d8e
73274 --- /dev/null
73275 +++ b/grsecurity/grsec_usb.c
73276 @@ -0,0 +1,15 @@
73277 +#include <linux/kernel.h>
73278 +#include <linux/grinternal.h>
73279 +#include <linux/module.h>
73280 +
73281 +int gr_handle_new_usb(void)
73282 +{
73283 +#ifdef CONFIG_GRKERNSEC_DENYUSB
73284 + if (grsec_deny_new_usb) {
73285 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
73286 + return 1;
73287 + }
73288 +#endif
73289 + return 0;
73290 +}
73291 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
73292 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
73293 new file mode 100644
73294 index 0000000..9f7b1ac
73295 --- /dev/null
73296 +++ b/grsecurity/grsum.c
73297 @@ -0,0 +1,61 @@
73298 +#include <linux/err.h>
73299 +#include <linux/kernel.h>
73300 +#include <linux/sched.h>
73301 +#include <linux/mm.h>
73302 +#include <linux/scatterlist.h>
73303 +#include <linux/crypto.h>
73304 +#include <linux/gracl.h>
73305 +
73306 +
73307 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
73308 +#error "crypto and sha256 must be built into the kernel"
73309 +#endif
73310 +
73311 +int
73312 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
73313 +{
73314 + char *p;
73315 + struct crypto_hash *tfm;
73316 + struct hash_desc desc;
73317 + struct scatterlist sg;
73318 + unsigned char temp_sum[GR_SHA_LEN];
73319 + volatile int retval = 0;
73320 + volatile int dummy = 0;
73321 + unsigned int i;
73322 +
73323 + sg_init_table(&sg, 1);
73324 +
73325 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
73326 + if (IS_ERR(tfm)) {
73327 + /* should never happen, since sha256 should be built in */
73328 + return 1;
73329 + }
73330 +
73331 + desc.tfm = tfm;
73332 + desc.flags = 0;
73333 +
73334 + crypto_hash_init(&desc);
73335 +
73336 + p = salt;
73337 + sg_set_buf(&sg, p, GR_SALT_LEN);
73338 + crypto_hash_update(&desc, &sg, sg.length);
73339 +
73340 + p = entry->pw;
73341 + sg_set_buf(&sg, p, strlen(p));
73342 +
73343 + crypto_hash_update(&desc, &sg, sg.length);
73344 +
73345 + crypto_hash_final(&desc, temp_sum);
73346 +
73347 + memset(entry->pw, 0, GR_PW_LEN);
73348 +
73349 + for (i = 0; i < GR_SHA_LEN; i++)
73350 + if (sum[i] != temp_sum[i])
73351 + retval = 1;
73352 + else
73353 + dummy = 1; // waste a cycle
73354 +
73355 + crypto_free_hash(tfm);
73356 +
73357 + return retval;
73358 +}
73359 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
73360 index 77ff547..181834f 100644
73361 --- a/include/asm-generic/4level-fixup.h
73362 +++ b/include/asm-generic/4level-fixup.h
73363 @@ -13,8 +13,10 @@
73364 #define pmd_alloc(mm, pud, address) \
73365 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
73366 NULL: pmd_offset(pud, address))
73367 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
73368
73369 #define pud_alloc(mm, pgd, address) (pgd)
73370 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
73371 #define pud_offset(pgd, start) (pgd)
73372 #define pud_none(pud) 0
73373 #define pud_bad(pud) 0
73374 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
73375 index b7babf0..97f4c4f 100644
73376 --- a/include/asm-generic/atomic-long.h
73377 +++ b/include/asm-generic/atomic-long.h
73378 @@ -22,6 +22,12 @@
73379
73380 typedef atomic64_t atomic_long_t;
73381
73382 +#ifdef CONFIG_PAX_REFCOUNT
73383 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
73384 +#else
73385 +typedef atomic64_t atomic_long_unchecked_t;
73386 +#endif
73387 +
73388 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
73389
73390 static inline long atomic_long_read(atomic_long_t *l)
73391 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
73392 return (long)atomic64_read(v);
73393 }
73394
73395 +#ifdef CONFIG_PAX_REFCOUNT
73396 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
73397 +{
73398 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73399 +
73400 + return (long)atomic64_read_unchecked(v);
73401 +}
73402 +#endif
73403 +
73404 static inline void atomic_long_set(atomic_long_t *l, long i)
73405 {
73406 atomic64_t *v = (atomic64_t *)l;
73407 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
73408 atomic64_set(v, i);
73409 }
73410
73411 +#ifdef CONFIG_PAX_REFCOUNT
73412 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
73413 +{
73414 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73415 +
73416 + atomic64_set_unchecked(v, i);
73417 +}
73418 +#endif
73419 +
73420 static inline void atomic_long_inc(atomic_long_t *l)
73421 {
73422 atomic64_t *v = (atomic64_t *)l;
73423 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
73424 atomic64_inc(v);
73425 }
73426
73427 +#ifdef CONFIG_PAX_REFCOUNT
73428 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
73429 +{
73430 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73431 +
73432 + atomic64_inc_unchecked(v);
73433 +}
73434 +#endif
73435 +
73436 static inline void atomic_long_dec(atomic_long_t *l)
73437 {
73438 atomic64_t *v = (atomic64_t *)l;
73439 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
73440 atomic64_dec(v);
73441 }
73442
73443 +#ifdef CONFIG_PAX_REFCOUNT
73444 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
73445 +{
73446 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73447 +
73448 + atomic64_dec_unchecked(v);
73449 +}
73450 +#endif
73451 +
73452 static inline void atomic_long_add(long i, atomic_long_t *l)
73453 {
73454 atomic64_t *v = (atomic64_t *)l;
73455 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
73456 atomic64_add(i, v);
73457 }
73458
73459 +#ifdef CONFIG_PAX_REFCOUNT
73460 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
73461 +{
73462 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73463 +
73464 + atomic64_add_unchecked(i, v);
73465 +}
73466 +#endif
73467 +
73468 static inline void atomic_long_sub(long i, atomic_long_t *l)
73469 {
73470 atomic64_t *v = (atomic64_t *)l;
73471 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
73472 atomic64_sub(i, v);
73473 }
73474
73475 +#ifdef CONFIG_PAX_REFCOUNT
73476 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
73477 +{
73478 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73479 +
73480 + atomic64_sub_unchecked(i, v);
73481 +}
73482 +#endif
73483 +
73484 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
73485 {
73486 atomic64_t *v = (atomic64_t *)l;
73487 @@ -94,13 +154,22 @@ static inline int atomic_long_add_negative(long i, atomic_long_t *l)
73488 return atomic64_add_negative(i, v);
73489 }
73490
73491 -static inline long atomic_long_add_return(long i, atomic_long_t *l)
73492 +static inline long __intentional_overflow(-1) atomic_long_add_return(long i, atomic_long_t *l)
73493 {
73494 atomic64_t *v = (atomic64_t *)l;
73495
73496 return (long)atomic64_add_return(i, v);
73497 }
73498
73499 +#ifdef CONFIG_PAX_REFCOUNT
73500 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
73501 +{
73502 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73503 +
73504 + return (long)atomic64_add_return_unchecked(i, v);
73505 +}
73506 +#endif
73507 +
73508 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
73509 {
73510 atomic64_t *v = (atomic64_t *)l;
73511 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
73512 return (long)atomic64_inc_return(v);
73513 }
73514
73515 +#ifdef CONFIG_PAX_REFCOUNT
73516 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
73517 +{
73518 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73519 +
73520 + return (long)atomic64_inc_return_unchecked(v);
73521 +}
73522 +#endif
73523 +
73524 static inline long atomic_long_dec_return(atomic_long_t *l)
73525 {
73526 atomic64_t *v = (atomic64_t *)l;
73527 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
73528
73529 typedef atomic_t atomic_long_t;
73530
73531 +#ifdef CONFIG_PAX_REFCOUNT
73532 +typedef atomic_unchecked_t atomic_long_unchecked_t;
73533 +#else
73534 +typedef atomic_t atomic_long_unchecked_t;
73535 +#endif
73536 +
73537 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
73538 static inline long atomic_long_read(atomic_long_t *l)
73539 {
73540 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
73541 return (long)atomic_read(v);
73542 }
73543
73544 +#ifdef CONFIG_PAX_REFCOUNT
73545 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
73546 +{
73547 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73548 +
73549 + return (long)atomic_read_unchecked(v);
73550 +}
73551 +#endif
73552 +
73553 static inline void atomic_long_set(atomic_long_t *l, long i)
73554 {
73555 atomic_t *v = (atomic_t *)l;
73556 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
73557 atomic_set(v, i);
73558 }
73559
73560 +#ifdef CONFIG_PAX_REFCOUNT
73561 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
73562 +{
73563 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73564 +
73565 + atomic_set_unchecked(v, i);
73566 +}
73567 +#endif
73568 +
73569 static inline void atomic_long_inc(atomic_long_t *l)
73570 {
73571 atomic_t *v = (atomic_t *)l;
73572 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
73573 atomic_inc(v);
73574 }
73575
73576 +#ifdef CONFIG_PAX_REFCOUNT
73577 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
73578 +{
73579 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73580 +
73581 + atomic_inc_unchecked(v);
73582 +}
73583 +#endif
73584 +
73585 static inline void atomic_long_dec(atomic_long_t *l)
73586 {
73587 atomic_t *v = (atomic_t *)l;
73588 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
73589 atomic_dec(v);
73590 }
73591
73592 +#ifdef CONFIG_PAX_REFCOUNT
73593 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
73594 +{
73595 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73596 +
73597 + atomic_dec_unchecked(v);
73598 +}
73599 +#endif
73600 +
73601 static inline void atomic_long_add(long i, atomic_long_t *l)
73602 {
73603 atomic_t *v = (atomic_t *)l;
73604 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
73605 atomic_add(i, v);
73606 }
73607
73608 +#ifdef CONFIG_PAX_REFCOUNT
73609 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
73610 +{
73611 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73612 +
73613 + atomic_add_unchecked(i, v);
73614 +}
73615 +#endif
73616 +
73617 static inline void atomic_long_sub(long i, atomic_long_t *l)
73618 {
73619 atomic_t *v = (atomic_t *)l;
73620 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
73621 atomic_sub(i, v);
73622 }
73623
73624 +#ifdef CONFIG_PAX_REFCOUNT
73625 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
73626 +{
73627 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73628 +
73629 + atomic_sub_unchecked(i, v);
73630 +}
73631 +#endif
73632 +
73633 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
73634 {
73635 atomic_t *v = (atomic_t *)l;
73636 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
73637 return (long)atomic_add_return(i, v);
73638 }
73639
73640 +#ifdef CONFIG_PAX_REFCOUNT
73641 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
73642 +{
73643 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73644 +
73645 + return (long)atomic_add_return_unchecked(i, v);
73646 +}
73647 +
73648 +#endif
73649 +
73650 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
73651 {
73652 atomic_t *v = (atomic_t *)l;
73653 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
73654 return (long)atomic_inc_return(v);
73655 }
73656
73657 +#ifdef CONFIG_PAX_REFCOUNT
73658 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
73659 +{
73660 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73661 +
73662 + return (long)atomic_inc_return_unchecked(v);
73663 +}
73664 +#endif
73665 +
73666 static inline long atomic_long_dec_return(atomic_long_t *l)
73667 {
73668 atomic_t *v = (atomic_t *)l;
73669 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
73670
73671 #endif /* BITS_PER_LONG == 64 */
73672
73673 +#ifdef CONFIG_PAX_REFCOUNT
73674 +static inline void pax_refcount_needs_these_functions(void)
73675 +{
73676 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
73677 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
73678 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
73679 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
73680 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
73681 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
73682 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
73683 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
73684 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
73685 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
73686 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
73687 +#ifdef CONFIG_X86
73688 + atomic_clear_mask_unchecked(0, NULL);
73689 + atomic_set_mask_unchecked(0, NULL);
73690 +#endif
73691 +
73692 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
73693 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
73694 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
73695 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
73696 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
73697 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
73698 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
73699 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
73700 +}
73701 +#else
73702 +#define atomic_read_unchecked(v) atomic_read(v)
73703 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
73704 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
73705 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
73706 +#define atomic_inc_unchecked(v) atomic_inc(v)
73707 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
73708 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
73709 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
73710 +#define atomic_dec_unchecked(v) atomic_dec(v)
73711 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
73712 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
73713 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
73714 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
73715 +
73716 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
73717 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
73718 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
73719 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
73720 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
73721 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
73722 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
73723 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
73724 +#endif
73725 +
73726 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
73727 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
73728 index 33bd2de..f31bff97 100644
73729 --- a/include/asm-generic/atomic.h
73730 +++ b/include/asm-generic/atomic.h
73731 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
73732 * Atomically clears the bits set in @mask from @v
73733 */
73734 #ifndef atomic_clear_mask
73735 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
73736 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
73737 {
73738 unsigned long flags;
73739
73740 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
73741 index b18ce4f..2ee2843 100644
73742 --- a/include/asm-generic/atomic64.h
73743 +++ b/include/asm-generic/atomic64.h
73744 @@ -16,6 +16,8 @@ typedef struct {
73745 long long counter;
73746 } atomic64_t;
73747
73748 +typedef atomic64_t atomic64_unchecked_t;
73749 +
73750 #define ATOMIC64_INIT(i) { (i) }
73751
73752 extern long long atomic64_read(const atomic64_t *v);
73753 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
73754 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
73755 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
73756
73757 +#define atomic64_read_unchecked(v) atomic64_read(v)
73758 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
73759 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
73760 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
73761 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
73762 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
73763 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
73764 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
73765 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
73766 +
73767 #endif /* _ASM_GENERIC_ATOMIC64_H */
73768 diff --git a/include/asm-generic/bitops/__fls.h b/include/asm-generic/bitops/__fls.h
73769 index a60a7cc..0fe12f2 100644
73770 --- a/include/asm-generic/bitops/__fls.h
73771 +++ b/include/asm-generic/bitops/__fls.h
73772 @@ -9,7 +9,7 @@
73773 *
73774 * Undefined if no set bit exists, so code should check against 0 first.
73775 */
73776 -static __always_inline unsigned long __fls(unsigned long word)
73777 +static __always_inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
73778 {
73779 int num = BITS_PER_LONG - 1;
73780
73781 diff --git a/include/asm-generic/bitops/fls.h b/include/asm-generic/bitops/fls.h
73782 index 0576d1f..dad6c71 100644
73783 --- a/include/asm-generic/bitops/fls.h
73784 +++ b/include/asm-generic/bitops/fls.h
73785 @@ -9,7 +9,7 @@
73786 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
73787 */
73788
73789 -static __always_inline int fls(int x)
73790 +static __always_inline int __intentional_overflow(-1) fls(int x)
73791 {
73792 int r = 32;
73793
73794 diff --git a/include/asm-generic/bitops/fls64.h b/include/asm-generic/bitops/fls64.h
73795 index b097cf8..3d40e14 100644
73796 --- a/include/asm-generic/bitops/fls64.h
73797 +++ b/include/asm-generic/bitops/fls64.h
73798 @@ -15,7 +15,7 @@
73799 * at position 64.
73800 */
73801 #if BITS_PER_LONG == 32
73802 -static __always_inline int fls64(__u64 x)
73803 +static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
73804 {
73805 __u32 h = x >> 32;
73806 if (h)
73807 @@ -23,7 +23,7 @@ static __always_inline int fls64(__u64 x)
73808 return fls(x);
73809 }
73810 #elif BITS_PER_LONG == 64
73811 -static __always_inline int fls64(__u64 x)
73812 +static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
73813 {
73814 if (x == 0)
73815 return 0;
73816 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
73817 index 1bfcfe5..e04c5c9 100644
73818 --- a/include/asm-generic/cache.h
73819 +++ b/include/asm-generic/cache.h
73820 @@ -6,7 +6,7 @@
73821 * cache lines need to provide their own cache.h.
73822 */
73823
73824 -#define L1_CACHE_SHIFT 5
73825 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
73826 +#define L1_CACHE_SHIFT 5UL
73827 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
73828
73829 #endif /* __ASM_GENERIC_CACHE_H */
73830 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
73831 index 0d68a1e..b74a761 100644
73832 --- a/include/asm-generic/emergency-restart.h
73833 +++ b/include/asm-generic/emergency-restart.h
73834 @@ -1,7 +1,7 @@
73835 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
73836 #define _ASM_GENERIC_EMERGENCY_RESTART_H
73837
73838 -static inline void machine_emergency_restart(void)
73839 +static inline __noreturn void machine_emergency_restart(void)
73840 {
73841 machine_restart(NULL);
73842 }
73843 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
73844 index 90f99c7..00ce236 100644
73845 --- a/include/asm-generic/kmap_types.h
73846 +++ b/include/asm-generic/kmap_types.h
73847 @@ -2,9 +2,9 @@
73848 #define _ASM_GENERIC_KMAP_TYPES_H
73849
73850 #ifdef __WITH_KM_FENCE
73851 -# define KM_TYPE_NR 41
73852 +# define KM_TYPE_NR 42
73853 #else
73854 -# define KM_TYPE_NR 20
73855 +# define KM_TYPE_NR 21
73856 #endif
73857
73858 #endif
73859 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
73860 index 9ceb03b..62b0b8f 100644
73861 --- a/include/asm-generic/local.h
73862 +++ b/include/asm-generic/local.h
73863 @@ -23,24 +23,37 @@ typedef struct
73864 atomic_long_t a;
73865 } local_t;
73866
73867 +typedef struct {
73868 + atomic_long_unchecked_t a;
73869 +} local_unchecked_t;
73870 +
73871 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
73872
73873 #define local_read(l) atomic_long_read(&(l)->a)
73874 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
73875 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
73876 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
73877 #define local_inc(l) atomic_long_inc(&(l)->a)
73878 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
73879 #define local_dec(l) atomic_long_dec(&(l)->a)
73880 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
73881 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
73882 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
73883 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
73884 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
73885
73886 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
73887 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
73888 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
73889 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
73890 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
73891 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
73892 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
73893 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
73894 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
73895
73896 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
73897 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
73898 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
73899 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
73900 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
73901 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
73902 index 725612b..9cc513a 100644
73903 --- a/include/asm-generic/pgtable-nopmd.h
73904 +++ b/include/asm-generic/pgtable-nopmd.h
73905 @@ -1,14 +1,19 @@
73906 #ifndef _PGTABLE_NOPMD_H
73907 #define _PGTABLE_NOPMD_H
73908
73909 -#ifndef __ASSEMBLY__
73910 -
73911 #include <asm-generic/pgtable-nopud.h>
73912
73913 -struct mm_struct;
73914 -
73915 #define __PAGETABLE_PMD_FOLDED
73916
73917 +#define PMD_SHIFT PUD_SHIFT
73918 +#define PTRS_PER_PMD 1
73919 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
73920 +#define PMD_MASK (~(PMD_SIZE-1))
73921 +
73922 +#ifndef __ASSEMBLY__
73923 +
73924 +struct mm_struct;
73925 +
73926 /*
73927 * Having the pmd type consist of a pud gets the size right, and allows
73928 * us to conceptually access the pud entry that this pmd is folded into
73929 @@ -16,11 +21,6 @@ struct mm_struct;
73930 */
73931 typedef struct { pud_t pud; } pmd_t;
73932
73933 -#define PMD_SHIFT PUD_SHIFT
73934 -#define PTRS_PER_PMD 1
73935 -#define PMD_SIZE (1UL << PMD_SHIFT)
73936 -#define PMD_MASK (~(PMD_SIZE-1))
73937 -
73938 /*
73939 * The "pud_xxx()" functions here are trivial for a folded two-level
73940 * setup: the pmd is never bad, and a pmd always exists (as it's folded
73941 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
73942 index 810431d..0ec4804f 100644
73943 --- a/include/asm-generic/pgtable-nopud.h
73944 +++ b/include/asm-generic/pgtable-nopud.h
73945 @@ -1,10 +1,15 @@
73946 #ifndef _PGTABLE_NOPUD_H
73947 #define _PGTABLE_NOPUD_H
73948
73949 -#ifndef __ASSEMBLY__
73950 -
73951 #define __PAGETABLE_PUD_FOLDED
73952
73953 +#define PUD_SHIFT PGDIR_SHIFT
73954 +#define PTRS_PER_PUD 1
73955 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
73956 +#define PUD_MASK (~(PUD_SIZE-1))
73957 +
73958 +#ifndef __ASSEMBLY__
73959 +
73960 /*
73961 * Having the pud type consist of a pgd gets the size right, and allows
73962 * us to conceptually access the pgd entry that this pud is folded into
73963 @@ -12,11 +17,6 @@
73964 */
73965 typedef struct { pgd_t pgd; } pud_t;
73966
73967 -#define PUD_SHIFT PGDIR_SHIFT
73968 -#define PTRS_PER_PUD 1
73969 -#define PUD_SIZE (1UL << PUD_SHIFT)
73970 -#define PUD_MASK (~(PUD_SIZE-1))
73971 -
73972 /*
73973 * The "pgd_xxx()" functions here are trivial for a folded two-level
73974 * setup: the pud is never bad, and a pud always exists (as it's folded
73975 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
73976 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
73977
73978 #define pgd_populate(mm, pgd, pud) do { } while (0)
73979 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
73980 /*
73981 * (puds are folded into pgds so this doesn't get actually called,
73982 * but the define is needed for a generic inline function.)
73983 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
73984 index b12079a..86683e3 100644
73985 --- a/include/asm-generic/pgtable.h
73986 +++ b/include/asm-generic/pgtable.h
73987 @@ -599,11 +599,10 @@ static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)
73988 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
73989 barrier();
73990 #endif
73991 - if (pmd_none(pmdval))
73992 + if (pmd_none(pmdval) || pmd_trans_huge(pmdval))
73993 return 1;
73994 if (unlikely(pmd_bad(pmdval))) {
73995 - if (!pmd_trans_huge(pmdval))
73996 - pmd_clear_bad(pmd);
73997 + pmd_clear_bad(pmd);
73998 return 1;
73999 }
74000 return 0;
74001 @@ -737,6 +736,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
74002 }
74003 #endif /* CONFIG_NUMA_BALANCING */
74004
74005 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
74006 +#ifdef CONFIG_PAX_KERNEXEC
74007 +#error KERNEXEC requires pax_open_kernel
74008 +#else
74009 +static inline unsigned long pax_open_kernel(void) { return 0; }
74010 +#endif
74011 +#endif
74012 +
74013 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
74014 +#ifdef CONFIG_PAX_KERNEXEC
74015 +#error KERNEXEC requires pax_close_kernel
74016 +#else
74017 +static inline unsigned long pax_close_kernel(void) { return 0; }
74018 +#endif
74019 +#endif
74020 +
74021 #endif /* CONFIG_MMU */
74022
74023 #endif /* !__ASSEMBLY__ */
74024 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
74025 index dc1269c..48a4f51 100644
74026 --- a/include/asm-generic/uaccess.h
74027 +++ b/include/asm-generic/uaccess.h
74028 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
74029 return __clear_user(to, n);
74030 }
74031
74032 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
74033 +#ifdef CONFIG_PAX_MEMORY_UDEREF
74034 +#error UDEREF requires pax_open_userland
74035 +#else
74036 +static inline unsigned long pax_open_userland(void) { return 0; }
74037 +#endif
74038 +#endif
74039 +
74040 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
74041 +#ifdef CONFIG_PAX_MEMORY_UDEREF
74042 +#error UDEREF requires pax_close_userland
74043 +#else
74044 +static inline unsigned long pax_close_userland(void) { return 0; }
74045 +#endif
74046 +#endif
74047 +
74048 #endif /* __ASM_GENERIC_UACCESS_H */
74049 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
74050 index 83e2c31..eeb4a04 100644
74051 --- a/include/asm-generic/vmlinux.lds.h
74052 +++ b/include/asm-generic/vmlinux.lds.h
74053 @@ -232,6 +232,7 @@
74054 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
74055 VMLINUX_SYMBOL(__start_rodata) = .; \
74056 *(.rodata) *(.rodata.*) \
74057 + *(.data..read_only) \
74058 *(__vermagic) /* Kernel version magic */ \
74059 . = ALIGN(8); \
74060 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
74061 @@ -715,17 +716,18 @@
74062 * section in the linker script will go there too. @phdr should have
74063 * a leading colon.
74064 *
74065 - * Note that this macros defines __per_cpu_load as an absolute symbol.
74066 + * Note that this macros defines per_cpu_load as an absolute symbol.
74067 * If there is no need to put the percpu section at a predetermined
74068 * address, use PERCPU_SECTION.
74069 */
74070 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
74071 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
74072 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
74073 + per_cpu_load = .; \
74074 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
74075 - LOAD_OFFSET) { \
74076 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
74077 PERCPU_INPUT(cacheline) \
74078 } phdr \
74079 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
74080 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
74081
74082 /**
74083 * PERCPU_SECTION - define output section for percpu area, simple version
74084 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
74085 index 418d270..bfd2794 100644
74086 --- a/include/crypto/algapi.h
74087 +++ b/include/crypto/algapi.h
74088 @@ -34,7 +34,7 @@ struct crypto_type {
74089 unsigned int maskclear;
74090 unsigned int maskset;
74091 unsigned int tfmsize;
74092 -};
74093 +} __do_const;
74094
74095 struct crypto_instance {
74096 struct crypto_alg alg;
74097 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
74098 index b46fb45..b30d6d5 100644
74099 --- a/include/drm/drmP.h
74100 +++ b/include/drm/drmP.h
74101 @@ -66,6 +66,7 @@
74102 #include <linux/workqueue.h>
74103 #include <linux/poll.h>
74104 #include <asm/pgalloc.h>
74105 +#include <asm/local.h>
74106 #include <drm/drm.h>
74107 #include <drm/drm_sarea.h>
74108 #include <drm/drm_vma_manager.h>
74109 @@ -277,10 +278,12 @@ do { \
74110 * \param cmd command.
74111 * \param arg argument.
74112 */
74113 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
74114 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
74115 + struct drm_file *file_priv);
74116 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
74117 struct drm_file *file_priv);
74118
74119 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
74120 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
74121 unsigned long arg);
74122
74123 #define DRM_IOCTL_NR(n) _IOC_NR(n)
74124 @@ -296,10 +299,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
74125 struct drm_ioctl_desc {
74126 unsigned int cmd;
74127 int flags;
74128 - drm_ioctl_t *func;
74129 + drm_ioctl_t func;
74130 unsigned int cmd_drv;
74131 const char *name;
74132 -};
74133 +} __do_const;
74134
74135 /**
74136 * Creates a driver or general drm_ioctl_desc array entry for the given
74137 @@ -1027,7 +1030,7 @@ struct drm_info_list {
74138 int (*show)(struct seq_file*, void*); /** show callback */
74139 u32 driver_features; /**< Required driver features for this entry */
74140 void *data;
74141 -};
74142 +} __do_const;
74143
74144 /**
74145 * debugfs node structure. This structure represents a debugfs file.
74146 @@ -1098,7 +1101,7 @@ struct drm_device {
74147
74148 /** \name Usage Counters */
74149 /*@{ */
74150 - int open_count; /**< Outstanding files open */
74151 + local_t open_count; /**< Outstanding files open */
74152 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
74153 atomic_t vma_count; /**< Outstanding vma areas open */
74154 int buf_use; /**< Buffers in use -- cannot alloc */
74155 @@ -1109,7 +1112,7 @@ struct drm_device {
74156 /*@{ */
74157 unsigned long counters;
74158 enum drm_stat_type types[15];
74159 - atomic_t counts[15];
74160 + atomic_unchecked_t counts[15];
74161 /*@} */
74162
74163 struct list_head filelist;
74164 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
74165 index f43d556..94d9343 100644
74166 --- a/include/drm/drm_crtc_helper.h
74167 +++ b/include/drm/drm_crtc_helper.h
74168 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
74169 struct drm_connector *connector);
74170 /* disable encoder when not in use - more explicit than dpms off */
74171 void (*disable)(struct drm_encoder *encoder);
74172 -};
74173 +} __no_const;
74174
74175 /**
74176 * drm_connector_helper_funcs - helper operations for connectors
74177 diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
74178 index 8a10f5c..5de7f5c 100644
74179 --- a/include/drm/i915_pciids.h
74180 +++ b/include/drm/i915_pciids.h
74181 @@ -37,7 +37,7 @@
74182 */
74183 #define INTEL_VGA_DEVICE(id, info) { \
74184 0x8086, id, \
74185 - ~0, ~0, \
74186 + PCI_ANY_ID, PCI_ANY_ID, \
74187 0x030000, 0xff0000, \
74188 (unsigned long) info }
74189
74190 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
74191 index 72dcbe8..8db58d7 100644
74192 --- a/include/drm/ttm/ttm_memory.h
74193 +++ b/include/drm/ttm/ttm_memory.h
74194 @@ -48,7 +48,7 @@
74195
74196 struct ttm_mem_shrink {
74197 int (*do_shrink) (struct ttm_mem_shrink *);
74198 -};
74199 +} __no_const;
74200
74201 /**
74202 * struct ttm_mem_global - Global memory accounting structure.
74203 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
74204 index 4b840e8..155d235 100644
74205 --- a/include/keys/asymmetric-subtype.h
74206 +++ b/include/keys/asymmetric-subtype.h
74207 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
74208 /* Verify the signature on a key of this subtype (optional) */
74209 int (*verify_signature)(const struct key *key,
74210 const struct public_key_signature *sig);
74211 -};
74212 +} __do_const;
74213
74214 /**
74215 * asymmetric_key_subtype - Get the subtype from an asymmetric key
74216 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
74217 index c1da539..1dcec55 100644
74218 --- a/include/linux/atmdev.h
74219 +++ b/include/linux/atmdev.h
74220 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
74221 #endif
74222
74223 struct k_atm_aal_stats {
74224 -#define __HANDLE_ITEM(i) atomic_t i
74225 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
74226 __AAL_STAT_ITEMS
74227 #undef __HANDLE_ITEM
74228 };
74229 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
74230 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
74231 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
74232 struct module *owner;
74233 -};
74234 +} __do_const ;
74235
74236 struct atmphy_ops {
74237 int (*start)(struct atm_dev *dev);
74238 diff --git a/include/linux/audit.h b/include/linux/audit.h
74239 index 729a4d1..9b304ae 100644
74240 --- a/include/linux/audit.h
74241 +++ b/include/linux/audit.h
74242 @@ -193,7 +193,7 @@ static inline void audit_ptrace(struct task_struct *t)
74243 extern unsigned int audit_serial(void);
74244 extern int auditsc_get_stamp(struct audit_context *ctx,
74245 struct timespec *t, unsigned int *serial);
74246 -extern int audit_set_loginuid(kuid_t loginuid);
74247 +extern int __intentional_overflow(-1) audit_set_loginuid(kuid_t loginuid);
74248
74249 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
74250 {
74251 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
74252 index 7554fd4..0f86379 100644
74253 --- a/include/linux/binfmts.h
74254 +++ b/include/linux/binfmts.h
74255 @@ -73,8 +73,10 @@ struct linux_binfmt {
74256 int (*load_binary)(struct linux_binprm *);
74257 int (*load_shlib)(struct file *);
74258 int (*core_dump)(struct coredump_params *cprm);
74259 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
74260 + void (*handle_mmap)(struct file *);
74261 unsigned long min_coredump; /* minimal dump size */
74262 -};
74263 +} __do_const;
74264
74265 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
74266
74267 diff --git a/include/linux/bitops.h b/include/linux/bitops.h
74268 index a3b6b82..2a7d758 100644
74269 --- a/include/linux/bitops.h
74270 +++ b/include/linux/bitops.h
74271 @@ -91,7 +91,7 @@ static inline __u64 ror64(__u64 word, unsigned int shift)
74272 * @word: value to rotate
74273 * @shift: bits to roll
74274 */
74275 -static inline __u32 rol32(__u32 word, unsigned int shift)
74276 +static inline __u32 __intentional_overflow(-1) rol32(__u32 word, unsigned int shift)
74277 {
74278 return (word << shift) | (word >> (32 - shift));
74279 }
74280 @@ -101,7 +101,7 @@ static inline __u32 rol32(__u32 word, unsigned int shift)
74281 * @word: value to rotate
74282 * @shift: bits to roll
74283 */
74284 -static inline __u32 ror32(__u32 word, unsigned int shift)
74285 +static inline __u32 __intentional_overflow(-1) ror32(__u32 word, unsigned int shift)
74286 {
74287 return (word >> shift) | (word << (32 - shift));
74288 }
74289 @@ -157,7 +157,7 @@ static inline __s32 sign_extend32(__u32 value, int index)
74290 return (__s32)(value << shift) >> shift;
74291 }
74292
74293 -static inline unsigned fls_long(unsigned long l)
74294 +static inline unsigned __intentional_overflow(-1) fls_long(unsigned long l)
74295 {
74296 if (sizeof(l) == 4)
74297 return fls(l);
74298 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
74299 index 0e6f765..885bb2b 100644
74300 --- a/include/linux/blkdev.h
74301 +++ b/include/linux/blkdev.h
74302 @@ -1537,7 +1537,7 @@ struct block_device_operations {
74303 /* this callback is with swap_lock and sometimes page table lock held */
74304 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
74305 struct module *owner;
74306 -};
74307 +} __do_const;
74308
74309 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
74310 unsigned long);
74311 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
74312 index 7c2e030..b72475d 100644
74313 --- a/include/linux/blktrace_api.h
74314 +++ b/include/linux/blktrace_api.h
74315 @@ -23,7 +23,7 @@ struct blk_trace {
74316 struct dentry *dir;
74317 struct dentry *dropped_file;
74318 struct dentry *msg_file;
74319 - atomic_t dropped;
74320 + atomic_unchecked_t dropped;
74321 };
74322
74323 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
74324 diff --git a/include/linux/cache.h b/include/linux/cache.h
74325 index 4c57065..40346da 100644
74326 --- a/include/linux/cache.h
74327 +++ b/include/linux/cache.h
74328 @@ -16,6 +16,14 @@
74329 #define __read_mostly
74330 #endif
74331
74332 +#ifndef __read_only
74333 +#ifdef CONFIG_PAX_KERNEXEC
74334 +#error KERNEXEC requires __read_only
74335 +#else
74336 +#define __read_only __read_mostly
74337 +#endif
74338 +#endif
74339 +
74340 #ifndef ____cacheline_aligned
74341 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
74342 #endif
74343 diff --git a/include/linux/capability.h b/include/linux/capability.h
74344 index a6ee1f9..e1ca49d 100644
74345 --- a/include/linux/capability.h
74346 +++ b/include/linux/capability.h
74347 @@ -212,8 +212,13 @@ extern bool capable(int cap);
74348 extern bool ns_capable(struct user_namespace *ns, int cap);
74349 extern bool inode_capable(const struct inode *inode, int cap);
74350 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
74351 +extern bool capable_nolog(int cap);
74352 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
74353 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
74354
74355 /* audit system wants to get cap info from files as well */
74356 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
74357
74358 +extern int is_privileged_binary(const struct dentry *dentry);
74359 +
74360 #endif /* !_LINUX_CAPABILITY_H */
74361 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
74362 index 8609d57..86e4d79 100644
74363 --- a/include/linux/cdrom.h
74364 +++ b/include/linux/cdrom.h
74365 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
74366
74367 /* driver specifications */
74368 const int capability; /* capability flags */
74369 - int n_minors; /* number of active minor devices */
74370 /* handle uniform packets for scsi type devices (scsi,atapi) */
74371 int (*generic_packet) (struct cdrom_device_info *,
74372 struct packet_command *);
74373 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
74374 index 4ce9056..86caac6 100644
74375 --- a/include/linux/cleancache.h
74376 +++ b/include/linux/cleancache.h
74377 @@ -31,7 +31,7 @@ struct cleancache_ops {
74378 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
74379 void (*invalidate_inode)(int, struct cleancache_filekey);
74380 void (*invalidate_fs)(int);
74381 -};
74382 +} __no_const;
74383
74384 extern struct cleancache_ops *
74385 cleancache_register_ops(struct cleancache_ops *ops);
74386 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
74387 index 73bdb69..d66d47a 100644
74388 --- a/include/linux/clk-provider.h
74389 +++ b/include/linux/clk-provider.h
74390 @@ -141,6 +141,7 @@ struct clk_ops {
74391 unsigned long);
74392 void (*init)(struct clk_hw *hw);
74393 };
74394 +typedef struct clk_ops __no_const clk_ops_no_const;
74395
74396 /**
74397 * struct clk_init_data - holds init data that's common to all clocks and is
74398 diff --git a/include/linux/compat.h b/include/linux/compat.h
74399 index 345da00..b6eff26 100644
74400 --- a/include/linux/compat.h
74401 +++ b/include/linux/compat.h
74402 @@ -313,7 +313,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
74403 compat_size_t __user *len_ptr);
74404
74405 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
74406 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
74407 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
74408 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
74409 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
74410 compat_ssize_t msgsz, int msgflg);
74411 @@ -420,7 +420,7 @@ extern int compat_ptrace_request(struct task_struct *child,
74412 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
74413 compat_ulong_t addr, compat_ulong_t data);
74414 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
74415 - compat_long_t addr, compat_long_t data);
74416 + compat_ulong_t addr, compat_ulong_t data);
74417
74418 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
74419 /*
74420 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
74421 index ded4299..da50e3b 100644
74422 --- a/include/linux/compiler-gcc4.h
74423 +++ b/include/linux/compiler-gcc4.h
74424 @@ -39,9 +39,29 @@
74425 # define __compiletime_warning(message) __attribute__((warning(message)))
74426 # define __compiletime_error(message) __attribute__((error(message)))
74427 #endif /* __CHECKER__ */
74428 +
74429 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
74430 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
74431 +#define __bos0(ptr) __bos((ptr), 0)
74432 +#define __bos1(ptr) __bos((ptr), 1)
74433 #endif /* GCC_VERSION >= 40300 */
74434
74435 #if GCC_VERSION >= 40500
74436 +
74437 +#ifdef CONSTIFY_PLUGIN
74438 +#define __no_const __attribute__((no_const))
74439 +#define __do_const __attribute__((do_const))
74440 +#endif
74441 +
74442 +#ifdef SIZE_OVERFLOW_PLUGIN
74443 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
74444 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
74445 +#endif
74446 +
74447 +#ifdef LATENT_ENTROPY_PLUGIN
74448 +#define __latent_entropy __attribute__((latent_entropy))
74449 +#endif
74450 +
74451 /*
74452 * Mark a position in code as unreachable. This can be used to
74453 * suppress control flow warnings after asm blocks that transfer
74454 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
74455 index 92669cd..1771a15 100644
74456 --- a/include/linux/compiler.h
74457 +++ b/include/linux/compiler.h
74458 @@ -5,11 +5,14 @@
74459
74460 #ifdef __CHECKER__
74461 # define __user __attribute__((noderef, address_space(1)))
74462 +# define __force_user __force __user
74463 # define __kernel __attribute__((address_space(0)))
74464 +# define __force_kernel __force __kernel
74465 # define __safe __attribute__((safe))
74466 # define __force __attribute__((force))
74467 # define __nocast __attribute__((nocast))
74468 # define __iomem __attribute__((noderef, address_space(2)))
74469 +# define __force_iomem __force __iomem
74470 # define __must_hold(x) __attribute__((context(x,1,1)))
74471 # define __acquires(x) __attribute__((context(x,0,1)))
74472 # define __releases(x) __attribute__((context(x,1,0)))
74473 @@ -17,20 +20,37 @@
74474 # define __release(x) __context__(x,-1)
74475 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
74476 # define __percpu __attribute__((noderef, address_space(3)))
74477 +# define __force_percpu __force __percpu
74478 #ifdef CONFIG_SPARSE_RCU_POINTER
74479 # define __rcu __attribute__((noderef, address_space(4)))
74480 +# define __force_rcu __force __rcu
74481 #else
74482 # define __rcu
74483 +# define __force_rcu
74484 #endif
74485 extern void __chk_user_ptr(const volatile void __user *);
74486 extern void __chk_io_ptr(const volatile void __iomem *);
74487 #else
74488 -# define __user
74489 -# define __kernel
74490 +# ifdef CHECKER_PLUGIN
74491 +//# define __user
74492 +//# define __force_user
74493 +//# define __kernel
74494 +//# define __force_kernel
74495 +# else
74496 +# ifdef STRUCTLEAK_PLUGIN
74497 +# define __user __attribute__((user))
74498 +# else
74499 +# define __user
74500 +# endif
74501 +# define __force_user
74502 +# define __kernel
74503 +# define __force_kernel
74504 +# endif
74505 # define __safe
74506 # define __force
74507 # define __nocast
74508 # define __iomem
74509 +# define __force_iomem
74510 # define __chk_user_ptr(x) (void)0
74511 # define __chk_io_ptr(x) (void)0
74512 # define __builtin_warning(x, y...) (1)
74513 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
74514 # define __release(x) (void)0
74515 # define __cond_lock(x,c) (c)
74516 # define __percpu
74517 +# define __force_percpu
74518 # define __rcu
74519 +# define __force_rcu
74520 #endif
74521
74522 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
74523 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
74524 # define __attribute_const__ /* unimplemented */
74525 #endif
74526
74527 +#ifndef __no_const
74528 +# define __no_const
74529 +#endif
74530 +
74531 +#ifndef __do_const
74532 +# define __do_const
74533 +#endif
74534 +
74535 +#ifndef __size_overflow
74536 +# define __size_overflow(...)
74537 +#endif
74538 +
74539 +#ifndef __intentional_overflow
74540 +# define __intentional_overflow(...)
74541 +#endif
74542 +
74543 +#ifndef __latent_entropy
74544 +# define __latent_entropy
74545 +#endif
74546 +
74547 /*
74548 * Tell gcc if a function is cold. The compiler will assume any path
74549 * directly leading to the call is unlikely.
74550 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
74551 #define __cold
74552 #endif
74553
74554 +#ifndef __alloc_size
74555 +#define __alloc_size(...)
74556 +#endif
74557 +
74558 +#ifndef __bos
74559 +#define __bos(ptr, arg)
74560 +#endif
74561 +
74562 +#ifndef __bos0
74563 +#define __bos0(ptr)
74564 +#endif
74565 +
74566 +#ifndef __bos1
74567 +#define __bos1(ptr)
74568 +#endif
74569 +
74570 /* Simple shorthand for a section definition */
74571 #ifndef __section
74572 # define __section(S) __attribute__ ((__section__(#S)))
74573 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
74574 * use is to mediate communication between process-level code and irq/NMI
74575 * handlers, all running on the same CPU.
74576 */
74577 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
74578 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
74579 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
74580
74581 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
74582 #ifdef CONFIG_KPROBES
74583 diff --git a/include/linux/completion.h b/include/linux/completion.h
74584 index 3cd574d..240dcb0 100644
74585 --- a/include/linux/completion.h
74586 +++ b/include/linux/completion.h
74587 @@ -78,16 +78,16 @@ static inline void init_completion(struct completion *x)
74588
74589 extern void wait_for_completion(struct completion *);
74590 extern void wait_for_completion_io(struct completion *);
74591 -extern int wait_for_completion_interruptible(struct completion *x);
74592 -extern int wait_for_completion_killable(struct completion *x);
74593 +extern int wait_for_completion_interruptible(struct completion *x) __intentional_overflow(-1);
74594 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
74595 extern unsigned long wait_for_completion_timeout(struct completion *x,
74596 - unsigned long timeout);
74597 + unsigned long timeout) __intentional_overflow(-1);
74598 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
74599 - unsigned long timeout);
74600 + unsigned long timeout) __intentional_overflow(-1);
74601 extern long wait_for_completion_interruptible_timeout(
74602 - struct completion *x, unsigned long timeout);
74603 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
74604 extern long wait_for_completion_killable_timeout(
74605 - struct completion *x, unsigned long timeout);
74606 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
74607 extern bool try_wait_for_completion(struct completion *x);
74608 extern bool completion_done(struct completion *x);
74609
74610 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
74611 index 34025df..d94bbbc 100644
74612 --- a/include/linux/configfs.h
74613 +++ b/include/linux/configfs.h
74614 @@ -125,7 +125,7 @@ struct configfs_attribute {
74615 const char *ca_name;
74616 struct module *ca_owner;
74617 umode_t ca_mode;
74618 -};
74619 +} __do_const;
74620
74621 /*
74622 * Users often need to create attribute structures for their configurable
74623 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
74624 index fcabc42..cba5d93 100644
74625 --- a/include/linux/cpufreq.h
74626 +++ b/include/linux/cpufreq.h
74627 @@ -167,6 +167,7 @@ struct global_attr {
74628 ssize_t (*store)(struct kobject *a, struct attribute *b,
74629 const char *c, size_t count);
74630 };
74631 +typedef struct global_attr __no_const global_attr_no_const;
74632
74633 #define define_one_global_ro(_name) \
74634 static struct global_attr _name = \
74635 @@ -208,7 +209,7 @@ struct cpufreq_driver {
74636 int (*suspend) (struct cpufreq_policy *policy);
74637 int (*resume) (struct cpufreq_policy *policy);
74638 struct freq_attr **attr;
74639 -};
74640 +} __do_const;
74641
74642 /* flags */
74643 #define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if
74644 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
74645 index 781addc..d1e1fe6 100644
74646 --- a/include/linux/cpuidle.h
74647 +++ b/include/linux/cpuidle.h
74648 @@ -50,7 +50,8 @@ struct cpuidle_state {
74649 int index);
74650
74651 int (*enter_dead) (struct cpuidle_device *dev, int index);
74652 -};
74653 +} __do_const;
74654 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
74655
74656 /* Idle State Flags */
74657 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
74658 @@ -192,7 +193,7 @@ struct cpuidle_governor {
74659 void (*reflect) (struct cpuidle_device *dev, int index);
74660
74661 struct module *owner;
74662 -};
74663 +} __do_const;
74664
74665 #ifdef CONFIG_CPU_IDLE
74666
74667 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
74668 index d08e4d2..95fad61 100644
74669 --- a/include/linux/cpumask.h
74670 +++ b/include/linux/cpumask.h
74671 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
74672 }
74673
74674 /* Valid inputs for n are -1 and 0. */
74675 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
74676 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
74677 {
74678 return n+1;
74679 }
74680
74681 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
74682 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
74683 {
74684 return n+1;
74685 }
74686
74687 -static inline unsigned int cpumask_next_and(int n,
74688 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
74689 const struct cpumask *srcp,
74690 const struct cpumask *andp)
74691 {
74692 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
74693 *
74694 * Returns >= nr_cpu_ids if no further cpus set.
74695 */
74696 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
74697 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
74698 {
74699 /* -1 is a legal arg here. */
74700 if (n != -1)
74701 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
74702 *
74703 * Returns >= nr_cpu_ids if no further cpus unset.
74704 */
74705 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
74706 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
74707 {
74708 /* -1 is a legal arg here. */
74709 if (n != -1)
74710 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
74711 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
74712 }
74713
74714 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
74715 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
74716 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
74717
74718 /**
74719 diff --git a/include/linux/cred.h b/include/linux/cred.h
74720 index 04421e8..6bce4ef 100644
74721 --- a/include/linux/cred.h
74722 +++ b/include/linux/cred.h
74723 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
74724 static inline void validate_process_creds(void)
74725 {
74726 }
74727 +static inline void validate_task_creds(struct task_struct *task)
74728 +{
74729 +}
74730 #endif
74731
74732 /**
74733 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
74734 index b92eadf..b4ecdc1 100644
74735 --- a/include/linux/crypto.h
74736 +++ b/include/linux/crypto.h
74737 @@ -373,7 +373,7 @@ struct cipher_tfm {
74738 const u8 *key, unsigned int keylen);
74739 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
74740 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
74741 -};
74742 +} __no_const;
74743
74744 struct hash_tfm {
74745 int (*init)(struct hash_desc *desc);
74746 @@ -394,13 +394,13 @@ struct compress_tfm {
74747 int (*cot_decompress)(struct crypto_tfm *tfm,
74748 const u8 *src, unsigned int slen,
74749 u8 *dst, unsigned int *dlen);
74750 -};
74751 +} __no_const;
74752
74753 struct rng_tfm {
74754 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
74755 unsigned int dlen);
74756 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
74757 -};
74758 +} __no_const;
74759
74760 #define crt_ablkcipher crt_u.ablkcipher
74761 #define crt_aead crt_u.aead
74762 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
74763 index 653589e..4ef254a 100644
74764 --- a/include/linux/ctype.h
74765 +++ b/include/linux/ctype.h
74766 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
74767 * Fast implementation of tolower() for internal usage. Do not use in your
74768 * code.
74769 */
74770 -static inline char _tolower(const char c)
74771 +static inline unsigned char _tolower(const unsigned char c)
74772 {
74773 return c | 0x20;
74774 }
74775 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
74776 index 7925bf0..d5143d2 100644
74777 --- a/include/linux/decompress/mm.h
74778 +++ b/include/linux/decompress/mm.h
74779 @@ -77,7 +77,7 @@ static void free(void *where)
74780 * warnings when not needed (indeed large_malloc / large_free are not
74781 * needed by inflate */
74782
74783 -#define malloc(a) kmalloc(a, GFP_KERNEL)
74784 +#define malloc(a) kmalloc((a), GFP_KERNEL)
74785 #define free(a) kfree(a)
74786
74787 #define large_malloc(a) vmalloc(a)
74788 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
74789 index 5f1ab92..39c35ae 100644
74790 --- a/include/linux/devfreq.h
74791 +++ b/include/linux/devfreq.h
74792 @@ -114,7 +114,7 @@ struct devfreq_governor {
74793 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
74794 int (*event_handler)(struct devfreq *devfreq,
74795 unsigned int event, void *data);
74796 -};
74797 +} __do_const;
74798
74799 /**
74800 * struct devfreq - Device devfreq structure
74801 diff --git a/include/linux/device.h b/include/linux/device.h
74802 index 2a9d6ed..d14551e3 100644
74803 --- a/include/linux/device.h
74804 +++ b/include/linux/device.h
74805 @@ -313,7 +313,7 @@ struct subsys_interface {
74806 struct list_head node;
74807 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
74808 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
74809 -};
74810 +} __do_const;
74811
74812 int subsys_interface_register(struct subsys_interface *sif);
74813 void subsys_interface_unregister(struct subsys_interface *sif);
74814 @@ -501,7 +501,7 @@ struct device_type {
74815 void (*release)(struct device *dev);
74816
74817 const struct dev_pm_ops *pm;
74818 -};
74819 +} __do_const;
74820
74821 /* interface for exporting device attributes */
74822 struct device_attribute {
74823 @@ -511,11 +511,12 @@ struct device_attribute {
74824 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
74825 const char *buf, size_t count);
74826 };
74827 +typedef struct device_attribute __no_const device_attribute_no_const;
74828
74829 struct dev_ext_attribute {
74830 struct device_attribute attr;
74831 void *var;
74832 -};
74833 +} __do_const;
74834
74835 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
74836 char *buf);
74837 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
74838 index 3a8d0a2..c762be2 100644
74839 --- a/include/linux/dma-mapping.h
74840 +++ b/include/linux/dma-mapping.h
74841 @@ -54,7 +54,7 @@ struct dma_map_ops {
74842 u64 (*get_required_mask)(struct device *dev);
74843 #endif
74844 int is_phys;
74845 -};
74846 +} __do_const;
74847
74848 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
74849
74850 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
74851 index 0bc7275..4ccbf11 100644
74852 --- a/include/linux/dmaengine.h
74853 +++ b/include/linux/dmaengine.h
74854 @@ -1078,9 +1078,9 @@ struct dma_pinned_list {
74855 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
74856 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
74857
74858 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
74859 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
74860 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
74861 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
74862 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
74863 struct dma_pinned_list *pinned_list, struct page *page,
74864 unsigned int offset, size_t len);
74865
74866 diff --git a/include/linux/efi.h b/include/linux/efi.h
74867 index 094ddd0..f1dfcd3 100644
74868 --- a/include/linux/efi.h
74869 +++ b/include/linux/efi.h
74870 @@ -745,6 +745,7 @@ struct efivar_operations {
74871 efi_set_variable_t *set_variable;
74872 efi_query_variable_store_t *query_variable_store;
74873 };
74874 +typedef struct efivar_operations __no_const efivar_operations_no_const;
74875
74876 struct efivars {
74877 /*
74878 diff --git a/include/linux/elf.h b/include/linux/elf.h
74879 index 40a3c0e0..4c45a38 100644
74880 --- a/include/linux/elf.h
74881 +++ b/include/linux/elf.h
74882 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
74883 #define elf_note elf32_note
74884 #define elf_addr_t Elf32_Off
74885 #define Elf_Half Elf32_Half
74886 +#define elf_dyn Elf32_Dyn
74887
74888 #else
74889
74890 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
74891 #define elf_note elf64_note
74892 #define elf_addr_t Elf64_Off
74893 #define Elf_Half Elf64_Half
74894 +#define elf_dyn Elf64_Dyn
74895
74896 #endif
74897
74898 diff --git a/include/linux/err.h b/include/linux/err.h
74899 index 15f92e0..e825a8e 100644
74900 --- a/include/linux/err.h
74901 +++ b/include/linux/err.h
74902 @@ -19,12 +19,12 @@
74903
74904 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
74905
74906 -static inline void * __must_check ERR_PTR(long error)
74907 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
74908 {
74909 return (void *) error;
74910 }
74911
74912 -static inline long __must_check PTR_ERR(__force const void *ptr)
74913 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
74914 {
74915 return (long) ptr;
74916 }
74917 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
74918 index fcb51c8..bdafcf6 100644
74919 --- a/include/linux/extcon.h
74920 +++ b/include/linux/extcon.h
74921 @@ -134,7 +134,7 @@ struct extcon_dev {
74922 /* /sys/class/extcon/.../mutually_exclusive/... */
74923 struct attribute_group attr_g_muex;
74924 struct attribute **attrs_muex;
74925 - struct device_attribute *d_attrs_muex;
74926 + device_attribute_no_const *d_attrs_muex;
74927 };
74928
74929 /**
74930 diff --git a/include/linux/fb.h b/include/linux/fb.h
74931 index ffac70a..ca3e711 100644
74932 --- a/include/linux/fb.h
74933 +++ b/include/linux/fb.h
74934 @@ -304,7 +304,7 @@ struct fb_ops {
74935 /* called at KDB enter and leave time to prepare the console */
74936 int (*fb_debug_enter)(struct fb_info *info);
74937 int (*fb_debug_leave)(struct fb_info *info);
74938 -};
74939 +} __do_const;
74940
74941 #ifdef CONFIG_FB_TILEBLITTING
74942 #define FB_TILE_CURSOR_NONE 0
74943 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
74944 index 085197b..0fa6f0b 100644
74945 --- a/include/linux/fdtable.h
74946 +++ b/include/linux/fdtable.h
74947 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
74948 void put_files_struct(struct files_struct *fs);
74949 void reset_files_struct(struct files_struct *);
74950 int unshare_files(struct files_struct **);
74951 -struct files_struct *dup_fd(struct files_struct *, int *);
74952 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
74953 void do_close_on_exec(struct files_struct *);
74954 int iterate_fd(struct files_struct *, unsigned,
74955 int (*)(const void *, struct file *, unsigned),
74956 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
74957 index 8293262..2b3b8bd 100644
74958 --- a/include/linux/frontswap.h
74959 +++ b/include/linux/frontswap.h
74960 @@ -11,7 +11,7 @@ struct frontswap_ops {
74961 int (*load)(unsigned, pgoff_t, struct page *);
74962 void (*invalidate_page)(unsigned, pgoff_t);
74963 void (*invalidate_area)(unsigned);
74964 -};
74965 +} __no_const;
74966
74967 extern bool frontswap_enabled;
74968 extern struct frontswap_ops *
74969 diff --git a/include/linux/fs.h b/include/linux/fs.h
74970 index 164d2a9..0ffa41d0 100644
74971 --- a/include/linux/fs.h
74972 +++ b/include/linux/fs.h
74973 @@ -1552,7 +1552,8 @@ struct file_operations {
74974 long (*fallocate)(struct file *file, int mode, loff_t offset,
74975 loff_t len);
74976 int (*show_fdinfo)(struct seq_file *m, struct file *f);
74977 -};
74978 +} __do_const;
74979 +typedef struct file_operations __no_const file_operations_no_const;
74980
74981 struct inode_operations {
74982 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
74983 @@ -2747,4 +2748,14 @@ static inline bool dir_relax(struct inode *inode)
74984 return !IS_DEADDIR(inode);
74985 }
74986
74987 +static inline bool is_sidechannel_device(const struct inode *inode)
74988 +{
74989 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
74990 + umode_t mode = inode->i_mode;
74991 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
74992 +#else
74993 + return false;
74994 +#endif
74995 +}
74996 +
74997 #endif /* _LINUX_FS_H */
74998 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
74999 index 0efc3e6..e0e1e5f 100644
75000 --- a/include/linux/fs_struct.h
75001 +++ b/include/linux/fs_struct.h
75002 @@ -6,7 +6,7 @@
75003 #include <linux/seqlock.h>
75004
75005 struct fs_struct {
75006 - int users;
75007 + atomic_t users;
75008 spinlock_t lock;
75009 seqcount_t seq;
75010 int umask;
75011 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
75012 index 7823e9e..56b6f2f 100644
75013 --- a/include/linux/fscache-cache.h
75014 +++ b/include/linux/fscache-cache.h
75015 @@ -113,7 +113,7 @@ struct fscache_operation {
75016 fscache_operation_release_t release;
75017 };
75018
75019 -extern atomic_t fscache_op_debug_id;
75020 +extern atomic_unchecked_t fscache_op_debug_id;
75021 extern void fscache_op_work_func(struct work_struct *work);
75022
75023 extern void fscache_enqueue_operation(struct fscache_operation *);
75024 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
75025 INIT_WORK(&op->work, fscache_op_work_func);
75026 atomic_set(&op->usage, 1);
75027 op->state = FSCACHE_OP_ST_INITIALISED;
75028 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
75029 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
75030 op->processor = processor;
75031 op->release = release;
75032 INIT_LIST_HEAD(&op->pend_link);
75033 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
75034 index 19b4645..3b73dfc 100644
75035 --- a/include/linux/fscache.h
75036 +++ b/include/linux/fscache.h
75037 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
75038 * - this is mandatory for any object that may have data
75039 */
75040 void (*now_uncached)(void *cookie_netfs_data);
75041 -};
75042 +} __do_const;
75043
75044 /*
75045 * fscache cached network filesystem type
75046 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
75047 index 1c804b0..1432c2b 100644
75048 --- a/include/linux/fsnotify.h
75049 +++ b/include/linux/fsnotify.h
75050 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
75051 struct inode *inode = file_inode(file);
75052 __u32 mask = FS_ACCESS;
75053
75054 + if (is_sidechannel_device(inode))
75055 + return;
75056 +
75057 if (S_ISDIR(inode->i_mode))
75058 mask |= FS_ISDIR;
75059
75060 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
75061 struct inode *inode = file_inode(file);
75062 __u32 mask = FS_MODIFY;
75063
75064 + if (is_sidechannel_device(inode))
75065 + return;
75066 +
75067 if (S_ISDIR(inode->i_mode))
75068 mask |= FS_ISDIR;
75069
75070 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
75071 */
75072 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
75073 {
75074 - return kstrdup(name, GFP_KERNEL);
75075 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
75076 }
75077
75078 /*
75079 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
75080 index 9f3c275..8bdff5d 100644
75081 --- a/include/linux/genhd.h
75082 +++ b/include/linux/genhd.h
75083 @@ -194,7 +194,7 @@ struct gendisk {
75084 struct kobject *slave_dir;
75085
75086 struct timer_rand_state *random;
75087 - atomic_t sync_io; /* RAID */
75088 + atomic_unchecked_t sync_io; /* RAID */
75089 struct disk_events *ev;
75090 #ifdef CONFIG_BLK_DEV_INTEGRITY
75091 struct blk_integrity *integrity;
75092 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
75093 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
75094
75095 /* drivers/char/random.c */
75096 -extern void add_disk_randomness(struct gendisk *disk);
75097 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
75098 extern void rand_initialize_disk(struct gendisk *disk);
75099
75100 static inline sector_t get_start_sect(struct block_device *bdev)
75101 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
75102 index 023bc34..b02b46a 100644
75103 --- a/include/linux/genl_magic_func.h
75104 +++ b/include/linux/genl_magic_func.h
75105 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
75106 },
75107
75108 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
75109 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
75110 +static struct genl_ops ZZZ_genl_ops[] = {
75111 #include GENL_MAGIC_INCLUDE_FILE
75112 };
75113
75114 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
75115 index 9b4dd49..61fd41d 100644
75116 --- a/include/linux/gfp.h
75117 +++ b/include/linux/gfp.h
75118 @@ -35,6 +35,13 @@ struct vm_area_struct;
75119 #define ___GFP_NO_KSWAPD 0x400000u
75120 #define ___GFP_OTHER_NODE 0x800000u
75121 #define ___GFP_WRITE 0x1000000u
75122 +
75123 +#ifdef CONFIG_PAX_USERCOPY_SLABS
75124 +#define ___GFP_USERCOPY 0x2000000u
75125 +#else
75126 +#define ___GFP_USERCOPY 0
75127 +#endif
75128 +
75129 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
75130
75131 /*
75132 @@ -92,6 +99,7 @@ struct vm_area_struct;
75133 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
75134 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
75135 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
75136 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
75137
75138 /*
75139 * This may seem redundant, but it's a way of annotating false positives vs.
75140 @@ -99,7 +107,7 @@ struct vm_area_struct;
75141 */
75142 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
75143
75144 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
75145 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
75146 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
75147
75148 /* This equals 0, but use constants in case they ever change */
75149 @@ -153,6 +161,8 @@ struct vm_area_struct;
75150 /* 4GB DMA on some platforms */
75151 #define GFP_DMA32 __GFP_DMA32
75152
75153 +#define GFP_USERCOPY __GFP_USERCOPY
75154 +
75155 /* Convert GFP flags to their corresponding migrate type */
75156 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
75157 {
75158 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
75159 new file mode 100644
75160 index 0000000..edb2cb6
75161 --- /dev/null
75162 +++ b/include/linux/gracl.h
75163 @@ -0,0 +1,340 @@
75164 +#ifndef GR_ACL_H
75165 +#define GR_ACL_H
75166 +
75167 +#include <linux/grdefs.h>
75168 +#include <linux/resource.h>
75169 +#include <linux/capability.h>
75170 +#include <linux/dcache.h>
75171 +#include <asm/resource.h>
75172 +
75173 +/* Major status information */
75174 +
75175 +#define GR_VERSION "grsecurity 3.0"
75176 +#define GRSECURITY_VERSION 0x3000
75177 +
75178 +enum {
75179 + GR_SHUTDOWN = 0,
75180 + GR_ENABLE = 1,
75181 + GR_SPROLE = 2,
75182 + GR_OLDRELOAD = 3,
75183 + GR_SEGVMOD = 4,
75184 + GR_STATUS = 5,
75185 + GR_UNSPROLE = 6,
75186 + GR_PASSSET = 7,
75187 + GR_SPROLEPAM = 8,
75188 + GR_RELOAD = 9,
75189 +};
75190 +
75191 +/* Password setup definitions
75192 + * kernel/grhash.c */
75193 +enum {
75194 + GR_PW_LEN = 128,
75195 + GR_SALT_LEN = 16,
75196 + GR_SHA_LEN = 32,
75197 +};
75198 +
75199 +enum {
75200 + GR_SPROLE_LEN = 64,
75201 +};
75202 +
75203 +enum {
75204 + GR_NO_GLOB = 0,
75205 + GR_REG_GLOB,
75206 + GR_CREATE_GLOB
75207 +};
75208 +
75209 +#define GR_NLIMITS 32
75210 +
75211 +/* Begin Data Structures */
75212 +
75213 +struct sprole_pw {
75214 + unsigned char *rolename;
75215 + unsigned char salt[GR_SALT_LEN];
75216 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
75217 +};
75218 +
75219 +struct name_entry {
75220 + __u32 key;
75221 + ino_t inode;
75222 + dev_t device;
75223 + char *name;
75224 + __u16 len;
75225 + __u8 deleted;
75226 + struct name_entry *prev;
75227 + struct name_entry *next;
75228 +};
75229 +
75230 +struct inodev_entry {
75231 + struct name_entry *nentry;
75232 + struct inodev_entry *prev;
75233 + struct inodev_entry *next;
75234 +};
75235 +
75236 +struct acl_role_db {
75237 + struct acl_role_label **r_hash;
75238 + __u32 r_size;
75239 +};
75240 +
75241 +struct inodev_db {
75242 + struct inodev_entry **i_hash;
75243 + __u32 i_size;
75244 +};
75245 +
75246 +struct name_db {
75247 + struct name_entry **n_hash;
75248 + __u32 n_size;
75249 +};
75250 +
75251 +struct crash_uid {
75252 + uid_t uid;
75253 + unsigned long expires;
75254 +};
75255 +
75256 +struct gr_hash_struct {
75257 + void **table;
75258 + void **nametable;
75259 + void *first;
75260 + __u32 table_size;
75261 + __u32 used_size;
75262 + int type;
75263 +};
75264 +
75265 +/* Userspace Grsecurity ACL data structures */
75266 +
75267 +struct acl_subject_label {
75268 + char *filename;
75269 + ino_t inode;
75270 + dev_t device;
75271 + __u32 mode;
75272 + kernel_cap_t cap_mask;
75273 + kernel_cap_t cap_lower;
75274 + kernel_cap_t cap_invert_audit;
75275 +
75276 + struct rlimit res[GR_NLIMITS];
75277 + __u32 resmask;
75278 +
75279 + __u8 user_trans_type;
75280 + __u8 group_trans_type;
75281 + uid_t *user_transitions;
75282 + gid_t *group_transitions;
75283 + __u16 user_trans_num;
75284 + __u16 group_trans_num;
75285 +
75286 + __u32 sock_families[2];
75287 + __u32 ip_proto[8];
75288 + __u32 ip_type;
75289 + struct acl_ip_label **ips;
75290 + __u32 ip_num;
75291 + __u32 inaddr_any_override;
75292 +
75293 + __u32 crashes;
75294 + unsigned long expires;
75295 +
75296 + struct acl_subject_label *parent_subject;
75297 + struct gr_hash_struct *hash;
75298 + struct acl_subject_label *prev;
75299 + struct acl_subject_label *next;
75300 +
75301 + struct acl_object_label **obj_hash;
75302 + __u32 obj_hash_size;
75303 + __u16 pax_flags;
75304 +};
75305 +
75306 +struct role_allowed_ip {
75307 + __u32 addr;
75308 + __u32 netmask;
75309 +
75310 + struct role_allowed_ip *prev;
75311 + struct role_allowed_ip *next;
75312 +};
75313 +
75314 +struct role_transition {
75315 + char *rolename;
75316 +
75317 + struct role_transition *prev;
75318 + struct role_transition *next;
75319 +};
75320 +
75321 +struct acl_role_label {
75322 + char *rolename;
75323 + uid_t uidgid;
75324 + __u16 roletype;
75325 +
75326 + __u16 auth_attempts;
75327 + unsigned long expires;
75328 +
75329 + struct acl_subject_label *root_label;
75330 + struct gr_hash_struct *hash;
75331 +
75332 + struct acl_role_label *prev;
75333 + struct acl_role_label *next;
75334 +
75335 + struct role_transition *transitions;
75336 + struct role_allowed_ip *allowed_ips;
75337 + uid_t *domain_children;
75338 + __u16 domain_child_num;
75339 +
75340 + umode_t umask;
75341 +
75342 + struct acl_subject_label **subj_hash;
75343 + __u32 subj_hash_size;
75344 +};
75345 +
75346 +struct user_acl_role_db {
75347 + struct acl_role_label **r_table;
75348 + __u32 num_pointers; /* Number of allocations to track */
75349 + __u32 num_roles; /* Number of roles */
75350 + __u32 num_domain_children; /* Number of domain children */
75351 + __u32 num_subjects; /* Number of subjects */
75352 + __u32 num_objects; /* Number of objects */
75353 +};
75354 +
75355 +struct acl_object_label {
75356 + char *filename;
75357 + ino_t inode;
75358 + dev_t device;
75359 + __u32 mode;
75360 +
75361 + struct acl_subject_label *nested;
75362 + struct acl_object_label *globbed;
75363 +
75364 + /* next two structures not used */
75365 +
75366 + struct acl_object_label *prev;
75367 + struct acl_object_label *next;
75368 +};
75369 +
75370 +struct acl_ip_label {
75371 + char *iface;
75372 + __u32 addr;
75373 + __u32 netmask;
75374 + __u16 low, high;
75375 + __u8 mode;
75376 + __u32 type;
75377 + __u32 proto[8];
75378 +
75379 + /* next two structures not used */
75380 +
75381 + struct acl_ip_label *prev;
75382 + struct acl_ip_label *next;
75383 +};
75384 +
75385 +struct gr_arg {
75386 + struct user_acl_role_db role_db;
75387 + unsigned char pw[GR_PW_LEN];
75388 + unsigned char salt[GR_SALT_LEN];
75389 + unsigned char sum[GR_SHA_LEN];
75390 + unsigned char sp_role[GR_SPROLE_LEN];
75391 + struct sprole_pw *sprole_pws;
75392 + dev_t segv_device;
75393 + ino_t segv_inode;
75394 + uid_t segv_uid;
75395 + __u16 num_sprole_pws;
75396 + __u16 mode;
75397 +};
75398 +
75399 +struct gr_arg_wrapper {
75400 + struct gr_arg *arg;
75401 + __u32 version;
75402 + __u32 size;
75403 +};
75404 +
75405 +struct subject_map {
75406 + struct acl_subject_label *user;
75407 + struct acl_subject_label *kernel;
75408 + struct subject_map *prev;
75409 + struct subject_map *next;
75410 +};
75411 +
75412 +struct acl_subj_map_db {
75413 + struct subject_map **s_hash;
75414 + __u32 s_size;
75415 +};
75416 +
75417 +struct gr_policy_state {
75418 + struct sprole_pw **acl_special_roles;
75419 + __u16 num_sprole_pws;
75420 + struct acl_role_label *kernel_role;
75421 + struct acl_role_label *role_list;
75422 + struct acl_role_label *default_role;
75423 + struct acl_role_db acl_role_set;
75424 + struct acl_subj_map_db subj_map_set;
75425 + struct name_db name_set;
75426 + struct inodev_db inodev_set;
75427 +};
75428 +
75429 +struct gr_alloc_state {
75430 + unsigned long alloc_stack_next;
75431 + unsigned long alloc_stack_size;
75432 + void **alloc_stack;
75433 +};
75434 +
75435 +struct gr_reload_state {
75436 + struct gr_policy_state oldpolicy;
75437 + struct gr_alloc_state oldalloc;
75438 + struct gr_policy_state newpolicy;
75439 + struct gr_alloc_state newalloc;
75440 + struct gr_policy_state *oldpolicy_ptr;
75441 + struct gr_alloc_state *oldalloc_ptr;
75442 + unsigned char oldmode;
75443 +};
75444 +
75445 +/* End Data Structures Section */
75446 +
75447 +/* Hash functions generated by empirical testing by Brad Spengler
75448 + Makes good use of the low bits of the inode. Generally 0-1 times
75449 + in loop for successful match. 0-3 for unsuccessful match.
75450 + Shift/add algorithm with modulus of table size and an XOR*/
75451 +
75452 +static __inline__ unsigned int
75453 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
75454 +{
75455 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
75456 +}
75457 +
75458 + static __inline__ unsigned int
75459 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
75460 +{
75461 + return ((const unsigned long)userp % sz);
75462 +}
75463 +
75464 +static __inline__ unsigned int
75465 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
75466 +{
75467 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
75468 +}
75469 +
75470 +static __inline__ unsigned int
75471 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
75472 +{
75473 + return full_name_hash((const unsigned char *)name, len) % sz;
75474 +}
75475 +
75476 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
75477 + subj = NULL; \
75478 + iter = 0; \
75479 + while (iter < role->subj_hash_size) { \
75480 + if (subj == NULL) \
75481 + subj = role->subj_hash[iter]; \
75482 + if (subj == NULL) { \
75483 + iter++; \
75484 + continue; \
75485 + }
75486 +
75487 +#define FOR_EACH_SUBJECT_END(subj,iter) \
75488 + subj = subj->next; \
75489 + if (subj == NULL) \
75490 + iter++; \
75491 + }
75492 +
75493 +
75494 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
75495 + subj = role->hash->first; \
75496 + while (subj != NULL) {
75497 +
75498 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
75499 + subj = subj->next; \
75500 + }
75501 +
75502 +#endif
75503 +
75504 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
75505 new file mode 100644
75506 index 0000000..33ebd1f
75507 --- /dev/null
75508 +++ b/include/linux/gracl_compat.h
75509 @@ -0,0 +1,156 @@
75510 +#ifndef GR_ACL_COMPAT_H
75511 +#define GR_ACL_COMPAT_H
75512 +
75513 +#include <linux/resource.h>
75514 +#include <asm/resource.h>
75515 +
75516 +struct sprole_pw_compat {
75517 + compat_uptr_t rolename;
75518 + unsigned char salt[GR_SALT_LEN];
75519 + unsigned char sum[GR_SHA_LEN];
75520 +};
75521 +
75522 +struct gr_hash_struct_compat {
75523 + compat_uptr_t table;
75524 + compat_uptr_t nametable;
75525 + compat_uptr_t first;
75526 + __u32 table_size;
75527 + __u32 used_size;
75528 + int type;
75529 +};
75530 +
75531 +struct acl_subject_label_compat {
75532 + compat_uptr_t filename;
75533 + compat_ino_t inode;
75534 + __u32 device;
75535 + __u32 mode;
75536 + kernel_cap_t cap_mask;
75537 + kernel_cap_t cap_lower;
75538 + kernel_cap_t cap_invert_audit;
75539 +
75540 + struct compat_rlimit res[GR_NLIMITS];
75541 + __u32 resmask;
75542 +
75543 + __u8 user_trans_type;
75544 + __u8 group_trans_type;
75545 + compat_uptr_t user_transitions;
75546 + compat_uptr_t group_transitions;
75547 + __u16 user_trans_num;
75548 + __u16 group_trans_num;
75549 +
75550 + __u32 sock_families[2];
75551 + __u32 ip_proto[8];
75552 + __u32 ip_type;
75553 + compat_uptr_t ips;
75554 + __u32 ip_num;
75555 + __u32 inaddr_any_override;
75556 +
75557 + __u32 crashes;
75558 + compat_ulong_t expires;
75559 +
75560 + compat_uptr_t parent_subject;
75561 + compat_uptr_t hash;
75562 + compat_uptr_t prev;
75563 + compat_uptr_t next;
75564 +
75565 + compat_uptr_t obj_hash;
75566 + __u32 obj_hash_size;
75567 + __u16 pax_flags;
75568 +};
75569 +
75570 +struct role_allowed_ip_compat {
75571 + __u32 addr;
75572 + __u32 netmask;
75573 +
75574 + compat_uptr_t prev;
75575 + compat_uptr_t next;
75576 +};
75577 +
75578 +struct role_transition_compat {
75579 + compat_uptr_t rolename;
75580 +
75581 + compat_uptr_t prev;
75582 + compat_uptr_t next;
75583 +};
75584 +
75585 +struct acl_role_label_compat {
75586 + compat_uptr_t rolename;
75587 + uid_t uidgid;
75588 + __u16 roletype;
75589 +
75590 + __u16 auth_attempts;
75591 + compat_ulong_t expires;
75592 +
75593 + compat_uptr_t root_label;
75594 + compat_uptr_t hash;
75595 +
75596 + compat_uptr_t prev;
75597 + compat_uptr_t next;
75598 +
75599 + compat_uptr_t transitions;
75600 + compat_uptr_t allowed_ips;
75601 + compat_uptr_t domain_children;
75602 + __u16 domain_child_num;
75603 +
75604 + umode_t umask;
75605 +
75606 + compat_uptr_t subj_hash;
75607 + __u32 subj_hash_size;
75608 +};
75609 +
75610 +struct user_acl_role_db_compat {
75611 + compat_uptr_t r_table;
75612 + __u32 num_pointers;
75613 + __u32 num_roles;
75614 + __u32 num_domain_children;
75615 + __u32 num_subjects;
75616 + __u32 num_objects;
75617 +};
75618 +
75619 +struct acl_object_label_compat {
75620 + compat_uptr_t filename;
75621 + compat_ino_t inode;
75622 + __u32 device;
75623 + __u32 mode;
75624 +
75625 + compat_uptr_t nested;
75626 + compat_uptr_t globbed;
75627 +
75628 + compat_uptr_t prev;
75629 + compat_uptr_t next;
75630 +};
75631 +
75632 +struct acl_ip_label_compat {
75633 + compat_uptr_t iface;
75634 + __u32 addr;
75635 + __u32 netmask;
75636 + __u16 low, high;
75637 + __u8 mode;
75638 + __u32 type;
75639 + __u32 proto[8];
75640 +
75641 + compat_uptr_t prev;
75642 + compat_uptr_t next;
75643 +};
75644 +
75645 +struct gr_arg_compat {
75646 + struct user_acl_role_db_compat role_db;
75647 + unsigned char pw[GR_PW_LEN];
75648 + unsigned char salt[GR_SALT_LEN];
75649 + unsigned char sum[GR_SHA_LEN];
75650 + unsigned char sp_role[GR_SPROLE_LEN];
75651 + compat_uptr_t sprole_pws;
75652 + __u32 segv_device;
75653 + compat_ino_t segv_inode;
75654 + uid_t segv_uid;
75655 + __u16 num_sprole_pws;
75656 + __u16 mode;
75657 +};
75658 +
75659 +struct gr_arg_wrapper_compat {
75660 + compat_uptr_t arg;
75661 + __u32 version;
75662 + __u32 size;
75663 +};
75664 +
75665 +#endif
75666 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
75667 new file mode 100644
75668 index 0000000..323ecf2
75669 --- /dev/null
75670 +++ b/include/linux/gralloc.h
75671 @@ -0,0 +1,9 @@
75672 +#ifndef __GRALLOC_H
75673 +#define __GRALLOC_H
75674 +
75675 +void acl_free_all(void);
75676 +int acl_alloc_stack_init(unsigned long size);
75677 +void *acl_alloc(unsigned long len);
75678 +void *acl_alloc_num(unsigned long num, unsigned long len);
75679 +
75680 +#endif
75681 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
75682 new file mode 100644
75683 index 0000000..be66033
75684 --- /dev/null
75685 +++ b/include/linux/grdefs.h
75686 @@ -0,0 +1,140 @@
75687 +#ifndef GRDEFS_H
75688 +#define GRDEFS_H
75689 +
75690 +/* Begin grsecurity status declarations */
75691 +
75692 +enum {
75693 + GR_READY = 0x01,
75694 + GR_STATUS_INIT = 0x00 // disabled state
75695 +};
75696 +
75697 +/* Begin ACL declarations */
75698 +
75699 +/* Role flags */
75700 +
75701 +enum {
75702 + GR_ROLE_USER = 0x0001,
75703 + GR_ROLE_GROUP = 0x0002,
75704 + GR_ROLE_DEFAULT = 0x0004,
75705 + GR_ROLE_SPECIAL = 0x0008,
75706 + GR_ROLE_AUTH = 0x0010,
75707 + GR_ROLE_NOPW = 0x0020,
75708 + GR_ROLE_GOD = 0x0040,
75709 + GR_ROLE_LEARN = 0x0080,
75710 + GR_ROLE_TPE = 0x0100,
75711 + GR_ROLE_DOMAIN = 0x0200,
75712 + GR_ROLE_PAM = 0x0400,
75713 + GR_ROLE_PERSIST = 0x0800
75714 +};
75715 +
75716 +/* ACL Subject and Object mode flags */
75717 +enum {
75718 + GR_DELETED = 0x80000000
75719 +};
75720 +
75721 +/* ACL Object-only mode flags */
75722 +enum {
75723 + GR_READ = 0x00000001,
75724 + GR_APPEND = 0x00000002,
75725 + GR_WRITE = 0x00000004,
75726 + GR_EXEC = 0x00000008,
75727 + GR_FIND = 0x00000010,
75728 + GR_INHERIT = 0x00000020,
75729 + GR_SETID = 0x00000040,
75730 + GR_CREATE = 0x00000080,
75731 + GR_DELETE = 0x00000100,
75732 + GR_LINK = 0x00000200,
75733 + GR_AUDIT_READ = 0x00000400,
75734 + GR_AUDIT_APPEND = 0x00000800,
75735 + GR_AUDIT_WRITE = 0x00001000,
75736 + GR_AUDIT_EXEC = 0x00002000,
75737 + GR_AUDIT_FIND = 0x00004000,
75738 + GR_AUDIT_INHERIT= 0x00008000,
75739 + GR_AUDIT_SETID = 0x00010000,
75740 + GR_AUDIT_CREATE = 0x00020000,
75741 + GR_AUDIT_DELETE = 0x00040000,
75742 + GR_AUDIT_LINK = 0x00080000,
75743 + GR_PTRACERD = 0x00100000,
75744 + GR_NOPTRACE = 0x00200000,
75745 + GR_SUPPRESS = 0x00400000,
75746 + GR_NOLEARN = 0x00800000,
75747 + GR_INIT_TRANSFER= 0x01000000
75748 +};
75749 +
75750 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
75751 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
75752 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
75753 +
75754 +/* ACL subject-only mode flags */
75755 +enum {
75756 + GR_KILL = 0x00000001,
75757 + GR_VIEW = 0x00000002,
75758 + GR_PROTECTED = 0x00000004,
75759 + GR_LEARN = 0x00000008,
75760 + GR_OVERRIDE = 0x00000010,
75761 + /* just a placeholder, this mode is only used in userspace */
75762 + GR_DUMMY = 0x00000020,
75763 + GR_PROTSHM = 0x00000040,
75764 + GR_KILLPROC = 0x00000080,
75765 + GR_KILLIPPROC = 0x00000100,
75766 + /* just a placeholder, this mode is only used in userspace */
75767 + GR_NOTROJAN = 0x00000200,
75768 + GR_PROTPROCFD = 0x00000400,
75769 + GR_PROCACCT = 0x00000800,
75770 + GR_RELAXPTRACE = 0x00001000,
75771 + //GR_NESTED = 0x00002000,
75772 + GR_INHERITLEARN = 0x00004000,
75773 + GR_PROCFIND = 0x00008000,
75774 + GR_POVERRIDE = 0x00010000,
75775 + GR_KERNELAUTH = 0x00020000,
75776 + GR_ATSECURE = 0x00040000,
75777 + GR_SHMEXEC = 0x00080000
75778 +};
75779 +
75780 +enum {
75781 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
75782 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
75783 + GR_PAX_ENABLE_MPROTECT = 0x0004,
75784 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
75785 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
75786 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
75787 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
75788 + GR_PAX_DISABLE_MPROTECT = 0x0400,
75789 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
75790 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
75791 +};
75792 +
75793 +enum {
75794 + GR_ID_USER = 0x01,
75795 + GR_ID_GROUP = 0x02,
75796 +};
75797 +
75798 +enum {
75799 + GR_ID_ALLOW = 0x01,
75800 + GR_ID_DENY = 0x02,
75801 +};
75802 +
75803 +#define GR_CRASH_RES 31
75804 +#define GR_UIDTABLE_MAX 500
75805 +
75806 +/* begin resource learning section */
75807 +enum {
75808 + GR_RLIM_CPU_BUMP = 60,
75809 + GR_RLIM_FSIZE_BUMP = 50000,
75810 + GR_RLIM_DATA_BUMP = 10000,
75811 + GR_RLIM_STACK_BUMP = 1000,
75812 + GR_RLIM_CORE_BUMP = 10000,
75813 + GR_RLIM_RSS_BUMP = 500000,
75814 + GR_RLIM_NPROC_BUMP = 1,
75815 + GR_RLIM_NOFILE_BUMP = 5,
75816 + GR_RLIM_MEMLOCK_BUMP = 50000,
75817 + GR_RLIM_AS_BUMP = 500000,
75818 + GR_RLIM_LOCKS_BUMP = 2,
75819 + GR_RLIM_SIGPENDING_BUMP = 5,
75820 + GR_RLIM_MSGQUEUE_BUMP = 10000,
75821 + GR_RLIM_NICE_BUMP = 1,
75822 + GR_RLIM_RTPRIO_BUMP = 1,
75823 + GR_RLIM_RTTIME_BUMP = 1000000
75824 +};
75825 +
75826 +#endif
75827 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
75828 new file mode 100644
75829 index 0000000..d25522e
75830 --- /dev/null
75831 +++ b/include/linux/grinternal.h
75832 @@ -0,0 +1,229 @@
75833 +#ifndef __GRINTERNAL_H
75834 +#define __GRINTERNAL_H
75835 +
75836 +#ifdef CONFIG_GRKERNSEC
75837 +
75838 +#include <linux/fs.h>
75839 +#include <linux/mnt_namespace.h>
75840 +#include <linux/nsproxy.h>
75841 +#include <linux/gracl.h>
75842 +#include <linux/grdefs.h>
75843 +#include <linux/grmsg.h>
75844 +
75845 +void gr_add_learn_entry(const char *fmt, ...)
75846 + __attribute__ ((format (printf, 1, 2)));
75847 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
75848 + const struct vfsmount *mnt);
75849 +__u32 gr_check_create(const struct dentry *new_dentry,
75850 + const struct dentry *parent,
75851 + const struct vfsmount *mnt, const __u32 mode);
75852 +int gr_check_protected_task(const struct task_struct *task);
75853 +__u32 to_gr_audit(const __u32 reqmode);
75854 +int gr_set_acls(const int type);
75855 +int gr_acl_is_enabled(void);
75856 +char gr_roletype_to_char(void);
75857 +
75858 +void gr_handle_alertkill(struct task_struct *task);
75859 +char *gr_to_filename(const struct dentry *dentry,
75860 + const struct vfsmount *mnt);
75861 +char *gr_to_filename1(const struct dentry *dentry,
75862 + const struct vfsmount *mnt);
75863 +char *gr_to_filename2(const struct dentry *dentry,
75864 + const struct vfsmount *mnt);
75865 +char *gr_to_filename3(const struct dentry *dentry,
75866 + const struct vfsmount *mnt);
75867 +
75868 +extern int grsec_enable_ptrace_readexec;
75869 +extern int grsec_enable_harden_ptrace;
75870 +extern int grsec_enable_link;
75871 +extern int grsec_enable_fifo;
75872 +extern int grsec_enable_execve;
75873 +extern int grsec_enable_shm;
75874 +extern int grsec_enable_execlog;
75875 +extern int grsec_enable_signal;
75876 +extern int grsec_enable_audit_ptrace;
75877 +extern int grsec_enable_forkfail;
75878 +extern int grsec_enable_time;
75879 +extern int grsec_enable_rofs;
75880 +extern int grsec_deny_new_usb;
75881 +extern int grsec_enable_chroot_shmat;
75882 +extern int grsec_enable_chroot_mount;
75883 +extern int grsec_enable_chroot_double;
75884 +extern int grsec_enable_chroot_pivot;
75885 +extern int grsec_enable_chroot_chdir;
75886 +extern int grsec_enable_chroot_chmod;
75887 +extern int grsec_enable_chroot_mknod;
75888 +extern int grsec_enable_chroot_fchdir;
75889 +extern int grsec_enable_chroot_nice;
75890 +extern int grsec_enable_chroot_execlog;
75891 +extern int grsec_enable_chroot_caps;
75892 +extern int grsec_enable_chroot_sysctl;
75893 +extern int grsec_enable_chroot_unix;
75894 +extern int grsec_enable_symlinkown;
75895 +extern kgid_t grsec_symlinkown_gid;
75896 +extern int grsec_enable_tpe;
75897 +extern kgid_t grsec_tpe_gid;
75898 +extern int grsec_enable_tpe_all;
75899 +extern int grsec_enable_tpe_invert;
75900 +extern int grsec_enable_socket_all;
75901 +extern kgid_t grsec_socket_all_gid;
75902 +extern int grsec_enable_socket_client;
75903 +extern kgid_t grsec_socket_client_gid;
75904 +extern int grsec_enable_socket_server;
75905 +extern kgid_t grsec_socket_server_gid;
75906 +extern kgid_t grsec_audit_gid;
75907 +extern int grsec_enable_group;
75908 +extern int grsec_enable_log_rwxmaps;
75909 +extern int grsec_enable_mount;
75910 +extern int grsec_enable_chdir;
75911 +extern int grsec_resource_logging;
75912 +extern int grsec_enable_blackhole;
75913 +extern int grsec_lastack_retries;
75914 +extern int grsec_enable_brute;
75915 +extern int grsec_enable_harden_ipc;
75916 +extern int grsec_lock;
75917 +
75918 +extern spinlock_t grsec_alert_lock;
75919 +extern unsigned long grsec_alert_wtime;
75920 +extern unsigned long grsec_alert_fyet;
75921 +
75922 +extern spinlock_t grsec_audit_lock;
75923 +
75924 +extern rwlock_t grsec_exec_file_lock;
75925 +
75926 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
75927 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
75928 + (tsk)->exec_file->f_path.mnt) : "/")
75929 +
75930 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
75931 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
75932 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
75933 +
75934 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
75935 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
75936 + (tsk)->exec_file->f_path.mnt) : "/")
75937 +
75938 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
75939 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
75940 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
75941 +
75942 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
75943 +
75944 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
75945 +
75946 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
75947 +{
75948 + if (file1 && file2) {
75949 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
75950 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
75951 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
75952 + return true;
75953 + }
75954 +
75955 + return false;
75956 +}
75957 +
75958 +#define GR_CHROOT_CAPS {{ \
75959 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
75960 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
75961 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
75962 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
75963 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
75964 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
75965 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
75966 +
75967 +#define security_learn(normal_msg,args...) \
75968 +({ \
75969 + read_lock(&grsec_exec_file_lock); \
75970 + gr_add_learn_entry(normal_msg "\n", ## args); \
75971 + read_unlock(&grsec_exec_file_lock); \
75972 +})
75973 +
75974 +enum {
75975 + GR_DO_AUDIT,
75976 + GR_DONT_AUDIT,
75977 + /* used for non-audit messages that we shouldn't kill the task on */
75978 + GR_DONT_AUDIT_GOOD
75979 +};
75980 +
75981 +enum {
75982 + GR_TTYSNIFF,
75983 + GR_RBAC,
75984 + GR_RBAC_STR,
75985 + GR_STR_RBAC,
75986 + GR_RBAC_MODE2,
75987 + GR_RBAC_MODE3,
75988 + GR_FILENAME,
75989 + GR_SYSCTL_HIDDEN,
75990 + GR_NOARGS,
75991 + GR_ONE_INT,
75992 + GR_ONE_INT_TWO_STR,
75993 + GR_ONE_STR,
75994 + GR_STR_INT,
75995 + GR_TWO_STR_INT,
75996 + GR_TWO_INT,
75997 + GR_TWO_U64,
75998 + GR_THREE_INT,
75999 + GR_FIVE_INT_TWO_STR,
76000 + GR_TWO_STR,
76001 + GR_THREE_STR,
76002 + GR_FOUR_STR,
76003 + GR_STR_FILENAME,
76004 + GR_FILENAME_STR,
76005 + GR_FILENAME_TWO_INT,
76006 + GR_FILENAME_TWO_INT_STR,
76007 + GR_TEXTREL,
76008 + GR_PTRACE,
76009 + GR_RESOURCE,
76010 + GR_CAP,
76011 + GR_SIG,
76012 + GR_SIG2,
76013 + GR_CRASH1,
76014 + GR_CRASH2,
76015 + GR_PSACCT,
76016 + GR_RWXMAP,
76017 + GR_RWXMAPVMA
76018 +};
76019 +
76020 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
76021 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
76022 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
76023 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
76024 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
76025 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
76026 +#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)
76027 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
76028 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
76029 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
76030 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
76031 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
76032 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
76033 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
76034 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
76035 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
76036 +#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)
76037 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
76038 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
76039 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
76040 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
76041 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
76042 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
76043 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
76044 +#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)
76045 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
76046 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
76047 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
76048 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
76049 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
76050 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
76051 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
76052 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
76053 +#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)
76054 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
76055 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
76056 +
76057 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
76058 +
76059 +#endif
76060 +
76061 +#endif
76062 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
76063 new file mode 100644
76064 index 0000000..195cbe4
76065 --- /dev/null
76066 +++ b/include/linux/grmsg.h
76067 @@ -0,0 +1,115 @@
76068 +#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"
76069 +#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"
76070 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
76071 +#define GR_STOPMOD_MSG "denied modification of module state by "
76072 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
76073 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
76074 +#define GR_IOPERM_MSG "denied use of ioperm() by "
76075 +#define GR_IOPL_MSG "denied use of iopl() by "
76076 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
76077 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
76078 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
76079 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
76080 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
76081 +#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"
76082 +#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"
76083 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
76084 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
76085 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
76086 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
76087 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
76088 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
76089 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
76090 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
76091 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
76092 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
76093 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
76094 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
76095 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
76096 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
76097 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
76098 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
76099 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
76100 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
76101 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
76102 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
76103 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
76104 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
76105 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
76106 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
76107 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
76108 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
76109 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
76110 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
76111 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
76112 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
76113 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
76114 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
76115 +#define GR_SETXATTR_ACL_MSG "%s setting extended attribute of %.950s by "
76116 +#define GR_REMOVEXATTR_ACL_MSG "%s removing extended attribute of %.950s by "
76117 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
76118 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
76119 +#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"
76120 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
76121 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
76122 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
76123 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
76124 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
76125 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
76126 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
76127 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
76128 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
76129 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
76130 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
76131 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
76132 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
76133 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
76134 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
76135 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
76136 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
76137 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
76138 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
76139 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
76140 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
76141 +#define GR_NICE_CHROOT_MSG "denied priority change by "
76142 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
76143 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
76144 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
76145 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
76146 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
76147 +#define GR_TIME_MSG "time set by "
76148 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
76149 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
76150 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
76151 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
76152 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
76153 +#define GR_BIND_MSG "denied bind() by "
76154 +#define GR_CONNECT_MSG "denied connect() by "
76155 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
76156 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
76157 +#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"
76158 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
76159 +#define GR_CAP_ACL_MSG "use of %s denied for "
76160 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
76161 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
76162 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
76163 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
76164 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
76165 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
76166 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
76167 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
76168 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
76169 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
76170 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
76171 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
76172 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
76173 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
76174 +#define GR_VM86_MSG "denied use of vm86 by "
76175 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
76176 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
76177 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
76178 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
76179 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
76180 +#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 "
76181 +#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 "
76182 +#define GR_IPC_DENIED_MSG "denied %s of overly-permissive IPC object with creator uid %u by "
76183 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
76184 new file mode 100644
76185 index 0000000..d8b5b48
76186 --- /dev/null
76187 +++ b/include/linux/grsecurity.h
76188 @@ -0,0 +1,245 @@
76189 +#ifndef GR_SECURITY_H
76190 +#define GR_SECURITY_H
76191 +#include <linux/fs.h>
76192 +#include <linux/fs_struct.h>
76193 +#include <linux/binfmts.h>
76194 +#include <linux/gracl.h>
76195 +
76196 +/* notify of brain-dead configs */
76197 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76198 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
76199 +#endif
76200 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
76201 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
76202 +#endif
76203 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
76204 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
76205 +#endif
76206 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
76207 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
76208 +#endif
76209 +
76210 +int gr_handle_new_usb(void);
76211 +
76212 +void gr_handle_brute_attach(int dumpable);
76213 +void gr_handle_brute_check(void);
76214 +void gr_handle_kernel_exploit(void);
76215 +
76216 +char gr_roletype_to_char(void);
76217 +
76218 +int gr_acl_enable_at_secure(void);
76219 +
76220 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
76221 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
76222 +
76223 +void gr_del_task_from_ip_table(struct task_struct *p);
76224 +
76225 +int gr_pid_is_chrooted(struct task_struct *p);
76226 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
76227 +int gr_handle_chroot_nice(void);
76228 +int gr_handle_chroot_sysctl(const int op);
76229 +int gr_handle_chroot_setpriority(struct task_struct *p,
76230 + const int niceval);
76231 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
76232 +int gr_handle_chroot_chroot(const struct dentry *dentry,
76233 + const struct vfsmount *mnt);
76234 +void gr_handle_chroot_chdir(const struct path *path);
76235 +int gr_handle_chroot_chmod(const struct dentry *dentry,
76236 + const struct vfsmount *mnt, const int mode);
76237 +int gr_handle_chroot_mknod(const struct dentry *dentry,
76238 + const struct vfsmount *mnt, const int mode);
76239 +int gr_handle_chroot_mount(const struct dentry *dentry,
76240 + const struct vfsmount *mnt,
76241 + const char *dev_name);
76242 +int gr_handle_chroot_pivot(void);
76243 +int gr_handle_chroot_unix(const pid_t pid);
76244 +
76245 +int gr_handle_rawio(const struct inode *inode);
76246 +
76247 +void gr_handle_ioperm(void);
76248 +void gr_handle_iopl(void);
76249 +
76250 +umode_t gr_acl_umask(void);
76251 +
76252 +int gr_tpe_allow(const struct file *file);
76253 +
76254 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
76255 +void gr_clear_chroot_entries(struct task_struct *task);
76256 +
76257 +void gr_log_forkfail(const int retval);
76258 +void gr_log_timechange(void);
76259 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
76260 +void gr_log_chdir(const struct dentry *dentry,
76261 + const struct vfsmount *mnt);
76262 +void gr_log_chroot_exec(const struct dentry *dentry,
76263 + const struct vfsmount *mnt);
76264 +void gr_log_remount(const char *devname, const int retval);
76265 +void gr_log_unmount(const char *devname, const int retval);
76266 +void gr_log_mount(const char *from, const char *to, const int retval);
76267 +void gr_log_textrel(struct vm_area_struct *vma);
76268 +void gr_log_ptgnustack(struct file *file);
76269 +void gr_log_rwxmmap(struct file *file);
76270 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
76271 +
76272 +int gr_handle_follow_link(const struct inode *parent,
76273 + const struct inode *inode,
76274 + const struct dentry *dentry,
76275 + const struct vfsmount *mnt);
76276 +int gr_handle_fifo(const struct dentry *dentry,
76277 + const struct vfsmount *mnt,
76278 + const struct dentry *dir, const int flag,
76279 + const int acc_mode);
76280 +int gr_handle_hardlink(const struct dentry *dentry,
76281 + const struct vfsmount *mnt,
76282 + struct inode *inode,
76283 + const int mode, const struct filename *to);
76284 +
76285 +int gr_is_capable(const int cap);
76286 +int gr_is_capable_nolog(const int cap);
76287 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
76288 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
76289 +
76290 +void gr_copy_label(struct task_struct *tsk);
76291 +void gr_handle_crash(struct task_struct *task, const int sig);
76292 +int gr_handle_signal(const struct task_struct *p, const int sig);
76293 +int gr_check_crash_uid(const kuid_t uid);
76294 +int gr_check_protected_task(const struct task_struct *task);
76295 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
76296 +int gr_acl_handle_mmap(const struct file *file,
76297 + const unsigned long prot);
76298 +int gr_acl_handle_mprotect(const struct file *file,
76299 + const unsigned long prot);
76300 +int gr_check_hidden_task(const struct task_struct *tsk);
76301 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
76302 + const struct vfsmount *mnt);
76303 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
76304 + const struct vfsmount *mnt);
76305 +__u32 gr_acl_handle_access(const struct dentry *dentry,
76306 + const struct vfsmount *mnt, const int fmode);
76307 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
76308 + const struct vfsmount *mnt, umode_t *mode);
76309 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
76310 + const struct vfsmount *mnt);
76311 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
76312 + const struct vfsmount *mnt);
76313 +__u32 gr_acl_handle_removexattr(const struct dentry *dentry,
76314 + const struct vfsmount *mnt);
76315 +int gr_handle_ptrace(struct task_struct *task, const long request);
76316 +int gr_handle_proc_ptrace(struct task_struct *task);
76317 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
76318 + const struct vfsmount *mnt);
76319 +int gr_check_crash_exec(const struct file *filp);
76320 +int gr_acl_is_enabled(void);
76321 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
76322 + const kgid_t gid);
76323 +int gr_set_proc_label(const struct dentry *dentry,
76324 + const struct vfsmount *mnt,
76325 + const int unsafe_flags);
76326 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
76327 + const struct vfsmount *mnt);
76328 +__u32 gr_acl_handle_open(const struct dentry *dentry,
76329 + const struct vfsmount *mnt, int acc_mode);
76330 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
76331 + const struct dentry *p_dentry,
76332 + const struct vfsmount *p_mnt,
76333 + int open_flags, int acc_mode, const int imode);
76334 +void gr_handle_create(const struct dentry *dentry,
76335 + const struct vfsmount *mnt);
76336 +void gr_handle_proc_create(const struct dentry *dentry,
76337 + const struct inode *inode);
76338 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
76339 + const struct dentry *parent_dentry,
76340 + const struct vfsmount *parent_mnt,
76341 + const int mode);
76342 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
76343 + const struct dentry *parent_dentry,
76344 + const struct vfsmount *parent_mnt);
76345 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
76346 + const struct vfsmount *mnt);
76347 +void gr_handle_delete(const ino_t ino, const dev_t dev);
76348 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
76349 + const struct vfsmount *mnt);
76350 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
76351 + const struct dentry *parent_dentry,
76352 + const struct vfsmount *parent_mnt,
76353 + const struct filename *from);
76354 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
76355 + const struct dentry *parent_dentry,
76356 + const struct vfsmount *parent_mnt,
76357 + const struct dentry *old_dentry,
76358 + const struct vfsmount *old_mnt, const struct filename *to);
76359 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
76360 +int gr_acl_handle_rename(struct dentry *new_dentry,
76361 + struct dentry *parent_dentry,
76362 + const struct vfsmount *parent_mnt,
76363 + struct dentry *old_dentry,
76364 + struct inode *old_parent_inode,
76365 + struct vfsmount *old_mnt, const struct filename *newname);
76366 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
76367 + struct dentry *old_dentry,
76368 + struct dentry *new_dentry,
76369 + struct vfsmount *mnt, const __u8 replace);
76370 +__u32 gr_check_link(const struct dentry *new_dentry,
76371 + const struct dentry *parent_dentry,
76372 + const struct vfsmount *parent_mnt,
76373 + const struct dentry *old_dentry,
76374 + const struct vfsmount *old_mnt);
76375 +int gr_acl_handle_filldir(const struct file *file, const char *name,
76376 + const unsigned int namelen, const ino_t ino);
76377 +
76378 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
76379 + const struct vfsmount *mnt);
76380 +void gr_acl_handle_exit(void);
76381 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
76382 +int gr_acl_handle_procpidmem(const struct task_struct *task);
76383 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
76384 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
76385 +void gr_audit_ptrace(struct task_struct *task);
76386 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
76387 +void gr_put_exec_file(struct task_struct *task);
76388 +
76389 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
76390 +
76391 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
76392 +extern void gr_learn_resource(const struct task_struct *task, const int res,
76393 + const unsigned long wanted, const int gt);
76394 +#else
76395 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
76396 + const unsigned long wanted, const int gt)
76397 +{
76398 +}
76399 +#endif
76400 +
76401 +#ifdef CONFIG_GRKERNSEC_RESLOG
76402 +extern void gr_log_resource(const struct task_struct *task, const int res,
76403 + const unsigned long wanted, const int gt);
76404 +#else
76405 +static inline void gr_log_resource(const struct task_struct *task, const int res,
76406 + const unsigned long wanted, const int gt)
76407 +{
76408 +}
76409 +#endif
76410 +
76411 +#ifdef CONFIG_GRKERNSEC
76412 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
76413 +void gr_handle_vm86(void);
76414 +void gr_handle_mem_readwrite(u64 from, u64 to);
76415 +
76416 +void gr_log_badprocpid(const char *entry);
76417 +
76418 +extern int grsec_enable_dmesg;
76419 +extern int grsec_disable_privio;
76420 +
76421 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
76422 +extern kgid_t grsec_proc_gid;
76423 +#endif
76424 +
76425 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
76426 +extern int grsec_enable_chroot_findtask;
76427 +#endif
76428 +#ifdef CONFIG_GRKERNSEC_SETXID
76429 +extern int grsec_enable_setxid;
76430 +#endif
76431 +#endif
76432 +
76433 +#endif
76434 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
76435 new file mode 100644
76436 index 0000000..e7ffaaf
76437 --- /dev/null
76438 +++ b/include/linux/grsock.h
76439 @@ -0,0 +1,19 @@
76440 +#ifndef __GRSOCK_H
76441 +#define __GRSOCK_H
76442 +
76443 +extern void gr_attach_curr_ip(const struct sock *sk);
76444 +extern int gr_handle_sock_all(const int family, const int type,
76445 + const int protocol);
76446 +extern int gr_handle_sock_server(const struct sockaddr *sck);
76447 +extern int gr_handle_sock_server_other(const struct sock *sck);
76448 +extern int gr_handle_sock_client(const struct sockaddr *sck);
76449 +extern int gr_search_connect(struct socket * sock,
76450 + struct sockaddr_in * addr);
76451 +extern int gr_search_bind(struct socket * sock,
76452 + struct sockaddr_in * addr);
76453 +extern int gr_search_listen(struct socket * sock);
76454 +extern int gr_search_accept(struct socket * sock);
76455 +extern int gr_search_socket(const int domain, const int type,
76456 + const int protocol);
76457 +
76458 +#endif
76459 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
76460 index 7fb31da..08b5114 100644
76461 --- a/include/linux/highmem.h
76462 +++ b/include/linux/highmem.h
76463 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
76464 kunmap_atomic(kaddr);
76465 }
76466
76467 +static inline void sanitize_highpage(struct page *page)
76468 +{
76469 + void *kaddr;
76470 + unsigned long flags;
76471 +
76472 + local_irq_save(flags);
76473 + kaddr = kmap_atomic(page);
76474 + clear_page(kaddr);
76475 + kunmap_atomic(kaddr);
76476 + local_irq_restore(flags);
76477 +}
76478 +
76479 static inline void zero_user_segments(struct page *page,
76480 unsigned start1, unsigned end1,
76481 unsigned start2, unsigned end2)
76482 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
76483 index 1c7b89a..7dda400 100644
76484 --- a/include/linux/hwmon-sysfs.h
76485 +++ b/include/linux/hwmon-sysfs.h
76486 @@ -25,7 +25,8 @@
76487 struct sensor_device_attribute{
76488 struct device_attribute dev_attr;
76489 int index;
76490 -};
76491 +} __do_const;
76492 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
76493 #define to_sensor_dev_attr(_dev_attr) \
76494 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
76495
76496 @@ -41,7 +42,8 @@ struct sensor_device_attribute_2 {
76497 struct device_attribute dev_attr;
76498 u8 index;
76499 u8 nr;
76500 -};
76501 +} __do_const;
76502 +typedef struct sensor_device_attribute_2 __no_const sensor_device_attribute_2_no_const;
76503 #define to_sensor_dev_attr_2(_dev_attr) \
76504 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
76505
76506 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
76507 index 2ab11dc..663a3f2 100644
76508 --- a/include/linux/i2c.h
76509 +++ b/include/linux/i2c.h
76510 @@ -366,6 +366,7 @@ struct i2c_algorithm {
76511 /* To determine what the adapter supports */
76512 u32 (*functionality) (struct i2c_adapter *);
76513 };
76514 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
76515
76516 /**
76517 * struct i2c_bus_recovery_info - I2C bus recovery information
76518 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
76519 index d23c3c2..eb63c81 100644
76520 --- a/include/linux/i2o.h
76521 +++ b/include/linux/i2o.h
76522 @@ -565,7 +565,7 @@ struct i2o_controller {
76523 struct i2o_device *exec; /* Executive */
76524 #if BITS_PER_LONG == 64
76525 spinlock_t context_list_lock; /* lock for context_list */
76526 - atomic_t context_list_counter; /* needed for unique contexts */
76527 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
76528 struct list_head context_list; /* list of context id's
76529 and pointers */
76530 #endif
76531 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
76532 index aff7ad8..3942bbd 100644
76533 --- a/include/linux/if_pppox.h
76534 +++ b/include/linux/if_pppox.h
76535 @@ -76,7 +76,7 @@ struct pppox_proto {
76536 int (*ioctl)(struct socket *sock, unsigned int cmd,
76537 unsigned long arg);
76538 struct module *owner;
76539 -};
76540 +} __do_const;
76541
76542 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
76543 extern void unregister_pppox_proto(int proto_num);
76544 diff --git a/include/linux/init.h b/include/linux/init.h
76545 index f1c27a71..7d6010e 100644
76546 --- a/include/linux/init.h
76547 +++ b/include/linux/init.h
76548 @@ -39,9 +39,17 @@
76549 * Also note, that this data cannot be "const".
76550 */
76551
76552 +#define add_init_latent_entropy __latent_entropy
76553 +
76554 +#ifdef CONFIG_MEMORY_HOTPLUG
76555 +#define add_meminit_latent_entropy
76556 +#else
76557 +#define add_meminit_latent_entropy __latent_entropy
76558 +#endif
76559 +
76560 /* These are for everybody (although not all archs will actually
76561 discard it in modules) */
76562 -#define __init __section(.init.text) __cold notrace
76563 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
76564 #define __initdata __section(.init.data)
76565 #define __initconst __constsection(.init.rodata)
76566 #define __exitdata __section(.exit.data)
76567 @@ -102,7 +110,7 @@
76568 #define __cpuexitconst
76569
76570 /* Used for MEMORY_HOTPLUG */
76571 -#define __meminit __section(.meminit.text) __cold notrace
76572 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
76573 #define __meminitdata __section(.meminit.data)
76574 #define __meminitconst __constsection(.meminit.rodata)
76575 #define __memexit __section(.memexit.text) __exitused __cold notrace
76576 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
76577 index 5cd0f09..c9f67cc 100644
76578 --- a/include/linux/init_task.h
76579 +++ b/include/linux/init_task.h
76580 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
76581
76582 #define INIT_TASK_COMM "swapper"
76583
76584 +#ifdef CONFIG_X86
76585 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
76586 +#else
76587 +#define INIT_TASK_THREAD_INFO
76588 +#endif
76589 +
76590 /*
76591 * INIT_TASK is used to set up the first task table, touch at
76592 * your own risk!. Base=0, limit=0x1fffff (=2MB)
76593 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
76594 RCU_POINTER_INITIALIZER(cred, &init_cred), \
76595 .comm = INIT_TASK_COMM, \
76596 .thread = INIT_THREAD, \
76597 + INIT_TASK_THREAD_INFO \
76598 .fs = &init_fs, \
76599 .files = &init_files, \
76600 .signal = &init_signals, \
76601 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
76602 index 5e865b5..71bd258 100644
76603 --- a/include/linux/interrupt.h
76604 +++ b/include/linux/interrupt.h
76605 @@ -361,7 +361,7 @@ enum
76606 /* map softirq index to softirq name. update 'softirq_to_name' in
76607 * kernel/softirq.c when adding a new softirq.
76608 */
76609 -extern char *softirq_to_name[NR_SOFTIRQS];
76610 +extern const char * const softirq_to_name[NR_SOFTIRQS];
76611
76612 /* softirq mask and active fields moved to irq_cpustat_t in
76613 * asm/hardirq.h to get better cache usage. KAO
76614 @@ -369,12 +369,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
76615
76616 struct softirq_action
76617 {
76618 - void (*action)(struct softirq_action *);
76619 -};
76620 + void (*action)(void);
76621 +} __no_const;
76622
76623 asmlinkage void do_softirq(void);
76624 asmlinkage void __do_softirq(void);
76625 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
76626 +extern void open_softirq(int nr, void (*action)(void));
76627 extern void softirq_init(void);
76628 extern void __raise_softirq_irqoff(unsigned int nr);
76629
76630 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
76631 index 7ea319e..f9e971d 100644
76632 --- a/include/linux/iommu.h
76633 +++ b/include/linux/iommu.h
76634 @@ -129,7 +129,7 @@ struct iommu_ops {
76635 u32 (*domain_get_windows)(struct iommu_domain *domain);
76636
76637 unsigned long pgsize_bitmap;
76638 -};
76639 +} __do_const;
76640
76641 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
76642 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
76643 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
76644 index 89b7c24..382af74 100644
76645 --- a/include/linux/ioport.h
76646 +++ b/include/linux/ioport.h
76647 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
76648 int adjust_resource(struct resource *res, resource_size_t start,
76649 resource_size_t size);
76650 resource_size_t resource_alignment(struct resource *res);
76651 -static inline resource_size_t resource_size(const struct resource *res)
76652 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
76653 {
76654 return res->end - res->start + 1;
76655 }
76656 diff --git a/include/linux/irq.h b/include/linux/irq.h
76657 index 56bb0dc..8ae94d62 100644
76658 --- a/include/linux/irq.h
76659 +++ b/include/linux/irq.h
76660 @@ -333,7 +333,8 @@ struct irq_chip {
76661 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
76662
76663 unsigned long flags;
76664 -};
76665 +} __do_const;
76666 +typedef struct irq_chip __no_const irq_chip_no_const;
76667
76668 /*
76669 * irq_chip specific flags
76670 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
76671 index 0e5d9ec..46acb3a 100644
76672 --- a/include/linux/irqchip/arm-gic.h
76673 +++ b/include/linux/irqchip/arm-gic.h
76674 @@ -59,9 +59,11 @@
76675
76676 #ifndef __ASSEMBLY__
76677
76678 +#include <linux/irq.h>
76679 +
76680 struct device_node;
76681
76682 -extern struct irq_chip gic_arch_extn;
76683 +extern irq_chip_no_const gic_arch_extn;
76684
76685 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
76686 u32 offset, struct device_node *);
76687 diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
76688 index d235e88..8ccbe74 100644
76689 --- a/include/linux/jiffies.h
76690 +++ b/include/linux/jiffies.h
76691 @@ -292,14 +292,14 @@ extern unsigned long preset_lpj;
76692 /*
76693 * Convert various time units to each other:
76694 */
76695 -extern unsigned int jiffies_to_msecs(const unsigned long j);
76696 -extern unsigned int jiffies_to_usecs(const unsigned long j);
76697 -extern unsigned long msecs_to_jiffies(const unsigned int m);
76698 -extern unsigned long usecs_to_jiffies(const unsigned int u);
76699 -extern unsigned long timespec_to_jiffies(const struct timespec *value);
76700 +extern unsigned int jiffies_to_msecs(const unsigned long j) __intentional_overflow(-1);
76701 +extern unsigned int jiffies_to_usecs(const unsigned long j) __intentional_overflow(-1);
76702 +extern unsigned long msecs_to_jiffies(const unsigned int m) __intentional_overflow(-1);
76703 +extern unsigned long usecs_to_jiffies(const unsigned int u) __intentional_overflow(-1);
76704 +extern unsigned long timespec_to_jiffies(const struct timespec *value) __intentional_overflow(-1);
76705 extern void jiffies_to_timespec(const unsigned long jiffies,
76706 struct timespec *value);
76707 -extern unsigned long timeval_to_jiffies(const struct timeval *value);
76708 +extern unsigned long timeval_to_jiffies(const struct timeval *value) __intentional_overflow(-1);
76709 extern void jiffies_to_timeval(const unsigned long jiffies,
76710 struct timeval *value);
76711
76712 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
76713 index 6883e19..e854fcb 100644
76714 --- a/include/linux/kallsyms.h
76715 +++ b/include/linux/kallsyms.h
76716 @@ -15,7 +15,8 @@
76717
76718 struct module;
76719
76720 -#ifdef CONFIG_KALLSYMS
76721 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
76722 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76723 /* Lookup the address for a symbol. Returns 0 if not found. */
76724 unsigned long kallsyms_lookup_name(const char *name);
76725
76726 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
76727 /* Stupid that this does nothing, but I didn't create this mess. */
76728 #define __print_symbol(fmt, addr)
76729 #endif /*CONFIG_KALLSYMS*/
76730 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
76731 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
76732 +extern unsigned long kallsyms_lookup_name(const char *name);
76733 +extern void __print_symbol(const char *fmt, unsigned long address);
76734 +extern int sprint_backtrace(char *buffer, unsigned long address);
76735 +extern int sprint_symbol(char *buffer, unsigned long address);
76736 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
76737 +const char *kallsyms_lookup(unsigned long addr,
76738 + unsigned long *symbolsize,
76739 + unsigned long *offset,
76740 + char **modname, char *namebuf);
76741 +extern int kallsyms_lookup_size_offset(unsigned long addr,
76742 + unsigned long *symbolsize,
76743 + unsigned long *offset);
76744 +#endif
76745
76746 /* This macro allows us to keep printk typechecking */
76747 static __printf(1, 2)
76748 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
76749 index 518a53a..5e28358 100644
76750 --- a/include/linux/key-type.h
76751 +++ b/include/linux/key-type.h
76752 @@ -125,7 +125,7 @@ struct key_type {
76753 /* internal fields */
76754 struct list_head link; /* link in types list */
76755 struct lock_class_key lock_class; /* key->sem lock class */
76756 -};
76757 +} __do_const;
76758
76759 extern struct key_type key_type_keyring;
76760
76761 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
76762 index c6e091b..a940adf 100644
76763 --- a/include/linux/kgdb.h
76764 +++ b/include/linux/kgdb.h
76765 @@ -52,7 +52,7 @@ extern int kgdb_connected;
76766 extern int kgdb_io_module_registered;
76767
76768 extern atomic_t kgdb_setting_breakpoint;
76769 -extern atomic_t kgdb_cpu_doing_single_step;
76770 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
76771
76772 extern struct task_struct *kgdb_usethread;
76773 extern struct task_struct *kgdb_contthread;
76774 @@ -254,7 +254,7 @@ struct kgdb_arch {
76775 void (*correct_hw_break)(void);
76776
76777 void (*enable_nmi)(bool on);
76778 -};
76779 +} __do_const;
76780
76781 /**
76782 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
76783 @@ -279,7 +279,7 @@ struct kgdb_io {
76784 void (*pre_exception) (void);
76785 void (*post_exception) (void);
76786 int is_console;
76787 -};
76788 +} __do_const;
76789
76790 extern struct kgdb_arch arch_kgdb_ops;
76791
76792 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
76793 index 0555cc6..40116ce 100644
76794 --- a/include/linux/kmod.h
76795 +++ b/include/linux/kmod.h
76796 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
76797 * usually useless though. */
76798 extern __printf(2, 3)
76799 int __request_module(bool wait, const char *name, ...);
76800 +extern __printf(3, 4)
76801 +int ___request_module(bool wait, char *param_name, const char *name, ...);
76802 #define request_module(mod...) __request_module(true, mod)
76803 #define request_module_nowait(mod...) __request_module(false, mod)
76804 #define try_then_request_module(x, mod...) \
76805 @@ -57,6 +59,9 @@ struct subprocess_info {
76806 struct work_struct work;
76807 struct completion *complete;
76808 char *path;
76809 +#ifdef CONFIG_GRKERNSEC
76810 + char *origpath;
76811 +#endif
76812 char **argv;
76813 char **envp;
76814 int wait;
76815 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
76816 index de6dcbcc..4735f88 100644
76817 --- a/include/linux/kobject.h
76818 +++ b/include/linux/kobject.h
76819 @@ -115,7 +115,7 @@ struct kobj_type {
76820 struct attribute **default_attrs;
76821 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
76822 const void *(*namespace)(struct kobject *kobj);
76823 -};
76824 +} __do_const;
76825
76826 struct kobj_uevent_env {
76827 char *envp[UEVENT_NUM_ENVP];
76828 @@ -138,6 +138,7 @@ struct kobj_attribute {
76829 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
76830 const char *buf, size_t count);
76831 };
76832 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
76833
76834 extern const struct sysfs_ops kobj_sysfs_ops;
76835
76836 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
76837 index df32d25..fb52e27 100644
76838 --- a/include/linux/kobject_ns.h
76839 +++ b/include/linux/kobject_ns.h
76840 @@ -44,7 +44,7 @@ struct kobj_ns_type_operations {
76841 const void *(*netlink_ns)(struct sock *sk);
76842 const void *(*initial_ns)(void);
76843 void (*drop_ns)(void *);
76844 -};
76845 +} __do_const;
76846
76847 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
76848 int kobj_ns_type_registered(enum kobj_ns_type type);
76849 diff --git a/include/linux/kref.h b/include/linux/kref.h
76850 index 484604d..0f6c5b6 100644
76851 --- a/include/linux/kref.h
76852 +++ b/include/linux/kref.h
76853 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
76854 static inline int kref_sub(struct kref *kref, unsigned int count,
76855 void (*release)(struct kref *kref))
76856 {
76857 - WARN_ON(release == NULL);
76858 + BUG_ON(release == NULL);
76859
76860 if (atomic_sub_and_test((int) count, &kref->refcount)) {
76861 release(kref);
76862 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
76863 index 0fbbc7a..db081e3 100644
76864 --- a/include/linux/kvm_host.h
76865 +++ b/include/linux/kvm_host.h
76866 @@ -458,7 +458,7 @@ static inline void kvm_irqfd_exit(void)
76867 {
76868 }
76869 #endif
76870 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
76871 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
76872 struct module *module);
76873 void kvm_exit(void);
76874
76875 @@ -632,7 +632,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
76876 struct kvm_guest_debug *dbg);
76877 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
76878
76879 -int kvm_arch_init(void *opaque);
76880 +int kvm_arch_init(const void *opaque);
76881 void kvm_arch_exit(void);
76882
76883 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
76884 diff --git a/include/linux/libata.h b/include/linux/libata.h
76885 index 9b50337..712d748 100644
76886 --- a/include/linux/libata.h
76887 +++ b/include/linux/libata.h
76888 @@ -973,7 +973,7 @@ struct ata_port_operations {
76889 * fields must be pointers.
76890 */
76891 const struct ata_port_operations *inherits;
76892 -};
76893 +} __do_const;
76894
76895 struct ata_port_info {
76896 unsigned long flags;
76897 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
76898 index d3e8ad2..a949f68 100644
76899 --- a/include/linux/linkage.h
76900 +++ b/include/linux/linkage.h
76901 @@ -31,6 +31,7 @@
76902 #endif
76903
76904 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
76905 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
76906 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
76907
76908 /*
76909 diff --git a/include/linux/list.h b/include/linux/list.h
76910 index f4d8a2f..38e6e46 100644
76911 --- a/include/linux/list.h
76912 +++ b/include/linux/list.h
76913 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
76914 extern void list_del(struct list_head *entry);
76915 #endif
76916
76917 +extern void __pax_list_add(struct list_head *new,
76918 + struct list_head *prev,
76919 + struct list_head *next);
76920 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
76921 +{
76922 + __pax_list_add(new, head, head->next);
76923 +}
76924 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
76925 +{
76926 + __pax_list_add(new, head->prev, head);
76927 +}
76928 +extern void pax_list_del(struct list_head *entry);
76929 +
76930 /**
76931 * list_replace - replace old entry by new one
76932 * @old : the element to be replaced
76933 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
76934 INIT_LIST_HEAD(entry);
76935 }
76936
76937 +extern void pax_list_del_init(struct list_head *entry);
76938 +
76939 /**
76940 * list_move - delete from one list and add as another's head
76941 * @list: the entry to move
76942 diff --git a/include/linux/math64.h b/include/linux/math64.h
76943 index 69ed5f5..243ed51 100644
76944 --- a/include/linux/math64.h
76945 +++ b/include/linux/math64.h
76946 @@ -15,7 +15,7 @@
76947 * This is commonly provided by 32bit archs to provide an optimized 64bit
76948 * divide.
76949 */
76950 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76951 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76952 {
76953 *remainder = dividend % divisor;
76954 return dividend / divisor;
76955 @@ -42,7 +42,7 @@ static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
76956 /**
76957 * div64_u64 - unsigned 64bit divide with 64bit divisor
76958 */
76959 -static inline u64 div64_u64(u64 dividend, u64 divisor)
76960 +static inline u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
76961 {
76962 return dividend / divisor;
76963 }
76964 @@ -61,7 +61,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
76965 #define div64_ul(x, y) div_u64((x), (y))
76966
76967 #ifndef div_u64_rem
76968 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76969 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76970 {
76971 *remainder = do_div(dividend, divisor);
76972 return dividend;
76973 @@ -77,7 +77,7 @@ extern u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder);
76974 #endif
76975
76976 #ifndef div64_u64
76977 -extern u64 div64_u64(u64 dividend, u64 divisor);
76978 +extern u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor);
76979 #endif
76980
76981 #ifndef div64_s64
76982 @@ -94,7 +94,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
76983 * divide.
76984 */
76985 #ifndef div_u64
76986 -static inline u64 div_u64(u64 dividend, u32 divisor)
76987 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
76988 {
76989 u32 remainder;
76990 return div_u64_rem(dividend, divisor, &remainder);
76991 diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
76992 index da6716b..2e31db3 100644
76993 --- a/include/linux/mempolicy.h
76994 +++ b/include/linux/mempolicy.h
76995 @@ -91,6 +91,10 @@ static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
76996 }
76997
76998 #define vma_policy(vma) ((vma)->vm_policy)
76999 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
77000 +{
77001 + vma->vm_policy = pol;
77002 +}
77003
77004 static inline void mpol_get(struct mempolicy *pol)
77005 {
77006 @@ -240,6 +244,9 @@ mpol_shared_policy_lookup(struct shared_policy *sp, unsigned long idx)
77007 }
77008
77009 #define vma_policy(vma) NULL
77010 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
77011 +{
77012 +}
77013
77014 static inline int
77015 vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
77016 diff --git a/include/linux/mm.h b/include/linux/mm.h
77017 index 8b6e55e..c4edf39 100644
77018 --- a/include/linux/mm.h
77019 +++ b/include/linux/mm.h
77020 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
77021 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
77022 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
77023 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
77024 +
77025 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
77026 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
77027 +#endif
77028 +
77029 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
77030
77031 #ifdef CONFIG_MEM_SOFT_DIRTY
77032 @@ -215,8 +220,8 @@ struct vm_operations_struct {
77033 /* called by access_process_vm when get_user_pages() fails, typically
77034 * for use by special VMAs that can switch between memory and hardware
77035 */
77036 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
77037 - void *buf, int len, int write);
77038 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
77039 + void *buf, size_t len, int write);
77040 #ifdef CONFIG_NUMA
77041 /*
77042 * set_policy() op must add a reference to any non-NULL @new mempolicy
77043 @@ -246,6 +251,7 @@ struct vm_operations_struct {
77044 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
77045 unsigned long size, pgoff_t pgoff);
77046 };
77047 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
77048
77049 struct mmu_gather;
77050 struct inode;
77051 @@ -977,8 +983,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
77052 unsigned long *pfn);
77053 int follow_phys(struct vm_area_struct *vma, unsigned long address,
77054 unsigned int flags, unsigned long *prot, resource_size_t *phys);
77055 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
77056 - void *buf, int len, int write);
77057 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
77058 + void *buf, size_t len, int write);
77059
77060 static inline void unmap_shared_mapping_range(struct address_space *mapping,
77061 loff_t const holebegin, loff_t const holelen)
77062 @@ -1017,9 +1023,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
77063 }
77064 #endif
77065
77066 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
77067 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
77068 - void *buf, int len, int write);
77069 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
77070 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
77071 + void *buf, size_t len, int write);
77072
77073 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
77074 unsigned long start, unsigned long nr_pages,
77075 @@ -1051,34 +1057,6 @@ int set_page_dirty(struct page *page);
77076 int set_page_dirty_lock(struct page *page);
77077 int clear_page_dirty_for_io(struct page *page);
77078
77079 -/* Is the vma a continuation of the stack vma above it? */
77080 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
77081 -{
77082 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
77083 -}
77084 -
77085 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
77086 - unsigned long addr)
77087 -{
77088 - return (vma->vm_flags & VM_GROWSDOWN) &&
77089 - (vma->vm_start == addr) &&
77090 - !vma_growsdown(vma->vm_prev, addr);
77091 -}
77092 -
77093 -/* Is the vma a continuation of the stack vma below it? */
77094 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
77095 -{
77096 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
77097 -}
77098 -
77099 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
77100 - unsigned long addr)
77101 -{
77102 - return (vma->vm_flags & VM_GROWSUP) &&
77103 - (vma->vm_end == addr) &&
77104 - !vma_growsup(vma->vm_next, addr);
77105 -}
77106 -
77107 extern pid_t
77108 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
77109
77110 @@ -1178,6 +1156,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
77111 }
77112 #endif
77113
77114 +#ifdef CONFIG_MMU
77115 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
77116 +#else
77117 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
77118 +{
77119 + return __pgprot(0);
77120 +}
77121 +#endif
77122 +
77123 int vma_wants_writenotify(struct vm_area_struct *vma);
77124
77125 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
77126 @@ -1196,8 +1183,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
77127 {
77128 return 0;
77129 }
77130 +
77131 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
77132 + unsigned long address)
77133 +{
77134 + return 0;
77135 +}
77136 #else
77137 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
77138 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
77139 #endif
77140
77141 #ifdef __PAGETABLE_PMD_FOLDED
77142 @@ -1206,8 +1200,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
77143 {
77144 return 0;
77145 }
77146 +
77147 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
77148 + unsigned long address)
77149 +{
77150 + return 0;
77151 +}
77152 #else
77153 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
77154 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
77155 #endif
77156
77157 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
77158 @@ -1225,11 +1226,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
77159 NULL: pud_offset(pgd, address);
77160 }
77161
77162 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
77163 +{
77164 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
77165 + NULL: pud_offset(pgd, address);
77166 +}
77167 +
77168 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
77169 {
77170 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
77171 NULL: pmd_offset(pud, address);
77172 }
77173 +
77174 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
77175 +{
77176 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
77177 + NULL: pmd_offset(pud, address);
77178 +}
77179 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
77180
77181 #if USE_SPLIT_PTLOCKS
77182 @@ -1517,7 +1530,7 @@ extern int install_special_mapping(struct mm_struct *mm,
77183 unsigned long addr, unsigned long len,
77184 unsigned long flags, struct page **pages);
77185
77186 -extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
77187 +extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long) __intentional_overflow(-1);
77188
77189 extern unsigned long mmap_region(struct file *file, unsigned long addr,
77190 unsigned long len, vm_flags_t vm_flags, unsigned long pgoff);
77191 @@ -1525,6 +1538,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
77192 unsigned long len, unsigned long prot, unsigned long flags,
77193 unsigned long pgoff, unsigned long *populate);
77194 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
77195 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
77196
77197 #ifdef CONFIG_MMU
77198 extern int __mm_populate(unsigned long addr, unsigned long len,
77199 @@ -1553,10 +1567,11 @@ struct vm_unmapped_area_info {
77200 unsigned long high_limit;
77201 unsigned long align_mask;
77202 unsigned long align_offset;
77203 + unsigned long threadstack_offset;
77204 };
77205
77206 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
77207 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
77208 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
77209 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
77210
77211 /*
77212 * Search for an unmapped address range.
77213 @@ -1568,7 +1583,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
77214 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
77215 */
77216 static inline unsigned long
77217 -vm_unmapped_area(struct vm_unmapped_area_info *info)
77218 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
77219 {
77220 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
77221 return unmapped_area(info);
77222 @@ -1631,6 +1646,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
77223 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
77224 struct vm_area_struct **pprev);
77225
77226 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
77227 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
77228 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
77229 +
77230 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
77231 NULL if none. Assume start_addr < end_addr. */
77232 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
77233 @@ -1659,15 +1678,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
77234 return vma;
77235 }
77236
77237 -#ifdef CONFIG_MMU
77238 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
77239 -#else
77240 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
77241 -{
77242 - return __pgprot(0);
77243 -}
77244 -#endif
77245 -
77246 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
77247 unsigned long change_prot_numa(struct vm_area_struct *vma,
77248 unsigned long start, unsigned long end);
77249 @@ -1719,6 +1729,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
77250 static inline void vm_stat_account(struct mm_struct *mm,
77251 unsigned long flags, struct file *file, long pages)
77252 {
77253 +
77254 +#ifdef CONFIG_PAX_RANDMMAP
77255 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
77256 +#endif
77257 +
77258 mm->total_vm += pages;
77259 }
77260 #endif /* CONFIG_PROC_FS */
77261 @@ -1800,7 +1815,7 @@ extern int unpoison_memory(unsigned long pfn);
77262 extern int sysctl_memory_failure_early_kill;
77263 extern int sysctl_memory_failure_recovery;
77264 extern void shake_page(struct page *p, int access);
77265 -extern atomic_long_t num_poisoned_pages;
77266 +extern atomic_long_unchecked_t num_poisoned_pages;
77267 extern int soft_offline_page(struct page *page, int flags);
77268
77269 extern void dump_page(struct page *page);
77270 @@ -1837,5 +1852,11 @@ void __init setup_nr_node_ids(void);
77271 static inline void setup_nr_node_ids(void) {}
77272 #endif
77273
77274 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
77275 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
77276 +#else
77277 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
77278 +#endif
77279 +
77280 #endif /* __KERNEL__ */
77281 #endif /* _LINUX_MM_H */
77282 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
77283 index 8e082f1..f61f576 100644
77284 --- a/include/linux/mm_types.h
77285 +++ b/include/linux/mm_types.h
77286 @@ -289,6 +289,8 @@ struct vm_area_struct {
77287 #ifdef CONFIG_NUMA
77288 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
77289 #endif
77290 +
77291 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
77292 };
77293
77294 struct core_thread {
77295 @@ -444,6 +446,24 @@ struct mm_struct {
77296 bool tlb_flush_pending;
77297 #endif
77298 struct uprobes_state uprobes_state;
77299 +
77300 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
77301 + unsigned long pax_flags;
77302 +#endif
77303 +
77304 +#ifdef CONFIG_PAX_DLRESOLVE
77305 + unsigned long call_dl_resolve;
77306 +#endif
77307 +
77308 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
77309 + unsigned long call_syscall;
77310 +#endif
77311 +
77312 +#ifdef CONFIG_PAX_ASLR
77313 + unsigned long delta_mmap; /* randomized offset */
77314 + unsigned long delta_stack; /* randomized offset */
77315 +#endif
77316 +
77317 };
77318
77319 /* first nid will either be a valid NID or one of these values */
77320 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
77321 index c5d5278..f0b68c8 100644
77322 --- a/include/linux/mmiotrace.h
77323 +++ b/include/linux/mmiotrace.h
77324 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
77325 /* Called from ioremap.c */
77326 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
77327 void __iomem *addr);
77328 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
77329 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
77330
77331 /* For anyone to insert markers. Remember trailing newline. */
77332 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
77333 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
77334 {
77335 }
77336
77337 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
77338 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
77339 {
77340 }
77341
77342 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
77343 index bd791e4..8617c34f 100644
77344 --- a/include/linux/mmzone.h
77345 +++ b/include/linux/mmzone.h
77346 @@ -396,7 +396,7 @@ struct zone {
77347 unsigned long flags; /* zone flags, see below */
77348
77349 /* Zone statistics */
77350 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77351 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77352
77353 /*
77354 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
77355 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
77356 index 45e9214..a7227d6 100644
77357 --- a/include/linux/mod_devicetable.h
77358 +++ b/include/linux/mod_devicetable.h
77359 @@ -13,7 +13,7 @@
77360 typedef unsigned long kernel_ulong_t;
77361 #endif
77362
77363 -#define PCI_ANY_ID (~0)
77364 +#define PCI_ANY_ID ((__u16)~0)
77365
77366 struct pci_device_id {
77367 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
77368 @@ -139,7 +139,7 @@ struct usb_device_id {
77369 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
77370 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
77371
77372 -#define HID_ANY_ID (~0)
77373 +#define HID_ANY_ID (~0U)
77374 #define HID_BUS_ANY 0xffff
77375 #define HID_GROUP_ANY 0x0000
77376
77377 @@ -467,7 +467,7 @@ struct dmi_system_id {
77378 const char *ident;
77379 struct dmi_strmatch matches[4];
77380 void *driver_data;
77381 -};
77382 +} __do_const;
77383 /*
77384 * struct dmi_device_id appears during expansion of
77385 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
77386 diff --git a/include/linux/module.h b/include/linux/module.h
77387 index 05f2447..2aee07c 100644
77388 --- a/include/linux/module.h
77389 +++ b/include/linux/module.h
77390 @@ -17,9 +17,11 @@
77391 #include <linux/moduleparam.h>
77392 #include <linux/tracepoint.h>
77393 #include <linux/export.h>
77394 +#include <linux/fs.h>
77395
77396 #include <linux/percpu.h>
77397 #include <asm/module.h>
77398 +#include <asm/pgtable.h>
77399
77400 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
77401 #define MODULE_SIG_STRING "~Module signature appended~\n"
77402 @@ -55,12 +57,13 @@ struct module_attribute {
77403 int (*test)(struct module *);
77404 void (*free)(struct module *);
77405 };
77406 +typedef struct module_attribute __no_const module_attribute_no_const;
77407
77408 struct module_version_attribute {
77409 struct module_attribute mattr;
77410 const char *module_name;
77411 const char *version;
77412 -} __attribute__ ((__aligned__(sizeof(void *))));
77413 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
77414
77415 extern ssize_t __modver_version_show(struct module_attribute *,
77416 struct module_kobject *, char *);
77417 @@ -238,7 +241,7 @@ struct module
77418
77419 /* Sysfs stuff. */
77420 struct module_kobject mkobj;
77421 - struct module_attribute *modinfo_attrs;
77422 + module_attribute_no_const *modinfo_attrs;
77423 const char *version;
77424 const char *srcversion;
77425 struct kobject *holders_dir;
77426 @@ -287,19 +290,16 @@ struct module
77427 int (*init)(void);
77428
77429 /* If this is non-NULL, vfree after init() returns */
77430 - void *module_init;
77431 + void *module_init_rx, *module_init_rw;
77432
77433 /* Here is the actual code + data, vfree'd on unload. */
77434 - void *module_core;
77435 + void *module_core_rx, *module_core_rw;
77436
77437 /* Here are the sizes of the init and core sections */
77438 - unsigned int init_size, core_size;
77439 + unsigned int init_size_rw, core_size_rw;
77440
77441 /* The size of the executable code in each section. */
77442 - unsigned int init_text_size, core_text_size;
77443 -
77444 - /* Size of RO sections of the module (text+rodata) */
77445 - unsigned int init_ro_size, core_ro_size;
77446 + unsigned int init_size_rx, core_size_rx;
77447
77448 /* Arch-specific module values */
77449 struct mod_arch_specific arch;
77450 @@ -355,6 +355,10 @@ struct module
77451 #ifdef CONFIG_EVENT_TRACING
77452 struct ftrace_event_call **trace_events;
77453 unsigned int num_trace_events;
77454 + struct file_operations trace_id;
77455 + struct file_operations trace_enable;
77456 + struct file_operations trace_format;
77457 + struct file_operations trace_filter;
77458 #endif
77459 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
77460 unsigned int num_ftrace_callsites;
77461 @@ -402,16 +406,46 @@ bool is_module_address(unsigned long addr);
77462 bool is_module_percpu_address(unsigned long addr);
77463 bool is_module_text_address(unsigned long addr);
77464
77465 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
77466 +{
77467 +
77468 +#ifdef CONFIG_PAX_KERNEXEC
77469 + if (ktla_ktva(addr) >= (unsigned long)start &&
77470 + ktla_ktva(addr) < (unsigned long)start + size)
77471 + return 1;
77472 +#endif
77473 +
77474 + return ((void *)addr >= start && (void *)addr < start + size);
77475 +}
77476 +
77477 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
77478 +{
77479 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
77480 +}
77481 +
77482 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
77483 +{
77484 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
77485 +}
77486 +
77487 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
77488 +{
77489 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
77490 +}
77491 +
77492 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
77493 +{
77494 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
77495 +}
77496 +
77497 static inline int within_module_core(unsigned long addr, const struct module *mod)
77498 {
77499 - return (unsigned long)mod->module_core <= addr &&
77500 - addr < (unsigned long)mod->module_core + mod->core_size;
77501 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
77502 }
77503
77504 static inline int within_module_init(unsigned long addr, const struct module *mod)
77505 {
77506 - return (unsigned long)mod->module_init <= addr &&
77507 - addr < (unsigned long)mod->module_init + mod->init_size;
77508 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
77509 }
77510
77511 /* Search for module by name: must hold module_mutex. */
77512 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
77513 index 560ca53..ef621ef 100644
77514 --- a/include/linux/moduleloader.h
77515 +++ b/include/linux/moduleloader.h
77516 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
77517 sections. Returns NULL on failure. */
77518 void *module_alloc(unsigned long size);
77519
77520 +#ifdef CONFIG_PAX_KERNEXEC
77521 +void *module_alloc_exec(unsigned long size);
77522 +#else
77523 +#define module_alloc_exec(x) module_alloc(x)
77524 +#endif
77525 +
77526 /* Free memory returned from module_alloc. */
77527 void module_free(struct module *mod, void *module_region);
77528
77529 +#ifdef CONFIG_PAX_KERNEXEC
77530 +void module_free_exec(struct module *mod, void *module_region);
77531 +#else
77532 +#define module_free_exec(x, y) module_free((x), (y))
77533 +#endif
77534 +
77535 /*
77536 * Apply the given relocation to the (simplified) ELF. Return -error
77537 * or 0.
77538 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
77539 unsigned int relsec,
77540 struct module *me)
77541 {
77542 +#ifdef CONFIG_MODULES
77543 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
77544 +#endif
77545 return -ENOEXEC;
77546 }
77547 #endif
77548 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
77549 unsigned int relsec,
77550 struct module *me)
77551 {
77552 +#ifdef CONFIG_MODULES
77553 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
77554 +#endif
77555 return -ENOEXEC;
77556 }
77557 #endif
77558 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
77559 index c3eb102..073c4a6 100644
77560 --- a/include/linux/moduleparam.h
77561 +++ b/include/linux/moduleparam.h
77562 @@ -295,7 +295,7 @@ static inline void __kernel_param_unlock(void)
77563 * @len is usually just sizeof(string).
77564 */
77565 #define module_param_string(name, string, len, perm) \
77566 - static const struct kparam_string __param_string_##name \
77567 + static const struct kparam_string __param_string_##name __used \
77568 = { len, string }; \
77569 __module_param_call(MODULE_PARAM_PREFIX, name, \
77570 &param_ops_string, \
77571 @@ -434,7 +434,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
77572 */
77573 #define module_param_array_named(name, array, type, nump, perm) \
77574 param_check_##type(name, &(array)[0]); \
77575 - static const struct kparam_array __param_arr_##name \
77576 + static const struct kparam_array __param_arr_##name __used \
77577 = { .max = ARRAY_SIZE(array), .num = nump, \
77578 .ops = &param_ops_##type, \
77579 .elemsize = sizeof(array[0]), .elem = array }; \
77580 diff --git a/include/linux/namei.h b/include/linux/namei.h
77581 index 8e47bc7..c70fd73 100644
77582 --- a/include/linux/namei.h
77583 +++ b/include/linux/namei.h
77584 @@ -19,7 +19,7 @@ struct nameidata {
77585 unsigned seq;
77586 int last_type;
77587 unsigned depth;
77588 - char *saved_names[MAX_NESTED_LINKS + 1];
77589 + const char *saved_names[MAX_NESTED_LINKS + 1];
77590 };
77591
77592 /*
77593 @@ -83,12 +83,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
77594
77595 extern void nd_jump_link(struct nameidata *nd, struct path *path);
77596
77597 -static inline void nd_set_link(struct nameidata *nd, char *path)
77598 +static inline void nd_set_link(struct nameidata *nd, const char *path)
77599 {
77600 nd->saved_names[nd->depth] = path;
77601 }
77602
77603 -static inline char *nd_get_link(struct nameidata *nd)
77604 +static inline const char *nd_get_link(const struct nameidata *nd)
77605 {
77606 return nd->saved_names[nd->depth];
77607 }
77608 diff --git a/include/linux/net.h b/include/linux/net.h
77609 index 41103f8..631edff 100644
77610 --- a/include/linux/net.h
77611 +++ b/include/linux/net.h
77612 @@ -191,7 +191,7 @@ struct net_proto_family {
77613 int (*create)(struct net *net, struct socket *sock,
77614 int protocol, int kern);
77615 struct module *owner;
77616 -};
77617 +} __do_const;
77618
77619 struct iovec;
77620 struct kvec;
77621 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
77622 index 21eae43..4fff130 100644
77623 --- a/include/linux/netdevice.h
77624 +++ b/include/linux/netdevice.h
77625 @@ -1098,6 +1098,7 @@ struct net_device_ops {
77626 sa_family_t sa_family,
77627 __be16 port);
77628 };
77629 +typedef struct net_device_ops __no_const net_device_ops_no_const;
77630
77631 /*
77632 * The DEVICE structure.
77633 @@ -1169,7 +1170,7 @@ struct net_device {
77634 int iflink;
77635
77636 struct net_device_stats stats;
77637 - atomic_long_t rx_dropped; /* dropped packets by core network
77638 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
77639 * Do not use this in drivers.
77640 */
77641
77642 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
77643 index 708fe72ab9..77084a3 100644
77644 --- a/include/linux/netfilter.h
77645 +++ b/include/linux/netfilter.h
77646 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
77647 #endif
77648 /* Use the module struct to lock set/get code in place */
77649 struct module *owner;
77650 -};
77651 +} __do_const;
77652
77653 /* Function to register/unregister hook points. */
77654 int nf_register_hook(struct nf_hook_ops *reg);
77655 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
77656 index cadb740..d7c37c0 100644
77657 --- a/include/linux/netfilter/nfnetlink.h
77658 +++ b/include/linux/netfilter/nfnetlink.h
77659 @@ -16,7 +16,7 @@ struct nfnl_callback {
77660 const struct nlattr * const cda[]);
77661 const struct nla_policy *policy; /* netlink attribute policy */
77662 const u_int16_t attr_count; /* number of nlattr's */
77663 -};
77664 +} __do_const;
77665
77666 struct nfnetlink_subsystem {
77667 const char *name;
77668 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
77669 new file mode 100644
77670 index 0000000..33f4af8
77671 --- /dev/null
77672 +++ b/include/linux/netfilter/xt_gradm.h
77673 @@ -0,0 +1,9 @@
77674 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
77675 +#define _LINUX_NETFILTER_XT_GRADM_H 1
77676 +
77677 +struct xt_gradm_mtinfo {
77678 + __u16 flags;
77679 + __u16 invflags;
77680 +};
77681 +
77682 +#endif
77683 diff --git a/include/linux/nls.h b/include/linux/nls.h
77684 index 5dc635f..35f5e11 100644
77685 --- a/include/linux/nls.h
77686 +++ b/include/linux/nls.h
77687 @@ -31,7 +31,7 @@ struct nls_table {
77688 const unsigned char *charset2upper;
77689 struct module *owner;
77690 struct nls_table *next;
77691 -};
77692 +} __do_const;
77693
77694 /* this value hold the maximum octet of charset */
77695 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
77696 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
77697 index d14a4c3..a078786 100644
77698 --- a/include/linux/notifier.h
77699 +++ b/include/linux/notifier.h
77700 @@ -54,7 +54,8 @@ struct notifier_block {
77701 notifier_fn_t notifier_call;
77702 struct notifier_block __rcu *next;
77703 int priority;
77704 -};
77705 +} __do_const;
77706 +typedef struct notifier_block __no_const notifier_block_no_const;
77707
77708 struct atomic_notifier_head {
77709 spinlock_t lock;
77710 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
77711 index b2a0f15..4d7da32 100644
77712 --- a/include/linux/oprofile.h
77713 +++ b/include/linux/oprofile.h
77714 @@ -138,9 +138,9 @@ int oprofilefs_create_ulong(struct dentry * root,
77715 int oprofilefs_create_ro_ulong(struct dentry * root,
77716 char const * name, ulong * val);
77717
77718 -/** Create a file for read-only access to an atomic_t. */
77719 +/** Create a file for read-only access to an atomic_unchecked_t. */
77720 int oprofilefs_create_ro_atomic(struct dentry * root,
77721 - char const * name, atomic_t * val);
77722 + char const * name, atomic_unchecked_t * val);
77723
77724 /** create a directory */
77725 struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name);
77726 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
77727 index 430dd96..544e26e 100644
77728 --- a/include/linux/pci_hotplug.h
77729 +++ b/include/linux/pci_hotplug.h
77730 @@ -71,7 +71,8 @@ struct hotplug_slot_ops {
77731 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
77732 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
77733 int (*reset_slot) (struct hotplug_slot *slot, int probe);
77734 -};
77735 +} __do_const;
77736 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
77737
77738 /**
77739 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
77740 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
77741 index c8ba627..24bdfa8 100644
77742 --- a/include/linux/perf_event.h
77743 +++ b/include/linux/perf_event.h
77744 @@ -327,8 +327,8 @@ struct perf_event {
77745
77746 enum perf_event_active_state state;
77747 unsigned int attach_state;
77748 - local64_t count;
77749 - atomic64_t child_count;
77750 + local64_t count; /* PaX: fix it one day */
77751 + atomic64_unchecked_t child_count;
77752
77753 /*
77754 * These are the total time in nanoseconds that the event
77755 @@ -379,8 +379,8 @@ struct perf_event {
77756 * These accumulate total time (in nanoseconds) that children
77757 * events have been enabled and running, respectively.
77758 */
77759 - atomic64_t child_total_time_enabled;
77760 - atomic64_t child_total_time_running;
77761 + atomic64_unchecked_t child_total_time_enabled;
77762 + atomic64_unchecked_t child_total_time_running;
77763
77764 /*
77765 * Protect attach/detach and child_list:
77766 @@ -702,7 +702,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
77767 entry->ip[entry->nr++] = ip;
77768 }
77769
77770 -extern int sysctl_perf_event_paranoid;
77771 +extern int sysctl_perf_event_legitimately_concerned;
77772 extern int sysctl_perf_event_mlock;
77773 extern int sysctl_perf_event_sample_rate;
77774 extern int sysctl_perf_cpu_time_max_percent;
77775 @@ -717,19 +717,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
77776 loff_t *ppos);
77777
77778
77779 +static inline bool perf_paranoid_any(void)
77780 +{
77781 + return sysctl_perf_event_legitimately_concerned > 2;
77782 +}
77783 +
77784 static inline bool perf_paranoid_tracepoint_raw(void)
77785 {
77786 - return sysctl_perf_event_paranoid > -1;
77787 + return sysctl_perf_event_legitimately_concerned > -1;
77788 }
77789
77790 static inline bool perf_paranoid_cpu(void)
77791 {
77792 - return sysctl_perf_event_paranoid > 0;
77793 + return sysctl_perf_event_legitimately_concerned > 0;
77794 }
77795
77796 static inline bool perf_paranoid_kernel(void)
77797 {
77798 - return sysctl_perf_event_paranoid > 1;
77799 + return sysctl_perf_event_legitimately_concerned > 1;
77800 }
77801
77802 extern void perf_event_init(void);
77803 @@ -845,7 +850,7 @@ struct perf_pmu_events_attr {
77804 struct device_attribute attr;
77805 u64 id;
77806 const char *event_str;
77807 -};
77808 +} __do_const;
77809
77810 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
77811 static struct perf_pmu_events_attr _var = { \
77812 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
77813 index b8809fe..ae4ccd0 100644
77814 --- a/include/linux/pipe_fs_i.h
77815 +++ b/include/linux/pipe_fs_i.h
77816 @@ -47,10 +47,10 @@ struct pipe_inode_info {
77817 struct mutex mutex;
77818 wait_queue_head_t wait;
77819 unsigned int nrbufs, curbuf, buffers;
77820 - unsigned int readers;
77821 - unsigned int writers;
77822 - unsigned int files;
77823 - unsigned int waiting_writers;
77824 + atomic_t readers;
77825 + atomic_t writers;
77826 + atomic_t files;
77827 + atomic_t waiting_writers;
77828 unsigned int r_counter;
77829 unsigned int w_counter;
77830 struct page *tmp_page;
77831 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
77832 index 5f28cae..3d23723 100644
77833 --- a/include/linux/platform_data/usb-ehci-s5p.h
77834 +++ b/include/linux/platform_data/usb-ehci-s5p.h
77835 @@ -14,7 +14,7 @@
77836 struct s5p_ehci_platdata {
77837 int (*phy_init)(struct platform_device *pdev, int type);
77838 int (*phy_exit)(struct platform_device *pdev, int type);
77839 -};
77840 +} __no_const;
77841
77842 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
77843
77844 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
77845 index c256c59..8ea94c7 100644
77846 --- a/include/linux/platform_data/usb-ohci-exynos.h
77847 +++ b/include/linux/platform_data/usb-ohci-exynos.h
77848 @@ -14,7 +14,7 @@
77849 struct exynos4_ohci_platdata {
77850 int (*phy_init)(struct platform_device *pdev, int type);
77851 int (*phy_exit)(struct platform_device *pdev, int type);
77852 -};
77853 +} __no_const;
77854
77855 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
77856
77857 diff --git a/include/linux/pm.h b/include/linux/pm.h
77858 index a224c7f..92d8a97 100644
77859 --- a/include/linux/pm.h
77860 +++ b/include/linux/pm.h
77861 @@ -576,6 +576,7 @@ extern int dev_pm_put_subsys_data(struct device *dev);
77862 struct dev_pm_domain {
77863 struct dev_pm_ops ops;
77864 };
77865 +typedef struct dev_pm_domain __no_const dev_pm_domain_no_const;
77866
77867 /*
77868 * The PM_EVENT_ messages are also used by drivers implementing the legacy
77869 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
77870 index 7c1d252..c5c773e 100644
77871 --- a/include/linux/pm_domain.h
77872 +++ b/include/linux/pm_domain.h
77873 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
77874
77875 struct gpd_cpu_data {
77876 unsigned int saved_exit_latency;
77877 - struct cpuidle_state *idle_state;
77878 + cpuidle_state_no_const *idle_state;
77879 };
77880
77881 struct generic_pm_domain {
77882 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
77883 index 6fa7cea..7bf6415 100644
77884 --- a/include/linux/pm_runtime.h
77885 +++ b/include/linux/pm_runtime.h
77886 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
77887
77888 static inline void pm_runtime_mark_last_busy(struct device *dev)
77889 {
77890 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
77891 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
77892 }
77893
77894 #else /* !CONFIG_PM_RUNTIME */
77895 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
77896 index 195aafc..49a7bc2 100644
77897 --- a/include/linux/pnp.h
77898 +++ b/include/linux/pnp.h
77899 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
77900 struct pnp_fixup {
77901 char id[7];
77902 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
77903 -};
77904 +} __do_const;
77905
77906 /* config parameters */
77907 #define PNP_CONFIG_NORMAL 0x0001
77908 diff --git a/include/linux/poison.h b/include/linux/poison.h
77909 index 2110a81..13a11bb 100644
77910 --- a/include/linux/poison.h
77911 +++ b/include/linux/poison.h
77912 @@ -19,8 +19,8 @@
77913 * under normal circumstances, used to verify that nobody uses
77914 * non-initialized list entries.
77915 */
77916 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
77917 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
77918 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
77919 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
77920
77921 /********** include/linux/timer.h **********/
77922 /*
77923 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
77924 index d8b187c3..9a9257a 100644
77925 --- a/include/linux/power/smartreflex.h
77926 +++ b/include/linux/power/smartreflex.h
77927 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
77928 int (*notify)(struct omap_sr *sr, u32 status);
77929 u8 notify_flags;
77930 u8 class_type;
77931 -};
77932 +} __do_const;
77933
77934 /**
77935 * struct omap_sr_nvalue_table - Smartreflex n-target value info
77936 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
77937 index 4ea1d37..80f4b33 100644
77938 --- a/include/linux/ppp-comp.h
77939 +++ b/include/linux/ppp-comp.h
77940 @@ -84,7 +84,7 @@ struct compressor {
77941 struct module *owner;
77942 /* Extra skb space needed by the compressor algorithm */
77943 unsigned int comp_extra;
77944 -};
77945 +} __do_const;
77946
77947 /*
77948 * The return value from decompress routine is the length of the
77949 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
77950 index f5d4723..a6ea2fa 100644
77951 --- a/include/linux/preempt.h
77952 +++ b/include/linux/preempt.h
77953 @@ -18,8 +18,13 @@
77954 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
77955 #endif
77956
77957 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
77958 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
77959 +
77960 #define inc_preempt_count() add_preempt_count(1)
77961 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
77962 #define dec_preempt_count() sub_preempt_count(1)
77963 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
77964
77965 #define preempt_count() (current_thread_info()->preempt_count)
77966
77967 @@ -64,6 +69,12 @@ do { \
77968 barrier(); \
77969 } while (0)
77970
77971 +#define raw_preempt_disable() \
77972 +do { \
77973 + raw_inc_preempt_count(); \
77974 + barrier(); \
77975 +} while (0)
77976 +
77977 #define sched_preempt_enable_no_resched() \
77978 do { \
77979 barrier(); \
77980 @@ -72,6 +83,12 @@ do { \
77981
77982 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
77983
77984 +#define raw_preempt_enable_no_resched() \
77985 +do { \
77986 + barrier(); \
77987 + raw_dec_preempt_count(); \
77988 +} while (0)
77989 +
77990 #define preempt_enable() \
77991 do { \
77992 preempt_enable_no_resched(); \
77993 @@ -116,8 +133,10 @@ do { \
77994 * region.
77995 */
77996 #define preempt_disable() barrier()
77997 +#define raw_preempt_disable() barrier()
77998 #define sched_preempt_enable_no_resched() barrier()
77999 #define preempt_enable_no_resched() barrier()
78000 +#define raw_preempt_enable_no_resched() barrier()
78001 #define preempt_enable() barrier()
78002
78003 #define preempt_disable_notrace() barrier()
78004 diff --git a/include/linux/printk.h b/include/linux/printk.h
78005 index e6131a78..8e9fb61 100644
78006 --- a/include/linux/printk.h
78007 +++ b/include/linux/printk.h
78008 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
78009 void early_printk(const char *s, ...) { }
78010 #endif
78011
78012 +extern int kptr_restrict;
78013 +
78014 #ifdef CONFIG_PRINTK
78015 asmlinkage __printf(5, 0)
78016 int vprintk_emit(int facility, int level,
78017 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
78018
78019 extern int printk_delay_msec;
78020 extern int dmesg_restrict;
78021 -extern int kptr_restrict;
78022
78023 extern void wake_up_klogd(void);
78024
78025 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
78026 index 608e60a..c26f864 100644
78027 --- a/include/linux/proc_fs.h
78028 +++ b/include/linux/proc_fs.h
78029 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
78030 return proc_create_data(name, mode, parent, proc_fops, NULL);
78031 }
78032
78033 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
78034 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
78035 +{
78036 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78037 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
78038 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78039 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
78040 +#else
78041 + return proc_create_data(name, mode, parent, proc_fops, NULL);
78042 +#endif
78043 +}
78044 +
78045 +
78046 extern void proc_set_size(struct proc_dir_entry *, loff_t);
78047 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
78048 extern void *PDE_DATA(const struct inode *);
78049 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
78050 index 34a1e10..03a6d03 100644
78051 --- a/include/linux/proc_ns.h
78052 +++ b/include/linux/proc_ns.h
78053 @@ -14,7 +14,7 @@ struct proc_ns_operations {
78054 void (*put)(void *ns);
78055 int (*install)(struct nsproxy *nsproxy, void *ns);
78056 unsigned int (*inum)(void *ns);
78057 -};
78058 +} __do_const;
78059
78060 struct proc_ns {
78061 void *ns;
78062 diff --git a/include/linux/quota.h b/include/linux/quota.h
78063 index cc7494a..1e27036 100644
78064 --- a/include/linux/quota.h
78065 +++ b/include/linux/quota.h
78066 @@ -70,7 +70,7 @@ struct kqid { /* Type in which we store the quota identifier */
78067
78068 extern bool qid_eq(struct kqid left, struct kqid right);
78069 extern bool qid_lt(struct kqid left, struct kqid right);
78070 -extern qid_t from_kqid(struct user_namespace *to, struct kqid qid);
78071 +extern qid_t from_kqid(struct user_namespace *to, struct kqid qid) __intentional_overflow(-1);
78072 extern qid_t from_kqid_munged(struct user_namespace *to, struct kqid qid);
78073 extern bool qid_valid(struct kqid qid);
78074
78075 diff --git a/include/linux/random.h b/include/linux/random.h
78076 index bf9085e..1e8bbcf 100644
78077 --- a/include/linux/random.h
78078 +++ b/include/linux/random.h
78079 @@ -10,9 +10,19 @@
78080
78081
78082 extern void add_device_randomness(const void *, unsigned int);
78083 +
78084 +static inline void add_latent_entropy(void)
78085 +{
78086 +
78087 +#ifdef LATENT_ENTROPY_PLUGIN
78088 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
78089 +#endif
78090 +
78091 +}
78092 +
78093 extern void add_input_randomness(unsigned int type, unsigned int code,
78094 - unsigned int value);
78095 -extern void add_interrupt_randomness(int irq, int irq_flags);
78096 + unsigned int value) __latent_entropy;
78097 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
78098
78099 extern void get_random_bytes(void *buf, int nbytes);
78100 extern void get_random_bytes_arch(void *buf, int nbytes);
78101 @@ -23,16 +33,21 @@ extern int random_int_secret_init(void);
78102 extern const struct file_operations random_fops, urandom_fops;
78103 #endif
78104
78105 -unsigned int get_random_int(void);
78106 +unsigned int __intentional_overflow(-1) get_random_int(void);
78107 unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len);
78108
78109 -u32 prandom_u32(void);
78110 +u32 prandom_u32(void) __intentional_overflow(-1);
78111 void prandom_bytes(void *buf, int nbytes);
78112 void prandom_seed(u32 seed);
78113
78114 u32 prandom_u32_state(struct rnd_state *);
78115 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
78116
78117 +static inline unsigned long __intentional_overflow(-1) pax_get_random_long(void)
78118 +{
78119 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
78120 +}
78121 +
78122 /*
78123 * Handle minimum values for seeds
78124 */
78125 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
78126 index 4106721..132d42c 100644
78127 --- a/include/linux/rculist.h
78128 +++ b/include/linux/rculist.h
78129 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
78130 struct list_head *prev, struct list_head *next);
78131 #endif
78132
78133 +extern void __pax_list_add_rcu(struct list_head *new,
78134 + struct list_head *prev, struct list_head *next);
78135 +
78136 /**
78137 * list_add_rcu - add a new entry to rcu-protected list
78138 * @new: new entry to be added
78139 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
78140 __list_add_rcu(new, head, head->next);
78141 }
78142
78143 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
78144 +{
78145 + __pax_list_add_rcu(new, head, head->next);
78146 +}
78147 +
78148 /**
78149 * list_add_tail_rcu - add a new entry to rcu-protected list
78150 * @new: new entry to be added
78151 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
78152 __list_add_rcu(new, head->prev, head);
78153 }
78154
78155 +static inline void pax_list_add_tail_rcu(struct list_head *new,
78156 + struct list_head *head)
78157 +{
78158 + __pax_list_add_rcu(new, head->prev, head);
78159 +}
78160 +
78161 /**
78162 * list_del_rcu - deletes entry from list without re-initialization
78163 * @entry: the element to delete from the list.
78164 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
78165 entry->prev = LIST_POISON2;
78166 }
78167
78168 +extern void pax_list_del_rcu(struct list_head *entry);
78169 +
78170 /**
78171 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
78172 * @n: the element to delete from the hash list.
78173 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
78174 index 9e7db9e..7d4fd72 100644
78175 --- a/include/linux/reboot.h
78176 +++ b/include/linux/reboot.h
78177 @@ -44,9 +44,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
78178 */
78179
78180 extern void migrate_to_reboot_cpu(void);
78181 -extern void machine_restart(char *cmd);
78182 -extern void machine_halt(void);
78183 -extern void machine_power_off(void);
78184 +extern void machine_restart(char *cmd) __noreturn;
78185 +extern void machine_halt(void) __noreturn;
78186 +extern void machine_power_off(void) __noreturn;
78187
78188 extern void machine_shutdown(void);
78189 struct pt_regs;
78190 @@ -57,9 +57,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
78191 */
78192
78193 extern void kernel_restart_prepare(char *cmd);
78194 -extern void kernel_restart(char *cmd);
78195 -extern void kernel_halt(void);
78196 -extern void kernel_power_off(void);
78197 +extern void kernel_restart(char *cmd) __noreturn;
78198 +extern void kernel_halt(void) __noreturn;
78199 +extern void kernel_power_off(void) __noreturn;
78200
78201 extern int C_A_D; /* for sysctl */
78202 void ctrl_alt_del(void);
78203 @@ -73,7 +73,7 @@ extern int orderly_poweroff(bool force);
78204 * Emergency restart, callable from an interrupt handler.
78205 */
78206
78207 -extern void emergency_restart(void);
78208 +extern void emergency_restart(void) __noreturn;
78209 #include <asm/emergency-restart.h>
78210
78211 #endif /* _LINUX_REBOOT_H */
78212 diff --git a/include/linux/regset.h b/include/linux/regset.h
78213 index 8e0c9fe..ac4d221 100644
78214 --- a/include/linux/regset.h
78215 +++ b/include/linux/regset.h
78216 @@ -161,7 +161,8 @@ struct user_regset {
78217 unsigned int align;
78218 unsigned int bias;
78219 unsigned int core_note_type;
78220 -};
78221 +} __do_const;
78222 +typedef struct user_regset __no_const user_regset_no_const;
78223
78224 /**
78225 * struct user_regset_view - available regsets
78226 diff --git a/include/linux/relay.h b/include/linux/relay.h
78227 index d7c8359..818daf5 100644
78228 --- a/include/linux/relay.h
78229 +++ b/include/linux/relay.h
78230 @@ -157,7 +157,7 @@ struct rchan_callbacks
78231 * The callback should return 0 if successful, negative if not.
78232 */
78233 int (*remove_buf_file)(struct dentry *dentry);
78234 -};
78235 +} __no_const;
78236
78237 /*
78238 * CONFIG_RELAY kernel API, kernel/relay.c
78239 diff --git a/include/linux/rio.h b/include/linux/rio.h
78240 index b71d573..2f940bd 100644
78241 --- a/include/linux/rio.h
78242 +++ b/include/linux/rio.h
78243 @@ -355,7 +355,7 @@ struct rio_ops {
78244 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
78245 u64 rstart, u32 size, u32 flags);
78246 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
78247 -};
78248 +} __no_const;
78249
78250 #define RIO_RESOURCE_MEM 0x00000100
78251 #define RIO_RESOURCE_DOORBELL 0x00000200
78252 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
78253 index 6dacb93..6174423 100644
78254 --- a/include/linux/rmap.h
78255 +++ b/include/linux/rmap.h
78256 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
78257 void anon_vma_init(void); /* create anon_vma_cachep */
78258 int anon_vma_prepare(struct vm_area_struct *);
78259 void unlink_anon_vmas(struct vm_area_struct *);
78260 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
78261 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
78262 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
78263 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
78264
78265 static inline void anon_vma_merge(struct vm_area_struct *vma,
78266 struct vm_area_struct *next)
78267 diff --git a/include/linux/sched.h b/include/linux/sched.h
78268 index b1e963e..114b8fd 100644
78269 --- a/include/linux/sched.h
78270 +++ b/include/linux/sched.h
78271 @@ -62,6 +62,7 @@ struct bio_list;
78272 struct fs_struct;
78273 struct perf_event_context;
78274 struct blk_plug;
78275 +struct linux_binprm;
78276
78277 /*
78278 * List of flags we want to share for kernel threads,
78279 @@ -295,7 +296,7 @@ extern char __sched_text_start[], __sched_text_end[];
78280 extern int in_sched_functions(unsigned long addr);
78281
78282 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
78283 -extern signed long schedule_timeout(signed long timeout);
78284 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
78285 extern signed long schedule_timeout_interruptible(signed long timeout);
78286 extern signed long schedule_timeout_killable(signed long timeout);
78287 extern signed long schedule_timeout_uninterruptible(signed long timeout);
78288 @@ -306,6 +307,19 @@ struct nsproxy;
78289 struct user_namespace;
78290
78291 #ifdef CONFIG_MMU
78292 +
78293 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
78294 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
78295 +#else
78296 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
78297 +{
78298 + return 0;
78299 +}
78300 +#endif
78301 +
78302 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
78303 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
78304 +
78305 extern void arch_pick_mmap_layout(struct mm_struct *mm);
78306 extern unsigned long
78307 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
78308 @@ -585,6 +599,17 @@ struct signal_struct {
78309 #ifdef CONFIG_TASKSTATS
78310 struct taskstats *stats;
78311 #endif
78312 +
78313 +#ifdef CONFIG_GRKERNSEC
78314 + u32 curr_ip;
78315 + u32 saved_ip;
78316 + u32 gr_saddr;
78317 + u32 gr_daddr;
78318 + u16 gr_sport;
78319 + u16 gr_dport;
78320 + u8 used_accept:1;
78321 +#endif
78322 +
78323 #ifdef CONFIG_AUDIT
78324 unsigned audit_tty;
78325 unsigned audit_tty_log_passwd;
78326 @@ -665,6 +690,14 @@ struct user_struct {
78327 struct key *session_keyring; /* UID's default session keyring */
78328 #endif
78329
78330 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
78331 + unsigned char kernel_banned;
78332 +#endif
78333 +#ifdef CONFIG_GRKERNSEC_BRUTE
78334 + unsigned char suid_banned;
78335 + unsigned long suid_ban_expires;
78336 +#endif
78337 +
78338 /* Hash table maintenance information */
78339 struct hlist_node uidhash_node;
78340 kuid_t uid;
78341 @@ -1150,8 +1183,8 @@ struct task_struct {
78342 struct list_head thread_group;
78343
78344 struct completion *vfork_done; /* for vfork() */
78345 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
78346 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
78347 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
78348 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
78349
78350 cputime_t utime, stime, utimescaled, stimescaled;
78351 cputime_t gtime;
78352 @@ -1176,11 +1209,6 @@ struct task_struct {
78353 struct task_cputime cputime_expires;
78354 struct list_head cpu_timers[3];
78355
78356 -/* process credentials */
78357 - const struct cred __rcu *real_cred; /* objective and real subjective task
78358 - * credentials (COW) */
78359 - const struct cred __rcu *cred; /* effective (overridable) subjective task
78360 - * credentials (COW) */
78361 char comm[TASK_COMM_LEN]; /* executable name excluding path
78362 - access with [gs]et_task_comm (which lock
78363 it with task_lock())
78364 @@ -1197,6 +1225,10 @@ struct task_struct {
78365 #endif
78366 /* CPU-specific state of this task */
78367 struct thread_struct thread;
78368 +/* thread_info moved to task_struct */
78369 +#ifdef CONFIG_X86
78370 + struct thread_info tinfo;
78371 +#endif
78372 /* filesystem information */
78373 struct fs_struct *fs;
78374 /* open file information */
78375 @@ -1270,6 +1302,10 @@ struct task_struct {
78376 gfp_t lockdep_reclaim_gfp;
78377 #endif
78378
78379 +/* process credentials */
78380 + const struct cred __rcu *real_cred; /* objective and real subjective task
78381 + * credentials (COW) */
78382 +
78383 /* journalling filesystem info */
78384 void *journal_info;
78385
78386 @@ -1308,6 +1344,10 @@ struct task_struct {
78387 /* cg_list protected by css_set_lock and tsk->alloc_lock */
78388 struct list_head cg_list;
78389 #endif
78390 +
78391 + const struct cred __rcu *cred; /* effective (overridable) subjective task
78392 + * credentials (COW) */
78393 +
78394 #ifdef CONFIG_FUTEX
78395 struct robust_list_head __user *robust_list;
78396 #ifdef CONFIG_COMPAT
78397 @@ -1411,8 +1451,78 @@ struct task_struct {
78398 unsigned int sequential_io;
78399 unsigned int sequential_io_avg;
78400 #endif
78401 +
78402 +#ifdef CONFIG_GRKERNSEC
78403 + /* grsecurity */
78404 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
78405 + u64 exec_id;
78406 +#endif
78407 +#ifdef CONFIG_GRKERNSEC_SETXID
78408 + const struct cred *delayed_cred;
78409 +#endif
78410 + struct dentry *gr_chroot_dentry;
78411 + struct acl_subject_label *acl;
78412 + struct acl_subject_label *tmpacl;
78413 + struct acl_role_label *role;
78414 + struct file *exec_file;
78415 + unsigned long brute_expires;
78416 + u16 acl_role_id;
78417 + u8 inherited;
78418 + /* is this the task that authenticated to the special role */
78419 + u8 acl_sp_role;
78420 + u8 is_writable;
78421 + u8 brute;
78422 + u8 gr_is_chrooted;
78423 +#endif
78424 +
78425 };
78426
78427 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
78428 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
78429 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
78430 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
78431 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
78432 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
78433 +
78434 +#ifdef CONFIG_PAX_SOFTMODE
78435 +extern int pax_softmode;
78436 +#endif
78437 +
78438 +extern int pax_check_flags(unsigned long *);
78439 +
78440 +/* if tsk != current then task_lock must be held on it */
78441 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
78442 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
78443 +{
78444 + if (likely(tsk->mm))
78445 + return tsk->mm->pax_flags;
78446 + else
78447 + return 0UL;
78448 +}
78449 +
78450 +/* if tsk != current then task_lock must be held on it */
78451 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
78452 +{
78453 + if (likely(tsk->mm)) {
78454 + tsk->mm->pax_flags = flags;
78455 + return 0;
78456 + }
78457 + return -EINVAL;
78458 +}
78459 +#endif
78460 +
78461 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
78462 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
78463 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
78464 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
78465 +#endif
78466 +
78467 +struct path;
78468 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
78469 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
78470 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
78471 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
78472 +
78473 /* Future-safe accessor for struct task_struct's cpus_allowed. */
78474 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
78475
78476 @@ -1471,7 +1581,7 @@ struct pid_namespace;
78477 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
78478 struct pid_namespace *ns);
78479
78480 -static inline pid_t task_pid_nr(struct task_struct *tsk)
78481 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
78482 {
78483 return tsk->pid;
78484 }
78485 @@ -1921,7 +2031,9 @@ void yield(void);
78486 extern struct exec_domain default_exec_domain;
78487
78488 union thread_union {
78489 +#ifndef CONFIG_X86
78490 struct thread_info thread_info;
78491 +#endif
78492 unsigned long stack[THREAD_SIZE/sizeof(long)];
78493 };
78494
78495 @@ -1954,6 +2066,7 @@ extern struct pid_namespace init_pid_ns;
78496 */
78497
78498 extern struct task_struct *find_task_by_vpid(pid_t nr);
78499 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
78500 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
78501 struct pid_namespace *ns);
78502
78503 @@ -2118,7 +2231,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
78504 extern void exit_itimers(struct signal_struct *);
78505 extern void flush_itimer_signals(void);
78506
78507 -extern void do_group_exit(int);
78508 +extern __noreturn void do_group_exit(int);
78509
78510 extern int allow_signal(int);
78511 extern int disallow_signal(int);
78512 @@ -2309,9 +2422,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
78513
78514 #endif
78515
78516 -static inline int object_is_on_stack(void *obj)
78517 +static inline int object_starts_on_stack(void *obj)
78518 {
78519 - void *stack = task_stack_page(current);
78520 + const void *stack = task_stack_page(current);
78521
78522 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
78523 }
78524 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
78525 index bf8086b..962b035 100644
78526 --- a/include/linux/sched/sysctl.h
78527 +++ b/include/linux/sched/sysctl.h
78528 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
78529 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
78530
78531 extern int sysctl_max_map_count;
78532 +extern unsigned long sysctl_heap_stack_gap;
78533
78534 extern unsigned int sysctl_sched_latency;
78535 extern unsigned int sysctl_sched_min_granularity;
78536 diff --git a/include/linux/security.h b/include/linux/security.h
78537 index 9d37e2b..43368e4 100644
78538 --- a/include/linux/security.h
78539 +++ b/include/linux/security.h
78540 @@ -27,6 +27,7 @@
78541 #include <linux/slab.h>
78542 #include <linux/err.h>
78543 #include <linux/string.h>
78544 +#include <linux/grsecurity.h>
78545
78546 struct linux_binprm;
78547 struct cred;
78548 @@ -116,8 +117,6 @@ struct seq_file;
78549
78550 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
78551
78552 -void reset_security_ops(void);
78553 -
78554 #ifdef CONFIG_MMU
78555 extern unsigned long mmap_min_addr;
78556 extern unsigned long dac_mmap_min_addr;
78557 diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
78558 index dc368b8..e895209 100644
78559 --- a/include/linux/semaphore.h
78560 +++ b/include/linux/semaphore.h
78561 @@ -37,7 +37,7 @@ static inline void sema_init(struct semaphore *sem, int val)
78562 }
78563
78564 extern void down(struct semaphore *sem);
78565 -extern int __must_check down_interruptible(struct semaphore *sem);
78566 +extern int __must_check down_interruptible(struct semaphore *sem) __intentional_overflow(-1);
78567 extern int __must_check down_killable(struct semaphore *sem);
78568 extern int __must_check down_trylock(struct semaphore *sem);
78569 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
78570 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
78571 index 4e32edc..f8f2d18 100644
78572 --- a/include/linux/seq_file.h
78573 +++ b/include/linux/seq_file.h
78574 @@ -26,6 +26,9 @@ struct seq_file {
78575 struct mutex lock;
78576 const struct seq_operations *op;
78577 int poll_event;
78578 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
78579 + u64 exec_id;
78580 +#endif
78581 #ifdef CONFIG_USER_NS
78582 struct user_namespace *user_ns;
78583 #endif
78584 @@ -38,6 +41,7 @@ struct seq_operations {
78585 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
78586 int (*show) (struct seq_file *m, void *v);
78587 };
78588 +typedef struct seq_operations __no_const seq_operations_no_const;
78589
78590 #define SEQ_SKIP 1
78591
78592 diff --git a/include/linux/shm.h b/include/linux/shm.h
78593 index 429c199..4d42e38 100644
78594 --- a/include/linux/shm.h
78595 +++ b/include/linux/shm.h
78596 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
78597
78598 /* The task created the shm object. NULL if the task is dead. */
78599 struct task_struct *shm_creator;
78600 +#ifdef CONFIG_GRKERNSEC
78601 + time_t shm_createtime;
78602 + pid_t shm_lapid;
78603 +#endif
78604 };
78605
78606 /* shm_mode upper byte flags */
78607 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
78608 index efa1649..ff898ac 100644
78609 --- a/include/linux/skbuff.h
78610 +++ b/include/linux/skbuff.h
78611 @@ -639,7 +639,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
78612 extern struct sk_buff *__alloc_skb(unsigned int size,
78613 gfp_t priority, int flags, int node);
78614 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
78615 -static inline struct sk_buff *alloc_skb(unsigned int size,
78616 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
78617 gfp_t priority)
78618 {
78619 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
78620 @@ -755,7 +755,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
78621 */
78622 static inline int skb_queue_empty(const struct sk_buff_head *list)
78623 {
78624 - return list->next == (struct sk_buff *)list;
78625 + return list->next == (const struct sk_buff *)list;
78626 }
78627
78628 /**
78629 @@ -768,7 +768,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
78630 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
78631 const struct sk_buff *skb)
78632 {
78633 - return skb->next == (struct sk_buff *)list;
78634 + return skb->next == (const struct sk_buff *)list;
78635 }
78636
78637 /**
78638 @@ -781,7 +781,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
78639 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
78640 const struct sk_buff *skb)
78641 {
78642 - return skb->prev == (struct sk_buff *)list;
78643 + return skb->prev == (const struct sk_buff *)list;
78644 }
78645
78646 /**
78647 @@ -1746,7 +1746,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
78648 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
78649 */
78650 #ifndef NET_SKB_PAD
78651 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
78652 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
78653 #endif
78654
78655 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
78656 @@ -2344,7 +2344,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
78657 int noblock, int *err);
78658 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
78659 struct poll_table_struct *wait);
78660 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
78661 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
78662 int offset, struct iovec *to,
78663 int size);
78664 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
78665 @@ -2623,6 +2623,9 @@ static inline void nf_reset(struct sk_buff *skb)
78666 nf_bridge_put(skb->nf_bridge);
78667 skb->nf_bridge = NULL;
78668 #endif
78669 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
78670 + skb->nf_trace = 0;
78671 +#endif
78672 }
78673
78674 static inline void nf_reset_trace(struct sk_buff *skb)
78675 diff --git a/include/linux/slab.h b/include/linux/slab.h
78676 index 74f1058..914b7da 100644
78677 --- a/include/linux/slab.h
78678 +++ b/include/linux/slab.h
78679 @@ -14,15 +14,29 @@
78680 #include <linux/gfp.h>
78681 #include <linux/types.h>
78682 #include <linux/workqueue.h>
78683 -
78684 +#include <linux/err.h>
78685
78686 /*
78687 * Flags to pass to kmem_cache_create().
78688 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
78689 */
78690 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
78691 +
78692 +#ifdef CONFIG_PAX_USERCOPY_SLABS
78693 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
78694 +#else
78695 +#define SLAB_USERCOPY 0x00000000UL
78696 +#endif
78697 +
78698 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
78699 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
78700 +
78701 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
78702 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
78703 +#else
78704 +#define SLAB_NO_SANITIZE 0x00000000UL
78705 +#endif
78706 +
78707 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
78708 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
78709 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
78710 @@ -91,10 +105,13 @@
78711 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
78712 * Both make kfree a no-op.
78713 */
78714 -#define ZERO_SIZE_PTR ((void *)16)
78715 +#define ZERO_SIZE_PTR \
78716 +({ \
78717 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
78718 + (void *)(-MAX_ERRNO-1L); \
78719 +})
78720
78721 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
78722 - (unsigned long)ZERO_SIZE_PTR)
78723 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
78724
78725 #include <linux/kmemleak.h>
78726
78727 @@ -135,6 +152,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
78728 void kfree(const void *);
78729 void kzfree(const void *);
78730 size_t ksize(const void *);
78731 +const char *check_heap_object(const void *ptr, unsigned long n);
78732 +bool is_usercopy_object(const void *ptr);
78733
78734 /*
78735 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
78736 @@ -167,7 +186,7 @@ struct kmem_cache {
78737 unsigned int align; /* Alignment as calculated */
78738 unsigned long flags; /* Active flags on the slab */
78739 const char *name; /* Slab name for sysfs */
78740 - int refcount; /* Use counter */
78741 + atomic_t refcount; /* Use counter */
78742 void (*ctor)(void *); /* Called on object slot creation */
78743 struct list_head list; /* List of all slab caches on the system */
78744 };
78745 @@ -241,6 +260,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
78746 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
78747 #endif
78748
78749 +#ifdef CONFIG_PAX_USERCOPY_SLABS
78750 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
78751 +#endif
78752 +
78753 /*
78754 * Figure out which kmalloc slab an allocation of a certain size
78755 * belongs to.
78756 @@ -249,7 +272,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
78757 * 2 = 120 .. 192 bytes
78758 * n = 2^(n-1) .. 2^n -1
78759 */
78760 -static __always_inline int kmalloc_index(size_t size)
78761 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
78762 {
78763 if (!size)
78764 return 0;
78765 @@ -292,11 +315,11 @@ static __always_inline int kmalloc_index(size_t size)
78766 }
78767 #endif /* !CONFIG_SLOB */
78768
78769 -void *__kmalloc(size_t size, gfp_t flags);
78770 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1);
78771 void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags);
78772
78773 #ifdef CONFIG_NUMA
78774 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
78775 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __alloc_size(1);
78776 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
78777 #else
78778 static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
78779 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
78780 index e9346b4..1494959 100644
78781 --- a/include/linux/slab_def.h
78782 +++ b/include/linux/slab_def.h
78783 @@ -36,7 +36,7 @@ struct kmem_cache {
78784 /* 4) cache creation/removal */
78785 const char *name;
78786 struct list_head list;
78787 - int refcount;
78788 + atomic_t refcount;
78789 int object_size;
78790 int align;
78791
78792 @@ -52,10 +52,14 @@ struct kmem_cache {
78793 unsigned long node_allocs;
78794 unsigned long node_frees;
78795 unsigned long node_overflow;
78796 - atomic_t allochit;
78797 - atomic_t allocmiss;
78798 - atomic_t freehit;
78799 - atomic_t freemiss;
78800 + atomic_unchecked_t allochit;
78801 + atomic_unchecked_t allocmiss;
78802 + atomic_unchecked_t freehit;
78803 + atomic_unchecked_t freemiss;
78804 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
78805 + atomic_unchecked_t sanitized;
78806 + atomic_unchecked_t not_sanitized;
78807 +#endif
78808
78809 /*
78810 * If debugging is enabled, then the allocator can add additional
78811 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
78812 index cc0b67e..a0329b1 100644
78813 --- a/include/linux/slub_def.h
78814 +++ b/include/linux/slub_def.h
78815 @@ -74,7 +74,7 @@ struct kmem_cache {
78816 struct kmem_cache_order_objects max;
78817 struct kmem_cache_order_objects min;
78818 gfp_t allocflags; /* gfp flags to use on each alloc */
78819 - int refcount; /* Refcount for slab cache destroy */
78820 + atomic_t refcount; /* Refcount for slab cache destroy */
78821 void (*ctor)(void *);
78822 int inuse; /* Offset to metadata */
78823 int align; /* Alignment */
78824 diff --git a/include/linux/smp.h b/include/linux/smp.h
78825 index 731f523..3340268 100644
78826 --- a/include/linux/smp.h
78827 +++ b/include/linux/smp.h
78828 @@ -186,7 +186,9 @@ static inline void __smp_call_function_single(int cpuid,
78829 #endif
78830
78831 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
78832 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
78833 #define put_cpu() preempt_enable()
78834 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
78835
78836 /*
78837 * Callback to arch code if there's nosmp or maxcpus=0 on the
78838 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
78839 index 54f91d3..be2c379 100644
78840 --- a/include/linux/sock_diag.h
78841 +++ b/include/linux/sock_diag.h
78842 @@ -11,7 +11,7 @@ struct sock;
78843 struct sock_diag_handler {
78844 __u8 family;
78845 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
78846 -};
78847 +} __do_const;
78848
78849 int sock_diag_register(const struct sock_diag_handler *h);
78850 void sock_diag_unregister(const struct sock_diag_handler *h);
78851 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
78852 index 680f9a3..f13aeb0 100644
78853 --- a/include/linux/sonet.h
78854 +++ b/include/linux/sonet.h
78855 @@ -7,7 +7,7 @@
78856 #include <uapi/linux/sonet.h>
78857
78858 struct k_sonet_stats {
78859 -#define __HANDLE_ITEM(i) atomic_t i
78860 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
78861 __SONET_ITEMS
78862 #undef __HANDLE_ITEM
78863 };
78864 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
78865 index 07d8e53..dc934c9 100644
78866 --- a/include/linux/sunrpc/addr.h
78867 +++ b/include/linux/sunrpc/addr.h
78868 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
78869 {
78870 switch (sap->sa_family) {
78871 case AF_INET:
78872 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
78873 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
78874 case AF_INET6:
78875 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
78876 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
78877 }
78878 return 0;
78879 }
78880 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
78881 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
78882 const struct sockaddr *src)
78883 {
78884 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
78885 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
78886 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
78887
78888 dsin->sin_family = ssin->sin_family;
78889 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
78890 if (sa->sa_family != AF_INET6)
78891 return 0;
78892
78893 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
78894 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
78895 }
78896
78897 #endif /* _LINUX_SUNRPC_ADDR_H */
78898 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
78899 index 6740801..c535f27 100644
78900 --- a/include/linux/sunrpc/clnt.h
78901 +++ b/include/linux/sunrpc/clnt.h
78902 @@ -96,7 +96,7 @@ struct rpc_procinfo {
78903 unsigned int p_timer; /* Which RTT timer to use */
78904 u32 p_statidx; /* Which procedure to account */
78905 const char * p_name; /* name of procedure */
78906 -};
78907 +} __do_const;
78908
78909 #ifdef __KERNEL__
78910
78911 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
78912 index 6eecfc2..7ada79d 100644
78913 --- a/include/linux/sunrpc/svc.h
78914 +++ b/include/linux/sunrpc/svc.h
78915 @@ -410,7 +410,7 @@ struct svc_procedure {
78916 unsigned int pc_count; /* call count */
78917 unsigned int pc_cachetype; /* cache info (NFS) */
78918 unsigned int pc_xdrressize; /* maximum size of XDR reply */
78919 -};
78920 +} __do_const;
78921
78922 /*
78923 * Function prototypes.
78924 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
78925 index 0b8e3e6..33e0a01 100644
78926 --- a/include/linux/sunrpc/svc_rdma.h
78927 +++ b/include/linux/sunrpc/svc_rdma.h
78928 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
78929 extern unsigned int svcrdma_max_requests;
78930 extern unsigned int svcrdma_max_req_size;
78931
78932 -extern atomic_t rdma_stat_recv;
78933 -extern atomic_t rdma_stat_read;
78934 -extern atomic_t rdma_stat_write;
78935 -extern atomic_t rdma_stat_sq_starve;
78936 -extern atomic_t rdma_stat_rq_starve;
78937 -extern atomic_t rdma_stat_rq_poll;
78938 -extern atomic_t rdma_stat_rq_prod;
78939 -extern atomic_t rdma_stat_sq_poll;
78940 -extern atomic_t rdma_stat_sq_prod;
78941 +extern atomic_unchecked_t rdma_stat_recv;
78942 +extern atomic_unchecked_t rdma_stat_read;
78943 +extern atomic_unchecked_t rdma_stat_write;
78944 +extern atomic_unchecked_t rdma_stat_sq_starve;
78945 +extern atomic_unchecked_t rdma_stat_rq_starve;
78946 +extern atomic_unchecked_t rdma_stat_rq_poll;
78947 +extern atomic_unchecked_t rdma_stat_rq_prod;
78948 +extern atomic_unchecked_t rdma_stat_sq_poll;
78949 +extern atomic_unchecked_t rdma_stat_sq_prod;
78950
78951 #define RPCRDMA_VERSION 1
78952
78953 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
78954 index 8d71d65..f79586e 100644
78955 --- a/include/linux/sunrpc/svcauth.h
78956 +++ b/include/linux/sunrpc/svcauth.h
78957 @@ -120,7 +120,7 @@ struct auth_ops {
78958 int (*release)(struct svc_rqst *rq);
78959 void (*domain_release)(struct auth_domain *);
78960 int (*set_client)(struct svc_rqst *rq);
78961 -};
78962 +} __do_const;
78963
78964 #define SVC_GARBAGE 1
78965 #define SVC_SYSERR 2
78966 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
78967 index a5ffd32..0935dea 100644
78968 --- a/include/linux/swiotlb.h
78969 +++ b/include/linux/swiotlb.h
78970 @@ -60,7 +60,8 @@ extern void
78971
78972 extern void
78973 swiotlb_free_coherent(struct device *hwdev, size_t size,
78974 - void *vaddr, dma_addr_t dma_handle);
78975 + void *vaddr, dma_addr_t dma_handle,
78976 + struct dma_attrs *attrs);
78977
78978 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
78979 unsigned long offset, size_t size,
78980 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
78981 index 7fac04e..de57300 100644
78982 --- a/include/linux/syscalls.h
78983 +++ b/include/linux/syscalls.h
78984 @@ -97,8 +97,14 @@ struct sigaltstack;
78985 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
78986
78987 #define __SC_DECL(t, a) t a
78988 +#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))
78989 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
78990 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
78991 +#define __SC_LONG(t, a) __typeof( \
78992 + __builtin_choose_expr( \
78993 + sizeof(t) > sizeof(int), \
78994 + (t) 0, \
78995 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
78996 + )) a
78997 #define __SC_CAST(t, a) (t) a
78998 #define __SC_ARGS(t, a) a
78999 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
79000 @@ -363,11 +369,11 @@ asmlinkage long sys_sync(void);
79001 asmlinkage long sys_fsync(unsigned int fd);
79002 asmlinkage long sys_fdatasync(unsigned int fd);
79003 asmlinkage long sys_bdflush(int func, long data);
79004 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
79005 - char __user *type, unsigned long flags,
79006 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
79007 + const char __user *type, unsigned long flags,
79008 void __user *data);
79009 -asmlinkage long sys_umount(char __user *name, int flags);
79010 -asmlinkage long sys_oldumount(char __user *name);
79011 +asmlinkage long sys_umount(const char __user *name, int flags);
79012 +asmlinkage long sys_oldumount(const char __user *name);
79013 asmlinkage long sys_truncate(const char __user *path, long length);
79014 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
79015 asmlinkage long sys_stat(const char __user *filename,
79016 @@ -579,7 +585,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
79017 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
79018 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
79019 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
79020 - struct sockaddr __user *, int);
79021 + struct sockaddr __user *, int) __intentional_overflow(0);
79022 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
79023 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
79024 unsigned int vlen, unsigned flags);
79025 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
79026 index 27b3b0b..e093dd9 100644
79027 --- a/include/linux/syscore_ops.h
79028 +++ b/include/linux/syscore_ops.h
79029 @@ -16,7 +16,7 @@ struct syscore_ops {
79030 int (*suspend)(void);
79031 void (*resume)(void);
79032 void (*shutdown)(void);
79033 -};
79034 +} __do_const;
79035
79036 extern void register_syscore_ops(struct syscore_ops *ops);
79037 extern void unregister_syscore_ops(struct syscore_ops *ops);
79038 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
79039 index 14a8ff2..af52bad 100644
79040 --- a/include/linux/sysctl.h
79041 +++ b/include/linux/sysctl.h
79042 @@ -34,13 +34,13 @@ struct ctl_table_root;
79043 struct ctl_table_header;
79044 struct ctl_dir;
79045
79046 -typedef struct ctl_table ctl_table;
79047 -
79048 typedef int proc_handler (struct ctl_table *ctl, int write,
79049 void __user *buffer, size_t *lenp, loff_t *ppos);
79050
79051 extern int proc_dostring(struct ctl_table *, int,
79052 void __user *, size_t *, loff_t *);
79053 +extern int proc_dostring_modpriv(struct ctl_table *, int,
79054 + void __user *, size_t *, loff_t *);
79055 extern int proc_dointvec(struct ctl_table *, int,
79056 void __user *, size_t *, loff_t *);
79057 extern int proc_dointvec_minmax(struct ctl_table *, int,
79058 @@ -115,7 +115,9 @@ struct ctl_table
79059 struct ctl_table_poll *poll;
79060 void *extra1;
79061 void *extra2;
79062 -};
79063 +} __do_const;
79064 +typedef struct ctl_table __no_const ctl_table_no_const;
79065 +typedef struct ctl_table ctl_table;
79066
79067 struct ctl_node {
79068 struct rb_node node;
79069 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
79070 index 11baec7..706f99f 100644
79071 --- a/include/linux/sysfs.h
79072 +++ b/include/linux/sysfs.h
79073 @@ -33,7 +33,8 @@ struct attribute {
79074 struct lock_class_key *key;
79075 struct lock_class_key skey;
79076 #endif
79077 -};
79078 +} __do_const;
79079 +typedef struct attribute __no_const attribute_no_const;
79080
79081 /**
79082 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
79083 @@ -62,7 +63,8 @@ struct attribute_group {
79084 struct attribute *, int);
79085 struct attribute **attrs;
79086 struct bin_attribute **bin_attrs;
79087 -};
79088 +} __do_const;
79089 +typedef struct attribute_group __no_const attribute_group_no_const;
79090
79091 /**
79092 * Use these macros to make defining attributes easier. See include/linux/device.h
79093 @@ -126,7 +128,8 @@ struct bin_attribute {
79094 char *, loff_t, size_t);
79095 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
79096 struct vm_area_struct *vma);
79097 -};
79098 +} __do_const;
79099 +typedef struct bin_attribute __no_const bin_attribute_no_const;
79100
79101 /**
79102 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
79103 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
79104 index 7faf933..9b85a0c 100644
79105 --- a/include/linux/sysrq.h
79106 +++ b/include/linux/sysrq.h
79107 @@ -16,6 +16,7 @@
79108
79109 #include <linux/errno.h>
79110 #include <linux/types.h>
79111 +#include <linux/compiler.h>
79112
79113 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
79114 #define SYSRQ_DEFAULT_ENABLE 1
79115 @@ -36,7 +37,7 @@ struct sysrq_key_op {
79116 char *help_msg;
79117 char *action_msg;
79118 int enable_mask;
79119 -};
79120 +} __do_const;
79121
79122 #ifdef CONFIG_MAGIC_SYSRQ
79123
79124 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
79125 index 4ae6f32..425d3e1 100644
79126 --- a/include/linux/thread_info.h
79127 +++ b/include/linux/thread_info.h
79128 @@ -150,6 +150,15 @@ static inline bool test_and_clear_restore_sigmask(void)
79129 #error "no set_restore_sigmask() provided and default one won't work"
79130 #endif
79131
79132 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
79133 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
79134 +{
79135 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
79136 + if (!__builtin_constant_p(n))
79137 +#endif
79138 + __check_object_size(ptr, n, to_user);
79139 +}
79140 +
79141 #endif /* __KERNEL__ */
79142
79143 #endif /* _LINUX_THREAD_INFO_H */
79144 diff --git a/include/linux/tty.h b/include/linux/tty.h
79145 index 64f8646..1515fc7 100644
79146 --- a/include/linux/tty.h
79147 +++ b/include/linux/tty.h
79148 @@ -197,7 +197,7 @@ struct tty_port {
79149 const struct tty_port_operations *ops; /* Port operations */
79150 spinlock_t lock; /* Lock protecting tty field */
79151 int blocked_open; /* Waiting to open */
79152 - int count; /* Usage count */
79153 + atomic_t count; /* Usage count */
79154 wait_queue_head_t open_wait; /* Open waiters */
79155 wait_queue_head_t close_wait; /* Close waiters */
79156 wait_queue_head_t delta_msr_wait; /* Modem status change */
79157 @@ -546,7 +546,7 @@ extern int tty_port_open(struct tty_port *port,
79158 struct tty_struct *tty, struct file *filp);
79159 static inline int tty_port_users(struct tty_port *port)
79160 {
79161 - return port->count + port->blocked_open;
79162 + return atomic_read(&port->count) + port->blocked_open;
79163 }
79164
79165 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
79166 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
79167 index 756a609..b302dd6 100644
79168 --- a/include/linux/tty_driver.h
79169 +++ b/include/linux/tty_driver.h
79170 @@ -285,7 +285,7 @@ struct tty_operations {
79171 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
79172 #endif
79173 const struct file_operations *proc_fops;
79174 -};
79175 +} __do_const;
79176
79177 struct tty_driver {
79178 int magic; /* magic number for this structure */
79179 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
79180 index f15c898..207b7d1 100644
79181 --- a/include/linux/tty_ldisc.h
79182 +++ b/include/linux/tty_ldisc.h
79183 @@ -211,7 +211,7 @@ struct tty_ldisc_ops {
79184
79185 struct module *owner;
79186
79187 - int refcount;
79188 + atomic_t refcount;
79189 };
79190
79191 struct tty_ldisc {
79192 diff --git a/include/linux/types.h b/include/linux/types.h
79193 index 4d118ba..c3ee9bf 100644
79194 --- a/include/linux/types.h
79195 +++ b/include/linux/types.h
79196 @@ -176,10 +176,26 @@ typedef struct {
79197 int counter;
79198 } atomic_t;
79199
79200 +#ifdef CONFIG_PAX_REFCOUNT
79201 +typedef struct {
79202 + int counter;
79203 +} atomic_unchecked_t;
79204 +#else
79205 +typedef atomic_t atomic_unchecked_t;
79206 +#endif
79207 +
79208 #ifdef CONFIG_64BIT
79209 typedef struct {
79210 long counter;
79211 } atomic64_t;
79212 +
79213 +#ifdef CONFIG_PAX_REFCOUNT
79214 +typedef struct {
79215 + long counter;
79216 +} atomic64_unchecked_t;
79217 +#else
79218 +typedef atomic64_t atomic64_unchecked_t;
79219 +#endif
79220 #endif
79221
79222 struct list_head {
79223 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
79224 index 5ca0951..ab496a5 100644
79225 --- a/include/linux/uaccess.h
79226 +++ b/include/linux/uaccess.h
79227 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
79228 long ret; \
79229 mm_segment_t old_fs = get_fs(); \
79230 \
79231 - set_fs(KERNEL_DS); \
79232 pagefault_disable(); \
79233 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
79234 - pagefault_enable(); \
79235 + set_fs(KERNEL_DS); \
79236 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
79237 set_fs(old_fs); \
79238 + pagefault_enable(); \
79239 ret; \
79240 })
79241
79242 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
79243 index 8e522cbc..aa8572d 100644
79244 --- a/include/linux/uidgid.h
79245 +++ b/include/linux/uidgid.h
79246 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
79247
79248 #endif /* CONFIG_USER_NS */
79249
79250 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
79251 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
79252 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
79253 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
79254 +
79255 #endif /* _LINUX_UIDGID_H */
79256 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
79257 index 99c1b4d..562e6f3 100644
79258 --- a/include/linux/unaligned/access_ok.h
79259 +++ b/include/linux/unaligned/access_ok.h
79260 @@ -4,34 +4,34 @@
79261 #include <linux/kernel.h>
79262 #include <asm/byteorder.h>
79263
79264 -static inline u16 get_unaligned_le16(const void *p)
79265 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
79266 {
79267 - return le16_to_cpup((__le16 *)p);
79268 + return le16_to_cpup((const __le16 *)p);
79269 }
79270
79271 -static inline u32 get_unaligned_le32(const void *p)
79272 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
79273 {
79274 - return le32_to_cpup((__le32 *)p);
79275 + return le32_to_cpup((const __le32 *)p);
79276 }
79277
79278 -static inline u64 get_unaligned_le64(const void *p)
79279 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
79280 {
79281 - return le64_to_cpup((__le64 *)p);
79282 + return le64_to_cpup((const __le64 *)p);
79283 }
79284
79285 -static inline u16 get_unaligned_be16(const void *p)
79286 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
79287 {
79288 - return be16_to_cpup((__be16 *)p);
79289 + return be16_to_cpup((const __be16 *)p);
79290 }
79291
79292 -static inline u32 get_unaligned_be32(const void *p)
79293 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
79294 {
79295 - return be32_to_cpup((__be32 *)p);
79296 + return be32_to_cpup((const __be32 *)p);
79297 }
79298
79299 -static inline u64 get_unaligned_be64(const void *p)
79300 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
79301 {
79302 - return be64_to_cpup((__be64 *)p);
79303 + return be64_to_cpup((const __be64 *)p);
79304 }
79305
79306 static inline void put_unaligned_le16(u16 val, void *p)
79307 diff --git a/include/linux/usb.h b/include/linux/usb.h
79308 index 6b02370..2355ffa 100644
79309 --- a/include/linux/usb.h
79310 +++ b/include/linux/usb.h
79311 @@ -563,7 +563,7 @@ struct usb_device {
79312 int maxchild;
79313
79314 u32 quirks;
79315 - atomic_t urbnum;
79316 + atomic_unchecked_t urbnum;
79317
79318 unsigned long active_duration;
79319
79320 @@ -1639,7 +1639,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
79321
79322 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
79323 __u8 request, __u8 requesttype, __u16 value, __u16 index,
79324 - void *data, __u16 size, int timeout);
79325 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
79326 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
79327 void *data, int len, int *actual_length, int timeout);
79328 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
79329 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
79330 index e452ba6..78f8e80 100644
79331 --- a/include/linux/usb/renesas_usbhs.h
79332 +++ b/include/linux/usb/renesas_usbhs.h
79333 @@ -39,7 +39,7 @@ enum {
79334 */
79335 struct renesas_usbhs_driver_callback {
79336 int (*notify_hotplug)(struct platform_device *pdev);
79337 -};
79338 +} __no_const;
79339
79340 /*
79341 * callback functions for platform
79342 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
79343 index 6f8fbcf..8259001 100644
79344 --- a/include/linux/vermagic.h
79345 +++ b/include/linux/vermagic.h
79346 @@ -25,9 +25,35 @@
79347 #define MODULE_ARCH_VERMAGIC ""
79348 #endif
79349
79350 +#ifdef CONFIG_PAX_REFCOUNT
79351 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
79352 +#else
79353 +#define MODULE_PAX_REFCOUNT ""
79354 +#endif
79355 +
79356 +#ifdef CONSTIFY_PLUGIN
79357 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
79358 +#else
79359 +#define MODULE_CONSTIFY_PLUGIN ""
79360 +#endif
79361 +
79362 +#ifdef STACKLEAK_PLUGIN
79363 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
79364 +#else
79365 +#define MODULE_STACKLEAK_PLUGIN ""
79366 +#endif
79367 +
79368 +#ifdef CONFIG_GRKERNSEC
79369 +#define MODULE_GRSEC "GRSEC "
79370 +#else
79371 +#define MODULE_GRSEC ""
79372 +#endif
79373 +
79374 #define VERMAGIC_STRING \
79375 UTS_RELEASE " " \
79376 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
79377 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
79378 - MODULE_ARCH_VERMAGIC
79379 + MODULE_ARCH_VERMAGIC \
79380 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
79381 + MODULE_GRSEC
79382
79383 diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
79384 index 502073a..a7de024 100644
79385 --- a/include/linux/vga_switcheroo.h
79386 +++ b/include/linux/vga_switcheroo.h
79387 @@ -63,8 +63,8 @@ int vga_switcheroo_get_client_state(struct pci_dev *dev);
79388
79389 void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
79390
79391 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
79392 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
79393 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain);
79394 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain);
79395 #else
79396
79397 static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
79398 @@ -81,8 +81,8 @@ static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return
79399
79400 static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
79401
79402 -static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
79403 -static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
79404 +static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
79405 +static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
79406
79407 #endif
79408 #endif /* _LINUX_VGA_SWITCHEROO_H_ */
79409 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
79410 index 4b8a891..cb8df6e 100644
79411 --- a/include/linux/vmalloc.h
79412 +++ b/include/linux/vmalloc.h
79413 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
79414 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
79415 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
79416 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
79417 +
79418 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
79419 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
79420 +#endif
79421 +
79422 /* bits [20..32] reserved for arch specific ioremap internals */
79423
79424 /*
79425 @@ -142,7 +147,7 @@ extern void free_vm_area(struct vm_struct *area);
79426
79427 /* for /dev/kmem */
79428 extern long vread(char *buf, char *addr, unsigned long count);
79429 -extern long vwrite(char *buf, char *addr, unsigned long count);
79430 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
79431
79432 /*
79433 * Internals. Dont't use..
79434 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
79435 index e4b9480..5a5f65a 100644
79436 --- a/include/linux/vmstat.h
79437 +++ b/include/linux/vmstat.h
79438 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
79439 /*
79440 * Zone based page accounting with per cpu differentials.
79441 */
79442 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
79443 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
79444
79445 static inline void zone_page_state_add(long x, struct zone *zone,
79446 enum zone_stat_item item)
79447 {
79448 - atomic_long_add(x, &zone->vm_stat[item]);
79449 - atomic_long_add(x, &vm_stat[item]);
79450 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
79451 + atomic_long_add_unchecked(x, &vm_stat[item]);
79452 }
79453
79454 -static inline unsigned long global_page_state(enum zone_stat_item item)
79455 +static inline unsigned long __intentional_overflow(-1) global_page_state(enum zone_stat_item item)
79456 {
79457 - long x = atomic_long_read(&vm_stat[item]);
79458 + long x = atomic_long_read_unchecked(&vm_stat[item]);
79459 #ifdef CONFIG_SMP
79460 if (x < 0)
79461 x = 0;
79462 @@ -109,10 +109,10 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
79463 return x;
79464 }
79465
79466 -static inline unsigned long zone_page_state(struct zone *zone,
79467 +static inline unsigned long __intentional_overflow(-1) zone_page_state(struct zone *zone,
79468 enum zone_stat_item item)
79469 {
79470 - long x = atomic_long_read(&zone->vm_stat[item]);
79471 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
79472 #ifdef CONFIG_SMP
79473 if (x < 0)
79474 x = 0;
79475 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
79476 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
79477 enum zone_stat_item item)
79478 {
79479 - long x = atomic_long_read(&zone->vm_stat[item]);
79480 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
79481
79482 #ifdef CONFIG_SMP
79483 int cpu;
79484 @@ -220,8 +220,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
79485
79486 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
79487 {
79488 - atomic_long_inc(&zone->vm_stat[item]);
79489 - atomic_long_inc(&vm_stat[item]);
79490 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
79491 + atomic_long_inc_unchecked(&vm_stat[item]);
79492 }
79493
79494 static inline void __inc_zone_page_state(struct page *page,
79495 @@ -232,8 +232,8 @@ static inline void __inc_zone_page_state(struct page *page,
79496
79497 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
79498 {
79499 - atomic_long_dec(&zone->vm_stat[item]);
79500 - atomic_long_dec(&vm_stat[item]);
79501 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
79502 + atomic_long_dec_unchecked(&vm_stat[item]);
79503 }
79504
79505 static inline void __dec_zone_page_state(struct page *page,
79506 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
79507 index 91b0a68..0e9adf6 100644
79508 --- a/include/linux/xattr.h
79509 +++ b/include/linux/xattr.h
79510 @@ -28,7 +28,7 @@ struct xattr_handler {
79511 size_t size, int handler_flags);
79512 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
79513 size_t size, int flags, int handler_flags);
79514 -};
79515 +} __do_const;
79516
79517 struct xattr {
79518 const char *name;
79519 @@ -37,6 +37,9 @@ struct xattr {
79520 };
79521
79522 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
79523 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
79524 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
79525 +#endif
79526 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
79527 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
79528 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
79529 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
79530 index 9c5a6b4..09c9438 100644
79531 --- a/include/linux/zlib.h
79532 +++ b/include/linux/zlib.h
79533 @@ -31,6 +31,7 @@
79534 #define _ZLIB_H
79535
79536 #include <linux/zconf.h>
79537 +#include <linux/compiler.h>
79538
79539 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
79540 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
79541 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
79542
79543 /* basic functions */
79544
79545 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
79546 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
79547 /*
79548 Returns the number of bytes that needs to be allocated for a per-
79549 stream workspace with the specified parameters. A pointer to this
79550 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
79551 index c768c9f..bdcaa5a 100644
79552 --- a/include/media/v4l2-dev.h
79553 +++ b/include/media/v4l2-dev.h
79554 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
79555 int (*mmap) (struct file *, struct vm_area_struct *);
79556 int (*open) (struct file *);
79557 int (*release) (struct file *);
79558 -};
79559 +} __do_const;
79560
79561 /*
79562 * Newer version of video_device, handled by videodev2.c
79563 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
79564 index c9b1593..a572459 100644
79565 --- a/include/media/v4l2-device.h
79566 +++ b/include/media/v4l2-device.h
79567 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
79568 this function returns 0. If the name ends with a digit (e.g. cx18),
79569 then the name will be set to cx18-0 since cx180 looks really odd. */
79570 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
79571 - atomic_t *instance);
79572 + atomic_unchecked_t *instance);
79573
79574 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
79575 Since the parent disappears this ensures that v4l2_dev doesn't have an
79576 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
79577 index 9a36d92..0aafe2a 100644
79578 --- a/include/net/9p/transport.h
79579 +++ b/include/net/9p/transport.h
79580 @@ -60,7 +60,7 @@ struct p9_trans_module {
79581 int (*cancel) (struct p9_client *, struct p9_req_t *req);
79582 int (*zc_request)(struct p9_client *, struct p9_req_t *,
79583 char *, char *, int , int, int, int);
79584 -};
79585 +} __do_const;
79586
79587 void v9fs_register_trans(struct p9_trans_module *m);
79588 void v9fs_unregister_trans(struct p9_trans_module *m);
79589 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
79590 index 1a966af..2767cf6 100644
79591 --- a/include/net/bluetooth/l2cap.h
79592 +++ b/include/net/bluetooth/l2cap.h
79593 @@ -551,7 +551,7 @@ struct l2cap_ops {
79594 void (*defer) (struct l2cap_chan *chan);
79595 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
79596 unsigned long len, int nb);
79597 -};
79598 +} __do_const;
79599
79600 struct l2cap_conn {
79601 struct hci_conn *hcon;
79602 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
79603 index f2ae33d..c457cf0 100644
79604 --- a/include/net/caif/cfctrl.h
79605 +++ b/include/net/caif/cfctrl.h
79606 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
79607 void (*radioset_rsp)(void);
79608 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
79609 struct cflayer *client_layer);
79610 -};
79611 +} __no_const;
79612
79613 /* Link Setup Parameters for CAIF-Links. */
79614 struct cfctrl_link_param {
79615 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
79616 struct cfctrl {
79617 struct cfsrvl serv;
79618 struct cfctrl_rsp res;
79619 - atomic_t req_seq_no;
79620 - atomic_t rsp_seq_no;
79621 + atomic_unchecked_t req_seq_no;
79622 + atomic_unchecked_t rsp_seq_no;
79623 struct list_head list;
79624 /* Protects from simultaneous access to first_req list */
79625 spinlock_t info_list_lock;
79626 diff --git a/include/net/flow.h b/include/net/flow.h
79627 index 628e11b..4c475df 100644
79628 --- a/include/net/flow.h
79629 +++ b/include/net/flow.h
79630 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
79631
79632 extern void flow_cache_flush(void);
79633 extern void flow_cache_flush_deferred(void);
79634 -extern atomic_t flow_cache_genid;
79635 +extern atomic_unchecked_t flow_cache_genid;
79636
79637 #endif
79638 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
79639 index 8e0b6c8..73cf605 100644
79640 --- a/include/net/genetlink.h
79641 +++ b/include/net/genetlink.h
79642 @@ -120,7 +120,7 @@ struct genl_ops {
79643 struct netlink_callback *cb);
79644 int (*done)(struct netlink_callback *cb);
79645 struct list_head ops_list;
79646 -};
79647 +} __do_const;
79648
79649 extern int __genl_register_family(struct genl_family *family);
79650
79651 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
79652 index 734d9b5..48a9a4b 100644
79653 --- a/include/net/gro_cells.h
79654 +++ b/include/net/gro_cells.h
79655 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
79656 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
79657
79658 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
79659 - atomic_long_inc(&dev->rx_dropped);
79660 + atomic_long_inc_unchecked(&dev->rx_dropped);
79661 kfree_skb(skb);
79662 return;
79663 }
79664 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
79665 index de2c785..0588a6b 100644
79666 --- a/include/net/inet_connection_sock.h
79667 +++ b/include/net/inet_connection_sock.h
79668 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
79669 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
79670 int (*bind_conflict)(const struct sock *sk,
79671 const struct inet_bind_bucket *tb, bool relax);
79672 -};
79673 +} __do_const;
79674
79675 /** inet_connection_sock - INET connection oriented sock
79676 *
79677 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
79678 index 53f464d..0bd0b49 100644
79679 --- a/include/net/inetpeer.h
79680 +++ b/include/net/inetpeer.h
79681 @@ -47,8 +47,8 @@ struct inet_peer {
79682 */
79683 union {
79684 struct {
79685 - atomic_t rid; /* Frag reception counter */
79686 - atomic_t ip_id_count; /* IP ID for the next packet */
79687 + atomic_unchecked_t rid; /* Frag reception counter */
79688 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
79689 };
79690 struct rcu_head rcu;
79691 struct inet_peer *gc_next;
79692 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
79693 /* can be called with or without local BH being disabled */
79694 static inline int inet_getid(struct inet_peer *p, int more)
79695 {
79696 - int old, new;
79697 + int id;
79698 more++;
79699 inet_peer_refcheck(p);
79700 - do {
79701 - old = atomic_read(&p->ip_id_count);
79702 - new = old + more;
79703 - if (!new)
79704 - new = 1;
79705 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
79706 - return new;
79707 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
79708 + if (!id)
79709 + id = atomic_inc_return_unchecked(&p->ip_id_count);
79710 + return id;
79711 }
79712
79713 #endif /* _NET_INETPEER_H */
79714 diff --git a/include/net/ip.h b/include/net/ip.h
79715 index 301f10c..b52cdaf 100644
79716 --- a/include/net/ip.h
79717 +++ b/include/net/ip.h
79718 @@ -212,7 +212,7 @@ extern struct local_ports {
79719 } sysctl_local_ports;
79720 extern void inet_get_local_port_range(int *low, int *high);
79721
79722 -extern unsigned long *sysctl_local_reserved_ports;
79723 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
79724 static inline int inet_is_reserved_local_port(int port)
79725 {
79726 return test_bit(port, sysctl_local_reserved_ports);
79727 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
79728 index cbf2be3..3683f6d 100644
79729 --- a/include/net/ip_fib.h
79730 +++ b/include/net/ip_fib.h
79731 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
79732
79733 #define FIB_RES_SADDR(net, res) \
79734 ((FIB_RES_NH(res).nh_saddr_genid == \
79735 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
79736 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
79737 FIB_RES_NH(res).nh_saddr : \
79738 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
79739 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
79740 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
79741 index 772252d..1e69799 100644
79742 --- a/include/net/ip_vs.h
79743 +++ b/include/net/ip_vs.h
79744 @@ -558,7 +558,7 @@ struct ip_vs_conn {
79745 struct ip_vs_conn *control; /* Master control connection */
79746 atomic_t n_control; /* Number of controlled ones */
79747 struct ip_vs_dest *dest; /* real server */
79748 - atomic_t in_pkts; /* incoming packet counter */
79749 + atomic_unchecked_t in_pkts; /* incoming packet counter */
79750
79751 /* packet transmitter for different forwarding methods. If it
79752 mangles the packet, it must return NF_DROP or better NF_STOLEN,
79753 @@ -705,7 +705,7 @@ struct ip_vs_dest {
79754 __be16 port; /* port number of the server */
79755 union nf_inet_addr addr; /* IP address of the server */
79756 volatile unsigned int flags; /* dest status flags */
79757 - atomic_t conn_flags; /* flags to copy to conn */
79758 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
79759 atomic_t weight; /* server weight */
79760
79761 atomic_t refcnt; /* reference counter */
79762 @@ -960,11 +960,11 @@ struct netns_ipvs {
79763 /* ip_vs_lblc */
79764 int sysctl_lblc_expiration;
79765 struct ctl_table_header *lblc_ctl_header;
79766 - struct ctl_table *lblc_ctl_table;
79767 + ctl_table_no_const *lblc_ctl_table;
79768 /* ip_vs_lblcr */
79769 int sysctl_lblcr_expiration;
79770 struct ctl_table_header *lblcr_ctl_header;
79771 - struct ctl_table *lblcr_ctl_table;
79772 + ctl_table_no_const *lblcr_ctl_table;
79773 /* ip_vs_est */
79774 struct list_head est_list; /* estimator list */
79775 spinlock_t est_lock;
79776 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
79777 index 80ffde3..968b0f4 100644
79778 --- a/include/net/irda/ircomm_tty.h
79779 +++ b/include/net/irda/ircomm_tty.h
79780 @@ -35,6 +35,7 @@
79781 #include <linux/termios.h>
79782 #include <linux/timer.h>
79783 #include <linux/tty.h> /* struct tty_struct */
79784 +#include <asm/local.h>
79785
79786 #include <net/irda/irias_object.h>
79787 #include <net/irda/ircomm_core.h>
79788 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
79789 index 714cc9a..ea05f3e 100644
79790 --- a/include/net/iucv/af_iucv.h
79791 +++ b/include/net/iucv/af_iucv.h
79792 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
79793 struct iucv_sock_list {
79794 struct hlist_head head;
79795 rwlock_t lock;
79796 - atomic_t autobind_name;
79797 + atomic_unchecked_t autobind_name;
79798 };
79799
79800 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
79801 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
79802 index df83f69..9b640b8 100644
79803 --- a/include/net/llc_c_ac.h
79804 +++ b/include/net/llc_c_ac.h
79805 @@ -87,7 +87,7 @@
79806 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
79807 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
79808
79809 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
79810 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
79811
79812 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
79813 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
79814 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
79815 index 6ca3113..f8026dd 100644
79816 --- a/include/net/llc_c_ev.h
79817 +++ b/include/net/llc_c_ev.h
79818 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
79819 return (struct llc_conn_state_ev *)skb->cb;
79820 }
79821
79822 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
79823 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
79824 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
79825 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
79826
79827 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
79828 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
79829 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
79830 index 0e79cfb..f46db31 100644
79831 --- a/include/net/llc_c_st.h
79832 +++ b/include/net/llc_c_st.h
79833 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
79834 u8 next_state;
79835 llc_conn_ev_qfyr_t *ev_qualifiers;
79836 llc_conn_action_t *ev_actions;
79837 -};
79838 +} __do_const;
79839
79840 struct llc_conn_state {
79841 u8 current_state;
79842 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
79843 index 37a3bbd..55a4241 100644
79844 --- a/include/net/llc_s_ac.h
79845 +++ b/include/net/llc_s_ac.h
79846 @@ -23,7 +23,7 @@
79847 #define SAP_ACT_TEST_IND 9
79848
79849 /* All action functions must look like this */
79850 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
79851 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
79852
79853 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
79854 struct sk_buff *skb);
79855 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
79856 index 567c681..cd73ac0 100644
79857 --- a/include/net/llc_s_st.h
79858 +++ b/include/net/llc_s_st.h
79859 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
79860 llc_sap_ev_t ev;
79861 u8 next_state;
79862 llc_sap_action_t *ev_actions;
79863 -};
79864 +} __do_const;
79865
79866 struct llc_sap_state {
79867 u8 curr_state;
79868 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
79869 index cc6035f..a8406fc 100644
79870 --- a/include/net/mac80211.h
79871 +++ b/include/net/mac80211.h
79872 @@ -4361,7 +4361,7 @@ struct rate_control_ops {
79873 void (*add_sta_debugfs)(void *priv, void *priv_sta,
79874 struct dentry *dir);
79875 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
79876 -};
79877 +} __do_const;
79878
79879 static inline int rate_supported(struct ieee80211_sta *sta,
79880 enum ieee80211_band band,
79881 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
79882 index 536501a..7c6193c 100644
79883 --- a/include/net/neighbour.h
79884 +++ b/include/net/neighbour.h
79885 @@ -123,7 +123,7 @@ struct neigh_ops {
79886 void (*error_report)(struct neighbour *, struct sk_buff *);
79887 int (*output)(struct neighbour *, struct sk_buff *);
79888 int (*connected_output)(struct neighbour *, struct sk_buff *);
79889 -};
79890 +} __do_const;
79891
79892 struct pneigh_entry {
79893 struct pneigh_entry *next;
79894 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
79895 index 9d22f08..980fbf8 100644
79896 --- a/include/net/net_namespace.h
79897 +++ b/include/net/net_namespace.h
79898 @@ -120,7 +120,7 @@ struct net {
79899 struct netns_ipvs *ipvs;
79900 #endif
79901 struct sock *diag_nlsk;
79902 - atomic_t fnhe_genid;
79903 + atomic_unchecked_t fnhe_genid;
79904 };
79905
79906 /*
79907 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
79908 #define __net_init __init
79909 #define __net_exit __exit_refok
79910 #define __net_initdata __initdata
79911 +#ifdef CONSTIFY_PLUGIN
79912 #define __net_initconst __initconst
79913 +#else
79914 +#define __net_initconst __initdata
79915 +#endif
79916 #endif
79917
79918 struct pernet_operations {
79919 @@ -287,7 +291,7 @@ struct pernet_operations {
79920 void (*exit_batch)(struct list_head *net_exit_list);
79921 int *id;
79922 size_t size;
79923 -};
79924 +} __do_const;
79925
79926 /*
79927 * Use these carefully. If you implement a network device and it
79928 @@ -335,23 +339,23 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
79929
79930 static inline int rt_genid_ipv4(struct net *net)
79931 {
79932 - return atomic_read(&net->ipv4.rt_genid);
79933 + return atomic_read_unchecked(&net->ipv4.rt_genid);
79934 }
79935
79936 static inline void rt_genid_bump_ipv4(struct net *net)
79937 {
79938 - atomic_inc(&net->ipv4.rt_genid);
79939 + atomic_inc_unchecked(&net->ipv4.rt_genid);
79940 }
79941
79942 #if IS_ENABLED(CONFIG_IPV6)
79943 static inline int rt_genid_ipv6(struct net *net)
79944 {
79945 - return atomic_read(&net->ipv6.rt_genid);
79946 + return atomic_read_unchecked(&net->ipv6.rt_genid);
79947 }
79948
79949 static inline void rt_genid_bump_ipv6(struct net *net)
79950 {
79951 - atomic_inc(&net->ipv6.rt_genid);
79952 + atomic_inc_unchecked(&net->ipv6.rt_genid);
79953 }
79954 #else
79955 static inline int rt_genid_ipv6(struct net *net)
79956 @@ -373,12 +377,12 @@ static inline void rt_genid_bump_all(struct net *net)
79957
79958 static inline int fnhe_genid(struct net *net)
79959 {
79960 - return atomic_read(&net->fnhe_genid);
79961 + return atomic_read_unchecked(&net->fnhe_genid);
79962 }
79963
79964 static inline void fnhe_genid_bump(struct net *net)
79965 {
79966 - atomic_inc(&net->fnhe_genid);
79967 + atomic_inc_unchecked(&net->fnhe_genid);
79968 }
79969
79970 #endif /* __NET_NET_NAMESPACE_H */
79971 diff --git a/include/net/netdma.h b/include/net/netdma.h
79972 index 8ba8ce2..99b7fff 100644
79973 --- a/include/net/netdma.h
79974 +++ b/include/net/netdma.h
79975 @@ -24,7 +24,7 @@
79976 #include <linux/dmaengine.h>
79977 #include <linux/skbuff.h>
79978
79979 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
79980 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
79981 struct sk_buff *skb, int offset, struct iovec *to,
79982 size_t len, struct dma_pinned_list *pinned_list);
79983
79984 diff --git a/include/net/netlink.h b/include/net/netlink.h
79985 index 9690b0f..87aded7 100644
79986 --- a/include/net/netlink.h
79987 +++ b/include/net/netlink.h
79988 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
79989 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
79990 {
79991 if (mark)
79992 - skb_trim(skb, (unsigned char *) mark - skb->data);
79993 + skb_trim(skb, (const unsigned char *) mark - skb->data);
79994 }
79995
79996 /**
79997 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
79998 index c9c0c53..53f24c3 100644
79999 --- a/include/net/netns/conntrack.h
80000 +++ b/include/net/netns/conntrack.h
80001 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
80002 struct nf_proto_net {
80003 #ifdef CONFIG_SYSCTL
80004 struct ctl_table_header *ctl_table_header;
80005 - struct ctl_table *ctl_table;
80006 + ctl_table_no_const *ctl_table;
80007 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
80008 struct ctl_table_header *ctl_compat_header;
80009 - struct ctl_table *ctl_compat_table;
80010 + ctl_table_no_const *ctl_compat_table;
80011 #endif
80012 #endif
80013 unsigned int users;
80014 @@ -58,7 +58,7 @@ struct nf_ip_net {
80015 struct nf_icmp_net icmpv6;
80016 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
80017 struct ctl_table_header *ctl_table_header;
80018 - struct ctl_table *ctl_table;
80019 + ctl_table_no_const *ctl_table;
80020 #endif
80021 };
80022
80023 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
80024 index bf2ec22..5e7f9d9 100644
80025 --- a/include/net/netns/ipv4.h
80026 +++ b/include/net/netns/ipv4.h
80027 @@ -67,7 +67,7 @@ struct netns_ipv4 {
80028 kgid_t sysctl_ping_group_range[2];
80029 long sysctl_tcp_mem[3];
80030
80031 - atomic_t dev_addr_genid;
80032 + atomic_unchecked_t dev_addr_genid;
80033
80034 #ifdef CONFIG_IP_MROUTE
80035 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
80036 @@ -77,6 +77,6 @@ struct netns_ipv4 {
80037 struct fib_rules_ops *mr_rules_ops;
80038 #endif
80039 #endif
80040 - atomic_t rt_genid;
80041 + atomic_unchecked_t rt_genid;
80042 };
80043 #endif
80044 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
80045 index 0fb2401..477d81c 100644
80046 --- a/include/net/netns/ipv6.h
80047 +++ b/include/net/netns/ipv6.h
80048 @@ -71,8 +71,8 @@ struct netns_ipv6 {
80049 struct fib_rules_ops *mr6_rules_ops;
80050 #endif
80051 #endif
80052 - atomic_t dev_addr_genid;
80053 - atomic_t rt_genid;
80054 + atomic_unchecked_t dev_addr_genid;
80055 + atomic_unchecked_t rt_genid;
80056 };
80057
80058 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
80059 diff --git a/include/net/ping.h b/include/net/ping.h
80060 index 2b496e9..935fd8d 100644
80061 --- a/include/net/ping.h
80062 +++ b/include/net/ping.h
80063 @@ -56,7 +56,7 @@ struct ping_iter_state {
80064 extern struct proto ping_prot;
80065 extern struct ping_table ping_table;
80066 #if IS_ENABLED(CONFIG_IPV6)
80067 -extern struct pingv6_ops pingv6_ops;
80068 +extern struct pingv6_ops *pingv6_ops;
80069 #endif
80070
80071 struct pingfakehdr {
80072 diff --git a/include/net/protocol.h b/include/net/protocol.h
80073 index 047c047..b9dad15 100644
80074 --- a/include/net/protocol.h
80075 +++ b/include/net/protocol.h
80076 @@ -44,7 +44,7 @@ struct net_protocol {
80077 void (*err_handler)(struct sk_buff *skb, u32 info);
80078 unsigned int no_policy:1,
80079 netns_ok:1;
80080 -};
80081 +} __do_const;
80082
80083 #if IS_ENABLED(CONFIG_IPV6)
80084 struct inet6_protocol {
80085 @@ -57,7 +57,7 @@ struct inet6_protocol {
80086 u8 type, u8 code, int offset,
80087 __be32 info);
80088 unsigned int flags; /* INET6_PROTO_xxx */
80089 -};
80090 +} __do_const;
80091
80092 #define INET6_PROTO_NOPOLICY 0x1
80093 #define INET6_PROTO_FINAL 0x2
80094 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
80095 index 7026648..584cc8c 100644
80096 --- a/include/net/rtnetlink.h
80097 +++ b/include/net/rtnetlink.h
80098 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
80099 const struct net_device *dev);
80100 unsigned int (*get_num_tx_queues)(void);
80101 unsigned int (*get_num_rx_queues)(void);
80102 -};
80103 +} __do_const;
80104
80105 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
80106 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
80107 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
80108 index 4ef75af..5aa073a 100644
80109 --- a/include/net/sctp/sm.h
80110 +++ b/include/net/sctp/sm.h
80111 @@ -81,7 +81,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
80112 typedef struct {
80113 sctp_state_fn_t *fn;
80114 const char *name;
80115 -} sctp_sm_table_entry_t;
80116 +} __do_const sctp_sm_table_entry_t;
80117
80118 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
80119 * currently in use.
80120 @@ -293,7 +293,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
80121 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
80122
80123 /* Extern declarations for major data structures. */
80124 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
80125 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
80126
80127
80128 /* Get the size of a DATA chunk payload. */
80129 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
80130 index 2174d8d..71d5257 100644
80131 --- a/include/net/sctp/structs.h
80132 +++ b/include/net/sctp/structs.h
80133 @@ -508,7 +508,7 @@ struct sctp_pf {
80134 struct sctp_association *asoc);
80135 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
80136 struct sctp_af *af;
80137 -};
80138 +} __do_const;
80139
80140
80141 /* Structure to track chunk fragments that have been acked, but peer
80142 diff --git a/include/net/sock.h b/include/net/sock.h
80143 index 808cbc2..8617e9c 100644
80144 --- a/include/net/sock.h
80145 +++ b/include/net/sock.h
80146 @@ -332,7 +332,7 @@ struct sock {
80147 unsigned int sk_napi_id;
80148 unsigned int sk_ll_usec;
80149 #endif
80150 - atomic_t sk_drops;
80151 + atomic_unchecked_t sk_drops;
80152 int sk_rcvbuf;
80153
80154 struct sk_filter __rcu *sk_filter;
80155 @@ -1194,7 +1194,7 @@ static inline u64 memcg_memory_allocated_read(struct cg_proto *prot)
80156 return ret >> PAGE_SHIFT;
80157 }
80158
80159 -static inline long
80160 +static inline long __intentional_overflow(-1)
80161 sk_memory_allocated(const struct sock *sk)
80162 {
80163 struct proto *prot = sk->sk_prot;
80164 @@ -1821,7 +1821,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
80165 }
80166
80167 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
80168 - char __user *from, char *to,
80169 + char __user *from, unsigned char *to,
80170 int copy, int offset)
80171 {
80172 if (skb->ip_summed == CHECKSUM_NONE) {
80173 @@ -2083,7 +2083,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
80174 }
80175 }
80176
80177 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
80178 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
80179
80180 /**
80181 * sk_page_frag - return an appropriate page_frag
80182 diff --git a/include/net/tcp.h b/include/net/tcp.h
80183 index b1aa324..b8530ea 100644
80184 --- a/include/net/tcp.h
80185 +++ b/include/net/tcp.h
80186 @@ -527,7 +527,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
80187 extern void tcp_xmit_retransmit_queue(struct sock *);
80188 extern void tcp_simple_retransmit(struct sock *);
80189 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
80190 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
80191 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
80192
80193 extern void tcp_send_probe0(struct sock *);
80194 extern void tcp_send_partial(struct sock *);
80195 @@ -699,8 +699,8 @@ struct tcp_skb_cb {
80196 struct inet6_skb_parm h6;
80197 #endif
80198 } header; /* For incoming frames */
80199 - __u32 seq; /* Starting sequence number */
80200 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
80201 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
80202 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
80203 __u32 when; /* used to compute rtt's */
80204 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
80205
80206 @@ -714,7 +714,7 @@ struct tcp_skb_cb {
80207
80208 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
80209 /* 1 byte hole */
80210 - __u32 ack_seq; /* Sequence number ACK'd */
80211 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
80212 };
80213
80214 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
80215 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
80216 index e253bf0..2278b4b 100644
80217 --- a/include/net/xfrm.h
80218 +++ b/include/net/xfrm.h
80219 @@ -287,7 +287,6 @@ struct xfrm_dst;
80220 struct xfrm_policy_afinfo {
80221 unsigned short family;
80222 struct dst_ops *dst_ops;
80223 - void (*garbage_collect)(struct net *net);
80224 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
80225 const xfrm_address_t *saddr,
80226 const xfrm_address_t *daddr);
80227 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
80228 struct net_device *dev,
80229 const struct flowi *fl);
80230 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
80231 -};
80232 +} __do_const;
80233
80234 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
80235 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
80236 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
80237 int (*transport_finish)(struct sk_buff *skb,
80238 int async);
80239 void (*local_error)(struct sk_buff *skb, u32 mtu);
80240 -};
80241 +} __do_const;
80242
80243 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
80244 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
80245 @@ -427,7 +426,7 @@ struct xfrm_mode {
80246 struct module *owner;
80247 unsigned int encap;
80248 int flags;
80249 -};
80250 +} __do_const;
80251
80252 /* Flags for xfrm_mode. */
80253 enum {
80254 @@ -524,7 +523,7 @@ struct xfrm_policy {
80255 struct timer_list timer;
80256
80257 struct flow_cache_object flo;
80258 - atomic_t genid;
80259 + atomic_unchecked_t genid;
80260 u32 priority;
80261 u32 index;
80262 struct xfrm_mark mark;
80263 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
80264 }
80265
80266 extern void xfrm_garbage_collect(struct net *net);
80267 +extern void xfrm_garbage_collect_deferred(struct net *net);
80268
80269 #else
80270
80271 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
80272 static inline void xfrm_garbage_collect(struct net *net)
80273 {
80274 }
80275 +static inline void xfrm_garbage_collect_deferred(struct net *net)
80276 +{
80277 +}
80278 #endif
80279
80280 static __inline__
80281 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
80282 index 1017e0b..227aa4d 100644
80283 --- a/include/rdma/iw_cm.h
80284 +++ b/include/rdma/iw_cm.h
80285 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
80286 int backlog);
80287
80288 int (*destroy_listen)(struct iw_cm_id *cm_id);
80289 -};
80290 +} __no_const;
80291
80292 /**
80293 * iw_create_cm_id - Create an IW CM identifier.
80294 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
80295 index e1379b4..67eafbe 100644
80296 --- a/include/scsi/libfc.h
80297 +++ b/include/scsi/libfc.h
80298 @@ -762,6 +762,7 @@ struct libfc_function_template {
80299 */
80300 void (*disc_stop_final) (struct fc_lport *);
80301 };
80302 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
80303
80304 /**
80305 * struct fc_disc - Discovery context
80306 @@ -866,7 +867,7 @@ struct fc_lport {
80307 struct fc_vport *vport;
80308
80309 /* Operational Information */
80310 - struct libfc_function_template tt;
80311 + libfc_function_template_no_const tt;
80312 u8 link_up;
80313 u8 qfull;
80314 enum fc_lport_state state;
80315 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
80316 index d65fbec..f80fef2 100644
80317 --- a/include/scsi/scsi_device.h
80318 +++ b/include/scsi/scsi_device.h
80319 @@ -180,9 +180,9 @@ struct scsi_device {
80320 unsigned int max_device_blocked; /* what device_blocked counts down from */
80321 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
80322
80323 - atomic_t iorequest_cnt;
80324 - atomic_t iodone_cnt;
80325 - atomic_t ioerr_cnt;
80326 + atomic_unchecked_t iorequest_cnt;
80327 + atomic_unchecked_t iodone_cnt;
80328 + atomic_unchecked_t ioerr_cnt;
80329
80330 struct device sdev_gendev,
80331 sdev_dev;
80332 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
80333 index b797e8f..8e2c3aa 100644
80334 --- a/include/scsi/scsi_transport_fc.h
80335 +++ b/include/scsi/scsi_transport_fc.h
80336 @@ -751,7 +751,8 @@ struct fc_function_template {
80337 unsigned long show_host_system_hostname:1;
80338
80339 unsigned long disable_target_scan:1;
80340 -};
80341 +} __do_const;
80342 +typedef struct fc_function_template __no_const fc_function_template_no_const;
80343
80344
80345 /**
80346 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
80347 index ae6c3b8..fd748ac 100644
80348 --- a/include/sound/compress_driver.h
80349 +++ b/include/sound/compress_driver.h
80350 @@ -128,7 +128,7 @@ struct snd_compr_ops {
80351 struct snd_compr_caps *caps);
80352 int (*get_codec_caps) (struct snd_compr_stream *stream,
80353 struct snd_compr_codec_caps *codec);
80354 -};
80355 +} __no_const;
80356
80357 /**
80358 * struct snd_compr: Compressed device
80359 diff --git a/include/sound/soc.h b/include/sound/soc.h
80360 index d22cb0a..c6ba150 100644
80361 --- a/include/sound/soc.h
80362 +++ b/include/sound/soc.h
80363 @@ -780,7 +780,7 @@ struct snd_soc_codec_driver {
80364 /* probe ordering - for components with runtime dependencies */
80365 int probe_order;
80366 int remove_order;
80367 -};
80368 +} __do_const;
80369
80370 /* SoC platform interface */
80371 struct snd_soc_platform_driver {
80372 @@ -826,7 +826,7 @@ struct snd_soc_platform_driver {
80373 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
80374 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
80375 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
80376 -};
80377 +} __do_const;
80378
80379 struct snd_soc_platform {
80380 const char *name;
80381 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
80382 index 23bfd10..1ff3e35 100644
80383 --- a/include/target/target_core_base.h
80384 +++ b/include/target/target_core_base.h
80385 @@ -664,7 +664,7 @@ struct se_device {
80386 spinlock_t stats_lock;
80387 /* Active commands on this virtual SE device */
80388 atomic_t simple_cmds;
80389 - atomic_t dev_ordered_id;
80390 + atomic_unchecked_t dev_ordered_id;
80391 atomic_t dev_ordered_sync;
80392 atomic_t dev_qf_count;
80393 int export_count;
80394 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
80395 new file mode 100644
80396 index 0000000..fb634b7
80397 --- /dev/null
80398 +++ b/include/trace/events/fs.h
80399 @@ -0,0 +1,53 @@
80400 +#undef TRACE_SYSTEM
80401 +#define TRACE_SYSTEM fs
80402 +
80403 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
80404 +#define _TRACE_FS_H
80405 +
80406 +#include <linux/fs.h>
80407 +#include <linux/tracepoint.h>
80408 +
80409 +TRACE_EVENT(do_sys_open,
80410 +
80411 + TP_PROTO(const char *filename, int flags, int mode),
80412 +
80413 + TP_ARGS(filename, flags, mode),
80414 +
80415 + TP_STRUCT__entry(
80416 + __string( filename, filename )
80417 + __field( int, flags )
80418 + __field( int, mode )
80419 + ),
80420 +
80421 + TP_fast_assign(
80422 + __assign_str(filename, filename);
80423 + __entry->flags = flags;
80424 + __entry->mode = mode;
80425 + ),
80426 +
80427 + TP_printk("\"%s\" %x %o",
80428 + __get_str(filename), __entry->flags, __entry->mode)
80429 +);
80430 +
80431 +TRACE_EVENT(open_exec,
80432 +
80433 + TP_PROTO(const char *filename),
80434 +
80435 + TP_ARGS(filename),
80436 +
80437 + TP_STRUCT__entry(
80438 + __string( filename, filename )
80439 + ),
80440 +
80441 + TP_fast_assign(
80442 + __assign_str(filename, filename);
80443 + ),
80444 +
80445 + TP_printk("\"%s\"",
80446 + __get_str(filename))
80447 +);
80448 +
80449 +#endif /* _TRACE_FS_H */
80450 +
80451 +/* This part must be outside protection */
80452 +#include <trace/define_trace.h>
80453 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
80454 index 1c09820..7f5ec79 100644
80455 --- a/include/trace/events/irq.h
80456 +++ b/include/trace/events/irq.h
80457 @@ -36,7 +36,7 @@ struct softirq_action;
80458 */
80459 TRACE_EVENT(irq_handler_entry,
80460
80461 - TP_PROTO(int irq, struct irqaction *action),
80462 + TP_PROTO(int irq, const struct irqaction *action),
80463
80464 TP_ARGS(irq, action),
80465
80466 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
80467 */
80468 TRACE_EVENT(irq_handler_exit,
80469
80470 - TP_PROTO(int irq, struct irqaction *action, int ret),
80471 + TP_PROTO(int irq, const struct irqaction *action, int ret),
80472
80473 TP_ARGS(irq, action, ret),
80474
80475 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
80476 index 7caf44c..23c6f27 100644
80477 --- a/include/uapi/linux/a.out.h
80478 +++ b/include/uapi/linux/a.out.h
80479 @@ -39,6 +39,14 @@ enum machine_type {
80480 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
80481 };
80482
80483 +/* Constants for the N_FLAGS field */
80484 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
80485 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
80486 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
80487 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
80488 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
80489 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
80490 +
80491 #if !defined (N_MAGIC)
80492 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
80493 #endif
80494 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
80495 index d876736..ccce5c0 100644
80496 --- a/include/uapi/linux/byteorder/little_endian.h
80497 +++ b/include/uapi/linux/byteorder/little_endian.h
80498 @@ -42,51 +42,51 @@
80499
80500 static inline __le64 __cpu_to_le64p(const __u64 *p)
80501 {
80502 - return (__force __le64)*p;
80503 + return (__force const __le64)*p;
80504 }
80505 -static inline __u64 __le64_to_cpup(const __le64 *p)
80506 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
80507 {
80508 - return (__force __u64)*p;
80509 + return (__force const __u64)*p;
80510 }
80511 static inline __le32 __cpu_to_le32p(const __u32 *p)
80512 {
80513 - return (__force __le32)*p;
80514 + return (__force const __le32)*p;
80515 }
80516 static inline __u32 __le32_to_cpup(const __le32 *p)
80517 {
80518 - return (__force __u32)*p;
80519 + return (__force const __u32)*p;
80520 }
80521 static inline __le16 __cpu_to_le16p(const __u16 *p)
80522 {
80523 - return (__force __le16)*p;
80524 + return (__force const __le16)*p;
80525 }
80526 static inline __u16 __le16_to_cpup(const __le16 *p)
80527 {
80528 - return (__force __u16)*p;
80529 + return (__force const __u16)*p;
80530 }
80531 static inline __be64 __cpu_to_be64p(const __u64 *p)
80532 {
80533 - return (__force __be64)__swab64p(p);
80534 + return (__force const __be64)__swab64p(p);
80535 }
80536 static inline __u64 __be64_to_cpup(const __be64 *p)
80537 {
80538 - return __swab64p((__u64 *)p);
80539 + return __swab64p((const __u64 *)p);
80540 }
80541 static inline __be32 __cpu_to_be32p(const __u32 *p)
80542 {
80543 - return (__force __be32)__swab32p(p);
80544 + return (__force const __be32)__swab32p(p);
80545 }
80546 -static inline __u32 __be32_to_cpup(const __be32 *p)
80547 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
80548 {
80549 - return __swab32p((__u32 *)p);
80550 + return __swab32p((const __u32 *)p);
80551 }
80552 static inline __be16 __cpu_to_be16p(const __u16 *p)
80553 {
80554 - return (__force __be16)__swab16p(p);
80555 + return (__force const __be16)__swab16p(p);
80556 }
80557 static inline __u16 __be16_to_cpup(const __be16 *p)
80558 {
80559 - return __swab16p((__u16 *)p);
80560 + return __swab16p((const __u16 *)p);
80561 }
80562 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
80563 #define __le64_to_cpus(x) do { (void)(x); } while (0)
80564 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
80565 index ef6103b..d4e65dd 100644
80566 --- a/include/uapi/linux/elf.h
80567 +++ b/include/uapi/linux/elf.h
80568 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
80569 #define PT_GNU_EH_FRAME 0x6474e550
80570
80571 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
80572 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
80573 +
80574 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
80575 +
80576 +/* Constants for the e_flags field */
80577 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
80578 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
80579 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
80580 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
80581 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
80582 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
80583
80584 /*
80585 * Extended Numbering
80586 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
80587 #define DT_DEBUG 21
80588 #define DT_TEXTREL 22
80589 #define DT_JMPREL 23
80590 +#define DT_FLAGS 30
80591 + #define DF_TEXTREL 0x00000004
80592 #define DT_ENCODING 32
80593 #define OLD_DT_LOOS 0x60000000
80594 #define DT_LOOS 0x6000000d
80595 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
80596 #define PF_W 0x2
80597 #define PF_X 0x1
80598
80599 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
80600 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
80601 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
80602 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
80603 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
80604 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
80605 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
80606 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
80607 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
80608 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
80609 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
80610 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
80611 +
80612 typedef struct elf32_phdr{
80613 Elf32_Word p_type;
80614 Elf32_Off p_offset;
80615 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
80616 #define EI_OSABI 7
80617 #define EI_PAD 8
80618
80619 +#define EI_PAX 14
80620 +
80621 #define ELFMAG0 0x7f /* EI_MAG */
80622 #define ELFMAG1 'E'
80623 #define ELFMAG2 'L'
80624 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
80625 index aa169c4..6a2771d 100644
80626 --- a/include/uapi/linux/personality.h
80627 +++ b/include/uapi/linux/personality.h
80628 @@ -30,6 +30,7 @@ enum {
80629 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
80630 ADDR_NO_RANDOMIZE | \
80631 ADDR_COMPAT_LAYOUT | \
80632 + ADDR_LIMIT_3GB | \
80633 MMAP_PAGE_ZERO)
80634
80635 /*
80636 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
80637 index 7530e74..e714828 100644
80638 --- a/include/uapi/linux/screen_info.h
80639 +++ b/include/uapi/linux/screen_info.h
80640 @@ -43,7 +43,8 @@ struct screen_info {
80641 __u16 pages; /* 0x32 */
80642 __u16 vesa_attributes; /* 0x34 */
80643 __u32 capabilities; /* 0x36 */
80644 - __u8 _reserved[6]; /* 0x3a */
80645 + __u16 vesapm_size; /* 0x3a */
80646 + __u8 _reserved[4]; /* 0x3c */
80647 } __attribute__((packed));
80648
80649 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
80650 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
80651 index 0e011eb..82681b1 100644
80652 --- a/include/uapi/linux/swab.h
80653 +++ b/include/uapi/linux/swab.h
80654 @@ -43,7 +43,7 @@
80655 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
80656 */
80657
80658 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
80659 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
80660 {
80661 #ifdef __HAVE_BUILTIN_BSWAP16__
80662 return __builtin_bswap16(val);
80663 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
80664 #endif
80665 }
80666
80667 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
80668 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
80669 {
80670 #ifdef __HAVE_BUILTIN_BSWAP32__
80671 return __builtin_bswap32(val);
80672 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
80673 #endif
80674 }
80675
80676 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
80677 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
80678 {
80679 #ifdef __HAVE_BUILTIN_BSWAP64__
80680 return __builtin_bswap64(val);
80681 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
80682 index 6d67213..8dab561 100644
80683 --- a/include/uapi/linux/sysctl.h
80684 +++ b/include/uapi/linux/sysctl.h
80685 @@ -155,7 +155,11 @@ enum
80686 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
80687 };
80688
80689 -
80690 +#ifdef CONFIG_PAX_SOFTMODE
80691 +enum {
80692 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
80693 +};
80694 +#endif
80695
80696 /* CTL_VM names: */
80697 enum
80698 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
80699 index e4629b9..6958086 100644
80700 --- a/include/uapi/linux/xattr.h
80701 +++ b/include/uapi/linux/xattr.h
80702 @@ -63,5 +63,9 @@
80703 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
80704 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
80705
80706 +/* User namespace */
80707 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
80708 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
80709 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
80710
80711 #endif /* _UAPI_LINUX_XATTR_H */
80712 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
80713 index f9466fa..f4e2b81 100644
80714 --- a/include/video/udlfb.h
80715 +++ b/include/video/udlfb.h
80716 @@ -53,10 +53,10 @@ struct dlfb_data {
80717 u32 pseudo_palette[256];
80718 int blank_mode; /*one of FB_BLANK_ */
80719 /* blit-only rendering path metrics, exposed through sysfs */
80720 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
80721 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
80722 - atomic_t bytes_sent; /* to usb, after compression including overhead */
80723 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
80724 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
80725 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
80726 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
80727 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
80728 };
80729
80730 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
80731 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
80732 index 30f5362..8ed8ac9 100644
80733 --- a/include/video/uvesafb.h
80734 +++ b/include/video/uvesafb.h
80735 @@ -122,6 +122,7 @@ struct uvesafb_par {
80736 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
80737 u8 pmi_setpal; /* PMI for palette changes */
80738 u16 *pmi_base; /* protected mode interface location */
80739 + u8 *pmi_code; /* protected mode code location */
80740 void *pmi_start;
80741 void *pmi_pal;
80742 u8 *vbe_state_orig; /*
80743 diff --git a/init/Kconfig b/init/Kconfig
80744 index 3ecd8a1..627843f 100644
80745 --- a/init/Kconfig
80746 +++ b/init/Kconfig
80747 @@ -1086,6 +1086,7 @@ endif # CGROUPS
80748
80749 config CHECKPOINT_RESTORE
80750 bool "Checkpoint/restore support" if EXPERT
80751 + depends on !GRKERNSEC
80752 default n
80753 help
80754 Enables additional kernel features in a sake of checkpoint/restore.
80755 @@ -1557,7 +1558,7 @@ config SLUB_DEBUG
80756
80757 config COMPAT_BRK
80758 bool "Disable heap randomization"
80759 - default y
80760 + default n
80761 help
80762 Randomizing heap placement makes heap exploits harder, but it
80763 also breaks ancient binaries (including anything libc5 based).
80764 @@ -1832,7 +1833,7 @@ config INIT_ALL_POSSIBLE
80765 config STOP_MACHINE
80766 bool
80767 default y
80768 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
80769 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
80770 help
80771 Need stop_machine() primitive.
80772
80773 diff --git a/init/Makefile b/init/Makefile
80774 index 7bc47ee..6da2dc7 100644
80775 --- a/init/Makefile
80776 +++ b/init/Makefile
80777 @@ -2,6 +2,9 @@
80778 # Makefile for the linux kernel.
80779 #
80780
80781 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
80782 +asflags-y := $(GCC_PLUGINS_AFLAGS)
80783 +
80784 obj-y := main.o version.o mounts.o
80785 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
80786 obj-y += noinitramfs.o
80787 diff --git a/init/do_mounts.c b/init/do_mounts.c
80788 index a51cddc..25c2768 100644
80789 --- a/init/do_mounts.c
80790 +++ b/init/do_mounts.c
80791 @@ -357,11 +357,11 @@ static void __init get_fs_names(char *page)
80792 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
80793 {
80794 struct super_block *s;
80795 - int err = sys_mount(name, "/root", fs, flags, data);
80796 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
80797 if (err)
80798 return err;
80799
80800 - sys_chdir("/root");
80801 + sys_chdir((const char __force_user *)"/root");
80802 s = current->fs->pwd.dentry->d_sb;
80803 ROOT_DEV = s->s_dev;
80804 printk(KERN_INFO
80805 @@ -482,18 +482,18 @@ void __init change_floppy(char *fmt, ...)
80806 va_start(args, fmt);
80807 vsprintf(buf, fmt, args);
80808 va_end(args);
80809 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
80810 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
80811 if (fd >= 0) {
80812 sys_ioctl(fd, FDEJECT, 0);
80813 sys_close(fd);
80814 }
80815 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
80816 - fd = sys_open("/dev/console", O_RDWR, 0);
80817 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
80818 if (fd >= 0) {
80819 sys_ioctl(fd, TCGETS, (long)&termios);
80820 termios.c_lflag &= ~ICANON;
80821 sys_ioctl(fd, TCSETSF, (long)&termios);
80822 - sys_read(fd, &c, 1);
80823 + sys_read(fd, (char __user *)&c, 1);
80824 termios.c_lflag |= ICANON;
80825 sys_ioctl(fd, TCSETSF, (long)&termios);
80826 sys_close(fd);
80827 @@ -587,8 +587,8 @@ void __init prepare_namespace(void)
80828 mount_root();
80829 out:
80830 devtmpfs_mount("dev");
80831 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
80832 - sys_chroot(".");
80833 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
80834 + sys_chroot((const char __force_user *)".");
80835 }
80836
80837 static bool is_tmpfs;
80838 diff --git a/init/do_mounts.h b/init/do_mounts.h
80839 index f5b978a..69dbfe8 100644
80840 --- a/init/do_mounts.h
80841 +++ b/init/do_mounts.h
80842 @@ -15,15 +15,15 @@ extern int root_mountflags;
80843
80844 static inline int create_dev(char *name, dev_t dev)
80845 {
80846 - sys_unlink(name);
80847 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
80848 + sys_unlink((char __force_user *)name);
80849 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
80850 }
80851
80852 #if BITS_PER_LONG == 32
80853 static inline u32 bstat(char *name)
80854 {
80855 struct stat64 stat;
80856 - if (sys_stat64(name, &stat) != 0)
80857 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
80858 return 0;
80859 if (!S_ISBLK(stat.st_mode))
80860 return 0;
80861 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
80862 static inline u32 bstat(char *name)
80863 {
80864 struct stat stat;
80865 - if (sys_newstat(name, &stat) != 0)
80866 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
80867 return 0;
80868 if (!S_ISBLK(stat.st_mode))
80869 return 0;
80870 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
80871 index 3e0878e..8a9d7a0 100644
80872 --- a/init/do_mounts_initrd.c
80873 +++ b/init/do_mounts_initrd.c
80874 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
80875 {
80876 sys_unshare(CLONE_FS | CLONE_FILES);
80877 /* stdin/stdout/stderr for /linuxrc */
80878 - sys_open("/dev/console", O_RDWR, 0);
80879 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
80880 sys_dup(0);
80881 sys_dup(0);
80882 /* move initrd over / and chdir/chroot in initrd root */
80883 - sys_chdir("/root");
80884 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
80885 - sys_chroot(".");
80886 + sys_chdir((const char __force_user *)"/root");
80887 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
80888 + sys_chroot((const char __force_user *)".");
80889 sys_setsid();
80890 return 0;
80891 }
80892 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
80893 create_dev("/dev/root.old", Root_RAM0);
80894 /* mount initrd on rootfs' /root */
80895 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
80896 - sys_mkdir("/old", 0700);
80897 - sys_chdir("/old");
80898 + sys_mkdir((const char __force_user *)"/old", 0700);
80899 + sys_chdir((const char __force_user *)"/old");
80900
80901 /* try loading default modules from initrd */
80902 load_default_modules();
80903 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
80904 current->flags &= ~PF_FREEZER_SKIP;
80905
80906 /* move initrd to rootfs' /old */
80907 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
80908 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
80909 /* switch root and cwd back to / of rootfs */
80910 - sys_chroot("..");
80911 + sys_chroot((const char __force_user *)"..");
80912
80913 if (new_decode_dev(real_root_dev) == Root_RAM0) {
80914 - sys_chdir("/old");
80915 + sys_chdir((const char __force_user *)"/old");
80916 return;
80917 }
80918
80919 - sys_chdir("/");
80920 + sys_chdir((const char __force_user *)"/");
80921 ROOT_DEV = new_decode_dev(real_root_dev);
80922 mount_root();
80923
80924 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
80925 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
80926 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
80927 if (!error)
80928 printk("okay\n");
80929 else {
80930 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
80931 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
80932 if (error == -ENOENT)
80933 printk("/initrd does not exist. Ignored.\n");
80934 else
80935 printk("failed\n");
80936 printk(KERN_NOTICE "Unmounting old root\n");
80937 - sys_umount("/old", MNT_DETACH);
80938 + sys_umount((char __force_user *)"/old", MNT_DETACH);
80939 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
80940 if (fd < 0) {
80941 error = fd;
80942 @@ -127,11 +127,11 @@ int __init initrd_load(void)
80943 * mounted in the normal path.
80944 */
80945 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
80946 - sys_unlink("/initrd.image");
80947 + sys_unlink((const char __force_user *)"/initrd.image");
80948 handle_initrd();
80949 return 1;
80950 }
80951 }
80952 - sys_unlink("/initrd.image");
80953 + sys_unlink((const char __force_user *)"/initrd.image");
80954 return 0;
80955 }
80956 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
80957 index 8cb6db5..d729f50 100644
80958 --- a/init/do_mounts_md.c
80959 +++ b/init/do_mounts_md.c
80960 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
80961 partitioned ? "_d" : "", minor,
80962 md_setup_args[ent].device_names);
80963
80964 - fd = sys_open(name, 0, 0);
80965 + fd = sys_open((char __force_user *)name, 0, 0);
80966 if (fd < 0) {
80967 printk(KERN_ERR "md: open failed - cannot start "
80968 "array %s\n", name);
80969 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
80970 * array without it
80971 */
80972 sys_close(fd);
80973 - fd = sys_open(name, 0, 0);
80974 + fd = sys_open((char __force_user *)name, 0, 0);
80975 sys_ioctl(fd, BLKRRPART, 0);
80976 }
80977 sys_close(fd);
80978 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
80979
80980 wait_for_device_probe();
80981
80982 - fd = sys_open("/dev/md0", 0, 0);
80983 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
80984 if (fd >= 0) {
80985 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
80986 sys_close(fd);
80987 diff --git a/init/init_task.c b/init/init_task.c
80988 index ba0a7f36..2bcf1d5 100644
80989 --- a/init/init_task.c
80990 +++ b/init/init_task.c
80991 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
80992 * Initial thread structure. Alignment of this is handled by a special
80993 * linker map entry.
80994 */
80995 +#ifdef CONFIG_X86
80996 +union thread_union init_thread_union __init_task_data;
80997 +#else
80998 union thread_union init_thread_union __init_task_data =
80999 { INIT_THREAD_INFO(init_task) };
81000 +#endif
81001 diff --git a/init/initramfs.c b/init/initramfs.c
81002 index a67ef9d..2d17ed9 100644
81003 --- a/init/initramfs.c
81004 +++ b/init/initramfs.c
81005 @@ -84,7 +84,7 @@ static void __init free_hash(void)
81006 }
81007 }
81008
81009 -static long __init do_utime(char *filename, time_t mtime)
81010 +static long __init do_utime(char __force_user *filename, time_t mtime)
81011 {
81012 struct timespec t[2];
81013
81014 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
81015 struct dir_entry *de, *tmp;
81016 list_for_each_entry_safe(de, tmp, &dir_list, list) {
81017 list_del(&de->list);
81018 - do_utime(de->name, de->mtime);
81019 + do_utime((char __force_user *)de->name, de->mtime);
81020 kfree(de->name);
81021 kfree(de);
81022 }
81023 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
81024 if (nlink >= 2) {
81025 char *old = find_link(major, minor, ino, mode, collected);
81026 if (old)
81027 - return (sys_link(old, collected) < 0) ? -1 : 1;
81028 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
81029 }
81030 return 0;
81031 }
81032 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
81033 {
81034 struct stat st;
81035
81036 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
81037 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
81038 if (S_ISDIR(st.st_mode))
81039 - sys_rmdir(path);
81040 + sys_rmdir((char __force_user *)path);
81041 else
81042 - sys_unlink(path);
81043 + sys_unlink((char __force_user *)path);
81044 }
81045 }
81046
81047 @@ -315,7 +315,7 @@ static int __init do_name(void)
81048 int openflags = O_WRONLY|O_CREAT;
81049 if (ml != 1)
81050 openflags |= O_TRUNC;
81051 - wfd = sys_open(collected, openflags, mode);
81052 + wfd = sys_open((char __force_user *)collected, openflags, mode);
81053
81054 if (wfd >= 0) {
81055 sys_fchown(wfd, uid, gid);
81056 @@ -327,17 +327,17 @@ static int __init do_name(void)
81057 }
81058 }
81059 } else if (S_ISDIR(mode)) {
81060 - sys_mkdir(collected, mode);
81061 - sys_chown(collected, uid, gid);
81062 - sys_chmod(collected, mode);
81063 + sys_mkdir((char __force_user *)collected, mode);
81064 + sys_chown((char __force_user *)collected, uid, gid);
81065 + sys_chmod((char __force_user *)collected, mode);
81066 dir_add(collected, mtime);
81067 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
81068 S_ISFIFO(mode) || S_ISSOCK(mode)) {
81069 if (maybe_link() == 0) {
81070 - sys_mknod(collected, mode, rdev);
81071 - sys_chown(collected, uid, gid);
81072 - sys_chmod(collected, mode);
81073 - do_utime(collected, mtime);
81074 + sys_mknod((char __force_user *)collected, mode, rdev);
81075 + sys_chown((char __force_user *)collected, uid, gid);
81076 + sys_chmod((char __force_user *)collected, mode);
81077 + do_utime((char __force_user *)collected, mtime);
81078 }
81079 }
81080 return 0;
81081 @@ -346,15 +346,15 @@ static int __init do_name(void)
81082 static int __init do_copy(void)
81083 {
81084 if (count >= body_len) {
81085 - sys_write(wfd, victim, body_len);
81086 + sys_write(wfd, (char __force_user *)victim, body_len);
81087 sys_close(wfd);
81088 - do_utime(vcollected, mtime);
81089 + do_utime((char __force_user *)vcollected, mtime);
81090 kfree(vcollected);
81091 eat(body_len);
81092 state = SkipIt;
81093 return 0;
81094 } else {
81095 - sys_write(wfd, victim, count);
81096 + sys_write(wfd, (char __force_user *)victim, count);
81097 body_len -= count;
81098 eat(count);
81099 return 1;
81100 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
81101 {
81102 collected[N_ALIGN(name_len) + body_len] = '\0';
81103 clean_path(collected, 0);
81104 - sys_symlink(collected + N_ALIGN(name_len), collected);
81105 - sys_lchown(collected, uid, gid);
81106 - do_utime(collected, mtime);
81107 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
81108 + sys_lchown((char __force_user *)collected, uid, gid);
81109 + do_utime((char __force_user *)collected, mtime);
81110 state = SkipIt;
81111 next_state = Reset;
81112 return 0;
81113 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
81114 {
81115 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
81116 if (err)
81117 - panic(err); /* Failed to decompress INTERNAL initramfs */
81118 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
81119 if (initrd_start) {
81120 #ifdef CONFIG_BLK_DEV_RAM
81121 int fd;
81122 diff --git a/init/main.c b/init/main.c
81123 index 63d3e8f..50bd5f8 100644
81124 --- a/init/main.c
81125 +++ b/init/main.c
81126 @@ -103,6 +103,8 @@ static inline void mark_rodata_ro(void) { }
81127 extern void tc_init(void);
81128 #endif
81129
81130 +extern void grsecurity_init(void);
81131 +
81132 /*
81133 * Debug helper: via this flag we know that we are in 'early bootup code'
81134 * where only the boot processor is running with IRQ disabled. This means
81135 @@ -156,6 +158,75 @@ static int __init set_reset_devices(char *str)
81136
81137 __setup("reset_devices", set_reset_devices);
81138
81139 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
81140 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
81141 +static int __init setup_grsec_proc_gid(char *str)
81142 +{
81143 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
81144 + return 1;
81145 +}
81146 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
81147 +#endif
81148 +
81149 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
81150 +unsigned long pax_user_shadow_base __read_only;
81151 +EXPORT_SYMBOL(pax_user_shadow_base);
81152 +extern char pax_enter_kernel_user[];
81153 +extern char pax_exit_kernel_user[];
81154 +#endif
81155 +
81156 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
81157 +static int __init setup_pax_nouderef(char *str)
81158 +{
81159 +#ifdef CONFIG_X86_32
81160 + unsigned int cpu;
81161 + struct desc_struct *gdt;
81162 +
81163 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
81164 + gdt = get_cpu_gdt_table(cpu);
81165 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
81166 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
81167 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
81168 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
81169 + }
81170 + loadsegment(ds, __KERNEL_DS);
81171 + loadsegment(es, __KERNEL_DS);
81172 + loadsegment(ss, __KERNEL_DS);
81173 +#else
81174 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
81175 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
81176 + clone_pgd_mask = ~(pgdval_t)0UL;
81177 + pax_user_shadow_base = 0UL;
81178 + setup_clear_cpu_cap(X86_FEATURE_PCID);
81179 + setup_clear_cpu_cap(X86_FEATURE_INVPCID);
81180 +#endif
81181 +
81182 + return 0;
81183 +}
81184 +early_param("pax_nouderef", setup_pax_nouderef);
81185 +
81186 +#ifdef CONFIG_X86_64
81187 +static int __init setup_pax_weakuderef(char *str)
81188 +{
81189 + if (clone_pgd_mask != ~(pgdval_t)0UL)
81190 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
81191 + return 1;
81192 +}
81193 +__setup("pax_weakuderef", setup_pax_weakuderef);
81194 +#endif
81195 +#endif
81196 +
81197 +#ifdef CONFIG_PAX_SOFTMODE
81198 +int pax_softmode;
81199 +
81200 +static int __init setup_pax_softmode(char *str)
81201 +{
81202 + get_option(&str, &pax_softmode);
81203 + return 1;
81204 +}
81205 +__setup("pax_softmode=", setup_pax_softmode);
81206 +#endif
81207 +
81208 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
81209 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
81210 static const char *panic_later, *panic_param;
81211 @@ -682,25 +753,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
81212 {
81213 int count = preempt_count();
81214 int ret;
81215 - char msgbuf[64];
81216 + const char *msg1 = "", *msg2 = "";
81217
81218 if (initcall_debug)
81219 ret = do_one_initcall_debug(fn);
81220 else
81221 ret = fn();
81222
81223 - msgbuf[0] = 0;
81224 -
81225 if (preempt_count() != count) {
81226 - sprintf(msgbuf, "preemption imbalance ");
81227 + msg1 = " preemption imbalance";
81228 preempt_count() = count;
81229 }
81230 if (irqs_disabled()) {
81231 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
81232 + msg2 = " disabled interrupts";
81233 local_irq_enable();
81234 }
81235 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
81236 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
81237
81238 + add_latent_entropy();
81239 return ret;
81240 }
81241
81242 @@ -807,10 +877,14 @@ static int run_init_process(const char *init_filename)
81243 {
81244 argv_init[0] = init_filename;
81245 return do_execve(init_filename,
81246 - (const char __user *const __user *)argv_init,
81247 - (const char __user *const __user *)envp_init);
81248 + (const char __user *const __force_user *)argv_init,
81249 + (const char __user *const __force_user *)envp_init);
81250 }
81251
81252 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
81253 +extern int gr_init_ran;
81254 +#endif
81255 +
81256 static noinline void __init kernel_init_freeable(void);
81257
81258 static int __ref kernel_init(void *unused)
81259 @@ -831,6 +905,11 @@ static int __ref kernel_init(void *unused)
81260 pr_err("Failed to execute %s\n", ramdisk_execute_command);
81261 }
81262
81263 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
81264 + /* if no initrd was used, be extra sure we enforce chroot restrictions */
81265 + gr_init_ran = 1;
81266 +#endif
81267 +
81268 /*
81269 * We try each of these until one succeeds.
81270 *
81271 @@ -885,7 +964,7 @@ static noinline void __init kernel_init_freeable(void)
81272 do_basic_setup();
81273
81274 /* Open the /dev/console on the rootfs, this should never fail */
81275 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
81276 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
81277 pr_err("Warning: unable to open an initial console.\n");
81278
81279 (void) sys_dup(0);
81280 @@ -898,11 +977,13 @@ static noinline void __init kernel_init_freeable(void)
81281 if (!ramdisk_execute_command)
81282 ramdisk_execute_command = "/init";
81283
81284 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
81285 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
81286 ramdisk_execute_command = NULL;
81287 prepare_namespace();
81288 }
81289
81290 + grsecurity_init();
81291 +
81292 /*
81293 * Ok, we have completed the initial bootup, and
81294 * we're essentially up and running. Get rid of the
81295 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
81296 index b0e99de..09f385c 100644
81297 --- a/ipc/ipc_sysctl.c
81298 +++ b/ipc/ipc_sysctl.c
81299 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
81300 static int proc_ipc_dointvec(ctl_table *table, int write,
81301 void __user *buffer, size_t *lenp, loff_t *ppos)
81302 {
81303 - struct ctl_table ipc_table;
81304 + ctl_table_no_const ipc_table;
81305
81306 memcpy(&ipc_table, table, sizeof(ipc_table));
81307 ipc_table.data = get_ipc(table);
81308 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
81309 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
81310 void __user *buffer, size_t *lenp, loff_t *ppos)
81311 {
81312 - struct ctl_table ipc_table;
81313 + ctl_table_no_const ipc_table;
81314
81315 memcpy(&ipc_table, table, sizeof(ipc_table));
81316 ipc_table.data = get_ipc(table);
81317 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
81318 static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
81319 void __user *buffer, size_t *lenp, loff_t *ppos)
81320 {
81321 - struct ctl_table ipc_table;
81322 + ctl_table_no_const ipc_table;
81323 size_t lenp_bef = *lenp;
81324 int rc;
81325
81326 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
81327 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
81328 void __user *buffer, size_t *lenp, loff_t *ppos)
81329 {
81330 - struct ctl_table ipc_table;
81331 + ctl_table_no_const ipc_table;
81332 memcpy(&ipc_table, table, sizeof(ipc_table));
81333 ipc_table.data = get_ipc(table);
81334
81335 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
81336 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
81337 void __user *buffer, size_t *lenp, loff_t *ppos)
81338 {
81339 - struct ctl_table ipc_table;
81340 + ctl_table_no_const ipc_table;
81341 size_t lenp_bef = *lenp;
81342 int oldval;
81343 int rc;
81344 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
81345 index 383d638..943fdbb 100644
81346 --- a/ipc/mq_sysctl.c
81347 +++ b/ipc/mq_sysctl.c
81348 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
81349 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
81350 void __user *buffer, size_t *lenp, loff_t *ppos)
81351 {
81352 - struct ctl_table mq_table;
81353 + ctl_table_no_const mq_table;
81354 memcpy(&mq_table, table, sizeof(mq_table));
81355 mq_table.data = get_mq(table);
81356
81357 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
81358 index ae1996d..a35f2cc 100644
81359 --- a/ipc/mqueue.c
81360 +++ b/ipc/mqueue.c
81361 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
81362 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
81363 info->attr.mq_msgsize);
81364
81365 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
81366 spin_lock(&mq_lock);
81367 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
81368 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
81369 diff --git a/ipc/msg.c b/ipc/msg.c
81370 index 558aa91..359e718 100644
81371 --- a/ipc/msg.c
81372 +++ b/ipc/msg.c
81373 @@ -297,18 +297,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
81374 return security_msg_queue_associate(msq, msgflg);
81375 }
81376
81377 +static struct ipc_ops msg_ops = {
81378 + .getnew = newque,
81379 + .associate = msg_security,
81380 + .more_checks = NULL
81381 +};
81382 +
81383 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
81384 {
81385 struct ipc_namespace *ns;
81386 - struct ipc_ops msg_ops;
81387 struct ipc_params msg_params;
81388
81389 ns = current->nsproxy->ipc_ns;
81390
81391 - msg_ops.getnew = newque;
81392 - msg_ops.associate = msg_security;
81393 - msg_ops.more_checks = NULL;
81394 -
81395 msg_params.key = key;
81396 msg_params.flg = msgflg;
81397
81398 diff --git a/ipc/sem.c b/ipc/sem.c
81399 index db9d241..bc8427c 100644
81400 --- a/ipc/sem.c
81401 +++ b/ipc/sem.c
81402 @@ -562,10 +562,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
81403 return 0;
81404 }
81405
81406 +static struct ipc_ops sem_ops = {
81407 + .getnew = newary,
81408 + .associate = sem_security,
81409 + .more_checks = sem_more_checks
81410 +};
81411 +
81412 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
81413 {
81414 struct ipc_namespace *ns;
81415 - struct ipc_ops sem_ops;
81416 struct ipc_params sem_params;
81417
81418 ns = current->nsproxy->ipc_ns;
81419 @@ -573,10 +578,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
81420 if (nsems < 0 || nsems > ns->sc_semmsl)
81421 return -EINVAL;
81422
81423 - sem_ops.getnew = newary;
81424 - sem_ops.associate = sem_security;
81425 - sem_ops.more_checks = sem_more_checks;
81426 -
81427 sem_params.key = key;
81428 sem_params.flg = semflg;
81429 sem_params.u.nsems = nsems;
81430 diff --git a/ipc/shm.c b/ipc/shm.c
81431 index 7a51443..3a257d8 100644
81432 --- a/ipc/shm.c
81433 +++ b/ipc/shm.c
81434 @@ -72,6 +72,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
81435 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
81436 #endif
81437
81438 +#ifdef CONFIG_GRKERNSEC
81439 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
81440 + const time_t shm_createtime, const kuid_t cuid,
81441 + const int shmid);
81442 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
81443 + const time_t shm_createtime);
81444 +#endif
81445 +
81446 void shm_init_ns(struct ipc_namespace *ns)
81447 {
81448 ns->shm_ctlmax = SHMMAX;
81449 @@ -554,6 +562,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
81450 shp->shm_lprid = 0;
81451 shp->shm_atim = shp->shm_dtim = 0;
81452 shp->shm_ctim = get_seconds();
81453 +#ifdef CONFIG_GRKERNSEC
81454 + {
81455 + struct timespec timeval;
81456 + do_posix_clock_monotonic_gettime(&timeval);
81457 +
81458 + shp->shm_createtime = timeval.tv_sec;
81459 + }
81460 +#endif
81461 shp->shm_segsz = size;
81462 shp->shm_nattch = 0;
81463 shp->shm_file = file;
81464 @@ -607,18 +623,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
81465 return 0;
81466 }
81467
81468 +static struct ipc_ops shm_ops = {
81469 + .getnew = newseg,
81470 + .associate = shm_security,
81471 + .more_checks = shm_more_checks
81472 +};
81473 +
81474 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
81475 {
81476 struct ipc_namespace *ns;
81477 - struct ipc_ops shm_ops;
81478 struct ipc_params shm_params;
81479
81480 ns = current->nsproxy->ipc_ns;
81481
81482 - shm_ops.getnew = newseg;
81483 - shm_ops.associate = shm_security;
81484 - shm_ops.more_checks = shm_more_checks;
81485 -
81486 shm_params.key = key;
81487 shm_params.flg = shmflg;
81488 shm_params.u.size = size;
81489 @@ -1089,6 +1106,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
81490 f_mode = FMODE_READ | FMODE_WRITE;
81491 }
81492 if (shmflg & SHM_EXEC) {
81493 +
81494 +#ifdef CONFIG_PAX_MPROTECT
81495 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
81496 + goto out;
81497 +#endif
81498 +
81499 prot |= PROT_EXEC;
81500 acc_mode |= S_IXUGO;
81501 }
81502 @@ -1113,6 +1136,15 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
81503 if (err)
81504 goto out_unlock;
81505
81506 +#ifdef CONFIG_GRKERNSEC
81507 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
81508 + shp->shm_perm.cuid, shmid) ||
81509 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
81510 + err = -EACCES;
81511 + goto out_unlock;
81512 + }
81513 +#endif
81514 +
81515 ipc_lock_object(&shp->shm_perm);
81516
81517 /* check if shm_destroy() is tearing down shp */
81518 @@ -1125,6 +1157,9 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
81519 path = shp->shm_file->f_path;
81520 path_get(&path);
81521 shp->shm_nattch++;
81522 +#ifdef CONFIG_GRKERNSEC
81523 + shp->shm_lapid = current->pid;
81524 +#endif
81525 size = i_size_read(path.dentry->d_inode);
81526 ipc_unlock_object(&shp->shm_perm);
81527 rcu_read_unlock();
81528 diff --git a/ipc/util.c b/ipc/util.c
81529 index 7684f41..5bf1880 100644
81530 --- a/ipc/util.c
81531 +++ b/ipc/util.c
81532 @@ -71,6 +71,8 @@ struct ipc_proc_iface {
81533 int (*show)(struct seq_file *, void *);
81534 };
81535
81536 +extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
81537 +
81538 static void ipc_memory_notifier(struct work_struct *work)
81539 {
81540 ipcns_notify(IPCNS_MEMCHANGED);
81541 @@ -560,6 +562,10 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
81542 granted_mode >>= 6;
81543 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
81544 granted_mode >>= 3;
81545 +
81546 + if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
81547 + return -1;
81548 +
81549 /* is there some bit set in requested_mode but not in granted_mode? */
81550 if ((requested_mode & ~granted_mode & 0007) &&
81551 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
81552 diff --git a/kernel/acct.c b/kernel/acct.c
81553 index 8d6e145..33e0b1e 100644
81554 --- a/kernel/acct.c
81555 +++ b/kernel/acct.c
81556 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
81557 */
81558 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
81559 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
81560 - file->f_op->write(file, (char *)&ac,
81561 + file->f_op->write(file, (char __force_user *)&ac,
81562 sizeof(acct_t), &file->f_pos);
81563 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
81564 set_fs(fs);
81565 diff --git a/kernel/audit.c b/kernel/audit.c
81566 index 7ddfd8a..49766eb 100644
81567 --- a/kernel/audit.c
81568 +++ b/kernel/audit.c
81569 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
81570 3) suppressed due to audit_rate_limit
81571 4) suppressed due to audit_backlog_limit
81572 */
81573 -static atomic_t audit_lost = ATOMIC_INIT(0);
81574 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
81575
81576 /* The netlink socket. */
81577 static struct sock *audit_sock;
81578 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
81579 unsigned long now;
81580 int print;
81581
81582 - atomic_inc(&audit_lost);
81583 + atomic_inc_unchecked(&audit_lost);
81584
81585 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
81586
81587 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
81588 printk(KERN_WARNING
81589 "audit: audit_lost=%d audit_rate_limit=%d "
81590 "audit_backlog_limit=%d\n",
81591 - atomic_read(&audit_lost),
81592 + atomic_read_unchecked(&audit_lost),
81593 audit_rate_limit,
81594 audit_backlog_limit);
81595 audit_panic(message);
81596 @@ -665,7 +665,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
81597 status_set.pid = audit_pid;
81598 status_set.rate_limit = audit_rate_limit;
81599 status_set.backlog_limit = audit_backlog_limit;
81600 - status_set.lost = atomic_read(&audit_lost);
81601 + status_set.lost = atomic_read_unchecked(&audit_lost);
81602 status_set.backlog = skb_queue_len(&audit_skb_queue);
81603 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
81604 &status_set, sizeof(status_set));
81605 @@ -1252,7 +1252,7 @@ void audit_log_n_hex(struct audit_buffer *ab, const unsigned char *buf,
81606 int i, avail, new_len;
81607 unsigned char *ptr;
81608 struct sk_buff *skb;
81609 - static const unsigned char *hex = "0123456789ABCDEF";
81610 + static const unsigned char hex[] = "0123456789ABCDEF";
81611
81612 if (!ab)
81613 return;
81614 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
81615 index 9845cb3..3ec9369 100644
81616 --- a/kernel/auditsc.c
81617 +++ b/kernel/auditsc.c
81618 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
81619 }
81620
81621 /* global counter which is incremented every time something logs in */
81622 -static atomic_t session_id = ATOMIC_INIT(0);
81623 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
81624
81625 /**
81626 * audit_set_loginuid - set current task's audit_context loginuid
81627 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
81628 return -EPERM;
81629 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
81630
81631 - sessionid = atomic_inc_return(&session_id);
81632 + sessionid = atomic_inc_return_unchecked(&session_id);
81633 if (context && context->in_syscall) {
81634 struct audit_buffer *ab;
81635
81636 diff --git a/kernel/capability.c b/kernel/capability.c
81637 index 4e66bf9..cdccecf 100644
81638 --- a/kernel/capability.c
81639 +++ b/kernel/capability.c
81640 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
81641 * before modification is attempted and the application
81642 * fails.
81643 */
81644 + if (tocopy > ARRAY_SIZE(kdata))
81645 + return -EFAULT;
81646 +
81647 if (copy_to_user(dataptr, kdata, tocopy
81648 * sizeof(struct __user_cap_data_struct))) {
81649 return -EFAULT;
81650 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
81651 int ret;
81652
81653 rcu_read_lock();
81654 - ret = security_capable(__task_cred(t), ns, cap);
81655 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
81656 + gr_task_is_capable(t, __task_cred(t), cap);
81657 rcu_read_unlock();
81658
81659 - return (ret == 0);
81660 + return ret;
81661 }
81662
81663 /**
81664 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
81665 int ret;
81666
81667 rcu_read_lock();
81668 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
81669 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
81670 rcu_read_unlock();
81671
81672 - return (ret == 0);
81673 + return ret;
81674 }
81675
81676 /**
81677 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
81678 BUG();
81679 }
81680
81681 - if (security_capable(current_cred(), ns, cap) == 0) {
81682 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
81683 current->flags |= PF_SUPERPRIV;
81684 return true;
81685 }
81686 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
81687 }
81688 EXPORT_SYMBOL(ns_capable);
81689
81690 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
81691 +{
81692 + if (unlikely(!cap_valid(cap))) {
81693 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
81694 + BUG();
81695 + }
81696 +
81697 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
81698 + current->flags |= PF_SUPERPRIV;
81699 + return true;
81700 + }
81701 + return false;
81702 +}
81703 +EXPORT_SYMBOL(ns_capable_nolog);
81704 +
81705 /**
81706 * file_ns_capable - Determine if the file's opener had a capability in effect
81707 * @file: The file we want to check
81708 @@ -432,6 +451,12 @@ bool capable(int cap)
81709 }
81710 EXPORT_SYMBOL(capable);
81711
81712 +bool capable_nolog(int cap)
81713 +{
81714 + return ns_capable_nolog(&init_user_ns, cap);
81715 +}
81716 +EXPORT_SYMBOL(capable_nolog);
81717 +
81718 /**
81719 * inode_capable - Check superior capability over inode
81720 * @inode: The inode in question
81721 @@ -453,3 +478,11 @@ bool inode_capable(const struct inode *inode, int cap)
81722 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
81723 }
81724 EXPORT_SYMBOL(inode_capable);
81725 +
81726 +bool inode_capable_nolog(const struct inode *inode, int cap)
81727 +{
81728 + struct user_namespace *ns = current_user_ns();
81729 +
81730 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
81731 +}
81732 +EXPORT_SYMBOL(inode_capable_nolog);
81733 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
81734 index b6fd783..7f526b7 100644
81735 --- a/kernel/cgroup.c
81736 +++ b/kernel/cgroup.c
81737 @@ -5855,7 +5855,7 @@ static int cgroup_css_links_read(struct cgroup_subsys_state *css,
81738 struct css_set *cset = link->cset;
81739 struct task_struct *task;
81740 int count = 0;
81741 - seq_printf(seq, "css_set %p\n", cset);
81742 + seq_printf(seq, "css_set %pK\n", cset);
81743 list_for_each_entry(task, &cset->tasks, cg_list) {
81744 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
81745 seq_puts(seq, " ...\n");
81746 diff --git a/kernel/compat.c b/kernel/compat.c
81747 index 0a09e48..f44f3f0 100644
81748 --- a/kernel/compat.c
81749 +++ b/kernel/compat.c
81750 @@ -13,6 +13,7 @@
81751
81752 #include <linux/linkage.h>
81753 #include <linux/compat.h>
81754 +#include <linux/module.h>
81755 #include <linux/errno.h>
81756 #include <linux/time.h>
81757 #include <linux/signal.h>
81758 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
81759 mm_segment_t oldfs;
81760 long ret;
81761
81762 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
81763 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
81764 oldfs = get_fs();
81765 set_fs(KERNEL_DS);
81766 ret = hrtimer_nanosleep_restart(restart);
81767 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
81768 oldfs = get_fs();
81769 set_fs(KERNEL_DS);
81770 ret = hrtimer_nanosleep(&tu,
81771 - rmtp ? (struct timespec __user *)&rmt : NULL,
81772 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
81773 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
81774 set_fs(oldfs);
81775
81776 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
81777 mm_segment_t old_fs = get_fs();
81778
81779 set_fs(KERNEL_DS);
81780 - ret = sys_sigpending((old_sigset_t __user *) &s);
81781 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
81782 set_fs(old_fs);
81783 if (ret == 0)
81784 ret = put_user(s, set);
81785 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
81786 mm_segment_t old_fs = get_fs();
81787
81788 set_fs(KERNEL_DS);
81789 - ret = sys_old_getrlimit(resource, &r);
81790 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
81791 set_fs(old_fs);
81792
81793 if (!ret) {
81794 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
81795 set_fs (KERNEL_DS);
81796 ret = sys_wait4(pid,
81797 (stat_addr ?
81798 - (unsigned int __user *) &status : NULL),
81799 - options, (struct rusage __user *) &r);
81800 + (unsigned int __force_user *) &status : NULL),
81801 + options, (struct rusage __force_user *) &r);
81802 set_fs (old_fs);
81803
81804 if (ret > 0) {
81805 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
81806 memset(&info, 0, sizeof(info));
81807
81808 set_fs(KERNEL_DS);
81809 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
81810 - uru ? (struct rusage __user *)&ru : NULL);
81811 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
81812 + uru ? (struct rusage __force_user *)&ru : NULL);
81813 set_fs(old_fs);
81814
81815 if ((ret < 0) || (info.si_signo == 0))
81816 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
81817 oldfs = get_fs();
81818 set_fs(KERNEL_DS);
81819 err = sys_timer_settime(timer_id, flags,
81820 - (struct itimerspec __user *) &newts,
81821 - (struct itimerspec __user *) &oldts);
81822 + (struct itimerspec __force_user *) &newts,
81823 + (struct itimerspec __force_user *) &oldts);
81824 set_fs(oldfs);
81825 if (!err && old && put_compat_itimerspec(old, &oldts))
81826 return -EFAULT;
81827 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
81828 oldfs = get_fs();
81829 set_fs(KERNEL_DS);
81830 err = sys_timer_gettime(timer_id,
81831 - (struct itimerspec __user *) &ts);
81832 + (struct itimerspec __force_user *) &ts);
81833 set_fs(oldfs);
81834 if (!err && put_compat_itimerspec(setting, &ts))
81835 return -EFAULT;
81836 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
81837 oldfs = get_fs();
81838 set_fs(KERNEL_DS);
81839 err = sys_clock_settime(which_clock,
81840 - (struct timespec __user *) &ts);
81841 + (struct timespec __force_user *) &ts);
81842 set_fs(oldfs);
81843 return err;
81844 }
81845 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
81846 oldfs = get_fs();
81847 set_fs(KERNEL_DS);
81848 err = sys_clock_gettime(which_clock,
81849 - (struct timespec __user *) &ts);
81850 + (struct timespec __force_user *) &ts);
81851 set_fs(oldfs);
81852 if (!err && put_compat_timespec(&ts, tp))
81853 return -EFAULT;
81854 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
81855
81856 oldfs = get_fs();
81857 set_fs(KERNEL_DS);
81858 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
81859 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
81860 set_fs(oldfs);
81861
81862 err = compat_put_timex(utp, &txc);
81863 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
81864 oldfs = get_fs();
81865 set_fs(KERNEL_DS);
81866 err = sys_clock_getres(which_clock,
81867 - (struct timespec __user *) &ts);
81868 + (struct timespec __force_user *) &ts);
81869 set_fs(oldfs);
81870 if (!err && tp && put_compat_timespec(&ts, tp))
81871 return -EFAULT;
81872 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
81873 long err;
81874 mm_segment_t oldfs;
81875 struct timespec tu;
81876 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
81877 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
81878
81879 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
81880 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
81881 oldfs = get_fs();
81882 set_fs(KERNEL_DS);
81883 err = clock_nanosleep_restart(restart);
81884 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
81885 oldfs = get_fs();
81886 set_fs(KERNEL_DS);
81887 err = sys_clock_nanosleep(which_clock, flags,
81888 - (struct timespec __user *) &in,
81889 - (struct timespec __user *) &out);
81890 + (struct timespec __force_user *) &in,
81891 + (struct timespec __force_user *) &out);
81892 set_fs(oldfs);
81893
81894 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
81895 diff --git a/kernel/configs.c b/kernel/configs.c
81896 index c18b1f1..b9a0132 100644
81897 --- a/kernel/configs.c
81898 +++ b/kernel/configs.c
81899 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
81900 struct proc_dir_entry *entry;
81901
81902 /* create the current config file */
81903 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
81904 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
81905 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
81906 + &ikconfig_file_ops);
81907 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
81908 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
81909 + &ikconfig_file_ops);
81910 +#endif
81911 +#else
81912 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
81913 &ikconfig_file_ops);
81914 +#endif
81915 +
81916 if (!entry)
81917 return -ENOMEM;
81918
81919 diff --git a/kernel/cred.c b/kernel/cred.c
81920 index e0573a4..3874e41 100644
81921 --- a/kernel/cred.c
81922 +++ b/kernel/cred.c
81923 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
81924 validate_creds(cred);
81925 alter_cred_subscribers(cred, -1);
81926 put_cred(cred);
81927 +
81928 +#ifdef CONFIG_GRKERNSEC_SETXID
81929 + cred = (struct cred *) tsk->delayed_cred;
81930 + if (cred != NULL) {
81931 + tsk->delayed_cred = NULL;
81932 + validate_creds(cred);
81933 + alter_cred_subscribers(cred, -1);
81934 + put_cred(cred);
81935 + }
81936 +#endif
81937 }
81938
81939 /**
81940 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
81941 * Always returns 0 thus allowing this function to be tail-called at the end
81942 * of, say, sys_setgid().
81943 */
81944 -int commit_creds(struct cred *new)
81945 +static int __commit_creds(struct cred *new)
81946 {
81947 struct task_struct *task = current;
81948 const struct cred *old = task->real_cred;
81949 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
81950
81951 get_cred(new); /* we will require a ref for the subj creds too */
81952
81953 + gr_set_role_label(task, new->uid, new->gid);
81954 +
81955 /* dumpability changes */
81956 if (!uid_eq(old->euid, new->euid) ||
81957 !gid_eq(old->egid, new->egid) ||
81958 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
81959 put_cred(old);
81960 return 0;
81961 }
81962 +#ifdef CONFIG_GRKERNSEC_SETXID
81963 +extern int set_user(struct cred *new);
81964 +
81965 +void gr_delayed_cred_worker(void)
81966 +{
81967 + const struct cred *new = current->delayed_cred;
81968 + struct cred *ncred;
81969 +
81970 + current->delayed_cred = NULL;
81971 +
81972 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
81973 + // from doing get_cred on it when queueing this
81974 + put_cred(new);
81975 + return;
81976 + } else if (new == NULL)
81977 + return;
81978 +
81979 + ncred = prepare_creds();
81980 + if (!ncred)
81981 + goto die;
81982 + // uids
81983 + ncred->uid = new->uid;
81984 + ncred->euid = new->euid;
81985 + ncred->suid = new->suid;
81986 + ncred->fsuid = new->fsuid;
81987 + // gids
81988 + ncred->gid = new->gid;
81989 + ncred->egid = new->egid;
81990 + ncred->sgid = new->sgid;
81991 + ncred->fsgid = new->fsgid;
81992 + // groups
81993 + if (set_groups(ncred, new->group_info) < 0) {
81994 + abort_creds(ncred);
81995 + goto die;
81996 + }
81997 + // caps
81998 + ncred->securebits = new->securebits;
81999 + ncred->cap_inheritable = new->cap_inheritable;
82000 + ncred->cap_permitted = new->cap_permitted;
82001 + ncred->cap_effective = new->cap_effective;
82002 + ncred->cap_bset = new->cap_bset;
82003 +
82004 + if (set_user(ncred)) {
82005 + abort_creds(ncred);
82006 + goto die;
82007 + }
82008 +
82009 + // from doing get_cred on it when queueing this
82010 + put_cred(new);
82011 +
82012 + __commit_creds(ncred);
82013 + return;
82014 +die:
82015 + // from doing get_cred on it when queueing this
82016 + put_cred(new);
82017 + do_group_exit(SIGKILL);
82018 +}
82019 +#endif
82020 +
82021 +int commit_creds(struct cred *new)
82022 +{
82023 +#ifdef CONFIG_GRKERNSEC_SETXID
82024 + int ret;
82025 + int schedule_it = 0;
82026 + struct task_struct *t;
82027 +
82028 + /* we won't get called with tasklist_lock held for writing
82029 + and interrupts disabled as the cred struct in that case is
82030 + init_cred
82031 + */
82032 + if (grsec_enable_setxid && !current_is_single_threaded() &&
82033 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
82034 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
82035 + schedule_it = 1;
82036 + }
82037 + ret = __commit_creds(new);
82038 + if (schedule_it) {
82039 + rcu_read_lock();
82040 + read_lock(&tasklist_lock);
82041 + for (t = next_thread(current); t != current;
82042 + t = next_thread(t)) {
82043 + if (t->delayed_cred == NULL) {
82044 + t->delayed_cred = get_cred(new);
82045 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
82046 + set_tsk_need_resched(t);
82047 + }
82048 + }
82049 + read_unlock(&tasklist_lock);
82050 + rcu_read_unlock();
82051 + }
82052 + return ret;
82053 +#else
82054 + return __commit_creds(new);
82055 +#endif
82056 +}
82057 +
82058 EXPORT_SYMBOL(commit_creds);
82059
82060 /**
82061 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
82062 index 0506d44..2c20034 100644
82063 --- a/kernel/debug/debug_core.c
82064 +++ b/kernel/debug/debug_core.c
82065 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
82066 */
82067 static atomic_t masters_in_kgdb;
82068 static atomic_t slaves_in_kgdb;
82069 -static atomic_t kgdb_break_tasklet_var;
82070 +static atomic_unchecked_t kgdb_break_tasklet_var;
82071 atomic_t kgdb_setting_breakpoint;
82072
82073 struct task_struct *kgdb_usethread;
82074 @@ -133,7 +133,7 @@ int kgdb_single_step;
82075 static pid_t kgdb_sstep_pid;
82076
82077 /* to keep track of the CPU which is doing the single stepping*/
82078 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
82079 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
82080
82081 /*
82082 * If you are debugging a problem where roundup (the collection of
82083 @@ -541,7 +541,7 @@ return_normal:
82084 * kernel will only try for the value of sstep_tries before
82085 * giving up and continuing on.
82086 */
82087 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
82088 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
82089 (kgdb_info[cpu].task &&
82090 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
82091 atomic_set(&kgdb_active, -1);
82092 @@ -635,8 +635,8 @@ cpu_master_loop:
82093 }
82094
82095 kgdb_restore:
82096 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
82097 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
82098 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
82099 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
82100 if (kgdb_info[sstep_cpu].task)
82101 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
82102 else
82103 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
82104 static void kgdb_tasklet_bpt(unsigned long ing)
82105 {
82106 kgdb_breakpoint();
82107 - atomic_set(&kgdb_break_tasklet_var, 0);
82108 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
82109 }
82110
82111 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
82112
82113 void kgdb_schedule_breakpoint(void)
82114 {
82115 - if (atomic_read(&kgdb_break_tasklet_var) ||
82116 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
82117 atomic_read(&kgdb_active) != -1 ||
82118 atomic_read(&kgdb_setting_breakpoint))
82119 return;
82120 - atomic_inc(&kgdb_break_tasklet_var);
82121 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
82122 tasklet_schedule(&kgdb_tasklet_breakpoint);
82123 }
82124 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
82125 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
82126 index 00eb8f7..d7e3244 100644
82127 --- a/kernel/debug/kdb/kdb_main.c
82128 +++ b/kernel/debug/kdb/kdb_main.c
82129 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
82130 continue;
82131
82132 kdb_printf("%-20s%8u 0x%p ", mod->name,
82133 - mod->core_size, (void *)mod);
82134 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
82135 #ifdef CONFIG_MODULE_UNLOAD
82136 kdb_printf("%4ld ", module_refcount(mod));
82137 #endif
82138 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
82139 kdb_printf(" (Loading)");
82140 else
82141 kdb_printf(" (Live)");
82142 - kdb_printf(" 0x%p", mod->module_core);
82143 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
82144
82145 #ifdef CONFIG_MODULE_UNLOAD
82146 {
82147 diff --git a/kernel/events/core.c b/kernel/events/core.c
82148 index 953c143..5646bb1 100644
82149 --- a/kernel/events/core.c
82150 +++ b/kernel/events/core.c
82151 @@ -157,8 +157,15 @@ static struct srcu_struct pmus_srcu;
82152 * 0 - disallow raw tracepoint access for unpriv
82153 * 1 - disallow cpu events for unpriv
82154 * 2 - disallow kernel profiling for unpriv
82155 + * 3 - disallow all unpriv perf event use
82156 */
82157 -int sysctl_perf_event_paranoid __read_mostly = 1;
82158 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
82159 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
82160 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
82161 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
82162 +#else
82163 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
82164 +#endif
82165
82166 /* Minimum for 512 kiB + 1 user control page */
82167 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
82168 @@ -271,7 +278,7 @@ void perf_sample_event_took(u64 sample_len_ns)
82169 update_perf_cpu_limits();
82170 }
82171
82172 -static atomic64_t perf_event_id;
82173 +static atomic64_unchecked_t perf_event_id;
82174
82175 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
82176 enum event_type_t event_type);
82177 @@ -2940,7 +2947,7 @@ static void __perf_event_read(void *info)
82178
82179 static inline u64 perf_event_count(struct perf_event *event)
82180 {
82181 - return local64_read(&event->count) + atomic64_read(&event->child_count);
82182 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
82183 }
82184
82185 static u64 perf_event_read(struct perf_event *event)
82186 @@ -3308,9 +3315,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
82187 mutex_lock(&event->child_mutex);
82188 total += perf_event_read(event);
82189 *enabled += event->total_time_enabled +
82190 - atomic64_read(&event->child_total_time_enabled);
82191 + atomic64_read_unchecked(&event->child_total_time_enabled);
82192 *running += event->total_time_running +
82193 - atomic64_read(&event->child_total_time_running);
82194 + atomic64_read_unchecked(&event->child_total_time_running);
82195
82196 list_for_each_entry(child, &event->child_list, child_list) {
82197 total += perf_event_read(child);
82198 @@ -3725,10 +3732,10 @@ void perf_event_update_userpage(struct perf_event *event)
82199 userpg->offset -= local64_read(&event->hw.prev_count);
82200
82201 userpg->time_enabled = enabled +
82202 - atomic64_read(&event->child_total_time_enabled);
82203 + atomic64_read_unchecked(&event->child_total_time_enabled);
82204
82205 userpg->time_running = running +
82206 - atomic64_read(&event->child_total_time_running);
82207 + atomic64_read_unchecked(&event->child_total_time_running);
82208
82209 arch_perf_update_userpage(userpg, now);
82210
82211 @@ -4279,7 +4286,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
82212
82213 /* Data. */
82214 sp = perf_user_stack_pointer(regs);
82215 - rem = __output_copy_user(handle, (void *) sp, dump_size);
82216 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
82217 dyn_size = dump_size - rem;
82218
82219 perf_output_skip(handle, rem);
82220 @@ -4370,11 +4377,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
82221 values[n++] = perf_event_count(event);
82222 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
82223 values[n++] = enabled +
82224 - atomic64_read(&event->child_total_time_enabled);
82225 + atomic64_read_unchecked(&event->child_total_time_enabled);
82226 }
82227 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
82228 values[n++] = running +
82229 - atomic64_read(&event->child_total_time_running);
82230 + atomic64_read_unchecked(&event->child_total_time_running);
82231 }
82232 if (read_format & PERF_FORMAT_ID)
82233 values[n++] = primary_event_id(event);
82234 @@ -5112,12 +5119,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
82235 * need to add enough zero bytes after the string to handle
82236 * the 64bit alignment we do later.
82237 */
82238 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
82239 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
82240 if (!buf) {
82241 name = strncpy(tmp, "//enomem", sizeof(tmp));
82242 goto got_name;
82243 }
82244 - name = d_path(&file->f_path, buf, PATH_MAX);
82245 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
82246 if (IS_ERR(name)) {
82247 name = strncpy(tmp, "//toolong", sizeof(tmp));
82248 goto got_name;
82249 @@ -6639,7 +6646,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
82250 event->parent = parent_event;
82251
82252 event->ns = get_pid_ns(task_active_pid_ns(current));
82253 - event->id = atomic64_inc_return(&perf_event_id);
82254 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
82255
82256 event->state = PERF_EVENT_STATE_INACTIVE;
82257
82258 @@ -6938,6 +6945,11 @@ SYSCALL_DEFINE5(perf_event_open,
82259 if (flags & ~PERF_FLAG_ALL)
82260 return -EINVAL;
82261
82262 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
82263 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
82264 + return -EACCES;
82265 +#endif
82266 +
82267 err = perf_copy_attr(attr_uptr, &attr);
82268 if (err)
82269 return err;
82270 @@ -7271,10 +7283,10 @@ static void sync_child_event(struct perf_event *child_event,
82271 /*
82272 * Add back the child's count to the parent's count:
82273 */
82274 - atomic64_add(child_val, &parent_event->child_count);
82275 - atomic64_add(child_event->total_time_enabled,
82276 + atomic64_add_unchecked(child_val, &parent_event->child_count);
82277 + atomic64_add_unchecked(child_event->total_time_enabled,
82278 &parent_event->child_total_time_enabled);
82279 - atomic64_add(child_event->total_time_running,
82280 + atomic64_add_unchecked(child_event->total_time_running,
82281 &parent_event->child_total_time_running);
82282
82283 /*
82284 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
82285 index ca65997..60df03d 100644
82286 --- a/kernel/events/internal.h
82287 +++ b/kernel/events/internal.h
82288 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
82289 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
82290 }
82291
82292 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
82293 -static inline unsigned int \
82294 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
82295 +static inline unsigned long \
82296 func_name(struct perf_output_handle *handle, \
82297 - const void *buf, unsigned int len) \
82298 + const void user *buf, unsigned long len) \
82299 { \
82300 unsigned long size, written; \
82301 \
82302 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
82303 return n;
82304 }
82305
82306 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
82307 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
82308
82309 #define MEMCPY_SKIP(dst, src, n) (n)
82310
82311 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
82312 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
82313
82314 #ifndef arch_perf_out_copy_user
82315 #define arch_perf_out_copy_user __copy_from_user_inatomic
82316 #endif
82317
82318 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
82319 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
82320
82321 /* Callchain handling */
82322 extern struct perf_callchain_entry *
82323 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
82324 index ad8e1bd..fed7ba9 100644
82325 --- a/kernel/events/uprobes.c
82326 +++ b/kernel/events/uprobes.c
82327 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
82328 {
82329 struct page *page;
82330 uprobe_opcode_t opcode;
82331 - int result;
82332 + long result;
82333
82334 pagefault_disable();
82335 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
82336 diff --git a/kernel/exit.c b/kernel/exit.c
82337 index a949819..a5f127d 100644
82338 --- a/kernel/exit.c
82339 +++ b/kernel/exit.c
82340 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
82341 struct task_struct *leader;
82342 int zap_leader;
82343 repeat:
82344 +#ifdef CONFIG_NET
82345 + gr_del_task_from_ip_table(p);
82346 +#endif
82347 +
82348 /* don't need to get the RCU readlock here - the process is dead and
82349 * can't be modifying its own credentials. But shut RCU-lockdep up */
82350 rcu_read_lock();
82351 @@ -329,7 +333,7 @@ int allow_signal(int sig)
82352 * know it'll be handled, so that they don't get converted to
82353 * SIGKILL or just silently dropped.
82354 */
82355 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
82356 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
82357 recalc_sigpending();
82358 spin_unlock_irq(&current->sighand->siglock);
82359 return 0;
82360 @@ -698,6 +702,8 @@ void do_exit(long code)
82361 struct task_struct *tsk = current;
82362 int group_dead;
82363
82364 + set_fs(USER_DS);
82365 +
82366 profile_task_exit(tsk);
82367
82368 WARN_ON(blk_needs_flush_plug(tsk));
82369 @@ -714,7 +720,6 @@ void do_exit(long code)
82370 * mm_release()->clear_child_tid() from writing to a user-controlled
82371 * kernel address.
82372 */
82373 - set_fs(USER_DS);
82374
82375 ptrace_event(PTRACE_EVENT_EXIT, code);
82376
82377 @@ -773,6 +778,9 @@ void do_exit(long code)
82378 tsk->exit_code = code;
82379 taskstats_exit(tsk, group_dead);
82380
82381 + gr_acl_handle_psacct(tsk, code);
82382 + gr_acl_handle_exit();
82383 +
82384 exit_mm(tsk);
82385
82386 if (group_dead)
82387 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
82388 * Take down every thread in the group. This is called by fatal signals
82389 * as well as by sys_exit_group (below).
82390 */
82391 -void
82392 +__noreturn void
82393 do_group_exit(int exit_code)
82394 {
82395 struct signal_struct *sig = current->signal;
82396 diff --git a/kernel/fork.c b/kernel/fork.c
82397 index 690cfac..3be2d98 100644
82398 --- a/kernel/fork.c
82399 +++ b/kernel/fork.c
82400 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
82401 *stackend = STACK_END_MAGIC; /* for overflow detection */
82402
82403 #ifdef CONFIG_CC_STACKPROTECTOR
82404 - tsk->stack_canary = get_random_int();
82405 + tsk->stack_canary = pax_get_random_long();
82406 #endif
82407
82408 /*
82409 @@ -345,12 +345,80 @@ free_tsk:
82410 }
82411
82412 #ifdef CONFIG_MMU
82413 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
82414 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
82415 +{
82416 + struct vm_area_struct *tmp;
82417 + unsigned long charge;
82418 + struct file *file;
82419 + int retval;
82420 +
82421 + charge = 0;
82422 + if (mpnt->vm_flags & VM_ACCOUNT) {
82423 + unsigned long len = vma_pages(mpnt);
82424 +
82425 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
82426 + goto fail_nomem;
82427 + charge = len;
82428 + }
82429 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82430 + if (!tmp)
82431 + goto fail_nomem;
82432 + *tmp = *mpnt;
82433 + tmp->vm_mm = mm;
82434 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
82435 + retval = vma_dup_policy(mpnt, tmp);
82436 + if (retval)
82437 + goto fail_nomem_policy;
82438 + if (anon_vma_fork(tmp, mpnt))
82439 + goto fail_nomem_anon_vma_fork;
82440 + tmp->vm_flags &= ~VM_LOCKED;
82441 + tmp->vm_next = tmp->vm_prev = NULL;
82442 + tmp->vm_mirror = NULL;
82443 + file = tmp->vm_file;
82444 + if (file) {
82445 + struct inode *inode = file_inode(file);
82446 + struct address_space *mapping = file->f_mapping;
82447 +
82448 + get_file(file);
82449 + if (tmp->vm_flags & VM_DENYWRITE)
82450 + atomic_dec(&inode->i_writecount);
82451 + mutex_lock(&mapping->i_mmap_mutex);
82452 + if (tmp->vm_flags & VM_SHARED)
82453 + mapping->i_mmap_writable++;
82454 + flush_dcache_mmap_lock(mapping);
82455 + /* insert tmp into the share list, just after mpnt */
82456 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
82457 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
82458 + else
82459 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
82460 + flush_dcache_mmap_unlock(mapping);
82461 + mutex_unlock(&mapping->i_mmap_mutex);
82462 + }
82463 +
82464 + /*
82465 + * Clear hugetlb-related page reserves for children. This only
82466 + * affects MAP_PRIVATE mappings. Faults generated by the child
82467 + * are not guaranteed to succeed, even if read-only
82468 + */
82469 + if (is_vm_hugetlb_page(tmp))
82470 + reset_vma_resv_huge_pages(tmp);
82471 +
82472 + return tmp;
82473 +
82474 +fail_nomem_anon_vma_fork:
82475 + mpol_put(vma_policy(tmp));
82476 +fail_nomem_policy:
82477 + kmem_cache_free(vm_area_cachep, tmp);
82478 +fail_nomem:
82479 + vm_unacct_memory(charge);
82480 + return NULL;
82481 +}
82482 +
82483 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
82484 {
82485 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
82486 struct rb_node **rb_link, *rb_parent;
82487 int retval;
82488 - unsigned long charge;
82489
82490 uprobe_start_dup_mmap();
82491 down_write(&oldmm->mmap_sem);
82492 @@ -379,55 +447,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
82493
82494 prev = NULL;
82495 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
82496 - struct file *file;
82497 -
82498 if (mpnt->vm_flags & VM_DONTCOPY) {
82499 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
82500 -vma_pages(mpnt));
82501 continue;
82502 }
82503 - charge = 0;
82504 - if (mpnt->vm_flags & VM_ACCOUNT) {
82505 - unsigned long len = vma_pages(mpnt);
82506 -
82507 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
82508 - goto fail_nomem;
82509 - charge = len;
82510 - }
82511 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82512 - if (!tmp)
82513 - goto fail_nomem;
82514 - *tmp = *mpnt;
82515 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
82516 - retval = vma_dup_policy(mpnt, tmp);
82517 - if (retval)
82518 - goto fail_nomem_policy;
82519 - tmp->vm_mm = mm;
82520 - if (anon_vma_fork(tmp, mpnt))
82521 - goto fail_nomem_anon_vma_fork;
82522 - tmp->vm_flags &= ~VM_LOCKED;
82523 - tmp->vm_next = tmp->vm_prev = NULL;
82524 - file = tmp->vm_file;
82525 - if (file) {
82526 - struct inode *inode = file_inode(file);
82527 - struct address_space *mapping = file->f_mapping;
82528 -
82529 - get_file(file);
82530 - if (tmp->vm_flags & VM_DENYWRITE)
82531 - atomic_dec(&inode->i_writecount);
82532 - mutex_lock(&mapping->i_mmap_mutex);
82533 - if (tmp->vm_flags & VM_SHARED)
82534 - mapping->i_mmap_writable++;
82535 - flush_dcache_mmap_lock(mapping);
82536 - /* insert tmp into the share list, just after mpnt */
82537 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
82538 - vma_nonlinear_insert(tmp,
82539 - &mapping->i_mmap_nonlinear);
82540 - else
82541 - vma_interval_tree_insert_after(tmp, mpnt,
82542 - &mapping->i_mmap);
82543 - flush_dcache_mmap_unlock(mapping);
82544 - mutex_unlock(&mapping->i_mmap_mutex);
82545 + tmp = dup_vma(mm, oldmm, mpnt);
82546 + if (!tmp) {
82547 + retval = -ENOMEM;
82548 + goto out;
82549 }
82550
82551 /*
82552 @@ -459,6 +487,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
82553 if (retval)
82554 goto out;
82555 }
82556 +
82557 +#ifdef CONFIG_PAX_SEGMEXEC
82558 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
82559 + struct vm_area_struct *mpnt_m;
82560 +
82561 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
82562 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
82563 +
82564 + if (!mpnt->vm_mirror)
82565 + continue;
82566 +
82567 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
82568 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
82569 + mpnt->vm_mirror = mpnt_m;
82570 + } else {
82571 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
82572 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
82573 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
82574 + mpnt->vm_mirror->vm_mirror = mpnt;
82575 + }
82576 + }
82577 + BUG_ON(mpnt_m);
82578 + }
82579 +#endif
82580 +
82581 /* a new mm has just been created */
82582 arch_dup_mmap(oldmm, mm);
82583 retval = 0;
82584 @@ -468,14 +521,6 @@ out:
82585 up_write(&oldmm->mmap_sem);
82586 uprobe_end_dup_mmap();
82587 return retval;
82588 -fail_nomem_anon_vma_fork:
82589 - mpol_put(vma_policy(tmp));
82590 -fail_nomem_policy:
82591 - kmem_cache_free(vm_area_cachep, tmp);
82592 -fail_nomem:
82593 - retval = -ENOMEM;
82594 - vm_unacct_memory(charge);
82595 - goto out;
82596 }
82597
82598 static inline int mm_alloc_pgd(struct mm_struct *mm)
82599 @@ -689,8 +734,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
82600 return ERR_PTR(err);
82601
82602 mm = get_task_mm(task);
82603 - if (mm && mm != current->mm &&
82604 - !ptrace_may_access(task, mode)) {
82605 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
82606 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
82607 mmput(mm);
82608 mm = ERR_PTR(-EACCES);
82609 }
82610 @@ -912,13 +957,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
82611 spin_unlock(&fs->lock);
82612 return -EAGAIN;
82613 }
82614 - fs->users++;
82615 + atomic_inc(&fs->users);
82616 spin_unlock(&fs->lock);
82617 return 0;
82618 }
82619 tsk->fs = copy_fs_struct(fs);
82620 if (!tsk->fs)
82621 return -ENOMEM;
82622 + /* Carry through gr_chroot_dentry and is_chrooted instead
82623 + of recomputing it here. Already copied when the task struct
82624 + is duplicated. This allows pivot_root to not be treated as
82625 + a chroot
82626 + */
82627 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
82628 +
82629 return 0;
82630 }
82631
82632 @@ -1129,7 +1181,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
82633 * parts of the process environment (as per the clone
82634 * flags). The actual kick-off is left to the caller.
82635 */
82636 -static struct task_struct *copy_process(unsigned long clone_flags,
82637 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
82638 unsigned long stack_start,
82639 unsigned long stack_size,
82640 int __user *child_tidptr,
82641 @@ -1201,6 +1253,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
82642 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
82643 #endif
82644 retval = -EAGAIN;
82645 +
82646 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
82647 +
82648 if (atomic_read(&p->real_cred->user->processes) >=
82649 task_rlimit(p, RLIMIT_NPROC)) {
82650 if (p->real_cred->user != INIT_USER &&
82651 @@ -1450,6 +1505,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
82652 goto bad_fork_free_pid;
82653 }
82654
82655 + /* synchronizes with gr_set_acls()
82656 + we need to call this past the point of no return for fork()
82657 + */
82658 + gr_copy_label(p);
82659 +
82660 if (likely(p->pid)) {
82661 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
82662
82663 @@ -1535,6 +1595,8 @@ bad_fork_cleanup_count:
82664 bad_fork_free:
82665 free_task(p);
82666 fork_out:
82667 + gr_log_forkfail(retval);
82668 +
82669 return ERR_PTR(retval);
82670 }
82671
82672 @@ -1596,6 +1658,7 @@ long do_fork(unsigned long clone_flags,
82673
82674 p = copy_process(clone_flags, stack_start, stack_size,
82675 child_tidptr, NULL, trace);
82676 + add_latent_entropy();
82677 /*
82678 * Do this prior waking up the new thread - the thread pointer
82679 * might get invalid after that point, if the thread exits quickly.
82680 @@ -1610,6 +1673,8 @@ long do_fork(unsigned long clone_flags,
82681 if (clone_flags & CLONE_PARENT_SETTID)
82682 put_user(nr, parent_tidptr);
82683
82684 + gr_handle_brute_check();
82685 +
82686 if (clone_flags & CLONE_VFORK) {
82687 p->vfork_done = &vfork;
82688 init_completion(&vfork);
82689 @@ -1726,7 +1791,7 @@ void __init proc_caches_init(void)
82690 mm_cachep = kmem_cache_create("mm_struct",
82691 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
82692 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
82693 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
82694 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
82695 mmap_init();
82696 nsproxy_cache_init();
82697 }
82698 @@ -1766,7 +1831,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
82699 return 0;
82700
82701 /* don't need lock here; in the worst case we'll do useless copy */
82702 - if (fs->users == 1)
82703 + if (atomic_read(&fs->users) == 1)
82704 return 0;
82705
82706 *new_fsp = copy_fs_struct(fs);
82707 @@ -1873,7 +1938,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
82708 fs = current->fs;
82709 spin_lock(&fs->lock);
82710 current->fs = new_fs;
82711 - if (--fs->users)
82712 + gr_set_chroot_entries(current, &current->fs->root);
82713 + if (atomic_dec_return(&fs->users))
82714 new_fs = NULL;
82715 else
82716 new_fs = fs;
82717 diff --git a/kernel/futex.c b/kernel/futex.c
82718 index 221a58f..1b8cfce 100644
82719 --- a/kernel/futex.c
82720 +++ b/kernel/futex.c
82721 @@ -54,6 +54,7 @@
82722 #include <linux/mount.h>
82723 #include <linux/pagemap.h>
82724 #include <linux/syscalls.h>
82725 +#include <linux/ptrace.h>
82726 #include <linux/signal.h>
82727 #include <linux/export.h>
82728 #include <linux/magic.h>
82729 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
82730 struct page *page, *page_head;
82731 int err, ro = 0;
82732
82733 +#ifdef CONFIG_PAX_SEGMEXEC
82734 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
82735 + return -EFAULT;
82736 +#endif
82737 +
82738 /*
82739 * The futex address must be "naturally" aligned.
82740 */
82741 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
82742
82743 static int get_futex_value_locked(u32 *dest, u32 __user *from)
82744 {
82745 - int ret;
82746 + unsigned long ret;
82747
82748 pagefault_disable();
82749 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
82750 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
82751 {
82752 u32 curval;
82753 int i;
82754 + mm_segment_t oldfs;
82755
82756 /*
82757 * This will fail and we want it. Some arch implementations do
82758 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
82759 * implementation, the non-functional ones will return
82760 * -ENOSYS.
82761 */
82762 + oldfs = get_fs();
82763 + set_fs(USER_DS);
82764 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
82765 futex_cmpxchg_enabled = 1;
82766 + set_fs(oldfs);
82767
82768 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
82769 plist_head_init(&futex_queues[i].chain);
82770 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
82771 index f9f44fd..29885e4 100644
82772 --- a/kernel/futex_compat.c
82773 +++ b/kernel/futex_compat.c
82774 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
82775 return 0;
82776 }
82777
82778 -static void __user *futex_uaddr(struct robust_list __user *entry,
82779 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
82780 compat_long_t futex_offset)
82781 {
82782 compat_uptr_t base = ptr_to_compat(entry);
82783 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
82784 index 9b22d03..6295b62 100644
82785 --- a/kernel/gcov/base.c
82786 +++ b/kernel/gcov/base.c
82787 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
82788 }
82789
82790 #ifdef CONFIG_MODULES
82791 -static inline int within(void *addr, void *start, unsigned long size)
82792 -{
82793 - return ((addr >= start) && (addr < start + size));
82794 -}
82795 -
82796 /* Update list and generate events when modules are unloaded. */
82797 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
82798 void *data)
82799 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
82800 prev = NULL;
82801 /* Remove entries located in module from linked list. */
82802 for (info = gcov_info_head; info; info = info->next) {
82803 - if (within(info, mod->module_core, mod->core_size)) {
82804 + if (within_module_core_rw((unsigned long)info, mod)) {
82805 if (prev)
82806 prev->next = info->next;
82807 else
82808 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
82809 index 383319b..56ebb13 100644
82810 --- a/kernel/hrtimer.c
82811 +++ b/kernel/hrtimer.c
82812 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
82813 local_irq_restore(flags);
82814 }
82815
82816 -static void run_hrtimer_softirq(struct softirq_action *h)
82817 +static __latent_entropy void run_hrtimer_softirq(void)
82818 {
82819 hrtimer_peek_ahead_timers();
82820 }
82821 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
82822 index 55fcce6..0e4cf34 100644
82823 --- a/kernel/irq_work.c
82824 +++ b/kernel/irq_work.c
82825 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
82826 return NOTIFY_OK;
82827 }
82828
82829 -static struct notifier_block cpu_notify;
82830 +static struct notifier_block cpu_notify = {
82831 + .notifier_call = irq_work_cpu_notify,
82832 + .priority = 0,
82833 +};
82834
82835 static __init int irq_work_init_cpu_notifier(void)
82836 {
82837 - cpu_notify.notifier_call = irq_work_cpu_notify;
82838 - cpu_notify.priority = 0;
82839 register_cpu_notifier(&cpu_notify);
82840 return 0;
82841 }
82842 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
82843 index 297a924..7290070 100644
82844 --- a/kernel/jump_label.c
82845 +++ b/kernel/jump_label.c
82846 @@ -14,6 +14,7 @@
82847 #include <linux/err.h>
82848 #include <linux/static_key.h>
82849 #include <linux/jump_label_ratelimit.h>
82850 +#include <linux/mm.h>
82851
82852 #ifdef HAVE_JUMP_LABEL
82853
82854 @@ -51,7 +52,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
82855
82856 size = (((unsigned long)stop - (unsigned long)start)
82857 / sizeof(struct jump_entry));
82858 + pax_open_kernel();
82859 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
82860 + pax_close_kernel();
82861 }
82862
82863 static void jump_label_update(struct static_key *key, int enable);
82864 @@ -358,10 +361,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
82865 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
82866 struct jump_entry *iter;
82867
82868 + pax_open_kernel();
82869 for (iter = iter_start; iter < iter_stop; iter++) {
82870 if (within_module_init(iter->code, mod))
82871 iter->code = 0;
82872 }
82873 + pax_close_kernel();
82874 }
82875
82876 static int
82877 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
82878 index 3127ad5..159d880 100644
82879 --- a/kernel/kallsyms.c
82880 +++ b/kernel/kallsyms.c
82881 @@ -11,6 +11,9 @@
82882 * Changed the compression method from stem compression to "table lookup"
82883 * compression (see scripts/kallsyms.c for a more complete description)
82884 */
82885 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82886 +#define __INCLUDED_BY_HIDESYM 1
82887 +#endif
82888 #include <linux/kallsyms.h>
82889 #include <linux/module.h>
82890 #include <linux/init.h>
82891 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
82892
82893 static inline int is_kernel_inittext(unsigned long addr)
82894 {
82895 + if (system_state != SYSTEM_BOOTING)
82896 + return 0;
82897 +
82898 if (addr >= (unsigned long)_sinittext
82899 && addr <= (unsigned long)_einittext)
82900 return 1;
82901 return 0;
82902 }
82903
82904 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82905 +#ifdef CONFIG_MODULES
82906 +static inline int is_module_text(unsigned long addr)
82907 +{
82908 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
82909 + return 1;
82910 +
82911 + addr = ktla_ktva(addr);
82912 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
82913 +}
82914 +#else
82915 +static inline int is_module_text(unsigned long addr)
82916 +{
82917 + return 0;
82918 +}
82919 +#endif
82920 +#endif
82921 +
82922 static inline int is_kernel_text(unsigned long addr)
82923 {
82924 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
82925 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
82926
82927 static inline int is_kernel(unsigned long addr)
82928 {
82929 +
82930 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82931 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
82932 + return 1;
82933 +
82934 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
82935 +#else
82936 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
82937 +#endif
82938 +
82939 return 1;
82940 return in_gate_area_no_mm(addr);
82941 }
82942
82943 static int is_ksym_addr(unsigned long addr)
82944 {
82945 +
82946 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82947 + if (is_module_text(addr))
82948 + return 0;
82949 +#endif
82950 +
82951 if (all_var)
82952 return is_kernel(addr);
82953
82954 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
82955
82956 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
82957 {
82958 - iter->name[0] = '\0';
82959 iter->nameoff = get_symbol_offset(new_pos);
82960 iter->pos = new_pos;
82961 }
82962 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
82963 {
82964 struct kallsym_iter *iter = m->private;
82965
82966 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82967 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
82968 + return 0;
82969 +#endif
82970 +
82971 /* Some debugging symbols have no name. Ignore them. */
82972 if (!iter->name[0])
82973 return 0;
82974 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
82975 */
82976 type = iter->exported ? toupper(iter->type) :
82977 tolower(iter->type);
82978 +
82979 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
82980 type, iter->name, iter->module_name);
82981 } else
82982 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
82983 struct kallsym_iter *iter;
82984 int ret;
82985
82986 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
82987 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
82988 if (!iter)
82989 return -ENOMEM;
82990 reset_iter(iter, 0);
82991 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
82992 index e30ac0f..3528cac 100644
82993 --- a/kernel/kcmp.c
82994 +++ b/kernel/kcmp.c
82995 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
82996 struct task_struct *task1, *task2;
82997 int ret;
82998
82999 +#ifdef CONFIG_GRKERNSEC
83000 + return -ENOSYS;
83001 +#endif
83002 +
83003 rcu_read_lock();
83004
83005 /*
83006 diff --git a/kernel/kexec.c b/kernel/kexec.c
83007 index 355e13a..06b25d2 100644
83008 --- a/kernel/kexec.c
83009 +++ b/kernel/kexec.c
83010 @@ -1044,7 +1044,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
83011 unsigned long flags)
83012 {
83013 struct compat_kexec_segment in;
83014 - struct kexec_segment out, __user *ksegments;
83015 + struct kexec_segment out;
83016 + struct kexec_segment __user *ksegments;
83017 unsigned long i, result;
83018
83019 /* Don't allow clients that don't understand the native
83020 diff --git a/kernel/kmod.c b/kernel/kmod.c
83021 index b086006..6d2e579 100644
83022 --- a/kernel/kmod.c
83023 +++ b/kernel/kmod.c
83024 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
83025 kfree(info->argv);
83026 }
83027
83028 -static int call_modprobe(char *module_name, int wait)
83029 +static int call_modprobe(char *module_name, char *module_param, int wait)
83030 {
83031 struct subprocess_info *info;
83032 static char *envp[] = {
83033 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
83034 NULL
83035 };
83036
83037 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
83038 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
83039 if (!argv)
83040 goto out;
83041
83042 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
83043 argv[1] = "-q";
83044 argv[2] = "--";
83045 argv[3] = module_name; /* check free_modprobe_argv() */
83046 - argv[4] = NULL;
83047 + argv[4] = module_param;
83048 + argv[5] = NULL;
83049
83050 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
83051 NULL, free_modprobe_argv, NULL);
83052 @@ -129,9 +130,8 @@ out:
83053 * If module auto-loading support is disabled then this function
83054 * becomes a no-operation.
83055 */
83056 -int __request_module(bool wait, const char *fmt, ...)
83057 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
83058 {
83059 - va_list args;
83060 char module_name[MODULE_NAME_LEN];
83061 unsigned int max_modprobes;
83062 int ret;
83063 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
83064 if (!modprobe_path[0])
83065 return 0;
83066
83067 - va_start(args, fmt);
83068 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
83069 - va_end(args);
83070 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
83071 if (ret >= MODULE_NAME_LEN)
83072 return -ENAMETOOLONG;
83073
83074 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
83075 if (ret)
83076 return ret;
83077
83078 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83079 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
83080 + /* hack to workaround consolekit/udisks stupidity */
83081 + read_lock(&tasklist_lock);
83082 + if (!strcmp(current->comm, "mount") &&
83083 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
83084 + read_unlock(&tasklist_lock);
83085 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
83086 + return -EPERM;
83087 + }
83088 + read_unlock(&tasklist_lock);
83089 + }
83090 +#endif
83091 +
83092 /* If modprobe needs a service that is in a module, we get a recursive
83093 * loop. Limit the number of running kmod threads to max_threads/2 or
83094 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
83095 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
83096
83097 trace_module_request(module_name, wait, _RET_IP_);
83098
83099 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
83100 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
83101
83102 atomic_dec(&kmod_concurrent);
83103 return ret;
83104 }
83105 +
83106 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
83107 +{
83108 + va_list args;
83109 + int ret;
83110 +
83111 + va_start(args, fmt);
83112 + ret = ____request_module(wait, module_param, fmt, args);
83113 + va_end(args);
83114 +
83115 + return ret;
83116 +}
83117 +
83118 +int __request_module(bool wait, const char *fmt, ...)
83119 +{
83120 + va_list args;
83121 + int ret;
83122 +
83123 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83124 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
83125 + char module_param[MODULE_NAME_LEN];
83126 +
83127 + memset(module_param, 0, sizeof(module_param));
83128 +
83129 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
83130 +
83131 + va_start(args, fmt);
83132 + ret = ____request_module(wait, module_param, fmt, args);
83133 + va_end(args);
83134 +
83135 + return ret;
83136 + }
83137 +#endif
83138 +
83139 + va_start(args, fmt);
83140 + ret = ____request_module(wait, NULL, fmt, args);
83141 + va_end(args);
83142 +
83143 + return ret;
83144 +}
83145 +
83146 EXPORT_SYMBOL(__request_module);
83147 #endif /* CONFIG_MODULES */
83148
83149 @@ -218,6 +271,19 @@ static int ____call_usermodehelper(void *data)
83150 */
83151 set_user_nice(current, 0);
83152
83153 +#ifdef CONFIG_GRKERNSEC
83154 + /* this is race-free as far as userland is concerned as we copied
83155 + out the path to be used prior to this point and are now operating
83156 + on that copy
83157 + */
83158 + if ((strncmp(sub_info->path, "/sbin/", 6) && strncmp(sub_info->path, "/usr/lib/", 9) &&
83159 + strncmp(sub_info->path, "/lib/", 5) && strncmp(sub_info->path, "/lib64/", 7)) || strstr(sub_info->path, "..")) {
83160 + printk(KERN_ALERT "grsec: denied exec of usermode helper binary %.950s located outside of /sbin and system library paths\n", sub_info->path);
83161 + retval = -EPERM;
83162 + goto fail;
83163 + }
83164 +#endif
83165 +
83166 retval = -ENOMEM;
83167 new = prepare_kernel_cred(current);
83168 if (!new)
83169 @@ -260,6 +326,10 @@ static int call_helper(void *data)
83170
83171 static void call_usermodehelper_freeinfo(struct subprocess_info *info)
83172 {
83173 +#ifdef CONFIG_GRKERNSEC
83174 + kfree(info->path);
83175 + info->path = info->origpath;
83176 +#endif
83177 if (info->cleanup)
83178 (*info->cleanup)(info);
83179 kfree(info);
83180 @@ -303,7 +373,7 @@ static int wait_for_helper(void *data)
83181 *
83182 * Thus the __user pointer cast is valid here.
83183 */
83184 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
83185 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
83186
83187 /*
83188 * If ret is 0, either ____call_usermodehelper failed and the
83189 @@ -542,7 +612,12 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
83190 goto out;
83191
83192 INIT_WORK(&sub_info->work, __call_usermodehelper);
83193 +#ifdef CONFIG_GRKERNSEC
83194 + sub_info->origpath = path;
83195 + sub_info->path = kstrdup(path, gfp_mask);
83196 +#else
83197 sub_info->path = path;
83198 +#endif
83199 sub_info->argv = argv;
83200 sub_info->envp = envp;
83201
83202 @@ -650,7 +725,7 @@ EXPORT_SYMBOL(call_usermodehelper);
83203 static int proc_cap_handler(struct ctl_table *table, int write,
83204 void __user *buffer, size_t *lenp, loff_t *ppos)
83205 {
83206 - struct ctl_table t;
83207 + ctl_table_no_const t;
83208 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
83209 kernel_cap_t new_cap;
83210 int err, i;
83211 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
83212 index a0d367a..11c18b6 100644
83213 --- a/kernel/kprobes.c
83214 +++ b/kernel/kprobes.c
83215 @@ -31,6 +31,9 @@
83216 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
83217 * <prasanna@in.ibm.com> added function-return probes.
83218 */
83219 +#ifdef CONFIG_GRKERNSEC_HIDESYM
83220 +#define __INCLUDED_BY_HIDESYM 1
83221 +#endif
83222 #include <linux/kprobes.h>
83223 #include <linux/hash.h>
83224 #include <linux/init.h>
83225 @@ -135,12 +138,12 @@ enum kprobe_slot_state {
83226
83227 static void *alloc_insn_page(void)
83228 {
83229 - return module_alloc(PAGE_SIZE);
83230 + return module_alloc_exec(PAGE_SIZE);
83231 }
83232
83233 static void free_insn_page(void *page)
83234 {
83235 - module_free(NULL, page);
83236 + module_free_exec(NULL, page);
83237 }
83238
83239 struct kprobe_insn_cache kprobe_insn_slots = {
83240 @@ -2066,7 +2069,7 @@ static int __init init_kprobes(void)
83241 {
83242 int i, err = 0;
83243 unsigned long offset = 0, size = 0;
83244 - char *modname, namebuf[128];
83245 + char *modname, namebuf[KSYM_NAME_LEN];
83246 const char *symbol_name;
83247 void *addr;
83248 struct kprobe_blackpoint *kb;
83249 @@ -2151,11 +2154,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
83250 kprobe_type = "k";
83251
83252 if (sym)
83253 - seq_printf(pi, "%p %s %s+0x%x %s ",
83254 + seq_printf(pi, "%pK %s %s+0x%x %s ",
83255 p->addr, kprobe_type, sym, offset,
83256 (modname ? modname : " "));
83257 else
83258 - seq_printf(pi, "%p %s %p ",
83259 + seq_printf(pi, "%pK %s %pK ",
83260 p->addr, kprobe_type, p->addr);
83261
83262 if (!pp)
83263 @@ -2192,7 +2195,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
83264 const char *sym = NULL;
83265 unsigned int i = *(loff_t *) v;
83266 unsigned long offset = 0;
83267 - char *modname, namebuf[128];
83268 + char *modname, namebuf[KSYM_NAME_LEN];
83269
83270 head = &kprobe_table[i];
83271 preempt_disable();
83272 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
83273 index 9659d38..bffd520 100644
83274 --- a/kernel/ksysfs.c
83275 +++ b/kernel/ksysfs.c
83276 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
83277 {
83278 if (count+1 > UEVENT_HELPER_PATH_LEN)
83279 return -ENOENT;
83280 + if (!capable(CAP_SYS_ADMIN))
83281 + return -EPERM;
83282 memcpy(uevent_helper, buf, count);
83283 uevent_helper[count] = '\0';
83284 if (count && uevent_helper[count-1] == '\n')
83285 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
83286 return count;
83287 }
83288
83289 -static struct bin_attribute notes_attr = {
83290 +static bin_attribute_no_const notes_attr __read_only = {
83291 .attr = {
83292 .name = "notes",
83293 .mode = S_IRUGO,
83294 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
83295 index e16c45b..6f49c48 100644
83296 --- a/kernel/lockdep.c
83297 +++ b/kernel/lockdep.c
83298 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
83299 end = (unsigned long) &_end,
83300 addr = (unsigned long) obj;
83301
83302 +#ifdef CONFIG_PAX_KERNEXEC
83303 + start = ktla_ktva(start);
83304 +#endif
83305 +
83306 /*
83307 * static variable?
83308 */
83309 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
83310 if (!static_obj(lock->key)) {
83311 debug_locks_off();
83312 printk("INFO: trying to register non-static key.\n");
83313 + printk("lock:%pS key:%pS.\n", lock, lock->key);
83314 printk("the code is fine but needs lockdep annotation.\n");
83315 printk("turning off the locking correctness validator.\n");
83316 dump_stack();
83317 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
83318 if (!class)
83319 return 0;
83320 }
83321 - atomic_inc((atomic_t *)&class->ops);
83322 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
83323 if (very_verbose(class)) {
83324 printk("\nacquire class [%p] %s", class->key, class->name);
83325 if (class->name_version > 1)
83326 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
83327 index b2c71c5..7b88d63 100644
83328 --- a/kernel/lockdep_proc.c
83329 +++ b/kernel/lockdep_proc.c
83330 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
83331 return 0;
83332 }
83333
83334 - seq_printf(m, "%p", class->key);
83335 + seq_printf(m, "%pK", class->key);
83336 #ifdef CONFIG_DEBUG_LOCKDEP
83337 seq_printf(m, " OPS:%8ld", class->ops);
83338 #endif
83339 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
83340
83341 list_for_each_entry(entry, &class->locks_after, entry) {
83342 if (entry->distance == 1) {
83343 - seq_printf(m, " -> [%p] ", entry->class->key);
83344 + seq_printf(m, " -> [%pK] ", entry->class->key);
83345 print_name(m, entry->class);
83346 seq_puts(m, "\n");
83347 }
83348 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
83349 if (!class->key)
83350 continue;
83351
83352 - seq_printf(m, "[%p] ", class->key);
83353 + seq_printf(m, "[%pK] ", class->key);
83354 print_name(m, class);
83355 seq_puts(m, "\n");
83356 }
83357 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
83358 if (!i)
83359 seq_line(m, '-', 40-namelen, namelen);
83360
83361 - snprintf(ip, sizeof(ip), "[<%p>]",
83362 + snprintf(ip, sizeof(ip), "[<%pK>]",
83363 (void *)class->contention_point[i]);
83364 seq_printf(m, "%40s %14lu %29s %pS\n",
83365 name, stats->contention_point[i],
83366 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
83367 if (!i)
83368 seq_line(m, '-', 40-namelen, namelen);
83369
83370 - snprintf(ip, sizeof(ip), "[<%p>]",
83371 + snprintf(ip, sizeof(ip), "[<%pK>]",
83372 (void *)class->contending_point[i]);
83373 seq_printf(m, "%40s %14lu %29s %pS\n",
83374 name, stats->contending_point[i],
83375 diff --git a/kernel/module.c b/kernel/module.c
83376 index dc58274..3ddfa55 100644
83377 --- a/kernel/module.c
83378 +++ b/kernel/module.c
83379 @@ -61,6 +61,7 @@
83380 #include <linux/pfn.h>
83381 #include <linux/bsearch.h>
83382 #include <linux/fips.h>
83383 +#include <linux/grsecurity.h>
83384 #include <uapi/linux/module.h>
83385 #include "module-internal.h"
83386
83387 @@ -157,7 +158,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
83388
83389 /* Bounds of module allocation, for speeding __module_address.
83390 * Protected by module_mutex. */
83391 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
83392 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
83393 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
83394
83395 int register_module_notifier(struct notifier_block * nb)
83396 {
83397 @@ -324,7 +326,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
83398 return true;
83399
83400 list_for_each_entry_rcu(mod, &modules, list) {
83401 - struct symsearch arr[] = {
83402 + struct symsearch modarr[] = {
83403 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
83404 NOT_GPL_ONLY, false },
83405 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
83406 @@ -349,7 +351,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
83407 if (mod->state == MODULE_STATE_UNFORMED)
83408 continue;
83409
83410 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
83411 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
83412 return true;
83413 }
83414 return false;
83415 @@ -491,7 +493,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
83416 if (!pcpusec->sh_size)
83417 return 0;
83418
83419 - if (align > PAGE_SIZE) {
83420 + if (align-1 >= PAGE_SIZE) {
83421 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
83422 mod->name, align, PAGE_SIZE);
83423 align = PAGE_SIZE;
83424 @@ -1097,7 +1099,7 @@ struct module_attribute module_uevent =
83425 static ssize_t show_coresize(struct module_attribute *mattr,
83426 struct module_kobject *mk, char *buffer)
83427 {
83428 - return sprintf(buffer, "%u\n", mk->mod->core_size);
83429 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
83430 }
83431
83432 static struct module_attribute modinfo_coresize =
83433 @@ -1106,7 +1108,7 @@ static struct module_attribute modinfo_coresize =
83434 static ssize_t show_initsize(struct module_attribute *mattr,
83435 struct module_kobject *mk, char *buffer)
83436 {
83437 - return sprintf(buffer, "%u\n", mk->mod->init_size);
83438 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
83439 }
83440
83441 static struct module_attribute modinfo_initsize =
83442 @@ -1321,7 +1323,7 @@ resolve_symbol_wait(struct module *mod,
83443 */
83444 #ifdef CONFIG_SYSFS
83445
83446 -#ifdef CONFIG_KALLSYMS
83447 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
83448 static inline bool sect_empty(const Elf_Shdr *sect)
83449 {
83450 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
83451 @@ -1461,7 +1463,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
83452 {
83453 unsigned int notes, loaded, i;
83454 struct module_notes_attrs *notes_attrs;
83455 - struct bin_attribute *nattr;
83456 + bin_attribute_no_const *nattr;
83457
83458 /* failed to create section attributes, so can't create notes */
83459 if (!mod->sect_attrs)
83460 @@ -1573,7 +1575,7 @@ static void del_usage_links(struct module *mod)
83461 static int module_add_modinfo_attrs(struct module *mod)
83462 {
83463 struct module_attribute *attr;
83464 - struct module_attribute *temp_attr;
83465 + module_attribute_no_const *temp_attr;
83466 int error = 0;
83467 int i;
83468
83469 @@ -1795,21 +1797,21 @@ static void set_section_ro_nx(void *base,
83470
83471 static void unset_module_core_ro_nx(struct module *mod)
83472 {
83473 - set_page_attributes(mod->module_core + mod->core_text_size,
83474 - mod->module_core + mod->core_size,
83475 + set_page_attributes(mod->module_core_rw,
83476 + mod->module_core_rw + mod->core_size_rw,
83477 set_memory_x);
83478 - set_page_attributes(mod->module_core,
83479 - mod->module_core + mod->core_ro_size,
83480 + set_page_attributes(mod->module_core_rx,
83481 + mod->module_core_rx + mod->core_size_rx,
83482 set_memory_rw);
83483 }
83484
83485 static void unset_module_init_ro_nx(struct module *mod)
83486 {
83487 - set_page_attributes(mod->module_init + mod->init_text_size,
83488 - mod->module_init + mod->init_size,
83489 + set_page_attributes(mod->module_init_rw,
83490 + mod->module_init_rw + mod->init_size_rw,
83491 set_memory_x);
83492 - set_page_attributes(mod->module_init,
83493 - mod->module_init + mod->init_ro_size,
83494 + set_page_attributes(mod->module_init_rx,
83495 + mod->module_init_rx + mod->init_size_rx,
83496 set_memory_rw);
83497 }
83498
83499 @@ -1822,14 +1824,14 @@ void set_all_modules_text_rw(void)
83500 list_for_each_entry_rcu(mod, &modules, list) {
83501 if (mod->state == MODULE_STATE_UNFORMED)
83502 continue;
83503 - if ((mod->module_core) && (mod->core_text_size)) {
83504 - set_page_attributes(mod->module_core,
83505 - mod->module_core + mod->core_text_size,
83506 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
83507 + set_page_attributes(mod->module_core_rx,
83508 + mod->module_core_rx + mod->core_size_rx,
83509 set_memory_rw);
83510 }
83511 - if ((mod->module_init) && (mod->init_text_size)) {
83512 - set_page_attributes(mod->module_init,
83513 - mod->module_init + mod->init_text_size,
83514 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
83515 + set_page_attributes(mod->module_init_rx,
83516 + mod->module_init_rx + mod->init_size_rx,
83517 set_memory_rw);
83518 }
83519 }
83520 @@ -1845,14 +1847,14 @@ void set_all_modules_text_ro(void)
83521 list_for_each_entry_rcu(mod, &modules, list) {
83522 if (mod->state == MODULE_STATE_UNFORMED)
83523 continue;
83524 - if ((mod->module_core) && (mod->core_text_size)) {
83525 - set_page_attributes(mod->module_core,
83526 - mod->module_core + mod->core_text_size,
83527 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
83528 + set_page_attributes(mod->module_core_rx,
83529 + mod->module_core_rx + mod->core_size_rx,
83530 set_memory_ro);
83531 }
83532 - if ((mod->module_init) && (mod->init_text_size)) {
83533 - set_page_attributes(mod->module_init,
83534 - mod->module_init + mod->init_text_size,
83535 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
83536 + set_page_attributes(mod->module_init_rx,
83537 + mod->module_init_rx + mod->init_size_rx,
83538 set_memory_ro);
83539 }
83540 }
83541 @@ -1903,16 +1905,19 @@ static void free_module(struct module *mod)
83542
83543 /* This may be NULL, but that's OK */
83544 unset_module_init_ro_nx(mod);
83545 - module_free(mod, mod->module_init);
83546 + module_free(mod, mod->module_init_rw);
83547 + module_free_exec(mod, mod->module_init_rx);
83548 kfree(mod->args);
83549 percpu_modfree(mod);
83550
83551 /* Free lock-classes: */
83552 - lockdep_free_key_range(mod->module_core, mod->core_size);
83553 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
83554 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
83555
83556 /* Finally, free the core (containing the module structure) */
83557 unset_module_core_ro_nx(mod);
83558 - module_free(mod, mod->module_core);
83559 + module_free_exec(mod, mod->module_core_rx);
83560 + module_free(mod, mod->module_core_rw);
83561
83562 #ifdef CONFIG_MPU
83563 update_protections(current->mm);
83564 @@ -1982,9 +1987,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
83565 int ret = 0;
83566 const struct kernel_symbol *ksym;
83567
83568 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83569 + int is_fs_load = 0;
83570 + int register_filesystem_found = 0;
83571 + char *p;
83572 +
83573 + p = strstr(mod->args, "grsec_modharden_fs");
83574 + if (p) {
83575 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
83576 + /* copy \0 as well */
83577 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
83578 + is_fs_load = 1;
83579 + }
83580 +#endif
83581 +
83582 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
83583 const char *name = info->strtab + sym[i].st_name;
83584
83585 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83586 + /* it's a real shame this will never get ripped and copied
83587 + upstream! ;(
83588 + */
83589 + if (is_fs_load && !strcmp(name, "register_filesystem"))
83590 + register_filesystem_found = 1;
83591 +#endif
83592 +
83593 switch (sym[i].st_shndx) {
83594 case SHN_COMMON:
83595 /* We compiled with -fno-common. These are not
83596 @@ -2005,7 +2032,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
83597 ksym = resolve_symbol_wait(mod, info, name);
83598 /* Ok if resolved. */
83599 if (ksym && !IS_ERR(ksym)) {
83600 + pax_open_kernel();
83601 sym[i].st_value = ksym->value;
83602 + pax_close_kernel();
83603 break;
83604 }
83605
83606 @@ -2024,11 +2053,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
83607 secbase = (unsigned long)mod_percpu(mod);
83608 else
83609 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
83610 + pax_open_kernel();
83611 sym[i].st_value += secbase;
83612 + pax_close_kernel();
83613 break;
83614 }
83615 }
83616
83617 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83618 + if (is_fs_load && !register_filesystem_found) {
83619 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
83620 + ret = -EPERM;
83621 + }
83622 +#endif
83623 +
83624 return ret;
83625 }
83626
83627 @@ -2112,22 +2150,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
83628 || s->sh_entsize != ~0UL
83629 || strstarts(sname, ".init"))
83630 continue;
83631 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
83632 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
83633 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
83634 + else
83635 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
83636 pr_debug("\t%s\n", sname);
83637 }
83638 - switch (m) {
83639 - case 0: /* executable */
83640 - mod->core_size = debug_align(mod->core_size);
83641 - mod->core_text_size = mod->core_size;
83642 - break;
83643 - case 1: /* RO: text and ro-data */
83644 - mod->core_size = debug_align(mod->core_size);
83645 - mod->core_ro_size = mod->core_size;
83646 - break;
83647 - case 3: /* whole core */
83648 - mod->core_size = debug_align(mod->core_size);
83649 - break;
83650 - }
83651 }
83652
83653 pr_debug("Init section allocation order:\n");
83654 @@ -2141,23 +2169,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
83655 || s->sh_entsize != ~0UL
83656 || !strstarts(sname, ".init"))
83657 continue;
83658 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
83659 - | INIT_OFFSET_MASK);
83660 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
83661 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
83662 + else
83663 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
83664 + s->sh_entsize |= INIT_OFFSET_MASK;
83665 pr_debug("\t%s\n", sname);
83666 }
83667 - switch (m) {
83668 - case 0: /* executable */
83669 - mod->init_size = debug_align(mod->init_size);
83670 - mod->init_text_size = mod->init_size;
83671 - break;
83672 - case 1: /* RO: text and ro-data */
83673 - mod->init_size = debug_align(mod->init_size);
83674 - mod->init_ro_size = mod->init_size;
83675 - break;
83676 - case 3: /* whole init */
83677 - mod->init_size = debug_align(mod->init_size);
83678 - break;
83679 - }
83680 }
83681 }
83682
83683 @@ -2330,7 +2348,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
83684
83685 /* Put symbol section at end of init part of module. */
83686 symsect->sh_flags |= SHF_ALLOC;
83687 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
83688 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
83689 info->index.sym) | INIT_OFFSET_MASK;
83690 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
83691
83692 @@ -2347,13 +2365,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
83693 }
83694
83695 /* Append room for core symbols at end of core part. */
83696 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
83697 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
83698 - mod->core_size += strtab_size;
83699 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
83700 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
83701 + mod->core_size_rx += strtab_size;
83702
83703 /* Put string table section at end of init part of module. */
83704 strsect->sh_flags |= SHF_ALLOC;
83705 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
83706 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
83707 info->index.str) | INIT_OFFSET_MASK;
83708 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
83709 }
83710 @@ -2371,12 +2389,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
83711 /* Make sure we get permanent strtab: don't use info->strtab. */
83712 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
83713
83714 + pax_open_kernel();
83715 +
83716 /* Set types up while we still have access to sections. */
83717 for (i = 0; i < mod->num_symtab; i++)
83718 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
83719
83720 - mod->core_symtab = dst = mod->module_core + info->symoffs;
83721 - mod->core_strtab = s = mod->module_core + info->stroffs;
83722 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
83723 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
83724 src = mod->symtab;
83725 for (ndst = i = 0; i < mod->num_symtab; i++) {
83726 if (i == 0 ||
83727 @@ -2388,6 +2408,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
83728 }
83729 }
83730 mod->core_num_syms = ndst;
83731 +
83732 + pax_close_kernel();
83733 }
83734 #else
83735 static inline void layout_symtab(struct module *mod, struct load_info *info)
83736 @@ -2421,17 +2443,33 @@ void * __weak module_alloc(unsigned long size)
83737 return vmalloc_exec(size);
83738 }
83739
83740 -static void *module_alloc_update_bounds(unsigned long size)
83741 +static void *module_alloc_update_bounds_rw(unsigned long size)
83742 {
83743 void *ret = module_alloc(size);
83744
83745 if (ret) {
83746 mutex_lock(&module_mutex);
83747 /* Update module bounds. */
83748 - if ((unsigned long)ret < module_addr_min)
83749 - module_addr_min = (unsigned long)ret;
83750 - if ((unsigned long)ret + size > module_addr_max)
83751 - module_addr_max = (unsigned long)ret + size;
83752 + if ((unsigned long)ret < module_addr_min_rw)
83753 + module_addr_min_rw = (unsigned long)ret;
83754 + if ((unsigned long)ret + size > module_addr_max_rw)
83755 + module_addr_max_rw = (unsigned long)ret + size;
83756 + mutex_unlock(&module_mutex);
83757 + }
83758 + return ret;
83759 +}
83760 +
83761 +static void *module_alloc_update_bounds_rx(unsigned long size)
83762 +{
83763 + void *ret = module_alloc_exec(size);
83764 +
83765 + if (ret) {
83766 + mutex_lock(&module_mutex);
83767 + /* Update module bounds. */
83768 + if ((unsigned long)ret < module_addr_min_rx)
83769 + module_addr_min_rx = (unsigned long)ret;
83770 + if ((unsigned long)ret + size > module_addr_max_rx)
83771 + module_addr_max_rx = (unsigned long)ret + size;
83772 mutex_unlock(&module_mutex);
83773 }
83774 return ret;
83775 @@ -2706,8 +2744,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
83776 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
83777 {
83778 const char *modmagic = get_modinfo(info, "vermagic");
83779 + const char *license = get_modinfo(info, "license");
83780 int err;
83781
83782 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
83783 + if (!license || !license_is_gpl_compatible(license))
83784 + return -ENOEXEC;
83785 +#endif
83786 +
83787 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
83788 modmagic = NULL;
83789
83790 @@ -2733,7 +2777,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
83791 }
83792
83793 /* Set up license info based on the info section */
83794 - set_license(mod, get_modinfo(info, "license"));
83795 + set_license(mod, license);
83796
83797 return 0;
83798 }
83799 @@ -2814,7 +2858,7 @@ static int move_module(struct module *mod, struct load_info *info)
83800 void *ptr;
83801
83802 /* Do the allocs. */
83803 - ptr = module_alloc_update_bounds(mod->core_size);
83804 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
83805 /*
83806 * The pointer to this block is stored in the module structure
83807 * which is inside the block. Just mark it as not being a
83808 @@ -2824,11 +2868,11 @@ static int move_module(struct module *mod, struct load_info *info)
83809 if (!ptr)
83810 return -ENOMEM;
83811
83812 - memset(ptr, 0, mod->core_size);
83813 - mod->module_core = ptr;
83814 + memset(ptr, 0, mod->core_size_rw);
83815 + mod->module_core_rw = ptr;
83816
83817 - if (mod->init_size) {
83818 - ptr = module_alloc_update_bounds(mod->init_size);
83819 + if (mod->init_size_rw) {
83820 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
83821 /*
83822 * The pointer to this block is stored in the module structure
83823 * which is inside the block. This block doesn't need to be
83824 @@ -2837,13 +2881,45 @@ static int move_module(struct module *mod, struct load_info *info)
83825 */
83826 kmemleak_ignore(ptr);
83827 if (!ptr) {
83828 - module_free(mod, mod->module_core);
83829 + module_free(mod, mod->module_core_rw);
83830 return -ENOMEM;
83831 }
83832 - memset(ptr, 0, mod->init_size);
83833 - mod->module_init = ptr;
83834 + memset(ptr, 0, mod->init_size_rw);
83835 + mod->module_init_rw = ptr;
83836 } else
83837 - mod->module_init = NULL;
83838 + mod->module_init_rw = NULL;
83839 +
83840 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
83841 + kmemleak_not_leak(ptr);
83842 + if (!ptr) {
83843 + if (mod->module_init_rw)
83844 + module_free(mod, mod->module_init_rw);
83845 + module_free(mod, mod->module_core_rw);
83846 + return -ENOMEM;
83847 + }
83848 +
83849 + pax_open_kernel();
83850 + memset(ptr, 0, mod->core_size_rx);
83851 + pax_close_kernel();
83852 + mod->module_core_rx = ptr;
83853 +
83854 + if (mod->init_size_rx) {
83855 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
83856 + kmemleak_ignore(ptr);
83857 + if (!ptr && mod->init_size_rx) {
83858 + module_free_exec(mod, mod->module_core_rx);
83859 + if (mod->module_init_rw)
83860 + module_free(mod, mod->module_init_rw);
83861 + module_free(mod, mod->module_core_rw);
83862 + return -ENOMEM;
83863 + }
83864 +
83865 + pax_open_kernel();
83866 + memset(ptr, 0, mod->init_size_rx);
83867 + pax_close_kernel();
83868 + mod->module_init_rx = ptr;
83869 + } else
83870 + mod->module_init_rx = NULL;
83871
83872 /* Transfer each section which specifies SHF_ALLOC */
83873 pr_debug("final section addresses:\n");
83874 @@ -2854,16 +2930,45 @@ static int move_module(struct module *mod, struct load_info *info)
83875 if (!(shdr->sh_flags & SHF_ALLOC))
83876 continue;
83877
83878 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
83879 - dest = mod->module_init
83880 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
83881 - else
83882 - dest = mod->module_core + shdr->sh_entsize;
83883 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
83884 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
83885 + dest = mod->module_init_rw
83886 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
83887 + else
83888 + dest = mod->module_init_rx
83889 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
83890 + } else {
83891 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
83892 + dest = mod->module_core_rw + shdr->sh_entsize;
83893 + else
83894 + dest = mod->module_core_rx + shdr->sh_entsize;
83895 + }
83896 +
83897 + if (shdr->sh_type != SHT_NOBITS) {
83898 +
83899 +#ifdef CONFIG_PAX_KERNEXEC
83900 +#ifdef CONFIG_X86_64
83901 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
83902 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
83903 +#endif
83904 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
83905 + pax_open_kernel();
83906 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
83907 + pax_close_kernel();
83908 + } else
83909 +#endif
83910
83911 - if (shdr->sh_type != SHT_NOBITS)
83912 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
83913 + }
83914 /* Update sh_addr to point to copy in image. */
83915 - shdr->sh_addr = (unsigned long)dest;
83916 +
83917 +#ifdef CONFIG_PAX_KERNEXEC
83918 + if (shdr->sh_flags & SHF_EXECINSTR)
83919 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
83920 + else
83921 +#endif
83922 +
83923 + shdr->sh_addr = (unsigned long)dest;
83924 pr_debug("\t0x%lx %s\n",
83925 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
83926 }
83927 @@ -2920,12 +3025,12 @@ static void flush_module_icache(const struct module *mod)
83928 * Do it before processing of module parameters, so the module
83929 * can provide parameter accessor functions of its own.
83930 */
83931 - if (mod->module_init)
83932 - flush_icache_range((unsigned long)mod->module_init,
83933 - (unsigned long)mod->module_init
83934 - + mod->init_size);
83935 - flush_icache_range((unsigned long)mod->module_core,
83936 - (unsigned long)mod->module_core + mod->core_size);
83937 + if (mod->module_init_rx)
83938 + flush_icache_range((unsigned long)mod->module_init_rx,
83939 + (unsigned long)mod->module_init_rx
83940 + + mod->init_size_rx);
83941 + flush_icache_range((unsigned long)mod->module_core_rx,
83942 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
83943
83944 set_fs(old_fs);
83945 }
83946 @@ -2982,8 +3087,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
83947 static void module_deallocate(struct module *mod, struct load_info *info)
83948 {
83949 percpu_modfree(mod);
83950 - module_free(mod, mod->module_init);
83951 - module_free(mod, mod->module_core);
83952 + module_free_exec(mod, mod->module_init_rx);
83953 + module_free_exec(mod, mod->module_core_rx);
83954 + module_free(mod, mod->module_init_rw);
83955 + module_free(mod, mod->module_core_rw);
83956 }
83957
83958 int __weak module_finalize(const Elf_Ehdr *hdr,
83959 @@ -2996,7 +3103,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
83960 static int post_relocation(struct module *mod, const struct load_info *info)
83961 {
83962 /* Sort exception table now relocations are done. */
83963 + pax_open_kernel();
83964 sort_extable(mod->extable, mod->extable + mod->num_exentries);
83965 + pax_close_kernel();
83966
83967 /* Copy relocated percpu area over. */
83968 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
83969 @@ -3050,16 +3159,16 @@ static int do_init_module(struct module *mod)
83970 MODULE_STATE_COMING, mod);
83971
83972 /* Set RO and NX regions for core */
83973 - set_section_ro_nx(mod->module_core,
83974 - mod->core_text_size,
83975 - mod->core_ro_size,
83976 - mod->core_size);
83977 + set_section_ro_nx(mod->module_core_rx,
83978 + mod->core_size_rx,
83979 + mod->core_size_rx,
83980 + mod->core_size_rx);
83981
83982 /* Set RO and NX regions for init */
83983 - set_section_ro_nx(mod->module_init,
83984 - mod->init_text_size,
83985 - mod->init_ro_size,
83986 - mod->init_size);
83987 + set_section_ro_nx(mod->module_init_rx,
83988 + mod->init_size_rx,
83989 + mod->init_size_rx,
83990 + mod->init_size_rx);
83991
83992 do_mod_ctors(mod);
83993 /* Start the module */
83994 @@ -3121,11 +3230,12 @@ static int do_init_module(struct module *mod)
83995 mod->strtab = mod->core_strtab;
83996 #endif
83997 unset_module_init_ro_nx(mod);
83998 - module_free(mod, mod->module_init);
83999 - mod->module_init = NULL;
84000 - mod->init_size = 0;
84001 - mod->init_ro_size = 0;
84002 - mod->init_text_size = 0;
84003 + module_free(mod, mod->module_init_rw);
84004 + module_free_exec(mod, mod->module_init_rx);
84005 + mod->module_init_rw = NULL;
84006 + mod->module_init_rx = NULL;
84007 + mod->init_size_rw = 0;
84008 + mod->init_size_rx = 0;
84009 mutex_unlock(&module_mutex);
84010 wake_up_all(&module_wq);
84011
84012 @@ -3269,9 +3379,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
84013 if (err)
84014 goto free_unload;
84015
84016 + /* Now copy in args */
84017 + mod->args = strndup_user(uargs, ~0UL >> 1);
84018 + if (IS_ERR(mod->args)) {
84019 + err = PTR_ERR(mod->args);
84020 + goto free_unload;
84021 + }
84022 +
84023 /* Set up MODINFO_ATTR fields */
84024 setup_modinfo(mod, info);
84025
84026 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
84027 + {
84028 + char *p, *p2;
84029 +
84030 + if (strstr(mod->args, "grsec_modharden_netdev")) {
84031 + 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);
84032 + err = -EPERM;
84033 + goto free_modinfo;
84034 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
84035 + p += sizeof("grsec_modharden_normal") - 1;
84036 + p2 = strstr(p, "_");
84037 + if (p2) {
84038 + *p2 = '\0';
84039 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
84040 + *p2 = '_';
84041 + }
84042 + err = -EPERM;
84043 + goto free_modinfo;
84044 + }
84045 + }
84046 +#endif
84047 +
84048 /* Fix up syms, so that st_value is a pointer to location. */
84049 err = simplify_symbols(mod, info);
84050 if (err < 0)
84051 @@ -3287,13 +3426,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
84052
84053 flush_module_icache(mod);
84054
84055 - /* Now copy in args */
84056 - mod->args = strndup_user(uargs, ~0UL >> 1);
84057 - if (IS_ERR(mod->args)) {
84058 - err = PTR_ERR(mod->args);
84059 - goto free_arch_cleanup;
84060 - }
84061 -
84062 dynamic_debug_setup(info->debug, info->num_debug);
84063
84064 /* Finally it's fully formed, ready to start executing. */
84065 @@ -3328,11 +3460,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
84066 ddebug_cleanup:
84067 dynamic_debug_remove(info->debug);
84068 synchronize_sched();
84069 - kfree(mod->args);
84070 - free_arch_cleanup:
84071 module_arch_cleanup(mod);
84072 free_modinfo:
84073 free_modinfo(mod);
84074 + kfree(mod->args);
84075 free_unload:
84076 module_unload_free(mod);
84077 unlink_mod:
84078 @@ -3415,10 +3546,16 @@ static const char *get_ksymbol(struct module *mod,
84079 unsigned long nextval;
84080
84081 /* At worse, next value is at end of module */
84082 - if (within_module_init(addr, mod))
84083 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
84084 + if (within_module_init_rx(addr, mod))
84085 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
84086 + else if (within_module_init_rw(addr, mod))
84087 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
84088 + else if (within_module_core_rx(addr, mod))
84089 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
84090 + else if (within_module_core_rw(addr, mod))
84091 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
84092 else
84093 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
84094 + return NULL;
84095
84096 /* Scan for closest preceding symbol, and next symbol. (ELF
84097 starts real symbols at 1). */
84098 @@ -3669,7 +3806,7 @@ static int m_show(struct seq_file *m, void *p)
84099 return 0;
84100
84101 seq_printf(m, "%s %u",
84102 - mod->name, mod->init_size + mod->core_size);
84103 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
84104 print_unload_info(m, mod);
84105
84106 /* Informative for users. */
84107 @@ -3678,7 +3815,7 @@ static int m_show(struct seq_file *m, void *p)
84108 mod->state == MODULE_STATE_COMING ? "Loading":
84109 "Live");
84110 /* Used by oprofile and other similar tools. */
84111 - seq_printf(m, " 0x%pK", mod->module_core);
84112 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
84113
84114 /* Taints info */
84115 if (mod->taints)
84116 @@ -3714,7 +3851,17 @@ static const struct file_operations proc_modules_operations = {
84117
84118 static int __init proc_modules_init(void)
84119 {
84120 +#ifndef CONFIG_GRKERNSEC_HIDESYM
84121 +#ifdef CONFIG_GRKERNSEC_PROC_USER
84122 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
84123 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
84124 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
84125 +#else
84126 proc_create("modules", 0, NULL, &proc_modules_operations);
84127 +#endif
84128 +#else
84129 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
84130 +#endif
84131 return 0;
84132 }
84133 module_init(proc_modules_init);
84134 @@ -3775,14 +3922,14 @@ struct module *__module_address(unsigned long addr)
84135 {
84136 struct module *mod;
84137
84138 - if (addr < module_addr_min || addr > module_addr_max)
84139 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
84140 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
84141 return NULL;
84142
84143 list_for_each_entry_rcu(mod, &modules, list) {
84144 if (mod->state == MODULE_STATE_UNFORMED)
84145 continue;
84146 - if (within_module_core(addr, mod)
84147 - || within_module_init(addr, mod))
84148 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
84149 return mod;
84150 }
84151 return NULL;
84152 @@ -3817,11 +3964,20 @@ bool is_module_text_address(unsigned long addr)
84153 */
84154 struct module *__module_text_address(unsigned long addr)
84155 {
84156 - struct module *mod = __module_address(addr);
84157 + struct module *mod;
84158 +
84159 +#ifdef CONFIG_X86_32
84160 + addr = ktla_ktva(addr);
84161 +#endif
84162 +
84163 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
84164 + return NULL;
84165 +
84166 + mod = __module_address(addr);
84167 +
84168 if (mod) {
84169 /* Make sure it's within the text section. */
84170 - if (!within(addr, mod->module_init, mod->init_text_size)
84171 - && !within(addr, mod->module_core, mod->core_text_size))
84172 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
84173 mod = NULL;
84174 }
84175 return mod;
84176 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
84177 index 7e3443f..b2a1e6b 100644
84178 --- a/kernel/mutex-debug.c
84179 +++ b/kernel/mutex-debug.c
84180 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
84181 }
84182
84183 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
84184 - struct thread_info *ti)
84185 + struct task_struct *task)
84186 {
84187 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
84188
84189 /* Mark the current thread as blocked on the lock: */
84190 - ti->task->blocked_on = waiter;
84191 + task->blocked_on = waiter;
84192 }
84193
84194 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
84195 - struct thread_info *ti)
84196 + struct task_struct *task)
84197 {
84198 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
84199 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
84200 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
84201 - ti->task->blocked_on = NULL;
84202 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
84203 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
84204 + task->blocked_on = NULL;
84205
84206 list_del_init(&waiter->list);
84207 waiter->task = NULL;
84208 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
84209 index 0799fd3..d06ae3b 100644
84210 --- a/kernel/mutex-debug.h
84211 +++ b/kernel/mutex-debug.h
84212 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
84213 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
84214 extern void debug_mutex_add_waiter(struct mutex *lock,
84215 struct mutex_waiter *waiter,
84216 - struct thread_info *ti);
84217 + struct task_struct *task);
84218 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
84219 - struct thread_info *ti);
84220 + struct task_struct *task);
84221 extern void debug_mutex_unlock(struct mutex *lock);
84222 extern void debug_mutex_init(struct mutex *lock, const char *name,
84223 struct lock_class_key *key);
84224 diff --git a/kernel/mutex.c b/kernel/mutex.c
84225 index d24105b..15648eb 100644
84226 --- a/kernel/mutex.c
84227 +++ b/kernel/mutex.c
84228 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
84229 node->locked = 1;
84230 return;
84231 }
84232 - ACCESS_ONCE(prev->next) = node;
84233 + ACCESS_ONCE_RW(prev->next) = node;
84234 smp_wmb();
84235 /* Wait until the lock holder passes the lock down */
84236 while (!ACCESS_ONCE(node->locked))
84237 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
84238 while (!(next = ACCESS_ONCE(node->next)))
84239 arch_mutex_cpu_relax();
84240 }
84241 - ACCESS_ONCE(next->locked) = 1;
84242 + ACCESS_ONCE_RW(next->locked) = 1;
84243 smp_wmb();
84244 }
84245
84246 @@ -520,7 +520,7 @@ slowpath:
84247 goto skip_wait;
84248
84249 debug_mutex_lock_common(lock, &waiter);
84250 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
84251 + debug_mutex_add_waiter(lock, &waiter, task);
84252
84253 /* add waiting tasks to the end of the waitqueue (FIFO): */
84254 list_add_tail(&waiter.list, &lock->wait_list);
84255 @@ -564,7 +564,7 @@ slowpath:
84256 schedule_preempt_disabled();
84257 spin_lock_mutex(&lock->wait_lock, flags);
84258 }
84259 - mutex_remove_waiter(lock, &waiter, current_thread_info());
84260 + mutex_remove_waiter(lock, &waiter, task);
84261 /* set it to 0 if there are no waiters left: */
84262 if (likely(list_empty(&lock->wait_list)))
84263 atomic_set(&lock->count, 0);
84264 @@ -601,7 +601,7 @@ skip_wait:
84265 return 0;
84266
84267 err:
84268 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
84269 + mutex_remove_waiter(lock, &waiter, task);
84270 spin_unlock_mutex(&lock->wait_lock, flags);
84271 debug_mutex_free_waiter(&waiter);
84272 mutex_release(&lock->dep_map, 1, ip);
84273 diff --git a/kernel/notifier.c b/kernel/notifier.c
84274 index 2d5cc4c..d9ea600 100644
84275 --- a/kernel/notifier.c
84276 +++ b/kernel/notifier.c
84277 @@ -5,6 +5,7 @@
84278 #include <linux/rcupdate.h>
84279 #include <linux/vmalloc.h>
84280 #include <linux/reboot.h>
84281 +#include <linux/mm.h>
84282
84283 /*
84284 * Notifier list for kernel code which wants to be called
84285 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
84286 while ((*nl) != NULL) {
84287 if (n->priority > (*nl)->priority)
84288 break;
84289 - nl = &((*nl)->next);
84290 + nl = (struct notifier_block **)&((*nl)->next);
84291 }
84292 - n->next = *nl;
84293 + pax_open_kernel();
84294 + *(const void **)&n->next = *nl;
84295 rcu_assign_pointer(*nl, n);
84296 + pax_close_kernel();
84297 return 0;
84298 }
84299
84300 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
84301 return 0;
84302 if (n->priority > (*nl)->priority)
84303 break;
84304 - nl = &((*nl)->next);
84305 + nl = (struct notifier_block **)&((*nl)->next);
84306 }
84307 - n->next = *nl;
84308 + pax_open_kernel();
84309 + *(const void **)&n->next = *nl;
84310 rcu_assign_pointer(*nl, n);
84311 + pax_close_kernel();
84312 return 0;
84313 }
84314
84315 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
84316 {
84317 while ((*nl) != NULL) {
84318 if ((*nl) == n) {
84319 + pax_open_kernel();
84320 rcu_assign_pointer(*nl, n->next);
84321 + pax_close_kernel();
84322 return 0;
84323 }
84324 - nl = &((*nl)->next);
84325 + nl = (struct notifier_block **)&((*nl)->next);
84326 }
84327 return -ENOENT;
84328 }
84329 diff --git a/kernel/panic.c b/kernel/panic.c
84330 index b6c482c..5578061 100644
84331 --- a/kernel/panic.c
84332 +++ b/kernel/panic.c
84333 @@ -407,7 +407,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
84334 disable_trace_on_warning();
84335
84336 pr_warn("------------[ cut here ]------------\n");
84337 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
84338 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
84339 raw_smp_processor_id(), current->pid, file, line, caller);
84340
84341 if (args)
84342 @@ -461,7 +461,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
84343 */
84344 void __stack_chk_fail(void)
84345 {
84346 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
84347 + dump_stack();
84348 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
84349 __builtin_return_address(0));
84350 }
84351 EXPORT_SYMBOL(__stack_chk_fail);
84352 diff --git a/kernel/pid.c b/kernel/pid.c
84353 index 9b9a266..c20ef80 100644
84354 --- a/kernel/pid.c
84355 +++ b/kernel/pid.c
84356 @@ -33,6 +33,7 @@
84357 #include <linux/rculist.h>
84358 #include <linux/bootmem.h>
84359 #include <linux/hash.h>
84360 +#include <linux/security.h>
84361 #include <linux/pid_namespace.h>
84362 #include <linux/init_task.h>
84363 #include <linux/syscalls.h>
84364 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
84365
84366 int pid_max = PID_MAX_DEFAULT;
84367
84368 -#define RESERVED_PIDS 300
84369 +#define RESERVED_PIDS 500
84370
84371 int pid_max_min = RESERVED_PIDS + 1;
84372 int pid_max_max = PID_MAX_LIMIT;
84373 @@ -445,10 +446,18 @@ EXPORT_SYMBOL(pid_task);
84374 */
84375 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
84376 {
84377 + struct task_struct *task;
84378 +
84379 rcu_lockdep_assert(rcu_read_lock_held(),
84380 "find_task_by_pid_ns() needs rcu_read_lock()"
84381 " protection");
84382 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
84383 +
84384 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
84385 +
84386 + if (gr_pid_is_chrooted(task))
84387 + return NULL;
84388 +
84389 + return task;
84390 }
84391
84392 struct task_struct *find_task_by_vpid(pid_t vnr)
84393 @@ -456,6 +465,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
84394 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
84395 }
84396
84397 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
84398 +{
84399 + rcu_lockdep_assert(rcu_read_lock_held(),
84400 + "find_task_by_pid_ns() needs rcu_read_lock()"
84401 + " protection");
84402 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
84403 +}
84404 +
84405 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
84406 {
84407 struct pid *pid;
84408 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
84409 index 4208655..19f36a5 100644
84410 --- a/kernel/pid_namespace.c
84411 +++ b/kernel/pid_namespace.c
84412 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
84413 void __user *buffer, size_t *lenp, loff_t *ppos)
84414 {
84415 struct pid_namespace *pid_ns = task_active_pid_ns(current);
84416 - struct ctl_table tmp = *table;
84417 + ctl_table_no_const tmp = *table;
84418
84419 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
84420 return -EPERM;
84421 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
84422 index c7f31aa..2b44977 100644
84423 --- a/kernel/posix-cpu-timers.c
84424 +++ b/kernel/posix-cpu-timers.c
84425 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
84426
84427 static __init int init_posix_cpu_timers(void)
84428 {
84429 - struct k_clock process = {
84430 + static struct k_clock process = {
84431 .clock_getres = process_cpu_clock_getres,
84432 .clock_get = process_cpu_clock_get,
84433 .timer_create = process_cpu_timer_create,
84434 .nsleep = process_cpu_nsleep,
84435 .nsleep_restart = process_cpu_nsleep_restart,
84436 };
84437 - struct k_clock thread = {
84438 + static struct k_clock thread = {
84439 .clock_getres = thread_cpu_clock_getres,
84440 .clock_get = thread_cpu_clock_get,
84441 .timer_create = thread_cpu_timer_create,
84442 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
84443 index 424c2d4..679242f 100644
84444 --- a/kernel/posix-timers.c
84445 +++ b/kernel/posix-timers.c
84446 @@ -43,6 +43,7 @@
84447 #include <linux/hash.h>
84448 #include <linux/posix-clock.h>
84449 #include <linux/posix-timers.h>
84450 +#include <linux/grsecurity.h>
84451 #include <linux/syscalls.h>
84452 #include <linux/wait.h>
84453 #include <linux/workqueue.h>
84454 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
84455 * which we beg off on and pass to do_sys_settimeofday().
84456 */
84457
84458 -static struct k_clock posix_clocks[MAX_CLOCKS];
84459 +static struct k_clock *posix_clocks[MAX_CLOCKS];
84460
84461 /*
84462 * These ones are defined below.
84463 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
84464 */
84465 static __init int init_posix_timers(void)
84466 {
84467 - struct k_clock clock_realtime = {
84468 + static struct k_clock clock_realtime = {
84469 .clock_getres = hrtimer_get_res,
84470 .clock_get = posix_clock_realtime_get,
84471 .clock_set = posix_clock_realtime_set,
84472 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
84473 .timer_get = common_timer_get,
84474 .timer_del = common_timer_del,
84475 };
84476 - struct k_clock clock_monotonic = {
84477 + static struct k_clock clock_monotonic = {
84478 .clock_getres = hrtimer_get_res,
84479 .clock_get = posix_ktime_get_ts,
84480 .nsleep = common_nsleep,
84481 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
84482 .timer_get = common_timer_get,
84483 .timer_del = common_timer_del,
84484 };
84485 - struct k_clock clock_monotonic_raw = {
84486 + static struct k_clock clock_monotonic_raw = {
84487 .clock_getres = hrtimer_get_res,
84488 .clock_get = posix_get_monotonic_raw,
84489 };
84490 - struct k_clock clock_realtime_coarse = {
84491 + static struct k_clock clock_realtime_coarse = {
84492 .clock_getres = posix_get_coarse_res,
84493 .clock_get = posix_get_realtime_coarse,
84494 };
84495 - struct k_clock clock_monotonic_coarse = {
84496 + static struct k_clock clock_monotonic_coarse = {
84497 .clock_getres = posix_get_coarse_res,
84498 .clock_get = posix_get_monotonic_coarse,
84499 };
84500 - struct k_clock clock_tai = {
84501 + static struct k_clock clock_tai = {
84502 .clock_getres = hrtimer_get_res,
84503 .clock_get = posix_get_tai,
84504 .nsleep = common_nsleep,
84505 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
84506 .timer_get = common_timer_get,
84507 .timer_del = common_timer_del,
84508 };
84509 - struct k_clock clock_boottime = {
84510 + static struct k_clock clock_boottime = {
84511 .clock_getres = hrtimer_get_res,
84512 .clock_get = posix_get_boottime,
84513 .nsleep = common_nsleep,
84514 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
84515 return;
84516 }
84517
84518 - posix_clocks[clock_id] = *new_clock;
84519 + posix_clocks[clock_id] = new_clock;
84520 }
84521 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
84522
84523 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
84524 return (id & CLOCKFD_MASK) == CLOCKFD ?
84525 &clock_posix_dynamic : &clock_posix_cpu;
84526
84527 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
84528 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
84529 return NULL;
84530 - return &posix_clocks[id];
84531 + return posix_clocks[id];
84532 }
84533
84534 static int common_timer_create(struct k_itimer *new_timer)
84535 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
84536 struct k_clock *kc = clockid_to_kclock(which_clock);
84537 struct k_itimer *new_timer;
84538 int error, new_timer_id;
84539 - sigevent_t event;
84540 + sigevent_t event = { };
84541 int it_id_set = IT_ID_NOT_SET;
84542
84543 if (!kc)
84544 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
84545 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
84546 return -EFAULT;
84547
84548 + /* only the CLOCK_REALTIME clock can be set, all other clocks
84549 + have their clock_set fptr set to a nosettime dummy function
84550 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
84551 + call common_clock_set, which calls do_sys_settimeofday, which
84552 + we hook
84553 + */
84554 +
84555 return kc->clock_set(which_clock, &new_tp);
84556 }
84557
84558 diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
84559 index d444c4e..bc3de51 100644
84560 --- a/kernel/power/Kconfig
84561 +++ b/kernel/power/Kconfig
84562 @@ -24,6 +24,8 @@ config HIBERNATE_CALLBACKS
84563 config HIBERNATION
84564 bool "Hibernation (aka 'suspend to disk')"
84565 depends on SWAP && ARCH_HIBERNATION_POSSIBLE
84566 + depends on !GRKERNSEC_KMEM
84567 + depends on !PAX_MEMORY_SANITIZE
84568 select HIBERNATE_CALLBACKS
84569 select LZO_COMPRESS
84570 select LZO_DECOMPRESS
84571 diff --git a/kernel/power/process.c b/kernel/power/process.c
84572 index 06ec886..9dba35e 100644
84573 --- a/kernel/power/process.c
84574 +++ b/kernel/power/process.c
84575 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
84576 unsigned int elapsed_msecs;
84577 bool wakeup = false;
84578 int sleep_usecs = USEC_PER_MSEC;
84579 + bool timedout = false;
84580
84581 do_gettimeofday(&start);
84582
84583 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
84584
84585 while (true) {
84586 todo = 0;
84587 + if (time_after(jiffies, end_time))
84588 + timedout = true;
84589 read_lock(&tasklist_lock);
84590 do_each_thread(g, p) {
84591 if (p == current || !freeze_task(p))
84592 continue;
84593
84594 - if (!freezer_should_skip(p))
84595 + if (!freezer_should_skip(p)) {
84596 todo++;
84597 + if (timedout) {
84598 + printk(KERN_ERR "Task refusing to freeze:\n");
84599 + sched_show_task(p);
84600 + }
84601 + }
84602 } while_each_thread(g, p);
84603 read_unlock(&tasklist_lock);
84604
84605 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
84606 todo += wq_busy;
84607 }
84608
84609 - if (!todo || time_after(jiffies, end_time))
84610 + if (!todo || timedout)
84611 break;
84612
84613 if (pm_wakeup_pending()) {
84614 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
84615 index b4e8500..b457a6c 100644
84616 --- a/kernel/printk/printk.c
84617 +++ b/kernel/printk/printk.c
84618 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
84619 if (from_file && type != SYSLOG_ACTION_OPEN)
84620 return 0;
84621
84622 +#ifdef CONFIG_GRKERNSEC_DMESG
84623 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
84624 + return -EPERM;
84625 +#endif
84626 +
84627 if (syslog_action_restricted(type)) {
84628 if (capable(CAP_SYSLOG))
84629 return 0;
84630 diff --git a/kernel/profile.c b/kernel/profile.c
84631 index 6631e1e..310c266 100644
84632 --- a/kernel/profile.c
84633 +++ b/kernel/profile.c
84634 @@ -37,7 +37,7 @@ struct profile_hit {
84635 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
84636 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
84637
84638 -static atomic_t *prof_buffer;
84639 +static atomic_unchecked_t *prof_buffer;
84640 static unsigned long prof_len, prof_shift;
84641
84642 int prof_on __read_mostly;
84643 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
84644 hits[i].pc = 0;
84645 continue;
84646 }
84647 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
84648 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
84649 hits[i].hits = hits[i].pc = 0;
84650 }
84651 }
84652 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
84653 * Add the current hit(s) and flush the write-queue out
84654 * to the global buffer:
84655 */
84656 - atomic_add(nr_hits, &prof_buffer[pc]);
84657 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
84658 for (i = 0; i < NR_PROFILE_HIT; ++i) {
84659 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
84660 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
84661 hits[i].pc = hits[i].hits = 0;
84662 }
84663 out:
84664 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
84665 {
84666 unsigned long pc;
84667 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
84668 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
84669 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
84670 }
84671 #endif /* !CONFIG_SMP */
84672
84673 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
84674 return -EFAULT;
84675 buf++; p++; count--; read++;
84676 }
84677 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
84678 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
84679 if (copy_to_user(buf, (void *)pnt, count))
84680 return -EFAULT;
84681 read += count;
84682 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
84683 }
84684 #endif
84685 profile_discard_flip_buffers();
84686 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
84687 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
84688 return count;
84689 }
84690
84691 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
84692 index 1f4bcb3..99cf7ab 100644
84693 --- a/kernel/ptrace.c
84694 +++ b/kernel/ptrace.c
84695 @@ -327,7 +327,7 @@ static int ptrace_attach(struct task_struct *task, long request,
84696 if (seize)
84697 flags |= PT_SEIZED;
84698 rcu_read_lock();
84699 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
84700 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
84701 flags |= PT_PTRACE_CAP;
84702 rcu_read_unlock();
84703 task->ptrace = flags;
84704 @@ -538,7 +538,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
84705 break;
84706 return -EIO;
84707 }
84708 - if (copy_to_user(dst, buf, retval))
84709 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
84710 return -EFAULT;
84711 copied += retval;
84712 src += retval;
84713 @@ -806,7 +806,7 @@ int ptrace_request(struct task_struct *child, long request,
84714 bool seized = child->ptrace & PT_SEIZED;
84715 int ret = -EIO;
84716 siginfo_t siginfo, *si;
84717 - void __user *datavp = (void __user *) data;
84718 + void __user *datavp = (__force void __user *) data;
84719 unsigned long __user *datalp = datavp;
84720 unsigned long flags;
84721
84722 @@ -1052,14 +1052,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
84723 goto out;
84724 }
84725
84726 + if (gr_handle_ptrace(child, request)) {
84727 + ret = -EPERM;
84728 + goto out_put_task_struct;
84729 + }
84730 +
84731 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
84732 ret = ptrace_attach(child, request, addr, data);
84733 /*
84734 * Some architectures need to do book-keeping after
84735 * a ptrace attach.
84736 */
84737 - if (!ret)
84738 + if (!ret) {
84739 arch_ptrace_attach(child);
84740 + gr_audit_ptrace(child);
84741 + }
84742 goto out_put_task_struct;
84743 }
84744
84745 @@ -1087,7 +1094,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
84746 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
84747 if (copied != sizeof(tmp))
84748 return -EIO;
84749 - return put_user(tmp, (unsigned long __user *)data);
84750 + return put_user(tmp, (__force unsigned long __user *)data);
84751 }
84752
84753 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
84754 @@ -1181,7 +1188,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
84755 }
84756
84757 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
84758 - compat_long_t addr, compat_long_t data)
84759 + compat_ulong_t addr, compat_ulong_t data)
84760 {
84761 struct task_struct *child;
84762 long ret;
84763 @@ -1197,14 +1204,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
84764 goto out;
84765 }
84766
84767 + if (gr_handle_ptrace(child, request)) {
84768 + ret = -EPERM;
84769 + goto out_put_task_struct;
84770 + }
84771 +
84772 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
84773 ret = ptrace_attach(child, request, addr, data);
84774 /*
84775 * Some architectures need to do book-keeping after
84776 * a ptrace attach.
84777 */
84778 - if (!ret)
84779 + if (!ret) {
84780 arch_ptrace_attach(child);
84781 + gr_audit_ptrace(child);
84782 + }
84783 goto out_put_task_struct;
84784 }
84785
84786 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
84787 index b02a339..ce2d20c 100644
84788 --- a/kernel/rcupdate.c
84789 +++ b/kernel/rcupdate.c
84790 @@ -312,10 +312,10 @@ int rcu_jiffies_till_stall_check(void)
84791 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
84792 */
84793 if (till_stall_check < 3) {
84794 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
84795 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
84796 till_stall_check = 3;
84797 } else if (till_stall_check > 300) {
84798 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
84799 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
84800 till_stall_check = 300;
84801 }
84802 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
84803 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
84804 index 9ed6075..c9e8a63 100644
84805 --- a/kernel/rcutiny.c
84806 +++ b/kernel/rcutiny.c
84807 @@ -45,7 +45,7 @@
84808 /* Forward declarations for rcutiny_plugin.h. */
84809 struct rcu_ctrlblk;
84810 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
84811 -static void rcu_process_callbacks(struct softirq_action *unused);
84812 +static void rcu_process_callbacks(void);
84813 static void __call_rcu(struct rcu_head *head,
84814 void (*func)(struct rcu_head *rcu),
84815 struct rcu_ctrlblk *rcp);
84816 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
84817 false));
84818 }
84819
84820 -static void rcu_process_callbacks(struct softirq_action *unused)
84821 +static __latent_entropy void rcu_process_callbacks(void)
84822 {
84823 __rcu_process_callbacks(&rcu_sched_ctrlblk);
84824 __rcu_process_callbacks(&rcu_bh_ctrlblk);
84825 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
84826 index be63101..05cf721 100644
84827 --- a/kernel/rcutorture.c
84828 +++ b/kernel/rcutorture.c
84829 @@ -170,12 +170,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
84830 { 0 };
84831 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
84832 { 0 };
84833 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
84834 -static atomic_t n_rcu_torture_alloc;
84835 -static atomic_t n_rcu_torture_alloc_fail;
84836 -static atomic_t n_rcu_torture_free;
84837 -static atomic_t n_rcu_torture_mberror;
84838 -static atomic_t n_rcu_torture_error;
84839 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
84840 +static atomic_unchecked_t n_rcu_torture_alloc;
84841 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
84842 +static atomic_unchecked_t n_rcu_torture_free;
84843 +static atomic_unchecked_t n_rcu_torture_mberror;
84844 +static atomic_unchecked_t n_rcu_torture_error;
84845 static long n_rcu_torture_barrier_error;
84846 static long n_rcu_torture_boost_ktrerror;
84847 static long n_rcu_torture_boost_rterror;
84848 @@ -293,11 +293,11 @@ rcu_torture_alloc(void)
84849
84850 spin_lock_bh(&rcu_torture_lock);
84851 if (list_empty(&rcu_torture_freelist)) {
84852 - atomic_inc(&n_rcu_torture_alloc_fail);
84853 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
84854 spin_unlock_bh(&rcu_torture_lock);
84855 return NULL;
84856 }
84857 - atomic_inc(&n_rcu_torture_alloc);
84858 + atomic_inc_unchecked(&n_rcu_torture_alloc);
84859 p = rcu_torture_freelist.next;
84860 list_del_init(p);
84861 spin_unlock_bh(&rcu_torture_lock);
84862 @@ -310,7 +310,7 @@ rcu_torture_alloc(void)
84863 static void
84864 rcu_torture_free(struct rcu_torture *p)
84865 {
84866 - atomic_inc(&n_rcu_torture_free);
84867 + atomic_inc_unchecked(&n_rcu_torture_free);
84868 spin_lock_bh(&rcu_torture_lock);
84869 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
84870 spin_unlock_bh(&rcu_torture_lock);
84871 @@ -431,7 +431,7 @@ rcu_torture_cb(struct rcu_head *p)
84872 i = rp->rtort_pipe_count;
84873 if (i > RCU_TORTURE_PIPE_LEN)
84874 i = RCU_TORTURE_PIPE_LEN;
84875 - atomic_inc(&rcu_torture_wcount[i]);
84876 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
84877 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
84878 rp->rtort_mbtest = 0;
84879 rcu_torture_free(rp);
84880 @@ -821,7 +821,7 @@ rcu_torture_writer(void *arg)
84881 i = old_rp->rtort_pipe_count;
84882 if (i > RCU_TORTURE_PIPE_LEN)
84883 i = RCU_TORTURE_PIPE_LEN;
84884 - atomic_inc(&rcu_torture_wcount[i]);
84885 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
84886 old_rp->rtort_pipe_count++;
84887 if (gp_normal == gp_exp)
84888 exp = !!(rcu_random(&rand) & 0x80);
84889 @@ -839,7 +839,7 @@ rcu_torture_writer(void *arg)
84890 i = rp->rtort_pipe_count;
84891 if (i > RCU_TORTURE_PIPE_LEN)
84892 i = RCU_TORTURE_PIPE_LEN;
84893 - atomic_inc(&rcu_torture_wcount[i]);
84894 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
84895 if (++rp->rtort_pipe_count >=
84896 RCU_TORTURE_PIPE_LEN) {
84897 rp->rtort_mbtest = 0;
84898 @@ -938,7 +938,7 @@ static void rcu_torture_timer(unsigned long unused)
84899 return;
84900 }
84901 if (p->rtort_mbtest == 0)
84902 - atomic_inc(&n_rcu_torture_mberror);
84903 + atomic_inc_unchecked(&n_rcu_torture_mberror);
84904 spin_lock(&rand_lock);
84905 cur_ops->read_delay(&rand);
84906 n_rcu_torture_timers++;
84907 @@ -1008,7 +1008,7 @@ rcu_torture_reader(void *arg)
84908 continue;
84909 }
84910 if (p->rtort_mbtest == 0)
84911 - atomic_inc(&n_rcu_torture_mberror);
84912 + atomic_inc_unchecked(&n_rcu_torture_mberror);
84913 cur_ops->read_delay(&rand);
84914 preempt_disable();
84915 pipe_count = p->rtort_pipe_count;
84916 @@ -1071,11 +1071,11 @@ rcu_torture_printk(char *page)
84917 rcu_torture_current,
84918 rcu_torture_current_version,
84919 list_empty(&rcu_torture_freelist),
84920 - atomic_read(&n_rcu_torture_alloc),
84921 - atomic_read(&n_rcu_torture_alloc_fail),
84922 - atomic_read(&n_rcu_torture_free));
84923 + atomic_read_unchecked(&n_rcu_torture_alloc),
84924 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
84925 + atomic_read_unchecked(&n_rcu_torture_free));
84926 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
84927 - atomic_read(&n_rcu_torture_mberror),
84928 + atomic_read_unchecked(&n_rcu_torture_mberror),
84929 n_rcu_torture_boost_ktrerror,
84930 n_rcu_torture_boost_rterror);
84931 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
84932 @@ -1094,14 +1094,14 @@ rcu_torture_printk(char *page)
84933 n_barrier_attempts,
84934 n_rcu_torture_barrier_error);
84935 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
84936 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
84937 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
84938 n_rcu_torture_barrier_error != 0 ||
84939 n_rcu_torture_boost_ktrerror != 0 ||
84940 n_rcu_torture_boost_rterror != 0 ||
84941 n_rcu_torture_boost_failure != 0 ||
84942 i > 1) {
84943 cnt += sprintf(&page[cnt], "!!! ");
84944 - atomic_inc(&n_rcu_torture_error);
84945 + atomic_inc_unchecked(&n_rcu_torture_error);
84946 WARN_ON_ONCE(1);
84947 }
84948 cnt += sprintf(&page[cnt], "Reader Pipe: ");
84949 @@ -1115,7 +1115,7 @@ rcu_torture_printk(char *page)
84950 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
84951 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
84952 cnt += sprintf(&page[cnt], " %d",
84953 - atomic_read(&rcu_torture_wcount[i]));
84954 + atomic_read_unchecked(&rcu_torture_wcount[i]));
84955 }
84956 cnt += sprintf(&page[cnt], "\n");
84957 if (cur_ops->stats)
84958 @@ -1830,7 +1830,7 @@ rcu_torture_cleanup(void)
84959
84960 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
84961
84962 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
84963 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
84964 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
84965 else if (n_online_successes != n_online_attempts ||
84966 n_offline_successes != n_offline_attempts)
84967 @@ -1952,18 +1952,18 @@ rcu_torture_init(void)
84968
84969 rcu_torture_current = NULL;
84970 rcu_torture_current_version = 0;
84971 - atomic_set(&n_rcu_torture_alloc, 0);
84972 - atomic_set(&n_rcu_torture_alloc_fail, 0);
84973 - atomic_set(&n_rcu_torture_free, 0);
84974 - atomic_set(&n_rcu_torture_mberror, 0);
84975 - atomic_set(&n_rcu_torture_error, 0);
84976 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
84977 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
84978 + atomic_set_unchecked(&n_rcu_torture_free, 0);
84979 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
84980 + atomic_set_unchecked(&n_rcu_torture_error, 0);
84981 n_rcu_torture_barrier_error = 0;
84982 n_rcu_torture_boost_ktrerror = 0;
84983 n_rcu_torture_boost_rterror = 0;
84984 n_rcu_torture_boost_failure = 0;
84985 n_rcu_torture_boosts = 0;
84986 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
84987 - atomic_set(&rcu_torture_wcount[i], 0);
84988 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
84989 for_each_possible_cpu(cpu) {
84990 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
84991 per_cpu(rcu_torture_count, cpu)[i] = 0;
84992 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
84993 index 32618b3..c1fb822 100644
84994 --- a/kernel/rcutree.c
84995 +++ b/kernel/rcutree.c
84996 @@ -382,9 +382,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
84997 rcu_prepare_for_idle(smp_processor_id());
84998 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
84999 smp_mb__before_atomic_inc(); /* See above. */
85000 - atomic_inc(&rdtp->dynticks);
85001 + atomic_inc_unchecked(&rdtp->dynticks);
85002 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
85003 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
85004 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
85005
85006 /*
85007 * It is illegal to enter an extended quiescent state while
85008 @@ -501,10 +501,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
85009 int user)
85010 {
85011 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
85012 - atomic_inc(&rdtp->dynticks);
85013 + atomic_inc_unchecked(&rdtp->dynticks);
85014 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
85015 smp_mb__after_atomic_inc(); /* See above. */
85016 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
85017 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
85018 rcu_cleanup_after_idle(smp_processor_id());
85019 trace_rcu_dyntick(TPS("End"), oldval, rdtp->dynticks_nesting);
85020 if (!user && !is_idle_task(current)) {
85021 @@ -623,14 +623,14 @@ void rcu_nmi_enter(void)
85022 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
85023
85024 if (rdtp->dynticks_nmi_nesting == 0 &&
85025 - (atomic_read(&rdtp->dynticks) & 0x1))
85026 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
85027 return;
85028 rdtp->dynticks_nmi_nesting++;
85029 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
85030 - atomic_inc(&rdtp->dynticks);
85031 + atomic_inc_unchecked(&rdtp->dynticks);
85032 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
85033 smp_mb__after_atomic_inc(); /* See above. */
85034 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
85035 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
85036 }
85037
85038 /**
85039 @@ -649,9 +649,9 @@ void rcu_nmi_exit(void)
85040 return;
85041 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
85042 smp_mb__before_atomic_inc(); /* See above. */
85043 - atomic_inc(&rdtp->dynticks);
85044 + atomic_inc_unchecked(&rdtp->dynticks);
85045 smp_mb__after_atomic_inc(); /* Force delay to next write. */
85046 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
85047 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
85048 }
85049
85050 /**
85051 @@ -665,7 +665,7 @@ int rcu_is_cpu_idle(void)
85052 int ret;
85053
85054 preempt_disable();
85055 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
85056 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
85057 preempt_enable();
85058 return ret;
85059 }
85060 @@ -734,7 +734,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
85061 static int dyntick_save_progress_counter(struct rcu_data *rdp,
85062 bool *isidle, unsigned long *maxj)
85063 {
85064 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
85065 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
85066 rcu_sysidle_check_cpu(rdp, isidle, maxj);
85067 return (rdp->dynticks_snap & 0x1) == 0;
85068 }
85069 @@ -751,7 +751,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp,
85070 unsigned int curr;
85071 unsigned int snap;
85072
85073 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
85074 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
85075 snap = (unsigned int)rdp->dynticks_snap;
85076
85077 /*
85078 @@ -1341,9 +1341,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
85079 rdp = this_cpu_ptr(rsp->rda);
85080 rcu_preempt_check_blocked_tasks(rnp);
85081 rnp->qsmask = rnp->qsmaskinit;
85082 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
85083 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
85084 WARN_ON_ONCE(rnp->completed != rsp->completed);
85085 - ACCESS_ONCE(rnp->completed) = rsp->completed;
85086 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
85087 if (rnp == rdp->mynode)
85088 __note_gp_changes(rsp, rnp, rdp);
85089 rcu_preempt_boost_start_gp(rnp);
85090 @@ -1434,7 +1434,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
85091 */
85092 rcu_for_each_node_breadth_first(rsp, rnp) {
85093 raw_spin_lock_irq(&rnp->lock);
85094 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
85095 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
85096 rdp = this_cpu_ptr(rsp->rda);
85097 if (rnp == rdp->mynode)
85098 __note_gp_changes(rsp, rnp, rdp);
85099 @@ -1766,7 +1766,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
85100 rsp->qlen += rdp->qlen;
85101 rdp->n_cbs_orphaned += rdp->qlen;
85102 rdp->qlen_lazy = 0;
85103 - ACCESS_ONCE(rdp->qlen) = 0;
85104 + ACCESS_ONCE_RW(rdp->qlen) = 0;
85105 }
85106
85107 /*
85108 @@ -2012,7 +2012,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
85109 }
85110 smp_mb(); /* List handling before counting for rcu_barrier(). */
85111 rdp->qlen_lazy -= count_lazy;
85112 - ACCESS_ONCE(rdp->qlen) -= count;
85113 + ACCESS_ONCE_RW(rdp->qlen) -= count;
85114 rdp->n_cbs_invoked += count;
85115
85116 /* Reinstate batch limit if we have worked down the excess. */
85117 @@ -2209,7 +2209,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
85118 /*
85119 * Do RCU core processing for the current CPU.
85120 */
85121 -static void rcu_process_callbacks(struct softirq_action *unused)
85122 +static __latent_entropy void rcu_process_callbacks(void)
85123 {
85124 struct rcu_state *rsp;
85125
85126 @@ -2316,7 +2316,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
85127 WARN_ON_ONCE((unsigned long)head & 0x3); /* Misaligned rcu_head! */
85128 if (debug_rcu_head_queue(head)) {
85129 /* Probable double call_rcu(), so leak the callback. */
85130 - ACCESS_ONCE(head->func) = rcu_leak_callback;
85131 + ACCESS_ONCE_RW(head->func) = rcu_leak_callback;
85132 WARN_ONCE(1, "__call_rcu(): Leaked duplicate callback\n");
85133 return;
85134 }
85135 @@ -2344,7 +2344,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
85136 local_irq_restore(flags);
85137 return;
85138 }
85139 - ACCESS_ONCE(rdp->qlen)++;
85140 + ACCESS_ONCE_RW(rdp->qlen)++;
85141 if (lazy)
85142 rdp->qlen_lazy++;
85143 else
85144 @@ -2553,11 +2553,11 @@ void synchronize_sched_expedited(void)
85145 * counter wrap on a 32-bit system. Quite a few more CPUs would of
85146 * course be required on a 64-bit system.
85147 */
85148 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
85149 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
85150 (ulong)atomic_long_read(&rsp->expedited_done) +
85151 ULONG_MAX / 8)) {
85152 synchronize_sched();
85153 - atomic_long_inc(&rsp->expedited_wrap);
85154 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
85155 return;
85156 }
85157
85158 @@ -2565,7 +2565,7 @@ void synchronize_sched_expedited(void)
85159 * Take a ticket. Note that atomic_inc_return() implies a
85160 * full memory barrier.
85161 */
85162 - snap = atomic_long_inc_return(&rsp->expedited_start);
85163 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
85164 firstsnap = snap;
85165 get_online_cpus();
85166 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
85167 @@ -2578,14 +2578,14 @@ void synchronize_sched_expedited(void)
85168 synchronize_sched_expedited_cpu_stop,
85169 NULL) == -EAGAIN) {
85170 put_online_cpus();
85171 - atomic_long_inc(&rsp->expedited_tryfail);
85172 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
85173
85174 /* Check to see if someone else did our work for us. */
85175 s = atomic_long_read(&rsp->expedited_done);
85176 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
85177 /* ensure test happens before caller kfree */
85178 smp_mb__before_atomic_inc(); /* ^^^ */
85179 - atomic_long_inc(&rsp->expedited_workdone1);
85180 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
85181 return;
85182 }
85183
85184 @@ -2594,7 +2594,7 @@ void synchronize_sched_expedited(void)
85185 udelay(trycount * num_online_cpus());
85186 } else {
85187 wait_rcu_gp(call_rcu_sched);
85188 - atomic_long_inc(&rsp->expedited_normal);
85189 + atomic_long_inc_unchecked(&rsp->expedited_normal);
85190 return;
85191 }
85192
85193 @@ -2603,7 +2603,7 @@ void synchronize_sched_expedited(void)
85194 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
85195 /* ensure test happens before caller kfree */
85196 smp_mb__before_atomic_inc(); /* ^^^ */
85197 - atomic_long_inc(&rsp->expedited_workdone2);
85198 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
85199 return;
85200 }
85201
85202 @@ -2615,10 +2615,10 @@ void synchronize_sched_expedited(void)
85203 * period works for us.
85204 */
85205 get_online_cpus();
85206 - snap = atomic_long_read(&rsp->expedited_start);
85207 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
85208 smp_mb(); /* ensure read is before try_stop_cpus(). */
85209 }
85210 - atomic_long_inc(&rsp->expedited_stoppedcpus);
85211 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
85212
85213 /*
85214 * Everyone up to our most recent fetch is covered by our grace
85215 @@ -2627,16 +2627,16 @@ void synchronize_sched_expedited(void)
85216 * than we did already did their update.
85217 */
85218 do {
85219 - atomic_long_inc(&rsp->expedited_done_tries);
85220 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
85221 s = atomic_long_read(&rsp->expedited_done);
85222 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
85223 /* ensure test happens before caller kfree */
85224 smp_mb__before_atomic_inc(); /* ^^^ */
85225 - atomic_long_inc(&rsp->expedited_done_lost);
85226 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
85227 break;
85228 }
85229 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
85230 - atomic_long_inc(&rsp->expedited_done_exit);
85231 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
85232
85233 put_online_cpus();
85234 }
85235 @@ -2829,7 +2829,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
85236 * ACCESS_ONCE() to prevent the compiler from speculating
85237 * the increment to precede the early-exit check.
85238 */
85239 - ACCESS_ONCE(rsp->n_barrier_done)++;
85240 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
85241 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
85242 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
85243 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
85244 @@ -2879,7 +2879,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
85245
85246 /* Increment ->n_barrier_done to prevent duplicate work. */
85247 smp_mb(); /* Keep increment after above mechanism. */
85248 - ACCESS_ONCE(rsp->n_barrier_done)++;
85249 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
85250 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
85251 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
85252 smp_mb(); /* Keep increment before caller's subsequent code. */
85253 @@ -2924,10 +2924,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
85254 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
85255 init_callback_list(rdp);
85256 rdp->qlen_lazy = 0;
85257 - ACCESS_ONCE(rdp->qlen) = 0;
85258 + ACCESS_ONCE_RW(rdp->qlen) = 0;
85259 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
85260 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
85261 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
85262 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
85263 rdp->cpu = cpu;
85264 rdp->rsp = rsp;
85265 rcu_boot_init_nocb_percpu_data(rdp);
85266 @@ -2961,8 +2961,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
85267 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
85268 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
85269 rcu_sysidle_init_percpu_data(rdp->dynticks);
85270 - atomic_set(&rdp->dynticks->dynticks,
85271 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
85272 + atomic_set_unchecked(&rdp->dynticks->dynticks,
85273 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
85274 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
85275
85276 /* Add CPU to rcu_node bitmasks. */
85277 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
85278 index 5f97eab..db8f687 100644
85279 --- a/kernel/rcutree.h
85280 +++ b/kernel/rcutree.h
85281 @@ -87,11 +87,11 @@ struct rcu_dynticks {
85282 long long dynticks_nesting; /* Track irq/process nesting level. */
85283 /* Process level is worth LLONG_MAX/2. */
85284 int dynticks_nmi_nesting; /* Track NMI nesting level. */
85285 - atomic_t dynticks; /* Even value for idle, else odd. */
85286 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
85287 #ifdef CONFIG_NO_HZ_FULL_SYSIDLE
85288 long long dynticks_idle_nesting;
85289 /* irq/process nesting level from idle. */
85290 - atomic_t dynticks_idle; /* Even value for idle, else odd. */
85291 + atomic_unchecked_t dynticks_idle; /* Even value for idle, else odd. */
85292 /* "Idle" excludes userspace execution. */
85293 unsigned long dynticks_idle_jiffies;
85294 /* End of last non-NMI non-idle period. */
85295 @@ -427,17 +427,17 @@ struct rcu_state {
85296 /* _rcu_barrier(). */
85297 /* End of fields guarded by barrier_mutex. */
85298
85299 - atomic_long_t expedited_start; /* Starting ticket. */
85300 - atomic_long_t expedited_done; /* Done ticket. */
85301 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
85302 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
85303 - atomic_long_t expedited_workdone1; /* # done by others #1. */
85304 - atomic_long_t expedited_workdone2; /* # done by others #2. */
85305 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
85306 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
85307 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
85308 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
85309 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
85310 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
85311 + atomic_long_t expedited_done; /* Done ticket. */
85312 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
85313 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
85314 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
85315 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
85316 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
85317 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
85318 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
85319 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
85320 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
85321
85322 unsigned long jiffies_force_qs; /* Time at which to invoke */
85323 /* force_quiescent_state(). */
85324 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
85325 index 130c97b..bcbe7f7 100644
85326 --- a/kernel/rcutree_plugin.h
85327 +++ b/kernel/rcutree_plugin.h
85328 @@ -744,7 +744,7 @@ static int rcu_preempted_readers_exp(struct rcu_node *rnp)
85329 static int sync_rcu_preempt_exp_done(struct rcu_node *rnp)
85330 {
85331 return !rcu_preempted_readers_exp(rnp) &&
85332 - ACCESS_ONCE(rnp->expmask) == 0;
85333 + ACCESS_ONCE_RW(rnp->expmask) == 0;
85334 }
85335
85336 /*
85337 @@ -900,7 +900,7 @@ void synchronize_rcu_expedited(void)
85338
85339 /* Clean up and exit. */
85340 smp_mb(); /* ensure expedited GP seen before counter increment. */
85341 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
85342 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
85343 unlock_mb_ret:
85344 mutex_unlock(&sync_rcu_preempt_exp_mutex);
85345 mb_ret:
85346 @@ -1474,7 +1474,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
85347 free_cpumask_var(cm);
85348 }
85349
85350 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
85351 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
85352 .store = &rcu_cpu_kthread_task,
85353 .thread_should_run = rcu_cpu_kthread_should_run,
85354 .thread_fn = rcu_cpu_kthread,
85355 @@ -1939,7 +1939,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
85356 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
85357 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
85358 cpu, ticks_value, ticks_title,
85359 - atomic_read(&rdtp->dynticks) & 0xfff,
85360 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
85361 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
85362 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
85363 fast_no_hz);
85364 @@ -2102,7 +2102,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
85365
85366 /* Enqueue the callback on the nocb list and update counts. */
85367 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
85368 - ACCESS_ONCE(*old_rhpp) = rhp;
85369 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
85370 atomic_long_add(rhcount, &rdp->nocb_q_count);
85371 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
85372
85373 @@ -2242,12 +2242,12 @@ static int rcu_nocb_kthread(void *arg)
85374 * Extract queued callbacks, update counts, and wait
85375 * for a grace period to elapse.
85376 */
85377 - ACCESS_ONCE(rdp->nocb_head) = NULL;
85378 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
85379 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
85380 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
85381 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
85382 - ACCESS_ONCE(rdp->nocb_p_count) += c;
85383 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
85384 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
85385 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
85386 rcu_nocb_wait_gp(rdp);
85387
85388 /* Each pass through the following loop invokes a callback. */
85389 @@ -2269,8 +2269,8 @@ static int rcu_nocb_kthread(void *arg)
85390 list = next;
85391 }
85392 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
85393 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
85394 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
85395 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
85396 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
85397 rdp->n_nocbs_invoked += c;
85398 }
85399 return 0;
85400 @@ -2297,7 +2297,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
85401 t = kthread_run(rcu_nocb_kthread, rdp,
85402 "rcuo%c/%d", rsp->abbr, cpu);
85403 BUG_ON(IS_ERR(t));
85404 - ACCESS_ONCE(rdp->nocb_kthread) = t;
85405 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
85406 }
85407 }
85408
85409 @@ -2423,11 +2423,11 @@ static void rcu_sysidle_enter(struct rcu_dynticks *rdtp, int irq)
85410
85411 /* Record start of fully idle period. */
85412 j = jiffies;
85413 - ACCESS_ONCE(rdtp->dynticks_idle_jiffies) = j;
85414 + ACCESS_ONCE_RW(rdtp->dynticks_idle_jiffies) = j;
85415 smp_mb__before_atomic_inc();
85416 - atomic_inc(&rdtp->dynticks_idle);
85417 + atomic_inc_unchecked(&rdtp->dynticks_idle);
85418 smp_mb__after_atomic_inc();
85419 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks_idle) & 0x1);
85420 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1);
85421 }
85422
85423 /*
85424 @@ -2492,9 +2492,9 @@ static void rcu_sysidle_exit(struct rcu_dynticks *rdtp, int irq)
85425
85426 /* Record end of idle period. */
85427 smp_mb__before_atomic_inc();
85428 - atomic_inc(&rdtp->dynticks_idle);
85429 + atomic_inc_unchecked(&rdtp->dynticks_idle);
85430 smp_mb__after_atomic_inc();
85431 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks_idle) & 0x1));
85432 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1));
85433
85434 /*
85435 * If we are the timekeeping CPU, we are permitted to be non-idle
85436 @@ -2535,7 +2535,7 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle,
85437 WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu);
85438
85439 /* Pick up current idle and NMI-nesting counter and check. */
85440 - cur = atomic_read(&rdtp->dynticks_idle);
85441 + cur = atomic_read_unchecked(&rdtp->dynticks_idle);
85442 if (cur & 0x1) {
85443 *isidle = false; /* We are not idle! */
85444 return;
85445 @@ -2598,7 +2598,7 @@ static void rcu_sysidle(unsigned long j)
85446 case RCU_SYSIDLE_NOT:
85447
85448 /* First time all are idle, so note a short idle period. */
85449 - ACCESS_ONCE(full_sysidle_state) = RCU_SYSIDLE_SHORT;
85450 + ACCESS_ONCE_RW(full_sysidle_state) = RCU_SYSIDLE_SHORT;
85451 break;
85452
85453 case RCU_SYSIDLE_SHORT:
85454 @@ -2635,7 +2635,7 @@ static void rcu_sysidle(unsigned long j)
85455 static void rcu_sysidle_cancel(void)
85456 {
85457 smp_mb();
85458 - ACCESS_ONCE(full_sysidle_state) = RCU_SYSIDLE_NOT;
85459 + ACCESS_ONCE_RW(full_sysidle_state) = RCU_SYSIDLE_NOT;
85460 }
85461
85462 /*
85463 @@ -2683,7 +2683,7 @@ static void rcu_sysidle_cb(struct rcu_head *rhp)
85464 smp_mb(); /* grace period precedes setting inuse. */
85465
85466 rshp = container_of(rhp, struct rcu_sysidle_head, rh);
85467 - ACCESS_ONCE(rshp->inuse) = 0;
85468 + ACCESS_ONCE_RW(rshp->inuse) = 0;
85469 }
85470
85471 /*
85472 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
85473 index cf6c174..a8f4b50 100644
85474 --- a/kernel/rcutree_trace.c
85475 +++ b/kernel/rcutree_trace.c
85476 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
85477 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
85478 rdp->passed_quiesce, rdp->qs_pending);
85479 seq_printf(m, " dt=%d/%llx/%d df=%lu",
85480 - atomic_read(&rdp->dynticks->dynticks),
85481 + atomic_read_unchecked(&rdp->dynticks->dynticks),
85482 rdp->dynticks->dynticks_nesting,
85483 rdp->dynticks->dynticks_nmi_nesting,
85484 rdp->dynticks_fqs);
85485 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
85486 struct rcu_state *rsp = (struct rcu_state *)m->private;
85487
85488 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",
85489 - atomic_long_read(&rsp->expedited_start),
85490 + atomic_long_read_unchecked(&rsp->expedited_start),
85491 atomic_long_read(&rsp->expedited_done),
85492 - atomic_long_read(&rsp->expedited_wrap),
85493 - atomic_long_read(&rsp->expedited_tryfail),
85494 - atomic_long_read(&rsp->expedited_workdone1),
85495 - atomic_long_read(&rsp->expedited_workdone2),
85496 - atomic_long_read(&rsp->expedited_normal),
85497 - atomic_long_read(&rsp->expedited_stoppedcpus),
85498 - atomic_long_read(&rsp->expedited_done_tries),
85499 - atomic_long_read(&rsp->expedited_done_lost),
85500 - atomic_long_read(&rsp->expedited_done_exit));
85501 + atomic_long_read_unchecked(&rsp->expedited_wrap),
85502 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
85503 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
85504 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
85505 + atomic_long_read_unchecked(&rsp->expedited_normal),
85506 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
85507 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
85508 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
85509 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
85510 return 0;
85511 }
85512
85513 diff --git a/kernel/resource.c b/kernel/resource.c
85514 index 3f285dc..5755f62 100644
85515 --- a/kernel/resource.c
85516 +++ b/kernel/resource.c
85517 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
85518
85519 static int __init ioresources_init(void)
85520 {
85521 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85522 +#ifdef CONFIG_GRKERNSEC_PROC_USER
85523 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
85524 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
85525 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
85526 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
85527 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
85528 +#endif
85529 +#else
85530 proc_create("ioports", 0, NULL, &proc_ioports_operations);
85531 proc_create("iomem", 0, NULL, &proc_iomem_operations);
85532 +#endif
85533 return 0;
85534 }
85535 __initcall(ioresources_init);
85536 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
85537 index 1d96dd0..994ff19 100644
85538 --- a/kernel/rtmutex-tester.c
85539 +++ b/kernel/rtmutex-tester.c
85540 @@ -22,7 +22,7 @@
85541 #define MAX_RT_TEST_MUTEXES 8
85542
85543 static spinlock_t rttest_lock;
85544 -static atomic_t rttest_event;
85545 +static atomic_unchecked_t rttest_event;
85546
85547 struct test_thread_data {
85548 int opcode;
85549 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85550
85551 case RTTEST_LOCKCONT:
85552 td->mutexes[td->opdata] = 1;
85553 - td->event = atomic_add_return(1, &rttest_event);
85554 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85555 return 0;
85556
85557 case RTTEST_RESET:
85558 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85559 return 0;
85560
85561 case RTTEST_RESETEVENT:
85562 - atomic_set(&rttest_event, 0);
85563 + atomic_set_unchecked(&rttest_event, 0);
85564 return 0;
85565
85566 default:
85567 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85568 return ret;
85569
85570 td->mutexes[id] = 1;
85571 - td->event = atomic_add_return(1, &rttest_event);
85572 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85573 rt_mutex_lock(&mutexes[id]);
85574 - td->event = atomic_add_return(1, &rttest_event);
85575 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85576 td->mutexes[id] = 4;
85577 return 0;
85578
85579 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85580 return ret;
85581
85582 td->mutexes[id] = 1;
85583 - td->event = atomic_add_return(1, &rttest_event);
85584 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85585 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
85586 - td->event = atomic_add_return(1, &rttest_event);
85587 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85588 td->mutexes[id] = ret ? 0 : 4;
85589 return ret ? -EINTR : 0;
85590
85591 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85592 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
85593 return ret;
85594
85595 - td->event = atomic_add_return(1, &rttest_event);
85596 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85597 rt_mutex_unlock(&mutexes[id]);
85598 - td->event = atomic_add_return(1, &rttest_event);
85599 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85600 td->mutexes[id] = 0;
85601 return 0;
85602
85603 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
85604 break;
85605
85606 td->mutexes[dat] = 2;
85607 - td->event = atomic_add_return(1, &rttest_event);
85608 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85609 break;
85610
85611 default:
85612 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
85613 return;
85614
85615 td->mutexes[dat] = 3;
85616 - td->event = atomic_add_return(1, &rttest_event);
85617 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85618 break;
85619
85620 case RTTEST_LOCKNOWAIT:
85621 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
85622 return;
85623
85624 td->mutexes[dat] = 1;
85625 - td->event = atomic_add_return(1, &rttest_event);
85626 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85627 return;
85628
85629 default:
85630 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
85631 index 4a07353..66b5291 100644
85632 --- a/kernel/sched/auto_group.c
85633 +++ b/kernel/sched/auto_group.c
85634 @@ -11,7 +11,7 @@
85635
85636 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
85637 static struct autogroup autogroup_default;
85638 -static atomic_t autogroup_seq_nr;
85639 +static atomic_unchecked_t autogroup_seq_nr;
85640
85641 void __init autogroup_init(struct task_struct *init_task)
85642 {
85643 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
85644
85645 kref_init(&ag->kref);
85646 init_rwsem(&ag->lock);
85647 - ag->id = atomic_inc_return(&autogroup_seq_nr);
85648 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
85649 ag->tg = tg;
85650 #ifdef CONFIG_RT_GROUP_SCHED
85651 /*
85652 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
85653 index ceae65e..3ac1344 100644
85654 --- a/kernel/sched/core.c
85655 +++ b/kernel/sched/core.c
85656 @@ -2868,7 +2868,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
85657 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
85658 * or number of jiffies left till timeout) if completed.
85659 */
85660 -long __sched
85661 +long __sched __intentional_overflow(-1)
85662 wait_for_completion_interruptible_timeout(struct completion *x,
85663 unsigned long timeout)
85664 {
85665 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
85666 *
85667 * Return: -ERESTARTSYS if interrupted, 0 if completed.
85668 */
85669 -int __sched wait_for_completion_killable(struct completion *x)
85670 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
85671 {
85672 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
85673 if (t == -ERESTARTSYS)
85674 @@ -2906,7 +2906,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
85675 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
85676 * or number of jiffies left till timeout) if completed.
85677 */
85678 -long __sched
85679 +long __sched __intentional_overflow(-1)
85680 wait_for_completion_killable_timeout(struct completion *x,
85681 unsigned long timeout)
85682 {
85683 @@ -3132,6 +3132,8 @@ int can_nice(const struct task_struct *p, const int nice)
85684 /* convert nice value [19,-20] to rlimit style value [1,40] */
85685 int nice_rlim = 20 - nice;
85686
85687 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
85688 +
85689 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
85690 capable(CAP_SYS_NICE));
85691 }
85692 @@ -3165,7 +3167,8 @@ SYSCALL_DEFINE1(nice, int, increment)
85693 if (nice > 19)
85694 nice = 19;
85695
85696 - if (increment < 0 && !can_nice(current, nice))
85697 + if (increment < 0 && (!can_nice(current, nice) ||
85698 + gr_handle_chroot_nice()))
85699 return -EPERM;
85700
85701 retval = security_task_setnice(current, nice);
85702 @@ -3327,6 +3330,7 @@ recheck:
85703 unsigned long rlim_rtprio =
85704 task_rlimit(p, RLIMIT_RTPRIO);
85705
85706 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
85707 /* can't set/change the rt policy */
85708 if (policy != p->policy && !rlim_rtprio)
85709 return -EPERM;
85710 @@ -4456,7 +4460,7 @@ static void migrate_tasks(unsigned int dead_cpu)
85711
85712 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
85713
85714 -static struct ctl_table sd_ctl_dir[] = {
85715 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
85716 {
85717 .procname = "sched_domain",
85718 .mode = 0555,
85719 @@ -4473,17 +4477,17 @@ static struct ctl_table sd_ctl_root[] = {
85720 {}
85721 };
85722
85723 -static struct ctl_table *sd_alloc_ctl_entry(int n)
85724 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
85725 {
85726 - struct ctl_table *entry =
85727 + ctl_table_no_const *entry =
85728 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
85729
85730 return entry;
85731 }
85732
85733 -static void sd_free_ctl_entry(struct ctl_table **tablep)
85734 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
85735 {
85736 - struct ctl_table *entry;
85737 + ctl_table_no_const *entry;
85738
85739 /*
85740 * In the intermediate directories, both the child directory and
85741 @@ -4491,22 +4495,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
85742 * will always be set. In the lowest directory the names are
85743 * static strings and all have proc handlers.
85744 */
85745 - for (entry = *tablep; entry->mode; entry++) {
85746 - if (entry->child)
85747 - sd_free_ctl_entry(&entry->child);
85748 + for (entry = tablep; entry->mode; entry++) {
85749 + if (entry->child) {
85750 + sd_free_ctl_entry(entry->child);
85751 + pax_open_kernel();
85752 + entry->child = NULL;
85753 + pax_close_kernel();
85754 + }
85755 if (entry->proc_handler == NULL)
85756 kfree(entry->procname);
85757 }
85758
85759 - kfree(*tablep);
85760 - *tablep = NULL;
85761 + kfree(tablep);
85762 }
85763
85764 static int min_load_idx = 0;
85765 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
85766
85767 static void
85768 -set_table_entry(struct ctl_table *entry,
85769 +set_table_entry(ctl_table_no_const *entry,
85770 const char *procname, void *data, int maxlen,
85771 umode_t mode, proc_handler *proc_handler,
85772 bool load_idx)
85773 @@ -4526,7 +4533,7 @@ set_table_entry(struct ctl_table *entry,
85774 static struct ctl_table *
85775 sd_alloc_ctl_domain_table(struct sched_domain *sd)
85776 {
85777 - struct ctl_table *table = sd_alloc_ctl_entry(13);
85778 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
85779
85780 if (table == NULL)
85781 return NULL;
85782 @@ -4561,9 +4568,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
85783 return table;
85784 }
85785
85786 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
85787 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
85788 {
85789 - struct ctl_table *entry, *table;
85790 + ctl_table_no_const *entry, *table;
85791 struct sched_domain *sd;
85792 int domain_num = 0, i;
85793 char buf[32];
85794 @@ -4590,11 +4597,13 @@ static struct ctl_table_header *sd_sysctl_header;
85795 static void register_sched_domain_sysctl(void)
85796 {
85797 int i, cpu_num = num_possible_cpus();
85798 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
85799 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
85800 char buf[32];
85801
85802 WARN_ON(sd_ctl_dir[0].child);
85803 + pax_open_kernel();
85804 sd_ctl_dir[0].child = entry;
85805 + pax_close_kernel();
85806
85807 if (entry == NULL)
85808 return;
85809 @@ -4617,8 +4626,12 @@ static void unregister_sched_domain_sysctl(void)
85810 if (sd_sysctl_header)
85811 unregister_sysctl_table(sd_sysctl_header);
85812 sd_sysctl_header = NULL;
85813 - if (sd_ctl_dir[0].child)
85814 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
85815 + if (sd_ctl_dir[0].child) {
85816 + sd_free_ctl_entry(sd_ctl_dir[0].child);
85817 + pax_open_kernel();
85818 + sd_ctl_dir[0].child = NULL;
85819 + pax_close_kernel();
85820 + }
85821 }
85822 #else
85823 static void register_sched_domain_sysctl(void)
85824 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
85825 index 4117323..91c91ac 100644
85826 --- a/kernel/sched/fair.c
85827 +++ b/kernel/sched/fair.c
85828 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
85829
85830 static void reset_ptenuma_scan(struct task_struct *p)
85831 {
85832 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
85833 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
85834 p->mm->numa_scan_offset = 0;
85835 }
85836
85837 @@ -5864,7 +5864,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
85838 * run_rebalance_domains is triggered when needed from the scheduler tick.
85839 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
85840 */
85841 -static void run_rebalance_domains(struct softirq_action *h)
85842 +static __latent_entropy void run_rebalance_domains(void)
85843 {
85844 int this_cpu = smp_processor_id();
85845 struct rq *this_rq = cpu_rq(this_cpu);
85846 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
85847 index a6208af..a2d7bb5 100644
85848 --- a/kernel/sched/sched.h
85849 +++ b/kernel/sched/sched.h
85850 @@ -1004,7 +1004,7 @@ struct sched_class {
85851 #ifdef CONFIG_FAIR_GROUP_SCHED
85852 void (*task_move_group) (struct task_struct *p, int on_rq);
85853 #endif
85854 -};
85855 +} __do_const;
85856
85857 #define sched_class_highest (&stop_sched_class)
85858 #define for_each_class(class) \
85859 diff --git a/kernel/signal.c b/kernel/signal.c
85860 index ded28b9..6886c08 100644
85861 --- a/kernel/signal.c
85862 +++ b/kernel/signal.c
85863 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
85864
85865 int print_fatal_signals __read_mostly;
85866
85867 -static void __user *sig_handler(struct task_struct *t, int sig)
85868 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
85869 {
85870 return t->sighand->action[sig - 1].sa.sa_handler;
85871 }
85872
85873 -static int sig_handler_ignored(void __user *handler, int sig)
85874 +static int sig_handler_ignored(__sighandler_t handler, int sig)
85875 {
85876 /* Is it explicitly or implicitly ignored? */
85877 return handler == SIG_IGN ||
85878 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
85879
85880 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
85881 {
85882 - void __user *handler;
85883 + __sighandler_t handler;
85884
85885 handler = sig_handler(t, sig);
85886
85887 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
85888 atomic_inc(&user->sigpending);
85889 rcu_read_unlock();
85890
85891 + if (!override_rlimit)
85892 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
85893 +
85894 if (override_rlimit ||
85895 atomic_read(&user->sigpending) <=
85896 task_rlimit(t, RLIMIT_SIGPENDING)) {
85897 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
85898
85899 int unhandled_signal(struct task_struct *tsk, int sig)
85900 {
85901 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
85902 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
85903 if (is_global_init(tsk))
85904 return 1;
85905 if (handler != SIG_IGN && handler != SIG_DFL)
85906 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
85907 }
85908 }
85909
85910 + /* allow glibc communication via tgkill to other threads in our
85911 + thread group */
85912 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
85913 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
85914 + && gr_handle_signal(t, sig))
85915 + return -EPERM;
85916 +
85917 return security_task_kill(t, info, sig, 0);
85918 }
85919
85920 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
85921 return send_signal(sig, info, p, 1);
85922 }
85923
85924 -static int
85925 +int
85926 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85927 {
85928 return send_signal(sig, info, t, 0);
85929 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85930 unsigned long int flags;
85931 int ret, blocked, ignored;
85932 struct k_sigaction *action;
85933 + int is_unhandled = 0;
85934
85935 spin_lock_irqsave(&t->sighand->siglock, flags);
85936 action = &t->sighand->action[sig-1];
85937 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85938 }
85939 if (action->sa.sa_handler == SIG_DFL)
85940 t->signal->flags &= ~SIGNAL_UNKILLABLE;
85941 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
85942 + is_unhandled = 1;
85943 ret = specific_send_sig_info(sig, info, t);
85944 spin_unlock_irqrestore(&t->sighand->siglock, flags);
85945
85946 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
85947 + normal operation */
85948 + if (is_unhandled) {
85949 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
85950 + gr_handle_crash(t, sig);
85951 + }
85952 +
85953 return ret;
85954 }
85955
85956 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
85957 ret = check_kill_permission(sig, info, p);
85958 rcu_read_unlock();
85959
85960 - if (!ret && sig)
85961 + if (!ret && sig) {
85962 ret = do_send_sig_info(sig, info, p, true);
85963 + if (!ret)
85964 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
85965 + }
85966
85967 return ret;
85968 }
85969 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
85970 int error = -ESRCH;
85971
85972 rcu_read_lock();
85973 - p = find_task_by_vpid(pid);
85974 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
85975 + /* allow glibc communication via tgkill to other threads in our
85976 + thread group */
85977 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
85978 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
85979 + p = find_task_by_vpid_unrestricted(pid);
85980 + else
85981 +#endif
85982 + p = find_task_by_vpid(pid);
85983 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
85984 error = check_kill_permission(sig, info, p);
85985 /*
85986 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
85987 }
85988 seg = get_fs();
85989 set_fs(KERNEL_DS);
85990 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
85991 - (stack_t __force __user *) &uoss,
85992 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
85993 + (stack_t __force_user *) &uoss,
85994 compat_user_stack_pointer());
85995 set_fs(seg);
85996 if (ret >= 0 && uoss_ptr) {
85997 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
85998 index eb89e18..a4e6792 100644
85999 --- a/kernel/smpboot.c
86000 +++ b/kernel/smpboot.c
86001 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
86002 }
86003 smpboot_unpark_thread(plug_thread, cpu);
86004 }
86005 - list_add(&plug_thread->list, &hotplug_threads);
86006 + pax_list_add(&plug_thread->list, &hotplug_threads);
86007 out:
86008 mutex_unlock(&smpboot_threads_lock);
86009 return ret;
86010 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
86011 {
86012 get_online_cpus();
86013 mutex_lock(&smpboot_threads_lock);
86014 - list_del(&plug_thread->list);
86015 + pax_list_del(&plug_thread->list);
86016 smpboot_destroy_threads(plug_thread);
86017 mutex_unlock(&smpboot_threads_lock);
86018 put_online_cpus();
86019 diff --git a/kernel/softirq.c b/kernel/softirq.c
86020 index d7d498d..94fe0f7 100644
86021 --- a/kernel/softirq.c
86022 +++ b/kernel/softirq.c
86023 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
86024 EXPORT_SYMBOL(irq_stat);
86025 #endif
86026
86027 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
86028 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
86029
86030 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
86031
86032 -char *softirq_to_name[NR_SOFTIRQS] = {
86033 +const char * const softirq_to_name[NR_SOFTIRQS] = {
86034 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
86035 "TASKLET", "SCHED", "HRTIMER", "RCU"
86036 };
86037 @@ -248,7 +248,7 @@ restart:
86038 kstat_incr_softirqs_this_cpu(vec_nr);
86039
86040 trace_softirq_entry(vec_nr);
86041 - h->action(h);
86042 + h->action();
86043 trace_softirq_exit(vec_nr);
86044 if (unlikely(prev_count != preempt_count())) {
86045 printk(KERN_ERR "huh, entered softirq %u %s %p"
86046 @@ -412,7 +412,7 @@ void __raise_softirq_irqoff(unsigned int nr)
86047 or_softirq_pending(1UL << nr);
86048 }
86049
86050 -void open_softirq(int nr, void (*action)(struct softirq_action *))
86051 +void __init open_softirq(int nr, void (*action)(void))
86052 {
86053 softirq_vec[nr].action = action;
86054 }
86055 @@ -468,7 +468,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
86056
86057 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
86058
86059 -static void tasklet_action(struct softirq_action *a)
86060 +static __latent_entropy void tasklet_action(void)
86061 {
86062 struct tasklet_struct *list;
86063
86064 @@ -503,7 +503,7 @@ static void tasklet_action(struct softirq_action *a)
86065 }
86066 }
86067
86068 -static void tasklet_hi_action(struct softirq_action *a)
86069 +static __latent_entropy void tasklet_hi_action(void)
86070 {
86071 struct tasklet_struct *list;
86072
86073 @@ -858,7 +858,7 @@ static struct notifier_block cpu_nfb = {
86074 .notifier_call = cpu_callback
86075 };
86076
86077 -static struct smp_hotplug_thread softirq_threads = {
86078 +static struct smp_hotplug_thread softirq_threads __read_only = {
86079 .store = &ksoftirqd,
86080 .thread_should_run = ksoftirqd_should_run,
86081 .thread_fn = run_ksoftirqd,
86082 diff --git a/kernel/srcu.c b/kernel/srcu.c
86083 index 01d5ccb..cdcbee6 100644
86084 --- a/kernel/srcu.c
86085 +++ b/kernel/srcu.c
86086 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
86087
86088 idx = ACCESS_ONCE(sp->completed) & 0x1;
86089 preempt_disable();
86090 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
86091 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
86092 smp_mb(); /* B */ /* Avoid leaking the critical section. */
86093 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
86094 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
86095 preempt_enable();
86096 return idx;
86097 }
86098 diff --git a/kernel/sys.c b/kernel/sys.c
86099 index c18ecca..b3c2dd2 100644
86100 --- a/kernel/sys.c
86101 +++ b/kernel/sys.c
86102 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
86103 error = -EACCES;
86104 goto out;
86105 }
86106 +
86107 + if (gr_handle_chroot_setpriority(p, niceval)) {
86108 + error = -EACCES;
86109 + goto out;
86110 + }
86111 +
86112 no_nice = security_task_setnice(p, niceval);
86113 if (no_nice) {
86114 error = no_nice;
86115 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
86116 goto error;
86117 }
86118
86119 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
86120 + goto error;
86121 +
86122 if (rgid != (gid_t) -1 ||
86123 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
86124 new->sgid = new->egid;
86125 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
86126 old = current_cred();
86127
86128 retval = -EPERM;
86129 +
86130 + if (gr_check_group_change(kgid, kgid, kgid))
86131 + goto error;
86132 +
86133 if (ns_capable(old->user_ns, CAP_SETGID))
86134 new->gid = new->egid = new->sgid = new->fsgid = kgid;
86135 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
86136 @@ -404,7 +417,7 @@ error:
86137 /*
86138 * change the user struct in a credentials set to match the new UID
86139 */
86140 -static int set_user(struct cred *new)
86141 +int set_user(struct cred *new)
86142 {
86143 struct user_struct *new_user;
86144
86145 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
86146 goto error;
86147 }
86148
86149 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
86150 + goto error;
86151 +
86152 if (!uid_eq(new->uid, old->uid)) {
86153 retval = set_user(new);
86154 if (retval < 0)
86155 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
86156 old = current_cred();
86157
86158 retval = -EPERM;
86159 +
86160 + if (gr_check_crash_uid(kuid))
86161 + goto error;
86162 + if (gr_check_user_change(kuid, kuid, kuid))
86163 + goto error;
86164 +
86165 if (ns_capable(old->user_ns, CAP_SETUID)) {
86166 new->suid = new->uid = kuid;
86167 if (!uid_eq(kuid, old->uid)) {
86168 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
86169 goto error;
86170 }
86171
86172 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
86173 + goto error;
86174 +
86175 if (ruid != (uid_t) -1) {
86176 new->uid = kruid;
86177 if (!uid_eq(kruid, old->uid)) {
86178 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
86179 goto error;
86180 }
86181
86182 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
86183 + goto error;
86184 +
86185 if (rgid != (gid_t) -1)
86186 new->gid = krgid;
86187 if (egid != (gid_t) -1)
86188 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
86189 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
86190 ns_capable(old->user_ns, CAP_SETUID)) {
86191 if (!uid_eq(kuid, old->fsuid)) {
86192 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
86193 + goto error;
86194 +
86195 new->fsuid = kuid;
86196 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
86197 goto change_okay;
86198 }
86199 }
86200
86201 +error:
86202 abort_creds(new);
86203 return old_fsuid;
86204
86205 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
86206 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
86207 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
86208 ns_capable(old->user_ns, CAP_SETGID)) {
86209 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
86210 + goto error;
86211 +
86212 if (!gid_eq(kgid, old->fsgid)) {
86213 new->fsgid = kgid;
86214 goto change_okay;
86215 }
86216 }
86217
86218 +error:
86219 abort_creds(new);
86220 return old_fsgid;
86221
86222 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
86223 return -EFAULT;
86224
86225 down_read(&uts_sem);
86226 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
86227 + error = __copy_to_user(name->sysname, &utsname()->sysname,
86228 __OLD_UTS_LEN);
86229 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
86230 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
86231 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
86232 __OLD_UTS_LEN);
86233 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
86234 - error |= __copy_to_user(&name->release, &utsname()->release,
86235 + error |= __copy_to_user(name->release, &utsname()->release,
86236 __OLD_UTS_LEN);
86237 error |= __put_user(0, name->release + __OLD_UTS_LEN);
86238 - error |= __copy_to_user(&name->version, &utsname()->version,
86239 + error |= __copy_to_user(name->version, &utsname()->version,
86240 __OLD_UTS_LEN);
86241 error |= __put_user(0, name->version + __OLD_UTS_LEN);
86242 - error |= __copy_to_user(&name->machine, &utsname()->machine,
86243 + error |= __copy_to_user(name->machine, &utsname()->machine,
86244 __OLD_UTS_LEN);
86245 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
86246 up_read(&uts_sem);
86247 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
86248 */
86249 new_rlim->rlim_cur = 1;
86250 }
86251 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
86252 + is changed to a lower value. Since tasks can be created by the same
86253 + user in between this limit change and an execve by this task, force
86254 + a recheck only for this task by setting PF_NPROC_EXCEEDED
86255 + */
86256 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
86257 + tsk->flags |= PF_NPROC_EXCEEDED;
86258 }
86259 if (!retval) {
86260 if (old_rlim)
86261 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
86262 index b2f06f3..e6354ab 100644
86263 --- a/kernel/sysctl.c
86264 +++ b/kernel/sysctl.c
86265 @@ -93,7 +93,6 @@
86266
86267
86268 #if defined(CONFIG_SYSCTL)
86269 -
86270 /* External variables not in a header file. */
86271 extern int sysctl_overcommit_memory;
86272 extern int sysctl_overcommit_ratio;
86273 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
86274
86275 /* Constants used for minimum and maximum */
86276 #ifdef CONFIG_LOCKUP_DETECTOR
86277 -static int sixty = 60;
86278 +static int sixty __read_only = 60;
86279 #endif
86280
86281 -static int zero;
86282 -static int __maybe_unused one = 1;
86283 -static int __maybe_unused two = 2;
86284 -static int __maybe_unused three = 3;
86285 -static unsigned long one_ul = 1;
86286 -static int one_hundred = 100;
86287 +static int neg_one __read_only = -1;
86288 +static int zero __read_only = 0;
86289 +static int __maybe_unused one __read_only = 1;
86290 +static int __maybe_unused two __read_only = 2;
86291 +static int __maybe_unused three __read_only = 3;
86292 +static unsigned long one_ul __read_only = 1;
86293 +static int one_hundred __read_only = 100;
86294 #ifdef CONFIG_PRINTK
86295 -static int ten_thousand = 10000;
86296 +static int ten_thousand __read_only = 10000;
86297 #endif
86298
86299 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
86300 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
86301 void __user *buffer, size_t *lenp, loff_t *ppos);
86302 #endif
86303
86304 -#ifdef CONFIG_PRINTK
86305 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
86306 void __user *buffer, size_t *lenp, loff_t *ppos);
86307 -#endif
86308
86309 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
86310 void __user *buffer, size_t *lenp, loff_t *ppos);
86311 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
86312
86313 #endif
86314
86315 +extern struct ctl_table grsecurity_table[];
86316 +
86317 static struct ctl_table kern_table[];
86318 static struct ctl_table vm_table[];
86319 static struct ctl_table fs_table[];
86320 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
86321 int sysctl_legacy_va_layout;
86322 #endif
86323
86324 +#ifdef CONFIG_PAX_SOFTMODE
86325 +static ctl_table pax_table[] = {
86326 + {
86327 + .procname = "softmode",
86328 + .data = &pax_softmode,
86329 + .maxlen = sizeof(unsigned int),
86330 + .mode = 0600,
86331 + .proc_handler = &proc_dointvec,
86332 + },
86333 +
86334 + { }
86335 +};
86336 +#endif
86337 +
86338 /* The default sysctl tables: */
86339
86340 static struct ctl_table sysctl_base_table[] = {
86341 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
86342 #endif
86343
86344 static struct ctl_table kern_table[] = {
86345 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
86346 + {
86347 + .procname = "grsecurity",
86348 + .mode = 0500,
86349 + .child = grsecurity_table,
86350 + },
86351 +#endif
86352 +
86353 +#ifdef CONFIG_PAX_SOFTMODE
86354 + {
86355 + .procname = "pax",
86356 + .mode = 0500,
86357 + .child = pax_table,
86358 + },
86359 +#endif
86360 +
86361 {
86362 .procname = "sched_child_runs_first",
86363 .data = &sysctl_sched_child_runs_first,
86364 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
86365 .data = &modprobe_path,
86366 .maxlen = KMOD_PATH_LEN,
86367 .mode = 0644,
86368 - .proc_handler = proc_dostring,
86369 + .proc_handler = proc_dostring_modpriv,
86370 },
86371 {
86372 .procname = "modules_disabled",
86373 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
86374 .extra1 = &zero,
86375 .extra2 = &one,
86376 },
86377 +#endif
86378 {
86379 .procname = "kptr_restrict",
86380 .data = &kptr_restrict,
86381 .maxlen = sizeof(int),
86382 .mode = 0644,
86383 .proc_handler = proc_dointvec_minmax_sysadmin,
86384 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86385 + .extra1 = &two,
86386 +#else
86387 .extra1 = &zero,
86388 +#endif
86389 .extra2 = &two,
86390 },
86391 -#endif
86392 {
86393 .procname = "ngroups_max",
86394 .data = &ngroups_max,
86395 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
86396 */
86397 {
86398 .procname = "perf_event_paranoid",
86399 - .data = &sysctl_perf_event_paranoid,
86400 - .maxlen = sizeof(sysctl_perf_event_paranoid),
86401 + .data = &sysctl_perf_event_legitimately_concerned,
86402 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
86403 .mode = 0644,
86404 - .proc_handler = proc_dointvec,
86405 + /* go ahead, be a hero */
86406 + .proc_handler = proc_dointvec_minmax_sysadmin,
86407 + .extra1 = &neg_one,
86408 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
86409 + .extra2 = &three,
86410 +#else
86411 + .extra2 = &two,
86412 +#endif
86413 },
86414 {
86415 .procname = "perf_event_mlock_kb",
86416 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
86417 .proc_handler = proc_dointvec_minmax,
86418 .extra1 = &zero,
86419 },
86420 + {
86421 + .procname = "heap_stack_gap",
86422 + .data = &sysctl_heap_stack_gap,
86423 + .maxlen = sizeof(sysctl_heap_stack_gap),
86424 + .mode = 0644,
86425 + .proc_handler = proc_doulongvec_minmax,
86426 + },
86427 #else
86428 {
86429 .procname = "nr_trim_pages",
86430 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
86431 buffer, lenp, ppos);
86432 }
86433
86434 +int proc_dostring_modpriv(struct ctl_table *table, int write,
86435 + void __user *buffer, size_t *lenp, loff_t *ppos)
86436 +{
86437 + if (write && !capable(CAP_SYS_MODULE))
86438 + return -EPERM;
86439 +
86440 + return _proc_do_string(table->data, table->maxlen, write,
86441 + buffer, lenp, ppos);
86442 +}
86443 +
86444 static size_t proc_skip_spaces(char **buf)
86445 {
86446 size_t ret;
86447 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
86448 len = strlen(tmp);
86449 if (len > *size)
86450 len = *size;
86451 + if (len > sizeof(tmp))
86452 + len = sizeof(tmp);
86453 if (copy_to_user(*buf, tmp, len))
86454 return -EFAULT;
86455 *size -= len;
86456 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
86457 static int proc_taint(struct ctl_table *table, int write,
86458 void __user *buffer, size_t *lenp, loff_t *ppos)
86459 {
86460 - struct ctl_table t;
86461 + ctl_table_no_const t;
86462 unsigned long tmptaint = get_taint();
86463 int err;
86464
86465 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
86466 return err;
86467 }
86468
86469 -#ifdef CONFIG_PRINTK
86470 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
86471 void __user *buffer, size_t *lenp, loff_t *ppos)
86472 {
86473 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
86474
86475 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
86476 }
86477 -#endif
86478
86479 struct do_proc_dointvec_minmax_conv_param {
86480 int *min;
86481 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
86482 *i = val;
86483 } else {
86484 val = convdiv * (*i) / convmul;
86485 - if (!first)
86486 + if (!first) {
86487 err = proc_put_char(&buffer, &left, '\t');
86488 + if (err)
86489 + break;
86490 + }
86491 err = proc_put_long(&buffer, &left, val, false);
86492 if (err)
86493 break;
86494 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
86495 return -ENOSYS;
86496 }
86497
86498 +int proc_dostring_modpriv(struct ctl_table *table, int write,
86499 + void __user *buffer, size_t *lenp, loff_t *ppos)
86500 +{
86501 + return -ENOSYS;
86502 +}
86503 +
86504 int proc_dointvec(struct ctl_table *table, int write,
86505 void __user *buffer, size_t *lenp, loff_t *ppos)
86506 {
86507 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
86508 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
86509 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
86510 EXPORT_SYMBOL(proc_dostring);
86511 +EXPORT_SYMBOL(proc_dostring_modpriv);
86512 EXPORT_SYMBOL(proc_doulongvec_minmax);
86513 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
86514 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
86515 index 145bb4d..b2aa969 100644
86516 --- a/kernel/taskstats.c
86517 +++ b/kernel/taskstats.c
86518 @@ -28,9 +28,12 @@
86519 #include <linux/fs.h>
86520 #include <linux/file.h>
86521 #include <linux/pid_namespace.h>
86522 +#include <linux/grsecurity.h>
86523 #include <net/genetlink.h>
86524 #include <linux/atomic.h>
86525
86526 +extern int gr_is_taskstats_denied(int pid);
86527 +
86528 /*
86529 * Maximum length of a cpumask that can be specified in
86530 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
86531 @@ -570,6 +573,9 @@ err:
86532
86533 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
86534 {
86535 + if (gr_is_taskstats_denied(current->pid))
86536 + return -EACCES;
86537 +
86538 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
86539 return cmd_attr_register_cpumask(info);
86540 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
86541 diff --git a/kernel/time.c b/kernel/time.c
86542 index 7c7964c..2a0d412 100644
86543 --- a/kernel/time.c
86544 +++ b/kernel/time.c
86545 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
86546 return error;
86547
86548 if (tz) {
86549 + /* we log in do_settimeofday called below, so don't log twice
86550 + */
86551 + if (!tv)
86552 + gr_log_timechange();
86553 +
86554 sys_tz = *tz;
86555 update_vsyscall_tz();
86556 if (firsttime) {
86557 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
86558 index 88c9c65..7497ebc 100644
86559 --- a/kernel/time/alarmtimer.c
86560 +++ b/kernel/time/alarmtimer.c
86561 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
86562 struct platform_device *pdev;
86563 int error = 0;
86564 int i;
86565 - struct k_clock alarm_clock = {
86566 + static struct k_clock alarm_clock = {
86567 .clock_getres = alarm_clock_getres,
86568 .clock_get = alarm_clock_get,
86569 .timer_create = alarm_timer_create,
86570 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
86571 index 5cf6c70..ac341b0 100644
86572 --- a/kernel/time/timekeeping.c
86573 +++ b/kernel/time/timekeeping.c
86574 @@ -15,6 +15,7 @@
86575 #include <linux/init.h>
86576 #include <linux/mm.h>
86577 #include <linux/sched.h>
86578 +#include <linux/grsecurity.h>
86579 #include <linux/syscore_ops.h>
86580 #include <linux/clocksource.h>
86581 #include <linux/jiffies.h>
86582 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
86583 if (!timespec_valid_strict(tv))
86584 return -EINVAL;
86585
86586 + gr_log_timechange();
86587 +
86588 raw_spin_lock_irqsave(&timekeeper_lock, flags);
86589 write_seqcount_begin(&timekeeper_seq);
86590
86591 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
86592 index 61ed862..3b52c65 100644
86593 --- a/kernel/time/timer_list.c
86594 +++ b/kernel/time/timer_list.c
86595 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
86596
86597 static void print_name_offset(struct seq_file *m, void *sym)
86598 {
86599 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86600 + SEQ_printf(m, "<%p>", NULL);
86601 +#else
86602 char symname[KSYM_NAME_LEN];
86603
86604 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
86605 SEQ_printf(m, "<%pK>", sym);
86606 else
86607 SEQ_printf(m, "%s", symname);
86608 +#endif
86609 }
86610
86611 static void
86612 @@ -119,7 +123,11 @@ next_one:
86613 static void
86614 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
86615 {
86616 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86617 + SEQ_printf(m, " .base: %p\n", NULL);
86618 +#else
86619 SEQ_printf(m, " .base: %pK\n", base);
86620 +#endif
86621 SEQ_printf(m, " .index: %d\n",
86622 base->index);
86623 SEQ_printf(m, " .resolution: %Lu nsecs\n",
86624 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
86625 {
86626 struct proc_dir_entry *pe;
86627
86628 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
86629 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
86630 +#else
86631 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
86632 +#endif
86633 if (!pe)
86634 return -ENOMEM;
86635 return 0;
86636 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
86637 index 0b537f2..40d6c20 100644
86638 --- a/kernel/time/timer_stats.c
86639 +++ b/kernel/time/timer_stats.c
86640 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
86641 static unsigned long nr_entries;
86642 static struct entry entries[MAX_ENTRIES];
86643
86644 -static atomic_t overflow_count;
86645 +static atomic_unchecked_t overflow_count;
86646
86647 /*
86648 * The entries are in a hash-table, for fast lookup:
86649 @@ -140,7 +140,7 @@ static void reset_entries(void)
86650 nr_entries = 0;
86651 memset(entries, 0, sizeof(entries));
86652 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
86653 - atomic_set(&overflow_count, 0);
86654 + atomic_set_unchecked(&overflow_count, 0);
86655 }
86656
86657 static struct entry *alloc_entry(void)
86658 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
86659 if (likely(entry))
86660 entry->count++;
86661 else
86662 - atomic_inc(&overflow_count);
86663 + atomic_inc_unchecked(&overflow_count);
86664
86665 out_unlock:
86666 raw_spin_unlock_irqrestore(lock, flags);
86667 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
86668
86669 static void print_name_offset(struct seq_file *m, unsigned long addr)
86670 {
86671 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86672 + seq_printf(m, "<%p>", NULL);
86673 +#else
86674 char symname[KSYM_NAME_LEN];
86675
86676 if (lookup_symbol_name(addr, symname) < 0)
86677 - seq_printf(m, "<%p>", (void *)addr);
86678 + seq_printf(m, "<%pK>", (void *)addr);
86679 else
86680 seq_printf(m, "%s", symname);
86681 +#endif
86682 }
86683
86684 static int tstats_show(struct seq_file *m, void *v)
86685 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
86686
86687 seq_puts(m, "Timer Stats Version: v0.2\n");
86688 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
86689 - if (atomic_read(&overflow_count))
86690 + if (atomic_read_unchecked(&overflow_count))
86691 seq_printf(m, "Overflow: %d entries\n",
86692 - atomic_read(&overflow_count));
86693 + atomic_read_unchecked(&overflow_count));
86694
86695 for (i = 0; i < nr_entries; i++) {
86696 entry = entries + i;
86697 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
86698 {
86699 struct proc_dir_entry *pe;
86700
86701 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
86702 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
86703 +#else
86704 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
86705 +#endif
86706 if (!pe)
86707 return -ENOMEM;
86708 return 0;
86709 diff --git a/kernel/timer.c b/kernel/timer.c
86710 index 4296d13..0164b04 100644
86711 --- a/kernel/timer.c
86712 +++ b/kernel/timer.c
86713 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
86714 /*
86715 * This function runs timers and the timer-tq in bottom half context.
86716 */
86717 -static void run_timer_softirq(struct softirq_action *h)
86718 +static __latent_entropy void run_timer_softirq(void)
86719 {
86720 struct tvec_base *base = __this_cpu_read(tvec_bases);
86721
86722 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
86723 *
86724 * In all cases the return value is guaranteed to be non-negative.
86725 */
86726 -signed long __sched schedule_timeout(signed long timeout)
86727 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
86728 {
86729 struct timer_list timer;
86730 unsigned long expire;
86731 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
86732 index b8b8560..75b1a09 100644
86733 --- a/kernel/trace/blktrace.c
86734 +++ b/kernel/trace/blktrace.c
86735 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
86736 struct blk_trace *bt = filp->private_data;
86737 char buf[16];
86738
86739 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
86740 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
86741
86742 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
86743 }
86744 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
86745 return 1;
86746
86747 bt = buf->chan->private_data;
86748 - atomic_inc(&bt->dropped);
86749 + atomic_inc_unchecked(&bt->dropped);
86750 return 0;
86751 }
86752
86753 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
86754
86755 bt->dir = dir;
86756 bt->dev = dev;
86757 - atomic_set(&bt->dropped, 0);
86758 + atomic_set_unchecked(&bt->dropped, 0);
86759
86760 ret = -EIO;
86761 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
86762 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
86763 index 1345d9f..db46efe 100644
86764 --- a/kernel/trace/ftrace.c
86765 +++ b/kernel/trace/ftrace.c
86766 @@ -1944,12 +1944,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
86767 if (unlikely(ftrace_disabled))
86768 return 0;
86769
86770 + ret = ftrace_arch_code_modify_prepare();
86771 + FTRACE_WARN_ON(ret);
86772 + if (ret)
86773 + return 0;
86774 +
86775 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
86776 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
86777 if (ret) {
86778 ftrace_bug(ret, ip);
86779 - return 0;
86780 }
86781 - return 1;
86782 + return ret ? 0 : 1;
86783 }
86784
86785 /*
86786 @@ -4043,8 +4048,10 @@ static int ftrace_process_locs(struct module *mod,
86787 if (!count)
86788 return 0;
86789
86790 + pax_open_kernel();
86791 sort(start, count, sizeof(*start),
86792 ftrace_cmp_ips, ftrace_swap_ips);
86793 + pax_close_kernel();
86794
86795 start_pg = ftrace_allocate_pages(count);
86796 if (!start_pg)
86797 @@ -4766,8 +4773,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
86798 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
86799
86800 static int ftrace_graph_active;
86801 -static struct notifier_block ftrace_suspend_notifier;
86802 -
86803 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
86804 {
86805 return 0;
86806 @@ -4918,6 +4923,10 @@ static struct ftrace_ops fgraph_ops __read_mostly = {
86807 FTRACE_OPS_FL_RECURSION_SAFE,
86808 };
86809
86810 +static struct notifier_block ftrace_suspend_notifier = {
86811 + .notifier_call = ftrace_suspend_notifier_call
86812 +};
86813 +
86814 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
86815 trace_func_graph_ent_t entryfunc)
86816 {
86817 @@ -4931,7 +4940,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
86818 goto out;
86819 }
86820
86821 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
86822 register_pm_notifier(&ftrace_suspend_notifier);
86823
86824 ftrace_graph_active++;
86825 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
86826 index cc2f66f..05edd54 100644
86827 --- a/kernel/trace/ring_buffer.c
86828 +++ b/kernel/trace/ring_buffer.c
86829 @@ -352,9 +352,9 @@ struct buffer_data_page {
86830 */
86831 struct buffer_page {
86832 struct list_head list; /* list of buffer pages */
86833 - local_t write; /* index for next write */
86834 + local_unchecked_t write; /* index for next write */
86835 unsigned read; /* index for next read */
86836 - local_t entries; /* entries on this page */
86837 + local_unchecked_t entries; /* entries on this page */
86838 unsigned long real_end; /* real end of data */
86839 struct buffer_data_page *page; /* Actual data page */
86840 };
86841 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
86842 unsigned long last_overrun;
86843 local_t entries_bytes;
86844 local_t entries;
86845 - local_t overrun;
86846 - local_t commit_overrun;
86847 + local_unchecked_t overrun;
86848 + local_unchecked_t commit_overrun;
86849 local_t dropped_events;
86850 local_t committing;
86851 local_t commits;
86852 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
86853 *
86854 * We add a counter to the write field to denote this.
86855 */
86856 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
86857 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
86858 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
86859 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
86860
86861 /*
86862 * Just make sure we have seen our old_write and synchronize
86863 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
86864 * cmpxchg to only update if an interrupt did not already
86865 * do it for us. If the cmpxchg fails, we don't care.
86866 */
86867 - (void)local_cmpxchg(&next_page->write, old_write, val);
86868 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
86869 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
86870 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
86871
86872 /*
86873 * No need to worry about races with clearing out the commit.
86874 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
86875
86876 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
86877 {
86878 - return local_read(&bpage->entries) & RB_WRITE_MASK;
86879 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
86880 }
86881
86882 static inline unsigned long rb_page_write(struct buffer_page *bpage)
86883 {
86884 - return local_read(&bpage->write) & RB_WRITE_MASK;
86885 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
86886 }
86887
86888 static int
86889 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
86890 * bytes consumed in ring buffer from here.
86891 * Increment overrun to account for the lost events.
86892 */
86893 - local_add(page_entries, &cpu_buffer->overrun);
86894 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
86895 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
86896 }
86897
86898 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
86899 * it is our responsibility to update
86900 * the counters.
86901 */
86902 - local_add(entries, &cpu_buffer->overrun);
86903 + local_add_unchecked(entries, &cpu_buffer->overrun);
86904 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
86905
86906 /*
86907 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86908 if (tail == BUF_PAGE_SIZE)
86909 tail_page->real_end = 0;
86910
86911 - local_sub(length, &tail_page->write);
86912 + local_sub_unchecked(length, &tail_page->write);
86913 return;
86914 }
86915
86916 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86917 rb_event_set_padding(event);
86918
86919 /* Set the write back to the previous setting */
86920 - local_sub(length, &tail_page->write);
86921 + local_sub_unchecked(length, &tail_page->write);
86922 return;
86923 }
86924
86925 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86926
86927 /* Set write to end of buffer */
86928 length = (tail + length) - BUF_PAGE_SIZE;
86929 - local_sub(length, &tail_page->write);
86930 + local_sub_unchecked(length, &tail_page->write);
86931 }
86932
86933 /*
86934 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
86935 * about it.
86936 */
86937 if (unlikely(next_page == commit_page)) {
86938 - local_inc(&cpu_buffer->commit_overrun);
86939 + local_inc_unchecked(&cpu_buffer->commit_overrun);
86940 goto out_reset;
86941 }
86942
86943 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
86944 cpu_buffer->tail_page) &&
86945 (cpu_buffer->commit_page ==
86946 cpu_buffer->reader_page))) {
86947 - local_inc(&cpu_buffer->commit_overrun);
86948 + local_inc_unchecked(&cpu_buffer->commit_overrun);
86949 goto out_reset;
86950 }
86951 }
86952 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
86953 length += RB_LEN_TIME_EXTEND;
86954
86955 tail_page = cpu_buffer->tail_page;
86956 - write = local_add_return(length, &tail_page->write);
86957 + write = local_add_return_unchecked(length, &tail_page->write);
86958
86959 /* set write to only the index of the write */
86960 write &= RB_WRITE_MASK;
86961 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
86962 kmemcheck_annotate_bitfield(event, bitfield);
86963 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
86964
86965 - local_inc(&tail_page->entries);
86966 + local_inc_unchecked(&tail_page->entries);
86967
86968 /*
86969 * If this is the first commit on the page, then update
86970 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
86971
86972 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
86973 unsigned long write_mask =
86974 - local_read(&bpage->write) & ~RB_WRITE_MASK;
86975 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
86976 unsigned long event_length = rb_event_length(event);
86977 /*
86978 * This is on the tail page. It is possible that
86979 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
86980 */
86981 old_index += write_mask;
86982 new_index += write_mask;
86983 - index = local_cmpxchg(&bpage->write, old_index, new_index);
86984 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
86985 if (index == old_index) {
86986 /* update counters */
86987 local_sub(event_length, &cpu_buffer->entries_bytes);
86988 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
86989
86990 /* Do the likely case first */
86991 if (likely(bpage->page == (void *)addr)) {
86992 - local_dec(&bpage->entries);
86993 + local_dec_unchecked(&bpage->entries);
86994 return;
86995 }
86996
86997 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
86998 start = bpage;
86999 do {
87000 if (bpage->page == (void *)addr) {
87001 - local_dec(&bpage->entries);
87002 + local_dec_unchecked(&bpage->entries);
87003 return;
87004 }
87005 rb_inc_page(cpu_buffer, &bpage);
87006 @@ -3139,7 +3139,7 @@ static inline unsigned long
87007 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
87008 {
87009 return local_read(&cpu_buffer->entries) -
87010 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
87011 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
87012 }
87013
87014 /**
87015 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
87016 return 0;
87017
87018 cpu_buffer = buffer->buffers[cpu];
87019 - ret = local_read(&cpu_buffer->overrun);
87020 + ret = local_read_unchecked(&cpu_buffer->overrun);
87021
87022 return ret;
87023 }
87024 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
87025 return 0;
87026
87027 cpu_buffer = buffer->buffers[cpu];
87028 - ret = local_read(&cpu_buffer->commit_overrun);
87029 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
87030
87031 return ret;
87032 }
87033 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
87034 /* if you care about this being correct, lock the buffer */
87035 for_each_buffer_cpu(buffer, cpu) {
87036 cpu_buffer = buffer->buffers[cpu];
87037 - overruns += local_read(&cpu_buffer->overrun);
87038 + overruns += local_read_unchecked(&cpu_buffer->overrun);
87039 }
87040
87041 return overruns;
87042 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
87043 /*
87044 * Reset the reader page to size zero.
87045 */
87046 - local_set(&cpu_buffer->reader_page->write, 0);
87047 - local_set(&cpu_buffer->reader_page->entries, 0);
87048 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
87049 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
87050 local_set(&cpu_buffer->reader_page->page->commit, 0);
87051 cpu_buffer->reader_page->real_end = 0;
87052
87053 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
87054 * want to compare with the last_overrun.
87055 */
87056 smp_mb();
87057 - overwrite = local_read(&(cpu_buffer->overrun));
87058 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
87059
87060 /*
87061 * Here's the tricky part.
87062 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
87063
87064 cpu_buffer->head_page
87065 = list_entry(cpu_buffer->pages, struct buffer_page, list);
87066 - local_set(&cpu_buffer->head_page->write, 0);
87067 - local_set(&cpu_buffer->head_page->entries, 0);
87068 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
87069 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
87070 local_set(&cpu_buffer->head_page->page->commit, 0);
87071
87072 cpu_buffer->head_page->read = 0;
87073 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
87074
87075 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
87076 INIT_LIST_HEAD(&cpu_buffer->new_pages);
87077 - local_set(&cpu_buffer->reader_page->write, 0);
87078 - local_set(&cpu_buffer->reader_page->entries, 0);
87079 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
87080 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
87081 local_set(&cpu_buffer->reader_page->page->commit, 0);
87082 cpu_buffer->reader_page->read = 0;
87083
87084 local_set(&cpu_buffer->entries_bytes, 0);
87085 - local_set(&cpu_buffer->overrun, 0);
87086 - local_set(&cpu_buffer->commit_overrun, 0);
87087 + local_set_unchecked(&cpu_buffer->overrun, 0);
87088 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
87089 local_set(&cpu_buffer->dropped_events, 0);
87090 local_set(&cpu_buffer->entries, 0);
87091 local_set(&cpu_buffer->committing, 0);
87092 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
87093 rb_init_page(bpage);
87094 bpage = reader->page;
87095 reader->page = *data_page;
87096 - local_set(&reader->write, 0);
87097 - local_set(&reader->entries, 0);
87098 + local_set_unchecked(&reader->write, 0);
87099 + local_set_unchecked(&reader->entries, 0);
87100 reader->read = 0;
87101 *data_page = bpage;
87102
87103 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
87104 index b778e96..4e84621 100644
87105 --- a/kernel/trace/trace.c
87106 +++ b/kernel/trace/trace.c
87107 @@ -3335,7 +3335,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
87108 return 0;
87109 }
87110
87111 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
87112 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
87113 {
87114 /* do nothing if flag is already set */
87115 if (!!(trace_flags & mask) == !!enabled)
87116 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
87117 index 10c86fb..645ab0a 100644
87118 --- a/kernel/trace/trace.h
87119 +++ b/kernel/trace/trace.h
87120 @@ -1029,7 +1029,7 @@ extern const char *__stop___tracepoint_str[];
87121 void trace_printk_init_buffers(void);
87122 void trace_printk_start_comm(void);
87123 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
87124 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
87125 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
87126
87127 /*
87128 * Normal trace_printk() and friends allocates special buffers
87129 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
87130 index 26dc348..8708ca7 100644
87131 --- a/kernel/trace/trace_clock.c
87132 +++ b/kernel/trace/trace_clock.c
87133 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
87134 return now;
87135 }
87136
87137 -static atomic64_t trace_counter;
87138 +static atomic64_unchecked_t trace_counter;
87139
87140 /*
87141 * trace_clock_counter(): simply an atomic counter.
87142 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
87143 */
87144 u64 notrace trace_clock_counter(void)
87145 {
87146 - return atomic64_add_return(1, &trace_counter);
87147 + return atomic64_inc_return_unchecked(&trace_counter);
87148 }
87149 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
87150 index 368a4d5..7b6d1d5 100644
87151 --- a/kernel/trace/trace_events.c
87152 +++ b/kernel/trace/trace_events.c
87153 @@ -1673,7 +1673,6 @@ __trace_early_add_new_event(struct ftrace_event_call *call,
87154 return 0;
87155 }
87156
87157 -struct ftrace_module_file_ops;
87158 static void __add_event_to_tracers(struct ftrace_event_call *call);
87159
87160 /* Add an additional event_call dynamically */
87161 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
87162 index b3dcfb2..ebee344 100644
87163 --- a/kernel/trace/trace_mmiotrace.c
87164 +++ b/kernel/trace/trace_mmiotrace.c
87165 @@ -24,7 +24,7 @@ struct header_iter {
87166 static struct trace_array *mmio_trace_array;
87167 static bool overrun_detected;
87168 static unsigned long prev_overruns;
87169 -static atomic_t dropped_count;
87170 +static atomic_unchecked_t dropped_count;
87171
87172 static void mmio_reset_data(struct trace_array *tr)
87173 {
87174 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
87175
87176 static unsigned long count_overruns(struct trace_iterator *iter)
87177 {
87178 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
87179 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
87180 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
87181
87182 if (over > prev_overruns)
87183 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
87184 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
87185 sizeof(*entry), 0, pc);
87186 if (!event) {
87187 - atomic_inc(&dropped_count);
87188 + atomic_inc_unchecked(&dropped_count);
87189 return;
87190 }
87191 entry = ring_buffer_event_data(event);
87192 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
87193 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
87194 sizeof(*entry), 0, pc);
87195 if (!event) {
87196 - atomic_inc(&dropped_count);
87197 + atomic_inc_unchecked(&dropped_count);
87198 return;
87199 }
87200 entry = ring_buffer_event_data(event);
87201 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
87202 index 34e7cba..6f9a729 100644
87203 --- a/kernel/trace/trace_output.c
87204 +++ b/kernel/trace/trace_output.c
87205 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
87206
87207 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
87208 if (!IS_ERR(p)) {
87209 - p = mangle_path(s->buffer + s->len, p, "\n");
87210 + p = mangle_path(s->buffer + s->len, p, "\n\\");
87211 if (p) {
87212 s->len = p - s->buffer;
87213 return 1;
87214 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
87215 goto out;
87216 }
87217
87218 + pax_open_kernel();
87219 if (event->funcs->trace == NULL)
87220 - event->funcs->trace = trace_nop_print;
87221 + *(void **)&event->funcs->trace = trace_nop_print;
87222 if (event->funcs->raw == NULL)
87223 - event->funcs->raw = trace_nop_print;
87224 + *(void **)&event->funcs->raw = trace_nop_print;
87225 if (event->funcs->hex == NULL)
87226 - event->funcs->hex = trace_nop_print;
87227 + *(void **)&event->funcs->hex = trace_nop_print;
87228 if (event->funcs->binary == NULL)
87229 - event->funcs->binary = trace_nop_print;
87230 + *(void **)&event->funcs->binary = trace_nop_print;
87231 + pax_close_kernel();
87232
87233 key = event->type & (EVENT_HASHSIZE - 1);
87234
87235 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
87236 index b20428c..4845a10 100644
87237 --- a/kernel/trace/trace_stack.c
87238 +++ b/kernel/trace/trace_stack.c
87239 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
87240 return;
87241
87242 /* we do not handle interrupt stacks yet */
87243 - if (!object_is_on_stack(stack))
87244 + if (!object_starts_on_stack(stack))
87245 return;
87246
87247 local_irq_save(flags);
87248 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
87249 index 13fb113..a6ced3f 100644
87250 --- a/kernel/user_namespace.c
87251 +++ b/kernel/user_namespace.c
87252 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
87253 !kgid_has_mapping(parent_ns, group))
87254 return -EPERM;
87255
87256 +#ifdef CONFIG_GRKERNSEC
87257 + /*
87258 + * This doesn't really inspire confidence:
87259 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
87260 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
87261 + * Increases kernel attack surface in areas developers
87262 + * previously cared little about ("low importance due
87263 + * to requiring "root" capability")
87264 + * To be removed when this code receives *proper* review
87265 + */
87266 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
87267 + !capable(CAP_SETGID))
87268 + return -EPERM;
87269 +#endif
87270 +
87271 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
87272 if (!ns)
87273 return -ENOMEM;
87274 @@ -860,7 +875,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
87275 if (atomic_read(&current->mm->mm_users) > 1)
87276 return -EINVAL;
87277
87278 - if (current->fs->users != 1)
87279 + if (atomic_read(&current->fs->users) != 1)
87280 return -EINVAL;
87281
87282 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
87283 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
87284 index 4f69f9a..7c6f8f8 100644
87285 --- a/kernel/utsname_sysctl.c
87286 +++ b/kernel/utsname_sysctl.c
87287 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
87288 static int proc_do_uts_string(ctl_table *table, int write,
87289 void __user *buffer, size_t *lenp, loff_t *ppos)
87290 {
87291 - struct ctl_table uts_table;
87292 + ctl_table_no_const uts_table;
87293 int r;
87294 memcpy(&uts_table, table, sizeof(uts_table));
87295 uts_table.data = get_uts(table, write);
87296 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
87297 index 4431610..4265616 100644
87298 --- a/kernel/watchdog.c
87299 +++ b/kernel/watchdog.c
87300 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
87301 static void watchdog_nmi_disable(unsigned int cpu) { return; }
87302 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
87303
87304 -static struct smp_hotplug_thread watchdog_threads = {
87305 +static struct smp_hotplug_thread watchdog_threads __read_only = {
87306 .store = &softlockup_watchdog,
87307 .thread_should_run = watchdog_should_run,
87308 .thread_fn = watchdog,
87309 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
87310 index 93c2652..66a1cfd 100644
87311 --- a/kernel/workqueue.c
87312 +++ b/kernel/workqueue.c
87313 @@ -4668,7 +4668,7 @@ static void rebind_workers(struct worker_pool *pool)
87314 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
87315 worker_flags |= WORKER_REBOUND;
87316 worker_flags &= ~WORKER_UNBOUND;
87317 - ACCESS_ONCE(worker->flags) = worker_flags;
87318 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
87319 }
87320
87321 spin_unlock_irq(&pool->lock);
87322 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
87323 index 094f315..244a824 100644
87324 --- a/lib/Kconfig.debug
87325 +++ b/lib/Kconfig.debug
87326 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
87327
87328 config DEBUG_WW_MUTEX_SLOWPATH
87329 bool "Wait/wound mutex debugging: Slowpath testing"
87330 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
87331 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
87332 select DEBUG_LOCK_ALLOC
87333 select DEBUG_SPINLOCK
87334 select DEBUG_MUTEXES
87335 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
87336
87337 config DEBUG_LOCK_ALLOC
87338 bool "Lock debugging: detect incorrect freeing of live locks"
87339 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
87340 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
87341 select DEBUG_SPINLOCK
87342 select DEBUG_MUTEXES
87343 select LOCKDEP
87344 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
87345
87346 config PROVE_LOCKING
87347 bool "Lock debugging: prove locking correctness"
87348 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
87349 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
87350 select LOCKDEP
87351 select DEBUG_SPINLOCK
87352 select DEBUG_MUTEXES
87353 @@ -914,7 +914,7 @@ config LOCKDEP
87354
87355 config LOCK_STAT
87356 bool "Lock usage statistics"
87357 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
87358 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
87359 select LOCKDEP
87360 select DEBUG_SPINLOCK
87361 select DEBUG_MUTEXES
87362 @@ -1376,6 +1376,7 @@ config LATENCYTOP
87363 depends on DEBUG_KERNEL
87364 depends on STACKTRACE_SUPPORT
87365 depends on PROC_FS
87366 + depends on !GRKERNSEC_HIDESYM
87367 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC
87368 select KALLSYMS
87369 select KALLSYMS_ALL
87370 @@ -1392,7 +1393,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
87371 config DEBUG_STRICT_USER_COPY_CHECKS
87372 bool "Strict user copy size checks"
87373 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
87374 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
87375 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
87376 help
87377 Enabling this option turns a certain set of sanity checks for user
87378 copy operations into compile time failures.
87379 @@ -1502,7 +1503,7 @@ endmenu # runtime tests
87380
87381 config PROVIDE_OHCI1394_DMA_INIT
87382 bool "Remote debugging over FireWire early on boot"
87383 - depends on PCI && X86
87384 + depends on PCI && X86 && !GRKERNSEC
87385 help
87386 If you want to debug problems which hang or crash the kernel early
87387 on boot and the crashing machine has a FireWire port, you can use
87388 @@ -1531,7 +1532,7 @@ config PROVIDE_OHCI1394_DMA_INIT
87389
87390 config FIREWIRE_OHCI_REMOTE_DMA
87391 bool "Remote debugging over FireWire with firewire-ohci"
87392 - depends on FIREWIRE_OHCI
87393 + depends on FIREWIRE_OHCI && !GRKERNSEC
87394 help
87395 This option lets you use the FireWire bus for remote debugging
87396 with help of the firewire-ohci driver. It enables unfiltered
87397 diff --git a/lib/Makefile b/lib/Makefile
87398 index f3bb2cb..b358ace 100644
87399 --- a/lib/Makefile
87400 +++ b/lib/Makefile
87401 @@ -52,7 +52,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
87402
87403 obj-$(CONFIG_BTREE) += btree.o
87404 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
87405 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
87406 +obj-y += list_debug.o
87407 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
87408
87409 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
87410 diff --git a/lib/bitmap.c b/lib/bitmap.c
87411 index 06f7e4f..f3cf2b0 100644
87412 --- a/lib/bitmap.c
87413 +++ b/lib/bitmap.c
87414 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
87415 {
87416 int c, old_c, totaldigits, ndigits, nchunks, nbits;
87417 u32 chunk;
87418 - const char __user __force *ubuf = (const char __user __force *)buf;
87419 + const char __user *ubuf = (const char __force_user *)buf;
87420
87421 bitmap_zero(maskp, nmaskbits);
87422
87423 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
87424 {
87425 if (!access_ok(VERIFY_READ, ubuf, ulen))
87426 return -EFAULT;
87427 - return __bitmap_parse((const char __force *)ubuf,
87428 + return __bitmap_parse((const char __force_kernel *)ubuf,
87429 ulen, 1, maskp, nmaskbits);
87430
87431 }
87432 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
87433 {
87434 unsigned a, b;
87435 int c, old_c, totaldigits;
87436 - const char __user __force *ubuf = (const char __user __force *)buf;
87437 + const char __user *ubuf = (const char __force_user *)buf;
87438 int exp_digit, in_range;
87439
87440 totaldigits = c = 0;
87441 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
87442 {
87443 if (!access_ok(VERIFY_READ, ubuf, ulen))
87444 return -EFAULT;
87445 - return __bitmap_parselist((const char __force *)ubuf,
87446 + return __bitmap_parselist((const char __force_kernel *)ubuf,
87447 ulen, 1, maskp, nmaskbits);
87448 }
87449 EXPORT_SYMBOL(bitmap_parselist_user);
87450 diff --git a/lib/bug.c b/lib/bug.c
87451 index 1686034..a9c00c8 100644
87452 --- a/lib/bug.c
87453 +++ b/lib/bug.c
87454 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
87455 return BUG_TRAP_TYPE_NONE;
87456
87457 bug = find_bug(bugaddr);
87458 + if (!bug)
87459 + return BUG_TRAP_TYPE_NONE;
87460
87461 file = NULL;
87462 line = 0;
87463 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
87464 index bf2c8b1..1d00ccf 100644
87465 --- a/lib/debugobjects.c
87466 +++ b/lib/debugobjects.c
87467 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
87468 if (limit > 4)
87469 return;
87470
87471 - is_on_stack = object_is_on_stack(addr);
87472 + is_on_stack = object_starts_on_stack(addr);
87473 if (is_on_stack == onstack)
87474 return;
87475
87476 diff --git a/lib/devres.c b/lib/devres.c
87477 index 8235331..5881053 100644
87478 --- a/lib/devres.c
87479 +++ b/lib/devres.c
87480 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
87481 void devm_iounmap(struct device *dev, void __iomem *addr)
87482 {
87483 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
87484 - (void *)addr));
87485 + (void __force *)addr));
87486 iounmap(addr);
87487 }
87488 EXPORT_SYMBOL(devm_iounmap);
87489 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
87490 {
87491 ioport_unmap(addr);
87492 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
87493 - devm_ioport_map_match, (void *)addr));
87494 + devm_ioport_map_match, (void __force *)addr));
87495 }
87496 EXPORT_SYMBOL(devm_ioport_unmap);
87497 #endif /* CONFIG_HAS_IOPORT */
87498 diff --git a/lib/div64.c b/lib/div64.c
87499 index 4382ad7..08aa558 100644
87500 --- a/lib/div64.c
87501 +++ b/lib/div64.c
87502 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
87503 EXPORT_SYMBOL(__div64_32);
87504
87505 #ifndef div_s64_rem
87506 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
87507 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
87508 {
87509 u64 quotient;
87510
87511 @@ -130,7 +130,7 @@ EXPORT_SYMBOL(div64_u64_rem);
87512 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
87513 */
87514 #ifndef div64_u64
87515 -u64 div64_u64(u64 dividend, u64 divisor)
87516 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
87517 {
87518 u32 high = divisor >> 32;
87519 u64 quot;
87520 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
87521 index d87a17a..ac0d79a 100644
87522 --- a/lib/dma-debug.c
87523 +++ b/lib/dma-debug.c
87524 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
87525
87526 void dma_debug_add_bus(struct bus_type *bus)
87527 {
87528 - struct notifier_block *nb;
87529 + notifier_block_no_const *nb;
87530
87531 if (global_disable)
87532 return;
87533 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
87534
87535 static void check_for_stack(struct device *dev, void *addr)
87536 {
87537 - if (object_is_on_stack(addr))
87538 + if (object_starts_on_stack(addr))
87539 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
87540 "stack [addr=%p]\n", addr);
87541 }
87542 diff --git a/lib/inflate.c b/lib/inflate.c
87543 index 013a761..c28f3fc 100644
87544 --- a/lib/inflate.c
87545 +++ b/lib/inflate.c
87546 @@ -269,7 +269,7 @@ static void free(void *where)
87547 malloc_ptr = free_mem_ptr;
87548 }
87549 #else
87550 -#define malloc(a) kmalloc(a, GFP_KERNEL)
87551 +#define malloc(a) kmalloc((a), GFP_KERNEL)
87552 #define free(a) kfree(a)
87553 #endif
87554
87555 diff --git a/lib/ioremap.c b/lib/ioremap.c
87556 index 0c9216c..863bd89 100644
87557 --- a/lib/ioremap.c
87558 +++ b/lib/ioremap.c
87559 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
87560 unsigned long next;
87561
87562 phys_addr -= addr;
87563 - pmd = pmd_alloc(&init_mm, pud, addr);
87564 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
87565 if (!pmd)
87566 return -ENOMEM;
87567 do {
87568 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
87569 unsigned long next;
87570
87571 phys_addr -= addr;
87572 - pud = pud_alloc(&init_mm, pgd, addr);
87573 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
87574 if (!pud)
87575 return -ENOMEM;
87576 do {
87577 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
87578 index bd2bea9..6b3c95e 100644
87579 --- a/lib/is_single_threaded.c
87580 +++ b/lib/is_single_threaded.c
87581 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
87582 struct task_struct *p, *t;
87583 bool ret;
87584
87585 + if (!mm)
87586 + return true;
87587 +
87588 if (atomic_read(&task->signal->live) != 1)
87589 return false;
87590
87591 diff --git a/lib/kobject.c b/lib/kobject.c
87592 index 084f7b1..d265b8a 100644
87593 --- a/lib/kobject.c
87594 +++ b/lib/kobject.c
87595 @@ -875,9 +875,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
87596
87597
87598 static DEFINE_SPINLOCK(kobj_ns_type_lock);
87599 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
87600 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
87601
87602 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
87603 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
87604 {
87605 enum kobj_ns_type type = ops->type;
87606 int error;
87607 diff --git a/lib/list_debug.c b/lib/list_debug.c
87608 index c24c2f7..f0296f4 100644
87609 --- a/lib/list_debug.c
87610 +++ b/lib/list_debug.c
87611 @@ -11,7 +11,9 @@
87612 #include <linux/bug.h>
87613 #include <linux/kernel.h>
87614 #include <linux/rculist.h>
87615 +#include <linux/mm.h>
87616
87617 +#ifdef CONFIG_DEBUG_LIST
87618 /*
87619 * Insert a new entry between two known consecutive entries.
87620 *
87621 @@ -19,21 +21,40 @@
87622 * the prev/next entries already!
87623 */
87624
87625 +static bool __list_add_debug(struct list_head *new,
87626 + struct list_head *prev,
87627 + struct list_head *next)
87628 +{
87629 + if (unlikely(next->prev != prev)) {
87630 + printk(KERN_ERR "list_add corruption. next->prev should be "
87631 + "prev (%p), but was %p. (next=%p).\n",
87632 + prev, next->prev, next);
87633 + BUG();
87634 + return false;
87635 + }
87636 + if (unlikely(prev->next != next)) {
87637 + printk(KERN_ERR "list_add corruption. prev->next should be "
87638 + "next (%p), but was %p. (prev=%p).\n",
87639 + next, prev->next, prev);
87640 + BUG();
87641 + return false;
87642 + }
87643 + if (unlikely(new == prev || new == next)) {
87644 + printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
87645 + new, prev, next);
87646 + BUG();
87647 + return false;
87648 + }
87649 + return true;
87650 +}
87651 +
87652 void __list_add(struct list_head *new,
87653 - struct list_head *prev,
87654 - struct list_head *next)
87655 + struct list_head *prev,
87656 + struct list_head *next)
87657 {
87658 - WARN(next->prev != prev,
87659 - "list_add corruption. next->prev should be "
87660 - "prev (%p), but was %p. (next=%p).\n",
87661 - prev, next->prev, next);
87662 - WARN(prev->next != next,
87663 - "list_add corruption. prev->next should be "
87664 - "next (%p), but was %p. (prev=%p).\n",
87665 - next, prev->next, prev);
87666 - WARN(new == prev || new == next,
87667 - "list_add double add: new=%p, prev=%p, next=%p.\n",
87668 - new, prev, next);
87669 + if (!__list_add_debug(new, prev, next))
87670 + return;
87671 +
87672 next->prev = new;
87673 new->next = next;
87674 new->prev = prev;
87675 @@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
87676 }
87677 EXPORT_SYMBOL(__list_add);
87678
87679 -void __list_del_entry(struct list_head *entry)
87680 +static bool __list_del_entry_debug(struct list_head *entry)
87681 {
87682 struct list_head *prev, *next;
87683
87684 prev = entry->prev;
87685 next = entry->next;
87686
87687 - if (WARN(next == LIST_POISON1,
87688 - "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
87689 - entry, LIST_POISON1) ||
87690 - WARN(prev == LIST_POISON2,
87691 - "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
87692 - entry, LIST_POISON2) ||
87693 - WARN(prev->next != entry,
87694 - "list_del corruption. prev->next should be %p, "
87695 - "but was %p\n", entry, prev->next) ||
87696 - WARN(next->prev != entry,
87697 - "list_del corruption. next->prev should be %p, "
87698 - "but was %p\n", entry, next->prev))
87699 + if (unlikely(next == LIST_POISON1)) {
87700 + printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
87701 + entry, LIST_POISON1);
87702 + BUG();
87703 + return false;
87704 + }
87705 + if (unlikely(prev == LIST_POISON2)) {
87706 + printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
87707 + entry, LIST_POISON2);
87708 + BUG();
87709 + return false;
87710 + }
87711 + if (unlikely(entry->prev->next != entry)) {
87712 + printk(KERN_ERR "list_del corruption. prev->next should be %p, "
87713 + "but was %p\n", entry, prev->next);
87714 + BUG();
87715 + return false;
87716 + }
87717 + if (unlikely(entry->next->prev != entry)) {
87718 + printk(KERN_ERR "list_del corruption. next->prev should be %p, "
87719 + "but was %p\n", entry, next->prev);
87720 + BUG();
87721 + return false;
87722 + }
87723 + return true;
87724 +}
87725 +
87726 +void __list_del_entry(struct list_head *entry)
87727 +{
87728 + if (!__list_del_entry_debug(entry))
87729 return;
87730
87731 - __list_del(prev, next);
87732 + __list_del(entry->prev, entry->next);
87733 }
87734 EXPORT_SYMBOL(__list_del_entry);
87735
87736 @@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
87737 void __list_add_rcu(struct list_head *new,
87738 struct list_head *prev, struct list_head *next)
87739 {
87740 - WARN(next->prev != prev,
87741 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
87742 - prev, next->prev, next);
87743 - WARN(prev->next != next,
87744 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
87745 - next, prev->next, prev);
87746 + if (!__list_add_debug(new, prev, next))
87747 + return;
87748 +
87749 new->next = next;
87750 new->prev = prev;
87751 rcu_assign_pointer(list_next_rcu(prev), new);
87752 next->prev = new;
87753 }
87754 EXPORT_SYMBOL(__list_add_rcu);
87755 +#endif
87756 +
87757 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
87758 +{
87759 +#ifdef CONFIG_DEBUG_LIST
87760 + if (!__list_add_debug(new, prev, next))
87761 + return;
87762 +#endif
87763 +
87764 + pax_open_kernel();
87765 + next->prev = new;
87766 + new->next = next;
87767 + new->prev = prev;
87768 + prev->next = new;
87769 + pax_close_kernel();
87770 +}
87771 +EXPORT_SYMBOL(__pax_list_add);
87772 +
87773 +void pax_list_del(struct list_head *entry)
87774 +{
87775 +#ifdef CONFIG_DEBUG_LIST
87776 + if (!__list_del_entry_debug(entry))
87777 + return;
87778 +#endif
87779 +
87780 + pax_open_kernel();
87781 + __list_del(entry->prev, entry->next);
87782 + entry->next = LIST_POISON1;
87783 + entry->prev = LIST_POISON2;
87784 + pax_close_kernel();
87785 +}
87786 +EXPORT_SYMBOL(pax_list_del);
87787 +
87788 +void pax_list_del_init(struct list_head *entry)
87789 +{
87790 + pax_open_kernel();
87791 + __list_del(entry->prev, entry->next);
87792 + INIT_LIST_HEAD(entry);
87793 + pax_close_kernel();
87794 +}
87795 +EXPORT_SYMBOL(pax_list_del_init);
87796 +
87797 +void __pax_list_add_rcu(struct list_head *new,
87798 + struct list_head *prev, struct list_head *next)
87799 +{
87800 +#ifdef CONFIG_DEBUG_LIST
87801 + if (!__list_add_debug(new, prev, next))
87802 + return;
87803 +#endif
87804 +
87805 + pax_open_kernel();
87806 + new->next = next;
87807 + new->prev = prev;
87808 + rcu_assign_pointer(list_next_rcu(prev), new);
87809 + next->prev = new;
87810 + pax_close_kernel();
87811 +}
87812 +EXPORT_SYMBOL(__pax_list_add_rcu);
87813 +
87814 +void pax_list_del_rcu(struct list_head *entry)
87815 +{
87816 +#ifdef CONFIG_DEBUG_LIST
87817 + if (!__list_del_entry_debug(entry))
87818 + return;
87819 +#endif
87820 +
87821 + pax_open_kernel();
87822 + __list_del(entry->prev, entry->next);
87823 + entry->next = LIST_POISON1;
87824 + entry->prev = LIST_POISON2;
87825 + pax_close_kernel();
87826 +}
87827 +EXPORT_SYMBOL(pax_list_del_rcu);
87828 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
87829 index 1a53d49..ace934c 100644
87830 --- a/lib/percpu-refcount.c
87831 +++ b/lib/percpu-refcount.c
87832 @@ -29,7 +29,7 @@
87833 * can't hit 0 before we've added up all the percpu refs.
87834 */
87835
87836 -#define PCPU_COUNT_BIAS (1U << 31)
87837 +#define PCPU_COUNT_BIAS (1U << 30)
87838
87839 /**
87840 * percpu_ref_init - initialize a percpu refcount
87841 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
87842 index 7811ed3..f80ca19 100644
87843 --- a/lib/radix-tree.c
87844 +++ b/lib/radix-tree.c
87845 @@ -93,7 +93,7 @@ struct radix_tree_preload {
87846 int nr;
87847 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
87848 };
87849 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
87850 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
87851
87852 static inline void *ptr_to_indirect(void *ptr)
87853 {
87854 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
87855 index bb2b201..46abaf9 100644
87856 --- a/lib/strncpy_from_user.c
87857 +++ b/lib/strncpy_from_user.c
87858 @@ -21,7 +21,7 @@
87859 */
87860 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
87861 {
87862 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87863 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87864 long res = 0;
87865
87866 /*
87867 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
87868 index a28df52..3d55877 100644
87869 --- a/lib/strnlen_user.c
87870 +++ b/lib/strnlen_user.c
87871 @@ -26,7 +26,7 @@
87872 */
87873 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
87874 {
87875 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87876 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87877 long align, res = 0;
87878 unsigned long c;
87879
87880 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
87881 index 4e8686c..3e8c92f 100644
87882 --- a/lib/swiotlb.c
87883 +++ b/lib/swiotlb.c
87884 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
87885
87886 void
87887 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
87888 - dma_addr_t dev_addr)
87889 + dma_addr_t dev_addr, struct dma_attrs *attrs)
87890 {
87891 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
87892
87893 diff --git a/lib/usercopy.c b/lib/usercopy.c
87894 index 4f5b1dd..7cab418 100644
87895 --- a/lib/usercopy.c
87896 +++ b/lib/usercopy.c
87897 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
87898 WARN(1, "Buffer overflow detected!\n");
87899 }
87900 EXPORT_SYMBOL(copy_from_user_overflow);
87901 +
87902 +void copy_to_user_overflow(void)
87903 +{
87904 + WARN(1, "Buffer overflow detected!\n");
87905 +}
87906 +EXPORT_SYMBOL(copy_to_user_overflow);
87907 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
87908 index d76555c..62d4bfe 100644
87909 --- a/lib/vsprintf.c
87910 +++ b/lib/vsprintf.c
87911 @@ -16,6 +16,9 @@
87912 * - scnprintf and vscnprintf
87913 */
87914
87915 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87916 +#define __INCLUDED_BY_HIDESYM 1
87917 +#endif
87918 #include <stdarg.h>
87919 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
87920 #include <linux/types.h>
87921 @@ -1155,7 +1158,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
87922 return number(buf, end, *(const netdev_features_t *)addr, spec);
87923 }
87924
87925 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87926 +int kptr_restrict __read_mostly = 2;
87927 +#else
87928 int kptr_restrict __read_mostly;
87929 +#endif
87930
87931 /*
87932 * Show a '%p' thing. A kernel extension is that the '%p' is followed
87933 @@ -1168,6 +1175,7 @@ int kptr_restrict __read_mostly;
87934 * - 'f' For simple symbolic function names without offset
87935 * - 'S' For symbolic direct pointers with offset
87936 * - 's' For symbolic direct pointers without offset
87937 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
87938 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
87939 * - 'B' For backtraced symbolic direct pointers with offset
87940 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
87941 @@ -1232,12 +1240,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87942
87943 if (!ptr && *fmt != 'K') {
87944 /*
87945 - * Print (null) with the same width as a pointer so it makes
87946 + * Print (nil) with the same width as a pointer so it makes
87947 * tabular output look nice.
87948 */
87949 if (spec.field_width == -1)
87950 spec.field_width = default_width;
87951 - return string(buf, end, "(null)", spec);
87952 + return string(buf, end, "(nil)", spec);
87953 }
87954
87955 switch (*fmt) {
87956 @@ -1247,6 +1255,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87957 /* Fallthrough */
87958 case 'S':
87959 case 's':
87960 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87961 + break;
87962 +#else
87963 + return symbol_string(buf, end, ptr, spec, fmt);
87964 +#endif
87965 + case 'A':
87966 case 'B':
87967 return symbol_string(buf, end, ptr, spec, fmt);
87968 case 'R':
87969 @@ -1302,6 +1316,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87970 va_end(va);
87971 return buf;
87972 }
87973 + case 'P':
87974 + break;
87975 case 'K':
87976 /*
87977 * %pK cannot be used in IRQ context because its test
87978 @@ -1363,6 +1379,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87979 ((const struct file *)ptr)->f_path.dentry,
87980 spec, fmt);
87981 }
87982 +
87983 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87984 + /* 'P' = approved pointers to copy to userland,
87985 + as in the /proc/kallsyms case, as we make it display nothing
87986 + for non-root users, and the real contents for root users
87987 + Also ignore 'K' pointers, since we force their NULLing for non-root users
87988 + above
87989 + */
87990 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
87991 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
87992 + dump_stack();
87993 + ptr = NULL;
87994 + }
87995 +#endif
87996 +
87997 spec.flags |= SMALL;
87998 if (spec.field_width == -1) {
87999 spec.field_width = default_width;
88000 @@ -2086,11 +2117,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
88001 typeof(type) value; \
88002 if (sizeof(type) == 8) { \
88003 args = PTR_ALIGN(args, sizeof(u32)); \
88004 - *(u32 *)&value = *(u32 *)args; \
88005 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
88006 + *(u32 *)&value = *(const u32 *)args; \
88007 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
88008 } else { \
88009 args = PTR_ALIGN(args, sizeof(type)); \
88010 - value = *(typeof(type) *)args; \
88011 + value = *(const typeof(type) *)args; \
88012 } \
88013 args += sizeof(type); \
88014 value; \
88015 @@ -2153,7 +2184,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
88016 case FORMAT_TYPE_STR: {
88017 const char *str_arg = args;
88018 args += strlen(str_arg) + 1;
88019 - str = string(str, end, (char *)str_arg, spec);
88020 + str = string(str, end, str_arg, spec);
88021 break;
88022 }
88023
88024 diff --git a/localversion-grsec b/localversion-grsec
88025 new file mode 100644
88026 index 0000000..7cd6065
88027 --- /dev/null
88028 +++ b/localversion-grsec
88029 @@ -0,0 +1 @@
88030 +-grsec
88031 diff --git a/mm/Kconfig b/mm/Kconfig
88032 index 394838f..0e5f816 100644
88033 --- a/mm/Kconfig
88034 +++ b/mm/Kconfig
88035 @@ -317,10 +317,11 @@ config KSM
88036 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
88037
88038 config DEFAULT_MMAP_MIN_ADDR
88039 - int "Low address space to protect from user allocation"
88040 + int "Low address space to protect from user allocation"
88041 depends on MMU
88042 - default 4096
88043 - help
88044 + default 32768 if ALPHA || ARM || PARISC || SPARC32
88045 + default 65536
88046 + help
88047 This is the portion of low virtual memory which should be protected
88048 from userspace allocation. Keeping a user from writing to low pages
88049 can help reduce the impact of kernel NULL pointer bugs.
88050 @@ -351,7 +352,7 @@ config MEMORY_FAILURE
88051
88052 config HWPOISON_INJECT
88053 tristate "HWPoison pages injector"
88054 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
88055 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
88056 select PROC_PAGE_MONITOR
88057
88058 config NOMMU_INITIAL_TRIM_EXCESS
88059 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
88060 index ce682f7..1fb54f9 100644
88061 --- a/mm/backing-dev.c
88062 +++ b/mm/backing-dev.c
88063 @@ -12,7 +12,7 @@
88064 #include <linux/device.h>
88065 #include <trace/events/writeback.h>
88066
88067 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
88068 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
88069
88070 struct backing_dev_info default_backing_dev_info = {
88071 .name = "default",
88072 @@ -525,7 +525,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
88073 return err;
88074
88075 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
88076 - atomic_long_inc_return(&bdi_seq));
88077 + atomic_long_inc_return_unchecked(&bdi_seq));
88078 if (err) {
88079 bdi_destroy(bdi);
88080 return err;
88081 diff --git a/mm/filemap.c b/mm/filemap.c
88082 index ae4846f..b0acebe 100644
88083 --- a/mm/filemap.c
88084 +++ b/mm/filemap.c
88085 @@ -1768,7 +1768,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
88086 struct address_space *mapping = file->f_mapping;
88087
88088 if (!mapping->a_ops->readpage)
88089 - return -ENOEXEC;
88090 + return -ENODEV;
88091 file_accessed(file);
88092 vma->vm_ops = &generic_file_vm_ops;
88093 return 0;
88094 @@ -1950,7 +1950,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
88095
88096 while (bytes) {
88097 char __user *buf = iov->iov_base + base;
88098 - int copy = min(bytes, iov->iov_len - base);
88099 + size_t copy = min(bytes, iov->iov_len - base);
88100
88101 base = 0;
88102 left = __copy_from_user_inatomic(vaddr, buf, copy);
88103 @@ -1979,7 +1979,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
88104 BUG_ON(!in_atomic());
88105 kaddr = kmap_atomic(page);
88106 if (likely(i->nr_segs == 1)) {
88107 - int left;
88108 + size_t left;
88109 char __user *buf = i->iov->iov_base + i->iov_offset;
88110 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
88111 copied = bytes - left;
88112 @@ -2007,7 +2007,7 @@ size_t iov_iter_copy_from_user(struct page *page,
88113
88114 kaddr = kmap(page);
88115 if (likely(i->nr_segs == 1)) {
88116 - int left;
88117 + size_t left;
88118 char __user *buf = i->iov->iov_base + i->iov_offset;
88119 left = __copy_from_user(kaddr + offset, buf, bytes);
88120 copied = bytes - left;
88121 @@ -2037,7 +2037,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
88122 * zero-length segments (without overruning the iovec).
88123 */
88124 while (bytes || unlikely(i->count && !iov->iov_len)) {
88125 - int copy;
88126 + size_t copy;
88127
88128 copy = min(bytes, iov->iov_len - base);
88129 BUG_ON(!i->count || i->count < copy);
88130 @@ -2108,6 +2108,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
88131 *pos = i_size_read(inode);
88132
88133 if (limit != RLIM_INFINITY) {
88134 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
88135 if (*pos >= limit) {
88136 send_sig(SIGXFSZ, current, 0);
88137 return -EFBIG;
88138 diff --git a/mm/fremap.c b/mm/fremap.c
88139 index bbc4d66..117b798 100644
88140 --- a/mm/fremap.c
88141 +++ b/mm/fremap.c
88142 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
88143 retry:
88144 vma = find_vma(mm, start);
88145
88146 +#ifdef CONFIG_PAX_SEGMEXEC
88147 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
88148 + goto out;
88149 +#endif
88150 +
88151 /*
88152 * Make sure the vma is shared, that it supports prefaulting,
88153 * and that the remapped range is valid and fully within
88154 diff --git a/mm/highmem.c b/mm/highmem.c
88155 index b32b70c..e512eb0 100644
88156 --- a/mm/highmem.c
88157 +++ b/mm/highmem.c
88158 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
88159 * So no dangers, even with speculative execution.
88160 */
88161 page = pte_page(pkmap_page_table[i]);
88162 + pax_open_kernel();
88163 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
88164 -
88165 + pax_close_kernel();
88166 set_page_address(page, NULL);
88167 need_flush = 1;
88168 }
88169 @@ -198,9 +199,11 @@ start:
88170 }
88171 }
88172 vaddr = PKMAP_ADDR(last_pkmap_nr);
88173 +
88174 + pax_open_kernel();
88175 set_pte_at(&init_mm, vaddr,
88176 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
88177 -
88178 + pax_close_kernel();
88179 pkmap_count[last_pkmap_nr] = 1;
88180 set_page_address(page, (void *)vaddr);
88181
88182 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
88183 index 0b7656e..d21cefc 100644
88184 --- a/mm/hugetlb.c
88185 +++ b/mm/hugetlb.c
88186 @@ -2094,15 +2094,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
88187 struct hstate *h = &default_hstate;
88188 unsigned long tmp;
88189 int ret;
88190 + ctl_table_no_const hugetlb_table;
88191
88192 tmp = h->max_huge_pages;
88193
88194 if (write && h->order >= MAX_ORDER)
88195 return -EINVAL;
88196
88197 - table->data = &tmp;
88198 - table->maxlen = sizeof(unsigned long);
88199 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
88200 + hugetlb_table = *table;
88201 + hugetlb_table.data = &tmp;
88202 + hugetlb_table.maxlen = sizeof(unsigned long);
88203 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
88204 if (ret)
88205 goto out;
88206
88207 @@ -2147,15 +2149,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
88208 struct hstate *h = &default_hstate;
88209 unsigned long tmp;
88210 int ret;
88211 + ctl_table_no_const hugetlb_table;
88212
88213 tmp = h->nr_overcommit_huge_pages;
88214
88215 if (write && h->order >= MAX_ORDER)
88216 return -EINVAL;
88217
88218 - table->data = &tmp;
88219 - table->maxlen = sizeof(unsigned long);
88220 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
88221 + hugetlb_table = *table;
88222 + hugetlb_table.data = &tmp;
88223 + hugetlb_table.maxlen = sizeof(unsigned long);
88224 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
88225 if (ret)
88226 goto out;
88227
88228 @@ -2605,6 +2609,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
88229 return 1;
88230 }
88231
88232 +#ifdef CONFIG_PAX_SEGMEXEC
88233 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
88234 +{
88235 + struct mm_struct *mm = vma->vm_mm;
88236 + struct vm_area_struct *vma_m;
88237 + unsigned long address_m;
88238 + pte_t *ptep_m;
88239 +
88240 + vma_m = pax_find_mirror_vma(vma);
88241 + if (!vma_m)
88242 + return;
88243 +
88244 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
88245 + address_m = address + SEGMEXEC_TASK_SIZE;
88246 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
88247 + get_page(page_m);
88248 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
88249 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
88250 +}
88251 +#endif
88252 +
88253 /*
88254 * Hugetlb_cow() should be called with page lock of the original hugepage held.
88255 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
88256 @@ -2721,6 +2746,11 @@ retry_avoidcopy:
88257 make_huge_pte(vma, new_page, 1));
88258 page_remove_rmap(old_page);
88259 hugepage_add_new_anon_rmap(new_page, vma, address);
88260 +
88261 +#ifdef CONFIG_PAX_SEGMEXEC
88262 + pax_mirror_huge_pte(vma, address, new_page);
88263 +#endif
88264 +
88265 /* Make the old page be freed below */
88266 new_page = old_page;
88267 }
88268 @@ -2883,6 +2913,10 @@ retry:
88269 && (vma->vm_flags & VM_SHARED)));
88270 set_huge_pte_at(mm, address, ptep, new_pte);
88271
88272 +#ifdef CONFIG_PAX_SEGMEXEC
88273 + pax_mirror_huge_pte(vma, address, page);
88274 +#endif
88275 +
88276 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
88277 /* Optimization, do the COW without a second fault */
88278 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
88279 @@ -2912,6 +2946,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88280 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
88281 struct hstate *h = hstate_vma(vma);
88282
88283 +#ifdef CONFIG_PAX_SEGMEXEC
88284 + struct vm_area_struct *vma_m;
88285 +#endif
88286 +
88287 address &= huge_page_mask(h);
88288
88289 ptep = huge_pte_offset(mm, address);
88290 @@ -2925,6 +2963,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88291 VM_FAULT_SET_HINDEX(hstate_index(h));
88292 }
88293
88294 +#ifdef CONFIG_PAX_SEGMEXEC
88295 + vma_m = pax_find_mirror_vma(vma);
88296 + if (vma_m) {
88297 + unsigned long address_m;
88298 +
88299 + if (vma->vm_start > vma_m->vm_start) {
88300 + address_m = address;
88301 + address -= SEGMEXEC_TASK_SIZE;
88302 + vma = vma_m;
88303 + h = hstate_vma(vma);
88304 + } else
88305 + address_m = address + SEGMEXEC_TASK_SIZE;
88306 +
88307 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
88308 + return VM_FAULT_OOM;
88309 + address_m &= HPAGE_MASK;
88310 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
88311 + }
88312 +#endif
88313 +
88314 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
88315 if (!ptep)
88316 return VM_FAULT_OOM;
88317 diff --git a/mm/internal.h b/mm/internal.h
88318 index 684f7aa..9eb9edc 100644
88319 --- a/mm/internal.h
88320 +++ b/mm/internal.h
88321 @@ -97,6 +97,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
88322 * in mm/page_alloc.c
88323 */
88324 extern void __free_pages_bootmem(struct page *page, unsigned int order);
88325 +extern void free_compound_page(struct page *page);
88326 extern void prep_compound_page(struct page *page, unsigned long order);
88327 #ifdef CONFIG_MEMORY_FAILURE
88328 extern bool is_free_buddy_page(struct page *page);
88329 @@ -352,7 +353,7 @@ extern u32 hwpoison_filter_enable;
88330
88331 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
88332 unsigned long, unsigned long,
88333 - unsigned long, unsigned long);
88334 + unsigned long, unsigned long) __intentional_overflow(-1);
88335
88336 extern void set_pageblock_order(void);
88337 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
88338 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
88339 index e126b0e..e986018 100644
88340 --- a/mm/kmemleak.c
88341 +++ b/mm/kmemleak.c
88342 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
88343
88344 for (i = 0; i < object->trace_len; i++) {
88345 void *ptr = (void *)object->trace[i];
88346 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
88347 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
88348 }
88349 }
88350
88351 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
88352 return -ENOMEM;
88353 }
88354
88355 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
88356 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
88357 &kmemleak_fops);
88358 if (!dentry)
88359 pr_warning("Failed to create the debugfs kmemleak file\n");
88360 diff --git a/mm/maccess.c b/mm/maccess.c
88361 index d53adf9..03a24bf 100644
88362 --- a/mm/maccess.c
88363 +++ b/mm/maccess.c
88364 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
88365 set_fs(KERNEL_DS);
88366 pagefault_disable();
88367 ret = __copy_from_user_inatomic(dst,
88368 - (__force const void __user *)src, size);
88369 + (const void __force_user *)src, size);
88370 pagefault_enable();
88371 set_fs(old_fs);
88372
88373 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
88374
88375 set_fs(KERNEL_DS);
88376 pagefault_disable();
88377 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
88378 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
88379 pagefault_enable();
88380 set_fs(old_fs);
88381
88382 diff --git a/mm/madvise.c b/mm/madvise.c
88383 index 539eeb9..e24a987 100644
88384 --- a/mm/madvise.c
88385 +++ b/mm/madvise.c
88386 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct *vma,
88387 pgoff_t pgoff;
88388 unsigned long new_flags = vma->vm_flags;
88389
88390 +#ifdef CONFIG_PAX_SEGMEXEC
88391 + struct vm_area_struct *vma_m;
88392 +#endif
88393 +
88394 switch (behavior) {
88395 case MADV_NORMAL:
88396 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
88397 @@ -126,6 +130,13 @@ success:
88398 /*
88399 * vm_flags is protected by the mmap_sem held in write mode.
88400 */
88401 +
88402 +#ifdef CONFIG_PAX_SEGMEXEC
88403 + vma_m = pax_find_mirror_vma(vma);
88404 + if (vma_m)
88405 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
88406 +#endif
88407 +
88408 vma->vm_flags = new_flags;
88409
88410 out:
88411 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct *vma,
88412 struct vm_area_struct **prev,
88413 unsigned long start, unsigned long end)
88414 {
88415 +
88416 +#ifdef CONFIG_PAX_SEGMEXEC
88417 + struct vm_area_struct *vma_m;
88418 +#endif
88419 +
88420 *prev = vma;
88421 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
88422 return -EINVAL;
88423 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct *vma,
88424 zap_page_range(vma, start, end - start, &details);
88425 } else
88426 zap_page_range(vma, start, end - start, NULL);
88427 +
88428 +#ifdef CONFIG_PAX_SEGMEXEC
88429 + vma_m = pax_find_mirror_vma(vma);
88430 + if (vma_m) {
88431 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
88432 + struct zap_details details = {
88433 + .nonlinear_vma = vma_m,
88434 + .last_index = ULONG_MAX,
88435 + };
88436 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
88437 + } else
88438 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
88439 + }
88440 +#endif
88441 +
88442 return 0;
88443 }
88444
88445 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
88446 if (end < start)
88447 return error;
88448
88449 +#ifdef CONFIG_PAX_SEGMEXEC
88450 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
88451 + if (end > SEGMEXEC_TASK_SIZE)
88452 + return error;
88453 + } else
88454 +#endif
88455 +
88456 + if (end > TASK_SIZE)
88457 + return error;
88458 +
88459 error = 0;
88460 if (end == start)
88461 return error;
88462 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
88463 index 9aea53f..f239c30 100644
88464 --- a/mm/memory-failure.c
88465 +++ b/mm/memory-failure.c
88466 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
88467
88468 int sysctl_memory_failure_recovery __read_mostly = 1;
88469
88470 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
88471 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
88472
88473 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
88474
88475 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
88476 pfn, t->comm, t->pid);
88477 si.si_signo = SIGBUS;
88478 si.si_errno = 0;
88479 - si.si_addr = (void *)addr;
88480 + si.si_addr = (void __user *)addr;
88481 #ifdef __ARCH_SI_TRAPNO
88482 si.si_trapno = trapno;
88483 #endif
88484 @@ -762,7 +762,7 @@ static struct page_state {
88485 unsigned long res;
88486 char *msg;
88487 int (*action)(struct page *p, unsigned long pfn);
88488 -} error_states[] = {
88489 +} __do_const error_states[] = {
88490 { reserved, reserved, "reserved kernel", me_kernel },
88491 /*
88492 * free pages are specially detected outside this table:
88493 @@ -1063,7 +1063,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
88494 nr_pages = 1 << compound_order(hpage);
88495 else /* normal page or thp */
88496 nr_pages = 1;
88497 - atomic_long_add(nr_pages, &num_poisoned_pages);
88498 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
88499
88500 /*
88501 * We need/can do nothing about count=0 pages.
88502 @@ -1093,7 +1093,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
88503 if (!PageHWPoison(hpage)
88504 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
88505 || (p != hpage && TestSetPageHWPoison(hpage))) {
88506 - atomic_long_sub(nr_pages, &num_poisoned_pages);
88507 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
88508 return 0;
88509 }
88510 set_page_hwpoison_huge_page(hpage);
88511 @@ -1162,7 +1162,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
88512 }
88513 if (hwpoison_filter(p)) {
88514 if (TestClearPageHWPoison(p))
88515 - atomic_long_sub(nr_pages, &num_poisoned_pages);
88516 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
88517 unlock_page(hpage);
88518 put_page(hpage);
88519 return 0;
88520 @@ -1380,7 +1380,7 @@ int unpoison_memory(unsigned long pfn)
88521 return 0;
88522 }
88523 if (TestClearPageHWPoison(p))
88524 - atomic_long_dec(&num_poisoned_pages);
88525 + atomic_long_dec_unchecked(&num_poisoned_pages);
88526 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
88527 return 0;
88528 }
88529 @@ -1394,7 +1394,7 @@ int unpoison_memory(unsigned long pfn)
88530 */
88531 if (TestClearPageHWPoison(page)) {
88532 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
88533 - atomic_long_sub(nr_pages, &num_poisoned_pages);
88534 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
88535 freeit = 1;
88536 if (PageHuge(page))
88537 clear_page_hwpoison_huge_page(page);
88538 @@ -1533,11 +1533,11 @@ static int soft_offline_huge_page(struct page *page, int flags)
88539 if (PageHuge(page)) {
88540 set_page_hwpoison_huge_page(hpage);
88541 dequeue_hwpoisoned_huge_page(hpage);
88542 - atomic_long_add(1 << compound_order(hpage),
88543 + atomic_long_add_unchecked(1 << compound_order(hpage),
88544 &num_poisoned_pages);
88545 } else {
88546 SetPageHWPoison(page);
88547 - atomic_long_inc(&num_poisoned_pages);
88548 + atomic_long_inc_unchecked(&num_poisoned_pages);
88549 }
88550 }
88551 return ret;
88552 @@ -1576,7 +1576,7 @@ static int __soft_offline_page(struct page *page, int flags)
88553 put_page(page);
88554 pr_info("soft_offline: %#lx: invalidated\n", pfn);
88555 SetPageHWPoison(page);
88556 - atomic_long_inc(&num_poisoned_pages);
88557 + atomic_long_inc_unchecked(&num_poisoned_pages);
88558 return 0;
88559 }
88560
88561 @@ -1621,7 +1621,7 @@ static int __soft_offline_page(struct page *page, int flags)
88562 if (!is_free_buddy_page(page))
88563 pr_info("soft offline: %#lx: page leaked\n",
88564 pfn);
88565 - atomic_long_inc(&num_poisoned_pages);
88566 + atomic_long_inc_unchecked(&num_poisoned_pages);
88567 }
88568 } else {
88569 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
88570 @@ -1682,11 +1682,11 @@ int soft_offline_page(struct page *page, int flags)
88571 if (PageHuge(page)) {
88572 set_page_hwpoison_huge_page(hpage);
88573 dequeue_hwpoisoned_huge_page(hpage);
88574 - atomic_long_add(1 << compound_order(hpage),
88575 + atomic_long_add_unchecked(1 << compound_order(hpage),
88576 &num_poisoned_pages);
88577 } else {
88578 SetPageHWPoison(page);
88579 - atomic_long_inc(&num_poisoned_pages);
88580 + atomic_long_inc_unchecked(&num_poisoned_pages);
88581 }
88582 }
88583 unset:
88584 diff --git a/mm/memory.c b/mm/memory.c
88585 index d176154..cd1b387 100644
88586 --- a/mm/memory.c
88587 +++ b/mm/memory.c
88588 @@ -402,6 +402,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
88589 free_pte_range(tlb, pmd, addr);
88590 } while (pmd++, addr = next, addr != end);
88591
88592 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
88593 start &= PUD_MASK;
88594 if (start < floor)
88595 return;
88596 @@ -416,6 +417,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
88597 pmd = pmd_offset(pud, start);
88598 pud_clear(pud);
88599 pmd_free_tlb(tlb, pmd, start);
88600 +#endif
88601 +
88602 }
88603
88604 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
88605 @@ -435,6 +438,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
88606 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
88607 } while (pud++, addr = next, addr != end);
88608
88609 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
88610 start &= PGDIR_MASK;
88611 if (start < floor)
88612 return;
88613 @@ -449,6 +453,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
88614 pud = pud_offset(pgd, start);
88615 pgd_clear(pgd);
88616 pud_free_tlb(tlb, pud, start);
88617 +#endif
88618 +
88619 }
88620
88621 /*
88622 @@ -1636,12 +1642,6 @@ no_page_table:
88623 return page;
88624 }
88625
88626 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
88627 -{
88628 - return stack_guard_page_start(vma, addr) ||
88629 - stack_guard_page_end(vma, addr+PAGE_SIZE);
88630 -}
88631 -
88632 /**
88633 * __get_user_pages() - pin user pages in memory
88634 * @tsk: task_struct of target task
88635 @@ -1728,10 +1728,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
88636
88637 i = 0;
88638
88639 - do {
88640 + while (nr_pages) {
88641 struct vm_area_struct *vma;
88642
88643 - vma = find_extend_vma(mm, start);
88644 + vma = find_vma(mm, start);
88645 if (!vma && in_gate_area(mm, start)) {
88646 unsigned long pg = start & PAGE_MASK;
88647 pgd_t *pgd;
88648 @@ -1780,7 +1780,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
88649 goto next_page;
88650 }
88651
88652 - if (!vma ||
88653 + if (!vma || start < vma->vm_start ||
88654 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
88655 !(vm_flags & vma->vm_flags))
88656 return i ? : -EFAULT;
88657 @@ -1809,11 +1809,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
88658 int ret;
88659 unsigned int fault_flags = 0;
88660
88661 - /* For mlock, just skip the stack guard page. */
88662 - if (foll_flags & FOLL_MLOCK) {
88663 - if (stack_guard_page(vma, start))
88664 - goto next_page;
88665 - }
88666 if (foll_flags & FOLL_WRITE)
88667 fault_flags |= FAULT_FLAG_WRITE;
88668 if (nonblocking)
88669 @@ -1893,7 +1888,7 @@ next_page:
88670 start += page_increm * PAGE_SIZE;
88671 nr_pages -= page_increm;
88672 } while (nr_pages && start < vma->vm_end);
88673 - } while (nr_pages);
88674 + }
88675 return i;
88676 }
88677 EXPORT_SYMBOL(__get_user_pages);
88678 @@ -2100,6 +2095,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
88679 page_add_file_rmap(page);
88680 set_pte_at(mm, addr, pte, mk_pte(page, prot));
88681
88682 +#ifdef CONFIG_PAX_SEGMEXEC
88683 + pax_mirror_file_pte(vma, addr, page, ptl);
88684 +#endif
88685 +
88686 retval = 0;
88687 pte_unmap_unlock(pte, ptl);
88688 return retval;
88689 @@ -2144,9 +2143,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
88690 if (!page_count(page))
88691 return -EINVAL;
88692 if (!(vma->vm_flags & VM_MIXEDMAP)) {
88693 +
88694 +#ifdef CONFIG_PAX_SEGMEXEC
88695 + struct vm_area_struct *vma_m;
88696 +#endif
88697 +
88698 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
88699 BUG_ON(vma->vm_flags & VM_PFNMAP);
88700 vma->vm_flags |= VM_MIXEDMAP;
88701 +
88702 +#ifdef CONFIG_PAX_SEGMEXEC
88703 + vma_m = pax_find_mirror_vma(vma);
88704 + if (vma_m)
88705 + vma_m->vm_flags |= VM_MIXEDMAP;
88706 +#endif
88707 +
88708 }
88709 return insert_page(vma, addr, page, vma->vm_page_prot);
88710 }
88711 @@ -2229,6 +2240,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
88712 unsigned long pfn)
88713 {
88714 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
88715 + BUG_ON(vma->vm_mirror);
88716
88717 if (addr < vma->vm_start || addr >= vma->vm_end)
88718 return -EFAULT;
88719 @@ -2476,7 +2488,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
88720
88721 BUG_ON(pud_huge(*pud));
88722
88723 - pmd = pmd_alloc(mm, pud, addr);
88724 + pmd = (mm == &init_mm) ?
88725 + pmd_alloc_kernel(mm, pud, addr) :
88726 + pmd_alloc(mm, pud, addr);
88727 if (!pmd)
88728 return -ENOMEM;
88729 do {
88730 @@ -2496,7 +2510,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
88731 unsigned long next;
88732 int err;
88733
88734 - pud = pud_alloc(mm, pgd, addr);
88735 + pud = (mm == &init_mm) ?
88736 + pud_alloc_kernel(mm, pgd, addr) :
88737 + pud_alloc(mm, pgd, addr);
88738 if (!pud)
88739 return -ENOMEM;
88740 do {
88741 @@ -2584,6 +2600,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
88742 copy_user_highpage(dst, src, va, vma);
88743 }
88744
88745 +#ifdef CONFIG_PAX_SEGMEXEC
88746 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
88747 +{
88748 + struct mm_struct *mm = vma->vm_mm;
88749 + spinlock_t *ptl;
88750 + pte_t *pte, entry;
88751 +
88752 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
88753 + entry = *pte;
88754 + if (!pte_present(entry)) {
88755 + if (!pte_none(entry)) {
88756 + BUG_ON(pte_file(entry));
88757 + free_swap_and_cache(pte_to_swp_entry(entry));
88758 + pte_clear_not_present_full(mm, address, pte, 0);
88759 + }
88760 + } else {
88761 + struct page *page;
88762 +
88763 + flush_cache_page(vma, address, pte_pfn(entry));
88764 + entry = ptep_clear_flush(vma, address, pte);
88765 + BUG_ON(pte_dirty(entry));
88766 + page = vm_normal_page(vma, address, entry);
88767 + if (page) {
88768 + update_hiwater_rss(mm);
88769 + if (PageAnon(page))
88770 + dec_mm_counter_fast(mm, MM_ANONPAGES);
88771 + else
88772 + dec_mm_counter_fast(mm, MM_FILEPAGES);
88773 + page_remove_rmap(page);
88774 + page_cache_release(page);
88775 + }
88776 + }
88777 + pte_unmap_unlock(pte, ptl);
88778 +}
88779 +
88780 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
88781 + *
88782 + * the ptl of the lower mapped page is held on entry and is not released on exit
88783 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
88784 + */
88785 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
88786 +{
88787 + struct mm_struct *mm = vma->vm_mm;
88788 + unsigned long address_m;
88789 + spinlock_t *ptl_m;
88790 + struct vm_area_struct *vma_m;
88791 + pmd_t *pmd_m;
88792 + pte_t *pte_m, entry_m;
88793 +
88794 + BUG_ON(!page_m || !PageAnon(page_m));
88795 +
88796 + vma_m = pax_find_mirror_vma(vma);
88797 + if (!vma_m)
88798 + return;
88799 +
88800 + BUG_ON(!PageLocked(page_m));
88801 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
88802 + address_m = address + SEGMEXEC_TASK_SIZE;
88803 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
88804 + pte_m = pte_offset_map(pmd_m, address_m);
88805 + ptl_m = pte_lockptr(mm, pmd_m);
88806 + if (ptl != ptl_m) {
88807 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
88808 + if (!pte_none(*pte_m))
88809 + goto out;
88810 + }
88811 +
88812 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
88813 + page_cache_get(page_m);
88814 + page_add_anon_rmap(page_m, vma_m, address_m);
88815 + inc_mm_counter_fast(mm, MM_ANONPAGES);
88816 + set_pte_at(mm, address_m, pte_m, entry_m);
88817 + update_mmu_cache(vma_m, address_m, pte_m);
88818 +out:
88819 + if (ptl != ptl_m)
88820 + spin_unlock(ptl_m);
88821 + pte_unmap(pte_m);
88822 + unlock_page(page_m);
88823 +}
88824 +
88825 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
88826 +{
88827 + struct mm_struct *mm = vma->vm_mm;
88828 + unsigned long address_m;
88829 + spinlock_t *ptl_m;
88830 + struct vm_area_struct *vma_m;
88831 + pmd_t *pmd_m;
88832 + pte_t *pte_m, entry_m;
88833 +
88834 + BUG_ON(!page_m || PageAnon(page_m));
88835 +
88836 + vma_m = pax_find_mirror_vma(vma);
88837 + if (!vma_m)
88838 + return;
88839 +
88840 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
88841 + address_m = address + SEGMEXEC_TASK_SIZE;
88842 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
88843 + pte_m = pte_offset_map(pmd_m, address_m);
88844 + ptl_m = pte_lockptr(mm, pmd_m);
88845 + if (ptl != ptl_m) {
88846 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
88847 + if (!pte_none(*pte_m))
88848 + goto out;
88849 + }
88850 +
88851 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
88852 + page_cache_get(page_m);
88853 + page_add_file_rmap(page_m);
88854 + inc_mm_counter_fast(mm, MM_FILEPAGES);
88855 + set_pte_at(mm, address_m, pte_m, entry_m);
88856 + update_mmu_cache(vma_m, address_m, pte_m);
88857 +out:
88858 + if (ptl != ptl_m)
88859 + spin_unlock(ptl_m);
88860 + pte_unmap(pte_m);
88861 +}
88862 +
88863 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
88864 +{
88865 + struct mm_struct *mm = vma->vm_mm;
88866 + unsigned long address_m;
88867 + spinlock_t *ptl_m;
88868 + struct vm_area_struct *vma_m;
88869 + pmd_t *pmd_m;
88870 + pte_t *pte_m, entry_m;
88871 +
88872 + vma_m = pax_find_mirror_vma(vma);
88873 + if (!vma_m)
88874 + return;
88875 +
88876 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
88877 + address_m = address + SEGMEXEC_TASK_SIZE;
88878 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
88879 + pte_m = pte_offset_map(pmd_m, address_m);
88880 + ptl_m = pte_lockptr(mm, pmd_m);
88881 + if (ptl != ptl_m) {
88882 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
88883 + if (!pte_none(*pte_m))
88884 + goto out;
88885 + }
88886 +
88887 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
88888 + set_pte_at(mm, address_m, pte_m, entry_m);
88889 +out:
88890 + if (ptl != ptl_m)
88891 + spin_unlock(ptl_m);
88892 + pte_unmap(pte_m);
88893 +}
88894 +
88895 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
88896 +{
88897 + struct page *page_m;
88898 + pte_t entry;
88899 +
88900 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
88901 + goto out;
88902 +
88903 + entry = *pte;
88904 + page_m = vm_normal_page(vma, address, entry);
88905 + if (!page_m)
88906 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
88907 + else if (PageAnon(page_m)) {
88908 + if (pax_find_mirror_vma(vma)) {
88909 + pte_unmap_unlock(pte, ptl);
88910 + lock_page(page_m);
88911 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
88912 + if (pte_same(entry, *pte))
88913 + pax_mirror_anon_pte(vma, address, page_m, ptl);
88914 + else
88915 + unlock_page(page_m);
88916 + }
88917 + } else
88918 + pax_mirror_file_pte(vma, address, page_m, ptl);
88919 +
88920 +out:
88921 + pte_unmap_unlock(pte, ptl);
88922 +}
88923 +#endif
88924 +
88925 /*
88926 * This routine handles present pages, when users try to write
88927 * to a shared page. It is done by copying the page to a new address
88928 @@ -2800,6 +2996,12 @@ gotten:
88929 */
88930 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
88931 if (likely(pte_same(*page_table, orig_pte))) {
88932 +
88933 +#ifdef CONFIG_PAX_SEGMEXEC
88934 + if (pax_find_mirror_vma(vma))
88935 + BUG_ON(!trylock_page(new_page));
88936 +#endif
88937 +
88938 if (old_page) {
88939 if (!PageAnon(old_page)) {
88940 dec_mm_counter_fast(mm, MM_FILEPAGES);
88941 @@ -2851,6 +3053,10 @@ gotten:
88942 page_remove_rmap(old_page);
88943 }
88944
88945 +#ifdef CONFIG_PAX_SEGMEXEC
88946 + pax_mirror_anon_pte(vma, address, new_page, ptl);
88947 +#endif
88948 +
88949 /* Free the old page.. */
88950 new_page = old_page;
88951 ret |= VM_FAULT_WRITE;
88952 @@ -3128,6 +3334,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
88953 swap_free(entry);
88954 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
88955 try_to_free_swap(page);
88956 +
88957 +#ifdef CONFIG_PAX_SEGMEXEC
88958 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
88959 +#endif
88960 +
88961 unlock_page(page);
88962 if (page != swapcache) {
88963 /*
88964 @@ -3151,6 +3362,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
88965
88966 /* No need to invalidate - it was non-present before */
88967 update_mmu_cache(vma, address, page_table);
88968 +
88969 +#ifdef CONFIG_PAX_SEGMEXEC
88970 + pax_mirror_anon_pte(vma, address, page, ptl);
88971 +#endif
88972 +
88973 unlock:
88974 pte_unmap_unlock(page_table, ptl);
88975 out:
88976 @@ -3170,40 +3386,6 @@ out_release:
88977 }
88978
88979 /*
88980 - * This is like a special single-page "expand_{down|up}wards()",
88981 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
88982 - * doesn't hit another vma.
88983 - */
88984 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
88985 -{
88986 - address &= PAGE_MASK;
88987 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
88988 - struct vm_area_struct *prev = vma->vm_prev;
88989 -
88990 - /*
88991 - * Is there a mapping abutting this one below?
88992 - *
88993 - * That's only ok if it's the same stack mapping
88994 - * that has gotten split..
88995 - */
88996 - if (prev && prev->vm_end == address)
88997 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
88998 -
88999 - expand_downwards(vma, address - PAGE_SIZE);
89000 - }
89001 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
89002 - struct vm_area_struct *next = vma->vm_next;
89003 -
89004 - /* As VM_GROWSDOWN but s/below/above/ */
89005 - if (next && next->vm_start == address + PAGE_SIZE)
89006 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
89007 -
89008 - expand_upwards(vma, address + PAGE_SIZE);
89009 - }
89010 - return 0;
89011 -}
89012 -
89013 -/*
89014 * We enter with non-exclusive mmap_sem (to exclude vma changes,
89015 * but allow concurrent faults), and pte mapped but not yet locked.
89016 * We return with mmap_sem still held, but pte unmapped and unlocked.
89017 @@ -3212,27 +3394,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
89018 unsigned long address, pte_t *page_table, pmd_t *pmd,
89019 unsigned int flags)
89020 {
89021 - struct page *page;
89022 + struct page *page = NULL;
89023 spinlock_t *ptl;
89024 pte_t entry;
89025
89026 - pte_unmap(page_table);
89027 -
89028 - /* Check if we need to add a guard page to the stack */
89029 - if (check_stack_guard_page(vma, address) < 0)
89030 - return VM_FAULT_SIGBUS;
89031 -
89032 - /* Use the zero-page for reads */
89033 if (!(flags & FAULT_FLAG_WRITE)) {
89034 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
89035 vma->vm_page_prot));
89036 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
89037 + ptl = pte_lockptr(mm, pmd);
89038 + spin_lock(ptl);
89039 if (!pte_none(*page_table))
89040 goto unlock;
89041 goto setpte;
89042 }
89043
89044 /* Allocate our own private page. */
89045 + pte_unmap(page_table);
89046 +
89047 if (unlikely(anon_vma_prepare(vma)))
89048 goto oom;
89049 page = alloc_zeroed_user_highpage_movable(vma, address);
89050 @@ -3256,6 +3434,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
89051 if (!pte_none(*page_table))
89052 goto release;
89053
89054 +#ifdef CONFIG_PAX_SEGMEXEC
89055 + if (pax_find_mirror_vma(vma))
89056 + BUG_ON(!trylock_page(page));
89057 +#endif
89058 +
89059 inc_mm_counter_fast(mm, MM_ANONPAGES);
89060 page_add_new_anon_rmap(page, vma, address);
89061 setpte:
89062 @@ -3263,6 +3446,12 @@ setpte:
89063
89064 /* No need to invalidate - it was non-present before */
89065 update_mmu_cache(vma, address, page_table);
89066 +
89067 +#ifdef CONFIG_PAX_SEGMEXEC
89068 + if (page)
89069 + pax_mirror_anon_pte(vma, address, page, ptl);
89070 +#endif
89071 +
89072 unlock:
89073 pte_unmap_unlock(page_table, ptl);
89074 return 0;
89075 @@ -3406,6 +3595,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
89076 */
89077 /* Only go through if we didn't race with anybody else... */
89078 if (likely(pte_same(*page_table, orig_pte))) {
89079 +
89080 +#ifdef CONFIG_PAX_SEGMEXEC
89081 + if (anon && pax_find_mirror_vma(vma))
89082 + BUG_ON(!trylock_page(page));
89083 +#endif
89084 +
89085 flush_icache_page(vma, page);
89086 entry = mk_pte(page, vma->vm_page_prot);
89087 if (flags & FAULT_FLAG_WRITE)
89088 @@ -3427,6 +3622,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
89089
89090 /* no need to invalidate: a not-present page won't be cached */
89091 update_mmu_cache(vma, address, page_table);
89092 +
89093 +#ifdef CONFIG_PAX_SEGMEXEC
89094 + if (anon)
89095 + pax_mirror_anon_pte(vma, address, page, ptl);
89096 + else
89097 + pax_mirror_file_pte(vma, address, page, ptl);
89098 +#endif
89099 +
89100 } else {
89101 if (cow_page)
89102 mem_cgroup_uncharge_page(cow_page);
89103 @@ -3737,6 +3940,12 @@ static int handle_pte_fault(struct mm_struct *mm,
89104 if (flags & FAULT_FLAG_WRITE)
89105 flush_tlb_fix_spurious_fault(vma, address);
89106 }
89107 +
89108 +#ifdef CONFIG_PAX_SEGMEXEC
89109 + pax_mirror_pte(vma, address, pte, pmd, ptl);
89110 + return 0;
89111 +#endif
89112 +
89113 unlock:
89114 pte_unmap_unlock(pte, ptl);
89115 return 0;
89116 @@ -3753,9 +3962,41 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
89117 pmd_t *pmd;
89118 pte_t *pte;
89119
89120 +#ifdef CONFIG_PAX_SEGMEXEC
89121 + struct vm_area_struct *vma_m;
89122 +#endif
89123 +
89124 if (unlikely(is_vm_hugetlb_page(vma)))
89125 return hugetlb_fault(mm, vma, address, flags);
89126
89127 +#ifdef CONFIG_PAX_SEGMEXEC
89128 + vma_m = pax_find_mirror_vma(vma);
89129 + if (vma_m) {
89130 + unsigned long address_m;
89131 + pgd_t *pgd_m;
89132 + pud_t *pud_m;
89133 + pmd_t *pmd_m;
89134 +
89135 + if (vma->vm_start > vma_m->vm_start) {
89136 + address_m = address;
89137 + address -= SEGMEXEC_TASK_SIZE;
89138 + vma = vma_m;
89139 + } else
89140 + address_m = address + SEGMEXEC_TASK_SIZE;
89141 +
89142 + pgd_m = pgd_offset(mm, address_m);
89143 + pud_m = pud_alloc(mm, pgd_m, address_m);
89144 + if (!pud_m)
89145 + return VM_FAULT_OOM;
89146 + pmd_m = pmd_alloc(mm, pud_m, address_m);
89147 + if (!pmd_m)
89148 + return VM_FAULT_OOM;
89149 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
89150 + return VM_FAULT_OOM;
89151 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
89152 + }
89153 +#endif
89154 +
89155 retry:
89156 pgd = pgd_offset(mm, address);
89157 pud = pud_alloc(mm, pgd, address);
89158 @@ -3894,6 +4135,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
89159 spin_unlock(&mm->page_table_lock);
89160 return 0;
89161 }
89162 +
89163 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
89164 +{
89165 + pud_t *new = pud_alloc_one(mm, address);
89166 + if (!new)
89167 + return -ENOMEM;
89168 +
89169 + smp_wmb(); /* See comment in __pte_alloc */
89170 +
89171 + spin_lock(&mm->page_table_lock);
89172 + if (pgd_present(*pgd)) /* Another has populated it */
89173 + pud_free(mm, new);
89174 + else
89175 + pgd_populate_kernel(mm, pgd, new);
89176 + spin_unlock(&mm->page_table_lock);
89177 + return 0;
89178 +}
89179 #endif /* __PAGETABLE_PUD_FOLDED */
89180
89181 #ifndef __PAGETABLE_PMD_FOLDED
89182 @@ -3924,6 +4182,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
89183 spin_unlock(&mm->page_table_lock);
89184 return 0;
89185 }
89186 +
89187 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
89188 +{
89189 + pmd_t *new = pmd_alloc_one(mm, address);
89190 + if (!new)
89191 + return -ENOMEM;
89192 +
89193 + smp_wmb(); /* See comment in __pte_alloc */
89194 +
89195 + spin_lock(&mm->page_table_lock);
89196 +#ifndef __ARCH_HAS_4LEVEL_HACK
89197 + if (pud_present(*pud)) /* Another has populated it */
89198 + pmd_free(mm, new);
89199 + else
89200 + pud_populate_kernel(mm, pud, new);
89201 +#else
89202 + if (pgd_present(*pud)) /* Another has populated it */
89203 + pmd_free(mm, new);
89204 + else
89205 + pgd_populate_kernel(mm, pud, new);
89206 +#endif /* __ARCH_HAS_4LEVEL_HACK */
89207 + spin_unlock(&mm->page_table_lock);
89208 + return 0;
89209 +}
89210 #endif /* __PAGETABLE_PMD_FOLDED */
89211
89212 #if !defined(__HAVE_ARCH_GATE_AREA)
89213 @@ -3937,7 +4219,7 @@ static int __init gate_vma_init(void)
89214 gate_vma.vm_start = FIXADDR_USER_START;
89215 gate_vma.vm_end = FIXADDR_USER_END;
89216 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
89217 - gate_vma.vm_page_prot = __P101;
89218 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
89219
89220 return 0;
89221 }
89222 @@ -4071,8 +4353,8 @@ out:
89223 return ret;
89224 }
89225
89226 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
89227 - void *buf, int len, int write)
89228 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
89229 + void *buf, size_t len, int write)
89230 {
89231 resource_size_t phys_addr;
89232 unsigned long prot = 0;
89233 @@ -4098,8 +4380,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
89234 * Access another process' address space as given in mm. If non-NULL, use the
89235 * given task for page fault accounting.
89236 */
89237 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89238 - unsigned long addr, void *buf, int len, int write)
89239 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89240 + unsigned long addr, void *buf, size_t len, int write)
89241 {
89242 struct vm_area_struct *vma;
89243 void *old_buf = buf;
89244 @@ -4107,7 +4389,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89245 down_read(&mm->mmap_sem);
89246 /* ignore errors, just check how much was successfully transferred */
89247 while (len) {
89248 - int bytes, ret, offset;
89249 + ssize_t bytes, ret, offset;
89250 void *maddr;
89251 struct page *page = NULL;
89252
89253 @@ -4166,8 +4448,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89254 *
89255 * The caller must hold a reference on @mm.
89256 */
89257 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89258 - void *buf, int len, int write)
89259 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
89260 + void *buf, size_t len, int write)
89261 {
89262 return __access_remote_vm(NULL, mm, addr, buf, len, write);
89263 }
89264 @@ -4177,11 +4459,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89265 * Source/target buffer must be kernel space,
89266 * Do not walk the page table directly, use get_user_pages
89267 */
89268 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
89269 - void *buf, int len, int write)
89270 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
89271 + void *buf, size_t len, int write)
89272 {
89273 struct mm_struct *mm;
89274 - int ret;
89275 + ssize_t ret;
89276
89277 mm = get_task_mm(tsk);
89278 if (!mm)
89279 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
89280 index 6b22d8f9..8b5f6cf 100644
89281 --- a/mm/mempolicy.c
89282 +++ b/mm/mempolicy.c
89283 @@ -746,6 +746,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
89284 unsigned long vmstart;
89285 unsigned long vmend;
89286
89287 +#ifdef CONFIG_PAX_SEGMEXEC
89288 + struct vm_area_struct *vma_m;
89289 +#endif
89290 +
89291 vma = find_vma(mm, start);
89292 if (!vma || vma->vm_start > start)
89293 return -EFAULT;
89294 @@ -789,6 +793,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
89295 err = vma_replace_policy(vma, new_pol);
89296 if (err)
89297 goto out;
89298 +
89299 +#ifdef CONFIG_PAX_SEGMEXEC
89300 + vma_m = pax_find_mirror_vma(vma);
89301 + if (vma_m) {
89302 + err = vma_replace_policy(vma_m, new_pol);
89303 + if (err)
89304 + goto out;
89305 + }
89306 +#endif
89307 +
89308 }
89309
89310 out:
89311 @@ -1252,6 +1266,17 @@ static long do_mbind(unsigned long start, unsigned long len,
89312
89313 if (end < start)
89314 return -EINVAL;
89315 +
89316 +#ifdef CONFIG_PAX_SEGMEXEC
89317 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
89318 + if (end > SEGMEXEC_TASK_SIZE)
89319 + return -EINVAL;
89320 + } else
89321 +#endif
89322 +
89323 + if (end > TASK_SIZE)
89324 + return -EINVAL;
89325 +
89326 if (end == start)
89327 return 0;
89328
89329 @@ -1480,8 +1505,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
89330 */
89331 tcred = __task_cred(task);
89332 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
89333 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
89334 - !capable(CAP_SYS_NICE)) {
89335 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
89336 rcu_read_unlock();
89337 err = -EPERM;
89338 goto out_put;
89339 @@ -1512,6 +1536,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
89340 goto out;
89341 }
89342
89343 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
89344 + if (mm != current->mm &&
89345 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
89346 + mmput(mm);
89347 + err = -EPERM;
89348 + goto out;
89349 + }
89350 +#endif
89351 +
89352 err = do_migrate_pages(mm, old, new,
89353 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
89354
89355 diff --git a/mm/migrate.c b/mm/migrate.c
89356 index e3cf71d..c94506c 100644
89357 --- a/mm/migrate.c
89358 +++ b/mm/migrate.c
89359 @@ -1406,8 +1406,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
89360 */
89361 tcred = __task_cred(task);
89362 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
89363 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
89364 - !capable(CAP_SYS_NICE)) {
89365 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
89366 rcu_read_unlock();
89367 err = -EPERM;
89368 goto out;
89369 diff --git a/mm/mlock.c b/mm/mlock.c
89370 index 192e6ee..b044449 100644
89371 --- a/mm/mlock.c
89372 +++ b/mm/mlock.c
89373 @@ -14,6 +14,7 @@
89374 #include <linux/pagevec.h>
89375 #include <linux/mempolicy.h>
89376 #include <linux/syscalls.h>
89377 +#include <linux/security.h>
89378 #include <linux/sched.h>
89379 #include <linux/export.h>
89380 #include <linux/rmap.h>
89381 @@ -588,7 +589,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
89382 {
89383 unsigned long nstart, end, tmp;
89384 struct vm_area_struct * vma, * prev;
89385 - int error;
89386 + int error = 0;
89387
89388 VM_BUG_ON(start & ~PAGE_MASK);
89389 VM_BUG_ON(len != PAGE_ALIGN(len));
89390 @@ -597,6 +598,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
89391 return -EINVAL;
89392 if (end == start)
89393 return 0;
89394 + if (end > TASK_SIZE)
89395 + return -EINVAL;
89396 +
89397 vma = find_vma(current->mm, start);
89398 if (!vma || vma->vm_start > start)
89399 return -ENOMEM;
89400 @@ -608,6 +612,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
89401 for (nstart = start ; ; ) {
89402 vm_flags_t newflags;
89403
89404 +#ifdef CONFIG_PAX_SEGMEXEC
89405 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
89406 + break;
89407 +#endif
89408 +
89409 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
89410
89411 newflags = vma->vm_flags & ~VM_LOCKED;
89412 @@ -720,6 +729,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
89413 lock_limit >>= PAGE_SHIFT;
89414
89415 /* check against resource limits */
89416 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
89417 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
89418 error = do_mlock(start, len, 1);
89419 up_write(&current->mm->mmap_sem);
89420 @@ -754,6 +764,11 @@ static int do_mlockall(int flags)
89421 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
89422 vm_flags_t newflags;
89423
89424 +#ifdef CONFIG_PAX_SEGMEXEC
89425 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
89426 + break;
89427 +#endif
89428 +
89429 newflags = vma->vm_flags & ~VM_LOCKED;
89430 if (flags & MCL_CURRENT)
89431 newflags |= VM_LOCKED;
89432 @@ -787,6 +802,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
89433 lock_limit >>= PAGE_SHIFT;
89434
89435 ret = -ENOMEM;
89436 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
89437 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
89438 capable(CAP_IPC_LOCK))
89439 ret = do_mlockall(flags);
89440 diff --git a/mm/mmap.c b/mm/mmap.c
89441 index 362e5f1..8968e02 100644
89442 --- a/mm/mmap.c
89443 +++ b/mm/mmap.c
89444 @@ -36,6 +36,7 @@
89445 #include <linux/sched/sysctl.h>
89446 #include <linux/notifier.h>
89447 #include <linux/memory.h>
89448 +#include <linux/random.h>
89449
89450 #include <asm/uaccess.h>
89451 #include <asm/cacheflush.h>
89452 @@ -52,6 +53,16 @@
89453 #define arch_rebalance_pgtables(addr, len) (addr)
89454 #endif
89455
89456 +static inline void verify_mm_writelocked(struct mm_struct *mm)
89457 +{
89458 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
89459 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
89460 + up_read(&mm->mmap_sem);
89461 + BUG();
89462 + }
89463 +#endif
89464 +}
89465 +
89466 static void unmap_region(struct mm_struct *mm,
89467 struct vm_area_struct *vma, struct vm_area_struct *prev,
89468 unsigned long start, unsigned long end);
89469 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
89470 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
89471 *
89472 */
89473 -pgprot_t protection_map[16] = {
89474 +pgprot_t protection_map[16] __read_only = {
89475 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
89476 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
89477 };
89478
89479 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
89480 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
89481 {
89482 - return __pgprot(pgprot_val(protection_map[vm_flags &
89483 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
89484 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
89485 pgprot_val(arch_vm_get_page_prot(vm_flags)));
89486 +
89487 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
89488 + if (!(__supported_pte_mask & _PAGE_NX) &&
89489 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
89490 + (vm_flags & (VM_READ | VM_WRITE)))
89491 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
89492 +#endif
89493 +
89494 + return prot;
89495 }
89496 EXPORT_SYMBOL(vm_get_page_prot);
89497
89498 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
89499 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
89500 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
89501 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
89502 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
89503 /*
89504 * Make sure vm_committed_as in one cacheline and not cacheline shared with
89505 * other variables. It can be updated by several CPUs frequently.
89506 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
89507 struct vm_area_struct *next = vma->vm_next;
89508
89509 might_sleep();
89510 + BUG_ON(vma->vm_mirror);
89511 if (vma->vm_ops && vma->vm_ops->close)
89512 vma->vm_ops->close(vma);
89513 if (vma->vm_file)
89514 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
89515 * not page aligned -Ram Gupta
89516 */
89517 rlim = rlimit(RLIMIT_DATA);
89518 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
89519 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
89520 (mm->end_data - mm->start_data) > rlim)
89521 goto out;
89522 @@ -933,6 +956,12 @@ static int
89523 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
89524 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
89525 {
89526 +
89527 +#ifdef CONFIG_PAX_SEGMEXEC
89528 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
89529 + return 0;
89530 +#endif
89531 +
89532 if (is_mergeable_vma(vma, file, vm_flags) &&
89533 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
89534 if (vma->vm_pgoff == vm_pgoff)
89535 @@ -952,6 +981,12 @@ static int
89536 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
89537 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
89538 {
89539 +
89540 +#ifdef CONFIG_PAX_SEGMEXEC
89541 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
89542 + return 0;
89543 +#endif
89544 +
89545 if (is_mergeable_vma(vma, file, vm_flags) &&
89546 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
89547 pgoff_t vm_pglen;
89548 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
89549 struct vm_area_struct *vma_merge(struct mm_struct *mm,
89550 struct vm_area_struct *prev, unsigned long addr,
89551 unsigned long end, unsigned long vm_flags,
89552 - struct anon_vma *anon_vma, struct file *file,
89553 + struct anon_vma *anon_vma, struct file *file,
89554 pgoff_t pgoff, struct mempolicy *policy)
89555 {
89556 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
89557 struct vm_area_struct *area, *next;
89558 int err;
89559
89560 +#ifdef CONFIG_PAX_SEGMEXEC
89561 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
89562 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
89563 +
89564 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
89565 +#endif
89566 +
89567 /*
89568 * We later require that vma->vm_flags == vm_flags,
89569 * so this tests vma->vm_flags & VM_SPECIAL, too.
89570 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
89571 if (next && next->vm_end == end) /* cases 6, 7, 8 */
89572 next = next->vm_next;
89573
89574 +#ifdef CONFIG_PAX_SEGMEXEC
89575 + if (prev)
89576 + prev_m = pax_find_mirror_vma(prev);
89577 + if (area)
89578 + area_m = pax_find_mirror_vma(area);
89579 + if (next)
89580 + next_m = pax_find_mirror_vma(next);
89581 +#endif
89582 +
89583 /*
89584 * Can it merge with the predecessor?
89585 */
89586 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
89587 /* cases 1, 6 */
89588 err = vma_adjust(prev, prev->vm_start,
89589 next->vm_end, prev->vm_pgoff, NULL);
89590 - } else /* cases 2, 5, 7 */
89591 +
89592 +#ifdef CONFIG_PAX_SEGMEXEC
89593 + if (!err && prev_m)
89594 + err = vma_adjust(prev_m, prev_m->vm_start,
89595 + next_m->vm_end, prev_m->vm_pgoff, NULL);
89596 +#endif
89597 +
89598 + } else { /* cases 2, 5, 7 */
89599 err = vma_adjust(prev, prev->vm_start,
89600 end, prev->vm_pgoff, NULL);
89601 +
89602 +#ifdef CONFIG_PAX_SEGMEXEC
89603 + if (!err && prev_m)
89604 + err = vma_adjust(prev_m, prev_m->vm_start,
89605 + end_m, prev_m->vm_pgoff, NULL);
89606 +#endif
89607 +
89608 + }
89609 if (err)
89610 return NULL;
89611 khugepaged_enter_vma_merge(prev);
89612 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
89613 mpol_equal(policy, vma_policy(next)) &&
89614 can_vma_merge_before(next, vm_flags,
89615 anon_vma, file, pgoff+pglen)) {
89616 - if (prev && addr < prev->vm_end) /* case 4 */
89617 + if (prev && addr < prev->vm_end) { /* case 4 */
89618 err = vma_adjust(prev, prev->vm_start,
89619 addr, prev->vm_pgoff, NULL);
89620 - else /* cases 3, 8 */
89621 +
89622 +#ifdef CONFIG_PAX_SEGMEXEC
89623 + if (!err && prev_m)
89624 + err = vma_adjust(prev_m, prev_m->vm_start,
89625 + addr_m, prev_m->vm_pgoff, NULL);
89626 +#endif
89627 +
89628 + } else { /* cases 3, 8 */
89629 err = vma_adjust(area, addr, next->vm_end,
89630 next->vm_pgoff - pglen, NULL);
89631 +
89632 +#ifdef CONFIG_PAX_SEGMEXEC
89633 + if (!err && area_m)
89634 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
89635 + next_m->vm_pgoff - pglen, NULL);
89636 +#endif
89637 +
89638 + }
89639 if (err)
89640 return NULL;
89641 khugepaged_enter_vma_merge(area);
89642 @@ -1165,8 +1246,10 @@ none:
89643 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
89644 struct file *file, long pages)
89645 {
89646 - const unsigned long stack_flags
89647 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
89648 +
89649 +#ifdef CONFIG_PAX_RANDMMAP
89650 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
89651 +#endif
89652
89653 mm->total_vm += pages;
89654
89655 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
89656 mm->shared_vm += pages;
89657 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
89658 mm->exec_vm += pages;
89659 - } else if (flags & stack_flags)
89660 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
89661 mm->stack_vm += pages;
89662 }
89663 #endif /* CONFIG_PROC_FS */
89664 @@ -1212,7 +1295,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
89665 * (the exception is when the underlying filesystem is noexec
89666 * mounted, in which case we dont add PROT_EXEC.)
89667 */
89668 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
89669 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
89670 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
89671 prot |= PROT_EXEC;
89672
89673 @@ -1238,7 +1321,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
89674 /* Obtain the address to map to. we verify (or select) it and ensure
89675 * that it represents a valid section of the address space.
89676 */
89677 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
89678 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
89679 if (addr & ~PAGE_MASK)
89680 return addr;
89681
89682 @@ -1249,6 +1332,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
89683 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
89684 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
89685
89686 +#ifdef CONFIG_PAX_MPROTECT
89687 + if (mm->pax_flags & MF_PAX_MPROTECT) {
89688 +
89689 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
89690 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
89691 + mm->binfmt->handle_mmap)
89692 + mm->binfmt->handle_mmap(file);
89693 +#endif
89694 +
89695 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
89696 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
89697 + gr_log_rwxmmap(file);
89698 +
89699 +#ifdef CONFIG_PAX_EMUPLT
89700 + vm_flags &= ~VM_EXEC;
89701 +#else
89702 + return -EPERM;
89703 +#endif
89704 +
89705 + }
89706 +
89707 + if (!(vm_flags & VM_EXEC))
89708 + vm_flags &= ~VM_MAYEXEC;
89709 +#else
89710 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
89711 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
89712 +#endif
89713 + else
89714 + vm_flags &= ~VM_MAYWRITE;
89715 + }
89716 +#endif
89717 +
89718 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
89719 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
89720 + vm_flags &= ~VM_PAGEEXEC;
89721 +#endif
89722 +
89723 if (flags & MAP_LOCKED)
89724 if (!can_do_mlock())
89725 return -EPERM;
89726 @@ -1260,6 +1380,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
89727 locked += mm->locked_vm;
89728 lock_limit = rlimit(RLIMIT_MEMLOCK);
89729 lock_limit >>= PAGE_SHIFT;
89730 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
89731 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
89732 return -EAGAIN;
89733 }
89734 @@ -1344,6 +1465,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
89735 vm_flags |= VM_NORESERVE;
89736 }
89737
89738 + if (!gr_acl_handle_mmap(file, prot))
89739 + return -EACCES;
89740 +
89741 addr = mmap_region(file, addr, len, vm_flags, pgoff);
89742 if (!IS_ERR_VALUE(addr) &&
89743 ((vm_flags & VM_LOCKED) ||
89744 @@ -1437,7 +1561,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
89745 vm_flags_t vm_flags = vma->vm_flags;
89746
89747 /* If it was private or non-writable, the write bit is already clear */
89748 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
89749 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
89750 return 0;
89751
89752 /* The backer wishes to know when pages are first written to? */
89753 @@ -1483,7 +1607,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
89754 struct rb_node **rb_link, *rb_parent;
89755 unsigned long charged = 0;
89756
89757 +#ifdef CONFIG_PAX_SEGMEXEC
89758 + struct vm_area_struct *vma_m = NULL;
89759 +#endif
89760 +
89761 + /*
89762 + * mm->mmap_sem is required to protect against another thread
89763 + * changing the mappings in case we sleep.
89764 + */
89765 + verify_mm_writelocked(mm);
89766 +
89767 /* Check against address space limit. */
89768 +
89769 +#ifdef CONFIG_PAX_RANDMMAP
89770 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
89771 +#endif
89772 +
89773 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
89774 unsigned long nr_pages;
89775
89776 @@ -1502,11 +1641,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
89777
89778 /* Clear old maps */
89779 error = -ENOMEM;
89780 -munmap_back:
89781 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
89782 if (do_munmap(mm, addr, len))
89783 return -ENOMEM;
89784 - goto munmap_back;
89785 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
89786 }
89787
89788 /*
89789 @@ -1537,6 +1675,16 @@ munmap_back:
89790 goto unacct_error;
89791 }
89792
89793 +#ifdef CONFIG_PAX_SEGMEXEC
89794 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
89795 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89796 + if (!vma_m) {
89797 + error = -ENOMEM;
89798 + goto free_vma;
89799 + }
89800 + }
89801 +#endif
89802 +
89803 vma->vm_mm = mm;
89804 vma->vm_start = addr;
89805 vma->vm_end = addr + len;
89806 @@ -1556,6 +1704,13 @@ munmap_back:
89807 if (error)
89808 goto unmap_and_free_vma;
89809
89810 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
89811 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
89812 + vma->vm_flags |= VM_PAGEEXEC;
89813 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
89814 + }
89815 +#endif
89816 +
89817 /* Can addr have changed??
89818 *
89819 * Answer: Yes, several device drivers can do it in their
89820 @@ -1589,6 +1744,12 @@ munmap_back:
89821 }
89822
89823 vma_link(mm, vma, prev, rb_link, rb_parent);
89824 +
89825 +#ifdef CONFIG_PAX_SEGMEXEC
89826 + if (vma_m)
89827 + BUG_ON(pax_mirror_vma(vma_m, vma));
89828 +#endif
89829 +
89830 /* Once vma denies write, undo our temporary denial count */
89831 if (vm_flags & VM_DENYWRITE)
89832 allow_write_access(file);
89833 @@ -1597,6 +1758,7 @@ out:
89834 perf_event_mmap(vma);
89835
89836 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
89837 + track_exec_limit(mm, addr, addr + len, vm_flags);
89838 if (vm_flags & VM_LOCKED) {
89839 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
89840 vma == get_gate_vma(current->mm)))
89841 @@ -1629,6 +1791,12 @@ unmap_and_free_vma:
89842 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
89843 charged = 0;
89844 free_vma:
89845 +
89846 +#ifdef CONFIG_PAX_SEGMEXEC
89847 + if (vma_m)
89848 + kmem_cache_free(vm_area_cachep, vma_m);
89849 +#endif
89850 +
89851 kmem_cache_free(vm_area_cachep, vma);
89852 unacct_error:
89853 if (charged)
89854 @@ -1636,7 +1804,63 @@ unacct_error:
89855 return error;
89856 }
89857
89858 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
89859 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
89860 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
89861 +{
89862 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
89863 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
89864 +
89865 + return 0;
89866 +}
89867 +#endif
89868 +
89869 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
89870 +{
89871 + if (!vma) {
89872 +#ifdef CONFIG_STACK_GROWSUP
89873 + if (addr > sysctl_heap_stack_gap)
89874 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
89875 + else
89876 + vma = find_vma(current->mm, 0);
89877 + if (vma && (vma->vm_flags & VM_GROWSUP))
89878 + return false;
89879 +#endif
89880 + return true;
89881 + }
89882 +
89883 + if (addr + len > vma->vm_start)
89884 + return false;
89885 +
89886 + if (vma->vm_flags & VM_GROWSDOWN)
89887 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
89888 +#ifdef CONFIG_STACK_GROWSUP
89889 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
89890 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
89891 +#endif
89892 + else if (offset)
89893 + return offset <= vma->vm_start - addr - len;
89894 +
89895 + return true;
89896 +}
89897 +
89898 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
89899 +{
89900 + if (vma->vm_start < len)
89901 + return -ENOMEM;
89902 +
89903 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
89904 + if (offset <= vma->vm_start - len)
89905 + return vma->vm_start - len - offset;
89906 + else
89907 + return -ENOMEM;
89908 + }
89909 +
89910 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
89911 + return vma->vm_start - len - sysctl_heap_stack_gap;
89912 + return -ENOMEM;
89913 +}
89914 +
89915 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
89916 {
89917 /*
89918 * We implement the search by looking for an rbtree node that
89919 @@ -1684,11 +1908,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
89920 }
89921 }
89922
89923 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
89924 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
89925 check_current:
89926 /* Check if current node has a suitable gap */
89927 if (gap_start > high_limit)
89928 return -ENOMEM;
89929 +
89930 + if (gap_end - gap_start > info->threadstack_offset)
89931 + gap_start += info->threadstack_offset;
89932 + else
89933 + gap_start = gap_end;
89934 +
89935 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
89936 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89937 + gap_start += sysctl_heap_stack_gap;
89938 + else
89939 + gap_start = gap_end;
89940 + }
89941 + if (vma->vm_flags & VM_GROWSDOWN) {
89942 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89943 + gap_end -= sysctl_heap_stack_gap;
89944 + else
89945 + gap_end = gap_start;
89946 + }
89947 if (gap_end >= low_limit && gap_end - gap_start >= length)
89948 goto found;
89949
89950 @@ -1738,7 +1980,7 @@ found:
89951 return gap_start;
89952 }
89953
89954 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
89955 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
89956 {
89957 struct mm_struct *mm = current->mm;
89958 struct vm_area_struct *vma;
89959 @@ -1792,6 +2034,24 @@ check_current:
89960 gap_end = vma->vm_start;
89961 if (gap_end < low_limit)
89962 return -ENOMEM;
89963 +
89964 + if (gap_end - gap_start > info->threadstack_offset)
89965 + gap_end -= info->threadstack_offset;
89966 + else
89967 + gap_end = gap_start;
89968 +
89969 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
89970 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89971 + gap_start += sysctl_heap_stack_gap;
89972 + else
89973 + gap_start = gap_end;
89974 + }
89975 + if (vma->vm_flags & VM_GROWSDOWN) {
89976 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89977 + gap_end -= sysctl_heap_stack_gap;
89978 + else
89979 + gap_end = gap_start;
89980 + }
89981 if (gap_start <= high_limit && gap_end - gap_start >= length)
89982 goto found;
89983
89984 @@ -1855,6 +2115,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
89985 struct mm_struct *mm = current->mm;
89986 struct vm_area_struct *vma;
89987 struct vm_unmapped_area_info info;
89988 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
89989
89990 if (len > TASK_SIZE - mmap_min_addr)
89991 return -ENOMEM;
89992 @@ -1862,19 +2123,30 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
89993 if (flags & MAP_FIXED)
89994 return addr;
89995
89996 +#ifdef CONFIG_PAX_RANDMMAP
89997 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
89998 +#endif
89999 +
90000 if (addr) {
90001 addr = PAGE_ALIGN(addr);
90002 vma = find_vma(mm, addr);
90003 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
90004 - (!vma || addr + len <= vma->vm_start))
90005 + check_heap_stack_gap(vma, addr, len, offset))
90006 return addr;
90007 }
90008
90009 info.flags = 0;
90010 info.length = len;
90011 info.low_limit = TASK_UNMAPPED_BASE;
90012 +
90013 +#ifdef CONFIG_PAX_RANDMMAP
90014 + if (mm->pax_flags & MF_PAX_RANDMMAP)
90015 + info.low_limit += mm->delta_mmap;
90016 +#endif
90017 +
90018 info.high_limit = TASK_SIZE;
90019 info.align_mask = 0;
90020 + info.threadstack_offset = offset;
90021 return vm_unmapped_area(&info);
90022 }
90023 #endif
90024 @@ -1893,6 +2165,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
90025 struct mm_struct *mm = current->mm;
90026 unsigned long addr = addr0;
90027 struct vm_unmapped_area_info info;
90028 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
90029
90030 /* requested length too big for entire address space */
90031 if (len > TASK_SIZE - mmap_min_addr)
90032 @@ -1901,12 +2174,16 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
90033 if (flags & MAP_FIXED)
90034 return addr;
90035
90036 +#ifdef CONFIG_PAX_RANDMMAP
90037 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
90038 +#endif
90039 +
90040 /* requesting a specific address */
90041 if (addr) {
90042 addr = PAGE_ALIGN(addr);
90043 vma = find_vma(mm, addr);
90044 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
90045 - (!vma || addr + len <= vma->vm_start))
90046 + check_heap_stack_gap(vma, addr, len, offset))
90047 return addr;
90048 }
90049
90050 @@ -1915,6 +2192,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
90051 info.low_limit = max(PAGE_SIZE, mmap_min_addr);
90052 info.high_limit = mm->mmap_base;
90053 info.align_mask = 0;
90054 + info.threadstack_offset = offset;
90055 addr = vm_unmapped_area(&info);
90056
90057 /*
90058 @@ -1927,6 +2205,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
90059 VM_BUG_ON(addr != -ENOMEM);
90060 info.flags = 0;
90061 info.low_limit = TASK_UNMAPPED_BASE;
90062 +
90063 +#ifdef CONFIG_PAX_RANDMMAP
90064 + if (mm->pax_flags & MF_PAX_RANDMMAP)
90065 + info.low_limit += mm->delta_mmap;
90066 +#endif
90067 +
90068 info.high_limit = TASK_SIZE;
90069 addr = vm_unmapped_area(&info);
90070 }
90071 @@ -2028,6 +2312,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
90072 return vma;
90073 }
90074
90075 +#ifdef CONFIG_PAX_SEGMEXEC
90076 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
90077 +{
90078 + struct vm_area_struct *vma_m;
90079 +
90080 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
90081 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
90082 + BUG_ON(vma->vm_mirror);
90083 + return NULL;
90084 + }
90085 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
90086 + vma_m = vma->vm_mirror;
90087 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
90088 + BUG_ON(vma->vm_file != vma_m->vm_file);
90089 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
90090 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
90091 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
90092 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
90093 + return vma_m;
90094 +}
90095 +#endif
90096 +
90097 /*
90098 * Verify that the stack growth is acceptable and
90099 * update accounting. This is shared with both the
90100 @@ -2044,6 +2350,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
90101 return -ENOMEM;
90102
90103 /* Stack limit test */
90104 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
90105 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
90106 return -ENOMEM;
90107
90108 @@ -2054,6 +2361,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
90109 locked = mm->locked_vm + grow;
90110 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
90111 limit >>= PAGE_SHIFT;
90112 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
90113 if (locked > limit && !capable(CAP_IPC_LOCK))
90114 return -ENOMEM;
90115 }
90116 @@ -2083,37 +2391,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
90117 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
90118 * vma is the last one with address > vma->vm_end. Have to extend vma.
90119 */
90120 +#ifndef CONFIG_IA64
90121 +static
90122 +#endif
90123 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
90124 {
90125 int error;
90126 + bool locknext;
90127
90128 if (!(vma->vm_flags & VM_GROWSUP))
90129 return -EFAULT;
90130
90131 + /* Also guard against wrapping around to address 0. */
90132 + if (address < PAGE_ALIGN(address+1))
90133 + address = PAGE_ALIGN(address+1);
90134 + else
90135 + return -ENOMEM;
90136 +
90137 /*
90138 * We must make sure the anon_vma is allocated
90139 * so that the anon_vma locking is not a noop.
90140 */
90141 if (unlikely(anon_vma_prepare(vma)))
90142 return -ENOMEM;
90143 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
90144 + if (locknext && anon_vma_prepare(vma->vm_next))
90145 + return -ENOMEM;
90146 vma_lock_anon_vma(vma);
90147 + if (locknext)
90148 + vma_lock_anon_vma(vma->vm_next);
90149
90150 /*
90151 * vma->vm_start/vm_end cannot change under us because the caller
90152 * is required to hold the mmap_sem in read mode. We need the
90153 - * anon_vma lock to serialize against concurrent expand_stacks.
90154 - * Also guard against wrapping around to address 0.
90155 + * anon_vma locks to serialize against concurrent expand_stacks
90156 + * and expand_upwards.
90157 */
90158 - if (address < PAGE_ALIGN(address+4))
90159 - address = PAGE_ALIGN(address+4);
90160 - else {
90161 - vma_unlock_anon_vma(vma);
90162 - return -ENOMEM;
90163 - }
90164 error = 0;
90165
90166 /* Somebody else might have raced and expanded it already */
90167 - if (address > vma->vm_end) {
90168 + 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)
90169 + error = -ENOMEM;
90170 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
90171 unsigned long size, grow;
90172
90173 size = address - vma->vm_start;
90174 @@ -2148,6 +2467,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
90175 }
90176 }
90177 }
90178 + if (locknext)
90179 + vma_unlock_anon_vma(vma->vm_next);
90180 vma_unlock_anon_vma(vma);
90181 khugepaged_enter_vma_merge(vma);
90182 validate_mm(vma->vm_mm);
90183 @@ -2162,6 +2483,8 @@ int expand_downwards(struct vm_area_struct *vma,
90184 unsigned long address)
90185 {
90186 int error;
90187 + bool lockprev = false;
90188 + struct vm_area_struct *prev;
90189
90190 /*
90191 * We must make sure the anon_vma is allocated
90192 @@ -2175,6 +2498,15 @@ int expand_downwards(struct vm_area_struct *vma,
90193 if (error)
90194 return error;
90195
90196 + prev = vma->vm_prev;
90197 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
90198 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
90199 +#endif
90200 + if (lockprev && anon_vma_prepare(prev))
90201 + return -ENOMEM;
90202 + if (lockprev)
90203 + vma_lock_anon_vma(prev);
90204 +
90205 vma_lock_anon_vma(vma);
90206
90207 /*
90208 @@ -2184,9 +2516,17 @@ int expand_downwards(struct vm_area_struct *vma,
90209 */
90210
90211 /* Somebody else might have raced and expanded it already */
90212 - if (address < vma->vm_start) {
90213 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
90214 + error = -ENOMEM;
90215 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
90216 unsigned long size, grow;
90217
90218 +#ifdef CONFIG_PAX_SEGMEXEC
90219 + struct vm_area_struct *vma_m;
90220 +
90221 + vma_m = pax_find_mirror_vma(vma);
90222 +#endif
90223 +
90224 size = vma->vm_end - address;
90225 grow = (vma->vm_start - address) >> PAGE_SHIFT;
90226
90227 @@ -2211,13 +2551,27 @@ int expand_downwards(struct vm_area_struct *vma,
90228 vma->vm_pgoff -= grow;
90229 anon_vma_interval_tree_post_update_vma(vma);
90230 vma_gap_update(vma);
90231 +
90232 +#ifdef CONFIG_PAX_SEGMEXEC
90233 + if (vma_m) {
90234 + anon_vma_interval_tree_pre_update_vma(vma_m);
90235 + vma_m->vm_start -= grow << PAGE_SHIFT;
90236 + vma_m->vm_pgoff -= grow;
90237 + anon_vma_interval_tree_post_update_vma(vma_m);
90238 + vma_gap_update(vma_m);
90239 + }
90240 +#endif
90241 +
90242 spin_unlock(&vma->vm_mm->page_table_lock);
90243
90244 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
90245 perf_event_mmap(vma);
90246 }
90247 }
90248 }
90249 vma_unlock_anon_vma(vma);
90250 + if (lockprev)
90251 + vma_unlock_anon_vma(prev);
90252 khugepaged_enter_vma_merge(vma);
90253 validate_mm(vma->vm_mm);
90254 return error;
90255 @@ -2315,6 +2669,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
90256 do {
90257 long nrpages = vma_pages(vma);
90258
90259 +#ifdef CONFIG_PAX_SEGMEXEC
90260 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
90261 + vma = remove_vma(vma);
90262 + continue;
90263 + }
90264 +#endif
90265 +
90266 if (vma->vm_flags & VM_ACCOUNT)
90267 nr_accounted += nrpages;
90268 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
90269 @@ -2359,6 +2720,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
90270 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
90271 vma->vm_prev = NULL;
90272 do {
90273 +
90274 +#ifdef CONFIG_PAX_SEGMEXEC
90275 + if (vma->vm_mirror) {
90276 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
90277 + vma->vm_mirror->vm_mirror = NULL;
90278 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
90279 + vma->vm_mirror = NULL;
90280 + }
90281 +#endif
90282 +
90283 vma_rb_erase(vma, &mm->mm_rb);
90284 mm->map_count--;
90285 tail_vma = vma;
90286 @@ -2384,14 +2755,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
90287 struct vm_area_struct *new;
90288 int err = -ENOMEM;
90289
90290 +#ifdef CONFIG_PAX_SEGMEXEC
90291 + struct vm_area_struct *vma_m, *new_m = NULL;
90292 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
90293 +#endif
90294 +
90295 if (is_vm_hugetlb_page(vma) && (addr &
90296 ~(huge_page_mask(hstate_vma(vma)))))
90297 return -EINVAL;
90298
90299 +#ifdef CONFIG_PAX_SEGMEXEC
90300 + vma_m = pax_find_mirror_vma(vma);
90301 +#endif
90302 +
90303 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
90304 if (!new)
90305 goto out_err;
90306
90307 +#ifdef CONFIG_PAX_SEGMEXEC
90308 + if (vma_m) {
90309 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
90310 + if (!new_m) {
90311 + kmem_cache_free(vm_area_cachep, new);
90312 + goto out_err;
90313 + }
90314 + }
90315 +#endif
90316 +
90317 /* most fields are the same, copy all, and then fixup */
90318 *new = *vma;
90319
90320 @@ -2404,6 +2794,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
90321 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
90322 }
90323
90324 +#ifdef CONFIG_PAX_SEGMEXEC
90325 + if (vma_m) {
90326 + *new_m = *vma_m;
90327 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
90328 + new_m->vm_mirror = new;
90329 + new->vm_mirror = new_m;
90330 +
90331 + if (new_below)
90332 + new_m->vm_end = addr_m;
90333 + else {
90334 + new_m->vm_start = addr_m;
90335 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
90336 + }
90337 + }
90338 +#endif
90339 +
90340 err = vma_dup_policy(vma, new);
90341 if (err)
90342 goto out_free_vma;
90343 @@ -2423,6 +2829,38 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
90344 else
90345 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
90346
90347 +#ifdef CONFIG_PAX_SEGMEXEC
90348 + if (!err && vma_m) {
90349 + struct mempolicy *pol = vma_policy(new);
90350 +
90351 + if (anon_vma_clone(new_m, vma_m))
90352 + goto out_free_mpol;
90353 +
90354 + mpol_get(pol);
90355 + set_vma_policy(new_m, pol);
90356 +
90357 + if (new_m->vm_file)
90358 + get_file(new_m->vm_file);
90359 +
90360 + if (new_m->vm_ops && new_m->vm_ops->open)
90361 + new_m->vm_ops->open(new_m);
90362 +
90363 + if (new_below)
90364 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
90365 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
90366 + else
90367 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
90368 +
90369 + if (err) {
90370 + if (new_m->vm_ops && new_m->vm_ops->close)
90371 + new_m->vm_ops->close(new_m);
90372 + if (new_m->vm_file)
90373 + fput(new_m->vm_file);
90374 + mpol_put(pol);
90375 + }
90376 + }
90377 +#endif
90378 +
90379 /* Success. */
90380 if (!err)
90381 return 0;
90382 @@ -2432,10 +2870,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
90383 new->vm_ops->close(new);
90384 if (new->vm_file)
90385 fput(new->vm_file);
90386 - unlink_anon_vmas(new);
90387 out_free_mpol:
90388 mpol_put(vma_policy(new));
90389 out_free_vma:
90390 +
90391 +#ifdef CONFIG_PAX_SEGMEXEC
90392 + if (new_m) {
90393 + unlink_anon_vmas(new_m);
90394 + kmem_cache_free(vm_area_cachep, new_m);
90395 + }
90396 +#endif
90397 +
90398 + unlink_anon_vmas(new);
90399 kmem_cache_free(vm_area_cachep, new);
90400 out_err:
90401 return err;
90402 @@ -2448,6 +2894,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
90403 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
90404 unsigned long addr, int new_below)
90405 {
90406 +
90407 +#ifdef CONFIG_PAX_SEGMEXEC
90408 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
90409 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
90410 + if (mm->map_count >= sysctl_max_map_count-1)
90411 + return -ENOMEM;
90412 + } else
90413 +#endif
90414 +
90415 if (mm->map_count >= sysctl_max_map_count)
90416 return -ENOMEM;
90417
90418 @@ -2459,11 +2914,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
90419 * work. This now handles partial unmappings.
90420 * Jeremy Fitzhardinge <jeremy@goop.org>
90421 */
90422 +#ifdef CONFIG_PAX_SEGMEXEC
90423 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
90424 {
90425 + int ret = __do_munmap(mm, start, len);
90426 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
90427 + return ret;
90428 +
90429 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
90430 +}
90431 +
90432 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
90433 +#else
90434 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
90435 +#endif
90436 +{
90437 unsigned long end;
90438 struct vm_area_struct *vma, *prev, *last;
90439
90440 + /*
90441 + * mm->mmap_sem is required to protect against another thread
90442 + * changing the mappings in case we sleep.
90443 + */
90444 + verify_mm_writelocked(mm);
90445 +
90446 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
90447 return -EINVAL;
90448
90449 @@ -2538,6 +3012,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
90450 /* Fix up all other VM information */
90451 remove_vma_list(mm, vma);
90452
90453 + track_exec_limit(mm, start, end, 0UL);
90454 +
90455 return 0;
90456 }
90457
90458 @@ -2546,6 +3022,13 @@ int vm_munmap(unsigned long start, size_t len)
90459 int ret;
90460 struct mm_struct *mm = current->mm;
90461
90462 +
90463 +#ifdef CONFIG_PAX_SEGMEXEC
90464 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
90465 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
90466 + return -EINVAL;
90467 +#endif
90468 +
90469 down_write(&mm->mmap_sem);
90470 ret = do_munmap(mm, start, len);
90471 up_write(&mm->mmap_sem);
90472 @@ -2559,16 +3042,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
90473 return vm_munmap(addr, len);
90474 }
90475
90476 -static inline void verify_mm_writelocked(struct mm_struct *mm)
90477 -{
90478 -#ifdef CONFIG_DEBUG_VM
90479 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
90480 - WARN_ON(1);
90481 - up_read(&mm->mmap_sem);
90482 - }
90483 -#endif
90484 -}
90485 -
90486 /*
90487 * this is really a simplified "do_mmap". it only handles
90488 * anonymous maps. eventually we may be able to do some
90489 @@ -2582,6 +3055,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
90490 struct rb_node ** rb_link, * rb_parent;
90491 pgoff_t pgoff = addr >> PAGE_SHIFT;
90492 int error;
90493 + unsigned long charged;
90494
90495 len = PAGE_ALIGN(len);
90496 if (!len)
90497 @@ -2589,16 +3063,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
90498
90499 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
90500
90501 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
90502 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
90503 + flags &= ~VM_EXEC;
90504 +
90505 +#ifdef CONFIG_PAX_MPROTECT
90506 + if (mm->pax_flags & MF_PAX_MPROTECT)
90507 + flags &= ~VM_MAYEXEC;
90508 +#endif
90509 +
90510 + }
90511 +#endif
90512 +
90513 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
90514 if (error & ~PAGE_MASK)
90515 return error;
90516
90517 + charged = len >> PAGE_SHIFT;
90518 +
90519 /*
90520 * mlock MCL_FUTURE?
90521 */
90522 if (mm->def_flags & VM_LOCKED) {
90523 unsigned long locked, lock_limit;
90524 - locked = len >> PAGE_SHIFT;
90525 + locked = charged;
90526 locked += mm->locked_vm;
90527 lock_limit = rlimit(RLIMIT_MEMLOCK);
90528 lock_limit >>= PAGE_SHIFT;
90529 @@ -2615,21 +3103,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
90530 /*
90531 * Clear old maps. this also does some error checking for us
90532 */
90533 - munmap_back:
90534 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
90535 if (do_munmap(mm, addr, len))
90536 return -ENOMEM;
90537 - goto munmap_back;
90538 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
90539 }
90540
90541 /* Check against address space limits *after* clearing old maps... */
90542 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
90543 + if (!may_expand_vm(mm, charged))
90544 return -ENOMEM;
90545
90546 if (mm->map_count > sysctl_max_map_count)
90547 return -ENOMEM;
90548
90549 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
90550 + if (security_vm_enough_memory_mm(mm, charged))
90551 return -ENOMEM;
90552
90553 /* Can we just expand an old private anonymous mapping? */
90554 @@ -2643,7 +3130,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
90555 */
90556 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
90557 if (!vma) {
90558 - vm_unacct_memory(len >> PAGE_SHIFT);
90559 + vm_unacct_memory(charged);
90560 return -ENOMEM;
90561 }
90562
90563 @@ -2657,10 +3144,11 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
90564 vma_link(mm, vma, prev, rb_link, rb_parent);
90565 out:
90566 perf_event_mmap(vma);
90567 - mm->total_vm += len >> PAGE_SHIFT;
90568 + mm->total_vm += charged;
90569 if (flags & VM_LOCKED)
90570 - mm->locked_vm += (len >> PAGE_SHIFT);
90571 + mm->locked_vm += charged;
90572 vma->vm_flags |= VM_SOFTDIRTY;
90573 + track_exec_limit(mm, addr, addr + len, flags);
90574 return addr;
90575 }
90576
90577 @@ -2722,6 +3210,7 @@ void exit_mmap(struct mm_struct *mm)
90578 while (vma) {
90579 if (vma->vm_flags & VM_ACCOUNT)
90580 nr_accounted += vma_pages(vma);
90581 + vma->vm_mirror = NULL;
90582 vma = remove_vma(vma);
90583 }
90584 vm_unacct_memory(nr_accounted);
90585 @@ -2738,6 +3227,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
90586 struct vm_area_struct *prev;
90587 struct rb_node **rb_link, *rb_parent;
90588
90589 +#ifdef CONFIG_PAX_SEGMEXEC
90590 + struct vm_area_struct *vma_m = NULL;
90591 +#endif
90592 +
90593 + if (security_mmap_addr(vma->vm_start))
90594 + return -EPERM;
90595 +
90596 /*
90597 * The vm_pgoff of a purely anonymous vma should be irrelevant
90598 * until its first write fault, when page's anon_vma and index
90599 @@ -2761,7 +3257,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
90600 security_vm_enough_memory_mm(mm, vma_pages(vma)))
90601 return -ENOMEM;
90602
90603 +#ifdef CONFIG_PAX_SEGMEXEC
90604 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
90605 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
90606 + if (!vma_m)
90607 + return -ENOMEM;
90608 + }
90609 +#endif
90610 +
90611 vma_link(mm, vma, prev, rb_link, rb_parent);
90612 +
90613 +#ifdef CONFIG_PAX_SEGMEXEC
90614 + if (vma_m)
90615 + BUG_ON(pax_mirror_vma(vma_m, vma));
90616 +#endif
90617 +
90618 return 0;
90619 }
90620
90621 @@ -2780,6 +3290,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
90622 struct rb_node **rb_link, *rb_parent;
90623 bool faulted_in_anon_vma = true;
90624
90625 + BUG_ON(vma->vm_mirror);
90626 +
90627 /*
90628 * If anonymous vma has not yet been faulted, update new pgoff
90629 * to match new location, to increase its chance of merging.
90630 @@ -2844,6 +3356,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
90631 return NULL;
90632 }
90633
90634 +#ifdef CONFIG_PAX_SEGMEXEC
90635 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
90636 +{
90637 + struct vm_area_struct *prev_m;
90638 + struct rb_node **rb_link_m, *rb_parent_m;
90639 + struct mempolicy *pol_m;
90640 +
90641 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
90642 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
90643 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
90644 + *vma_m = *vma;
90645 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
90646 + if (anon_vma_clone(vma_m, vma))
90647 + return -ENOMEM;
90648 + pol_m = vma_policy(vma_m);
90649 + mpol_get(pol_m);
90650 + set_vma_policy(vma_m, pol_m);
90651 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
90652 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
90653 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
90654 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
90655 + if (vma_m->vm_file)
90656 + get_file(vma_m->vm_file);
90657 + if (vma_m->vm_ops && vma_m->vm_ops->open)
90658 + vma_m->vm_ops->open(vma_m);
90659 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
90660 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
90661 + vma_m->vm_mirror = vma;
90662 + vma->vm_mirror = vma_m;
90663 + return 0;
90664 +}
90665 +#endif
90666 +
90667 /*
90668 * Return true if the calling process may expand its vm space by the passed
90669 * number of pages
90670 @@ -2855,6 +3400,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
90671
90672 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
90673
90674 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
90675 if (cur + npages > lim)
90676 return 0;
90677 return 1;
90678 @@ -2925,6 +3471,22 @@ int install_special_mapping(struct mm_struct *mm,
90679 vma->vm_start = addr;
90680 vma->vm_end = addr + len;
90681
90682 +#ifdef CONFIG_PAX_MPROTECT
90683 + if (mm->pax_flags & MF_PAX_MPROTECT) {
90684 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
90685 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
90686 + return -EPERM;
90687 + if (!(vm_flags & VM_EXEC))
90688 + vm_flags &= ~VM_MAYEXEC;
90689 +#else
90690 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
90691 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
90692 +#endif
90693 + else
90694 + vm_flags &= ~VM_MAYWRITE;
90695 + }
90696 +#endif
90697 +
90698 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND | VM_SOFTDIRTY;
90699 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
90700
90701 diff --git a/mm/mprotect.c b/mm/mprotect.c
90702 index 7651a57..d761c62 100644
90703 --- a/mm/mprotect.c
90704 +++ b/mm/mprotect.c
90705 @@ -23,10 +23,18 @@
90706 #include <linux/mmu_notifier.h>
90707 #include <linux/migrate.h>
90708 #include <linux/perf_event.h>
90709 +#include <linux/sched/sysctl.h>
90710 +
90711 +#ifdef CONFIG_PAX_MPROTECT
90712 +#include <linux/elf.h>
90713 +#include <linux/binfmts.h>
90714 +#endif
90715 +
90716 #include <asm/uaccess.h>
90717 #include <asm/pgtable.h>
90718 #include <asm/cacheflush.h>
90719 #include <asm/tlbflush.h>
90720 +#include <asm/mmu_context.h>
90721
90722 #ifndef pgprot_modify
90723 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
90724 @@ -250,6 +258,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
90725 return pages;
90726 }
90727
90728 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
90729 +/* called while holding the mmap semaphor for writing except stack expansion */
90730 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
90731 +{
90732 + unsigned long oldlimit, newlimit = 0UL;
90733 +
90734 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
90735 + return;
90736 +
90737 + spin_lock(&mm->page_table_lock);
90738 + oldlimit = mm->context.user_cs_limit;
90739 + if ((prot & VM_EXEC) && oldlimit < end)
90740 + /* USER_CS limit moved up */
90741 + newlimit = end;
90742 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
90743 + /* USER_CS limit moved down */
90744 + newlimit = start;
90745 +
90746 + if (newlimit) {
90747 + mm->context.user_cs_limit = newlimit;
90748 +
90749 +#ifdef CONFIG_SMP
90750 + wmb();
90751 + cpus_clear(mm->context.cpu_user_cs_mask);
90752 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
90753 +#endif
90754 +
90755 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
90756 + }
90757 + spin_unlock(&mm->page_table_lock);
90758 + if (newlimit == end) {
90759 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
90760 +
90761 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
90762 + if (is_vm_hugetlb_page(vma))
90763 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
90764 + else
90765 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
90766 + }
90767 +}
90768 +#endif
90769 +
90770 int
90771 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
90772 unsigned long start, unsigned long end, unsigned long newflags)
90773 @@ -262,11 +312,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
90774 int error;
90775 int dirty_accountable = 0;
90776
90777 +#ifdef CONFIG_PAX_SEGMEXEC
90778 + struct vm_area_struct *vma_m = NULL;
90779 + unsigned long start_m, end_m;
90780 +
90781 + start_m = start + SEGMEXEC_TASK_SIZE;
90782 + end_m = end + SEGMEXEC_TASK_SIZE;
90783 +#endif
90784 +
90785 if (newflags == oldflags) {
90786 *pprev = vma;
90787 return 0;
90788 }
90789
90790 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
90791 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
90792 +
90793 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
90794 + return -ENOMEM;
90795 +
90796 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
90797 + return -ENOMEM;
90798 + }
90799 +
90800 /*
90801 * If we make a private mapping writable we increase our commit;
90802 * but (without finer accounting) cannot reduce our commit if we
90803 @@ -283,6 +351,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
90804 }
90805 }
90806
90807 +#ifdef CONFIG_PAX_SEGMEXEC
90808 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
90809 + if (start != vma->vm_start) {
90810 + error = split_vma(mm, vma, start, 1);
90811 + if (error)
90812 + goto fail;
90813 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
90814 + *pprev = (*pprev)->vm_next;
90815 + }
90816 +
90817 + if (end != vma->vm_end) {
90818 + error = split_vma(mm, vma, end, 0);
90819 + if (error)
90820 + goto fail;
90821 + }
90822 +
90823 + if (pax_find_mirror_vma(vma)) {
90824 + error = __do_munmap(mm, start_m, end_m - start_m);
90825 + if (error)
90826 + goto fail;
90827 + } else {
90828 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
90829 + if (!vma_m) {
90830 + error = -ENOMEM;
90831 + goto fail;
90832 + }
90833 + vma->vm_flags = newflags;
90834 + error = pax_mirror_vma(vma_m, vma);
90835 + if (error) {
90836 + vma->vm_flags = oldflags;
90837 + goto fail;
90838 + }
90839 + }
90840 + }
90841 +#endif
90842 +
90843 /*
90844 * First try to merge with previous and/or next vma.
90845 */
90846 @@ -313,9 +417,21 @@ success:
90847 * vm_flags and vm_page_prot are protected by the mmap_sem
90848 * held in write mode.
90849 */
90850 +
90851 +#ifdef CONFIG_PAX_SEGMEXEC
90852 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
90853 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
90854 +#endif
90855 +
90856 vma->vm_flags = newflags;
90857 +
90858 +#ifdef CONFIG_PAX_MPROTECT
90859 + if (mm->binfmt && mm->binfmt->handle_mprotect)
90860 + mm->binfmt->handle_mprotect(vma, newflags);
90861 +#endif
90862 +
90863 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
90864 - vm_get_page_prot(newflags));
90865 + vm_get_page_prot(vma->vm_flags));
90866
90867 if (vma_wants_writenotify(vma)) {
90868 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
90869 @@ -354,6 +470,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90870 end = start + len;
90871 if (end <= start)
90872 return -ENOMEM;
90873 +
90874 +#ifdef CONFIG_PAX_SEGMEXEC
90875 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
90876 + if (end > SEGMEXEC_TASK_SIZE)
90877 + return -EINVAL;
90878 + } else
90879 +#endif
90880 +
90881 + if (end > TASK_SIZE)
90882 + return -EINVAL;
90883 +
90884 if (!arch_validate_prot(prot))
90885 return -EINVAL;
90886
90887 @@ -361,7 +488,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90888 /*
90889 * Does the application expect PROT_READ to imply PROT_EXEC:
90890 */
90891 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
90892 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
90893 prot |= PROT_EXEC;
90894
90895 vm_flags = calc_vm_prot_bits(prot);
90896 @@ -393,6 +520,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90897 if (start > vma->vm_start)
90898 prev = vma;
90899
90900 +#ifdef CONFIG_PAX_MPROTECT
90901 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
90902 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
90903 +#endif
90904 +
90905 for (nstart = start ; ; ) {
90906 unsigned long newflags;
90907
90908 @@ -403,6 +535,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90909
90910 /* newflags >> 4 shift VM_MAY% in place of VM_% */
90911 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
90912 + if (prot & (PROT_WRITE | PROT_EXEC))
90913 + gr_log_rwxmprotect(vma);
90914 +
90915 + error = -EACCES;
90916 + goto out;
90917 + }
90918 +
90919 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
90920 error = -EACCES;
90921 goto out;
90922 }
90923 @@ -417,6 +557,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90924 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
90925 if (error)
90926 goto out;
90927 +
90928 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
90929 +
90930 nstart = tmp;
90931
90932 if (nstart < prev->vm_end)
90933 diff --git a/mm/mremap.c b/mm/mremap.c
90934 index 0843feb..4f5b2e6 100644
90935 --- a/mm/mremap.c
90936 +++ b/mm/mremap.c
90937 @@ -144,6 +144,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
90938 continue;
90939 pte = ptep_get_and_clear(mm, old_addr, old_pte);
90940 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
90941 +
90942 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
90943 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
90944 + pte = pte_exprotect(pte);
90945 +#endif
90946 +
90947 pte = move_soft_dirty_pte(pte);
90948 set_pte_at(mm, new_addr, new_pte, pte);
90949 }
90950 @@ -337,6 +343,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
90951 if (is_vm_hugetlb_page(vma))
90952 goto Einval;
90953
90954 +#ifdef CONFIG_PAX_SEGMEXEC
90955 + if (pax_find_mirror_vma(vma))
90956 + goto Einval;
90957 +#endif
90958 +
90959 /* We can't remap across vm area boundaries */
90960 if (old_len > vma->vm_end - addr)
90961 goto Efault;
90962 @@ -392,20 +403,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
90963 unsigned long ret = -EINVAL;
90964 unsigned long charged = 0;
90965 unsigned long map_flags;
90966 + unsigned long pax_task_size = TASK_SIZE;
90967
90968 if (new_addr & ~PAGE_MASK)
90969 goto out;
90970
90971 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
90972 +#ifdef CONFIG_PAX_SEGMEXEC
90973 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
90974 + pax_task_size = SEGMEXEC_TASK_SIZE;
90975 +#endif
90976 +
90977 + pax_task_size -= PAGE_SIZE;
90978 +
90979 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
90980 goto out;
90981
90982 /* Check if the location we're moving into overlaps the
90983 * old location at all, and fail if it does.
90984 */
90985 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
90986 - goto out;
90987 -
90988 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
90989 + if (addr + old_len > new_addr && new_addr + new_len > addr)
90990 goto out;
90991
90992 ret = do_munmap(mm, new_addr, new_len);
90993 @@ -474,6 +490,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90994 unsigned long ret = -EINVAL;
90995 unsigned long charged = 0;
90996 bool locked = false;
90997 + unsigned long pax_task_size = TASK_SIZE;
90998
90999 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
91000 return ret;
91001 @@ -495,6 +512,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
91002 if (!new_len)
91003 return ret;
91004
91005 +#ifdef CONFIG_PAX_SEGMEXEC
91006 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
91007 + pax_task_size = SEGMEXEC_TASK_SIZE;
91008 +#endif
91009 +
91010 + pax_task_size -= PAGE_SIZE;
91011 +
91012 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
91013 + old_len > pax_task_size || addr > pax_task_size-old_len)
91014 + return ret;
91015 +
91016 down_write(&current->mm->mmap_sem);
91017
91018 if (flags & MREMAP_FIXED) {
91019 @@ -545,6 +573,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
91020 new_addr = addr;
91021 }
91022 ret = addr;
91023 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
91024 goto out;
91025 }
91026 }
91027 @@ -568,7 +597,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
91028 goto out;
91029 }
91030
91031 + map_flags = vma->vm_flags;
91032 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
91033 + if (!(ret & ~PAGE_MASK)) {
91034 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
91035 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
91036 + }
91037 }
91038 out:
91039 if (ret & ~PAGE_MASK)
91040 diff --git a/mm/nommu.c b/mm/nommu.c
91041 index ecd1f15..77039bd 100644
91042 --- a/mm/nommu.c
91043 +++ b/mm/nommu.c
91044 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
91045 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
91046 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
91047 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
91048 -int heap_stack_gap = 0;
91049
91050 atomic_long_t mmap_pages_allocated;
91051
91052 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
91053 EXPORT_SYMBOL(find_vma);
91054
91055 /*
91056 - * find a VMA
91057 - * - we don't extend stack VMAs under NOMMU conditions
91058 - */
91059 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
91060 -{
91061 - return find_vma(mm, addr);
91062 -}
91063 -
91064 -/*
91065 * expand a stack to a given address
91066 * - not supported under NOMMU conditions
91067 */
91068 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
91069
91070 /* most fields are the same, copy all, and then fixup */
91071 *new = *vma;
91072 + INIT_LIST_HEAD(&new->anon_vma_chain);
91073 *region = *vma->vm_region;
91074 new->vm_region = region;
91075
91076 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
91077 }
91078 EXPORT_SYMBOL(generic_file_remap_pages);
91079
91080 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
91081 - unsigned long addr, void *buf, int len, int write)
91082 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
91083 + unsigned long addr, void *buf, size_t len, int write)
91084 {
91085 struct vm_area_struct *vma;
91086
91087 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
91088 *
91089 * The caller must hold a reference on @mm.
91090 */
91091 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
91092 - void *buf, int len, int write)
91093 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
91094 + void *buf, size_t len, int write)
91095 {
91096 return __access_remote_vm(NULL, mm, addr, buf, len, write);
91097 }
91098 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
91099 * Access another process' address space.
91100 * - source/target buffer must be kernel space
91101 */
91102 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
91103 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
91104 {
91105 struct mm_struct *mm;
91106
91107 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
91108 index 6380758..4064aec 100644
91109 --- a/mm/page-writeback.c
91110 +++ b/mm/page-writeback.c
91111 @@ -690,7 +690,7 @@ static inline long long pos_ratio_polynom(unsigned long setpoint,
91112 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
91113 * - the bdi dirty thresh drops quickly due to change of JBOD workload
91114 */
91115 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
91116 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
91117 unsigned long thresh,
91118 unsigned long bg_thresh,
91119 unsigned long dirty,
91120 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
91121 index 317ea74..a4a1977 100644
91122 --- a/mm/page_alloc.c
91123 +++ b/mm/page_alloc.c
91124 @@ -61,6 +61,7 @@
91125 #include <linux/page-debug-flags.h>
91126 #include <linux/hugetlb.h>
91127 #include <linux/sched/rt.h>
91128 +#include <linux/random.h>
91129
91130 #include <asm/sections.h>
91131 #include <asm/tlbflush.h>
91132 @@ -354,7 +355,7 @@ out:
91133 * This usage means that zero-order pages may not be compound.
91134 */
91135
91136 -static void free_compound_page(struct page *page)
91137 +void free_compound_page(struct page *page)
91138 {
91139 __free_pages_ok(page, compound_order(page));
91140 }
91141 @@ -712,6 +713,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
91142 int i;
91143 int bad = 0;
91144
91145 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91146 + unsigned long index = 1UL << order;
91147 +#endif
91148 +
91149 trace_mm_page_free(page, order);
91150 kmemcheck_free_shadow(page, order);
91151
91152 @@ -728,6 +733,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
91153 debug_check_no_obj_freed(page_address(page),
91154 PAGE_SIZE << order);
91155 }
91156 +
91157 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91158 + for (; index; --index)
91159 + sanitize_highpage(page + index - 1);
91160 +#endif
91161 +
91162 arch_free_page(page, order);
91163 kernel_map_pages(page, 1 << order, 0);
91164
91165 @@ -750,6 +761,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
91166 local_irq_restore(flags);
91167 }
91168
91169 +#ifdef CONFIG_PAX_LATENT_ENTROPY
91170 +bool __meminitdata extra_latent_entropy;
91171 +
91172 +static int __init setup_pax_extra_latent_entropy(char *str)
91173 +{
91174 + extra_latent_entropy = true;
91175 + return 0;
91176 +}
91177 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
91178 +
91179 +volatile u64 latent_entropy __latent_entropy;
91180 +EXPORT_SYMBOL(latent_entropy);
91181 +#endif
91182 +
91183 void __init __free_pages_bootmem(struct page *page, unsigned int order)
91184 {
91185 unsigned int nr_pages = 1 << order;
91186 @@ -765,6 +790,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
91187 __ClearPageReserved(p);
91188 set_page_count(p, 0);
91189
91190 +#ifdef CONFIG_PAX_LATENT_ENTROPY
91191 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
91192 + u64 hash = 0;
91193 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
91194 + const u64 *data = lowmem_page_address(page);
91195 +
91196 + for (index = 0; index < end; index++)
91197 + hash ^= hash + data[index];
91198 + latent_entropy ^= hash;
91199 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
91200 + }
91201 +#endif
91202 +
91203 page_zone(page)->managed_pages += nr_pages;
91204 set_page_refcounted(page);
91205 __free_pages(page, order);
91206 @@ -870,8 +908,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
91207 arch_alloc_page(page, order);
91208 kernel_map_pages(page, 1 << order, 1);
91209
91210 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
91211 if (gfp_flags & __GFP_ZERO)
91212 prep_zero_page(page, order, gfp_flags);
91213 +#endif
91214
91215 if (order && (gfp_flags & __GFP_COMP))
91216 prep_compound_page(page, order);
91217 diff --git a/mm/page_io.c b/mm/page_io.c
91218 index 8c79a47..a689e0d 100644
91219 --- a/mm/page_io.c
91220 +++ b/mm/page_io.c
91221 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
91222 struct file *swap_file = sis->swap_file;
91223 struct address_space *mapping = swap_file->f_mapping;
91224 struct iovec iov = {
91225 - .iov_base = kmap(page),
91226 + .iov_base = (void __force_user *)kmap(page),
91227 .iov_len = PAGE_SIZE,
91228 };
91229
91230 diff --git a/mm/percpu.c b/mm/percpu.c
91231 index 8c8e08f..73a5cda 100644
91232 --- a/mm/percpu.c
91233 +++ b/mm/percpu.c
91234 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
91235 static unsigned int pcpu_high_unit_cpu __read_mostly;
91236
91237 /* the address of the first chunk which starts with the kernel static area */
91238 -void *pcpu_base_addr __read_mostly;
91239 +void *pcpu_base_addr __read_only;
91240 EXPORT_SYMBOL_GPL(pcpu_base_addr);
91241
91242 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
91243 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
91244 index fd26d04..0cea1b0 100644
91245 --- a/mm/process_vm_access.c
91246 +++ b/mm/process_vm_access.c
91247 @@ -13,6 +13,7 @@
91248 #include <linux/uio.h>
91249 #include <linux/sched.h>
91250 #include <linux/highmem.h>
91251 +#include <linux/security.h>
91252 #include <linux/ptrace.h>
91253 #include <linux/slab.h>
91254 #include <linux/syscalls.h>
91255 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
91256 size_t iov_l_curr_offset = 0;
91257 ssize_t iov_len;
91258
91259 + return -ENOSYS; // PaX: until properly audited
91260 +
91261 /*
91262 * Work out how many pages of struct pages we're going to need
91263 * when eventually calling get_user_pages
91264 */
91265 for (i = 0; i < riovcnt; i++) {
91266 iov_len = rvec[i].iov_len;
91267 - if (iov_len > 0) {
91268 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
91269 - + iov_len)
91270 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
91271 - / PAGE_SIZE + 1;
91272 - nr_pages = max(nr_pages, nr_pages_iov);
91273 - }
91274 + if (iov_len <= 0)
91275 + continue;
91276 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
91277 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
91278 + nr_pages = max(nr_pages, nr_pages_iov);
91279 }
91280
91281 if (nr_pages == 0)
91282 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
91283 goto free_proc_pages;
91284 }
91285
91286 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
91287 + rc = -EPERM;
91288 + goto put_task_struct;
91289 + }
91290 +
91291 mm = mm_access(task, PTRACE_MODE_ATTACH);
91292 if (!mm || IS_ERR(mm)) {
91293 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
91294 diff --git a/mm/rmap.c b/mm/rmap.c
91295 index b9d2222..e4baa1f 100644
91296 --- a/mm/rmap.c
91297 +++ b/mm/rmap.c
91298 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
91299 struct anon_vma *anon_vma = vma->anon_vma;
91300 struct anon_vma_chain *avc;
91301
91302 +#ifdef CONFIG_PAX_SEGMEXEC
91303 + struct anon_vma_chain *avc_m = NULL;
91304 +#endif
91305 +
91306 might_sleep();
91307 if (unlikely(!anon_vma)) {
91308 struct mm_struct *mm = vma->vm_mm;
91309 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
91310 if (!avc)
91311 goto out_enomem;
91312
91313 +#ifdef CONFIG_PAX_SEGMEXEC
91314 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
91315 + if (!avc_m)
91316 + goto out_enomem_free_avc;
91317 +#endif
91318 +
91319 anon_vma = find_mergeable_anon_vma(vma);
91320 allocated = NULL;
91321 if (!anon_vma) {
91322 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
91323 /* page_table_lock to protect against threads */
91324 spin_lock(&mm->page_table_lock);
91325 if (likely(!vma->anon_vma)) {
91326 +
91327 +#ifdef CONFIG_PAX_SEGMEXEC
91328 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
91329 +
91330 + if (vma_m) {
91331 + BUG_ON(vma_m->anon_vma);
91332 + vma_m->anon_vma = anon_vma;
91333 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
91334 + avc_m = NULL;
91335 + }
91336 +#endif
91337 +
91338 vma->anon_vma = anon_vma;
91339 anon_vma_chain_link(vma, avc, anon_vma);
91340 allocated = NULL;
91341 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
91342
91343 if (unlikely(allocated))
91344 put_anon_vma(allocated);
91345 +
91346 +#ifdef CONFIG_PAX_SEGMEXEC
91347 + if (unlikely(avc_m))
91348 + anon_vma_chain_free(avc_m);
91349 +#endif
91350 +
91351 if (unlikely(avc))
91352 anon_vma_chain_free(avc);
91353 }
91354 return 0;
91355
91356 out_enomem_free_avc:
91357 +
91358 +#ifdef CONFIG_PAX_SEGMEXEC
91359 + if (avc_m)
91360 + anon_vma_chain_free(avc_m);
91361 +#endif
91362 +
91363 anon_vma_chain_free(avc);
91364 out_enomem:
91365 return -ENOMEM;
91366 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
91367 * Attach the anon_vmas from src to dst.
91368 * Returns 0 on success, -ENOMEM on failure.
91369 */
91370 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
91371 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
91372 {
91373 struct anon_vma_chain *avc, *pavc;
91374 struct anon_vma *root = NULL;
91375 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
91376 * the corresponding VMA in the parent process is attached to.
91377 * Returns 0 on success, non-zero on failure.
91378 */
91379 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
91380 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
91381 {
91382 struct anon_vma_chain *avc;
91383 struct anon_vma *anon_vma;
91384 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
91385 void __init anon_vma_init(void)
91386 {
91387 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
91388 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
91389 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
91390 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
91391 + anon_vma_ctor);
91392 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
91393 + SLAB_PANIC|SLAB_NO_SANITIZE);
91394 }
91395
91396 /*
91397 diff --git a/mm/shmem.c b/mm/shmem.c
91398 index 8297623..6b9dfe9 100644
91399 --- a/mm/shmem.c
91400 +++ b/mm/shmem.c
91401 @@ -33,7 +33,7 @@
91402 #include <linux/swap.h>
91403 #include <linux/aio.h>
91404
91405 -static struct vfsmount *shm_mnt;
91406 +struct vfsmount *shm_mnt;
91407
91408 #ifdef CONFIG_SHMEM
91409 /*
91410 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
91411 #define BOGO_DIRENT_SIZE 20
91412
91413 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
91414 -#define SHORT_SYMLINK_LEN 128
91415 +#define SHORT_SYMLINK_LEN 64
91416
91417 /*
91418 * shmem_fallocate and shmem_writepage communicate via inode->i_private
91419 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
91420 static int shmem_xattr_validate(const char *name)
91421 {
91422 struct { const char *prefix; size_t len; } arr[] = {
91423 +
91424 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
91425 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
91426 +#endif
91427 +
91428 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
91429 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
91430 };
91431 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
91432 if (err)
91433 return err;
91434
91435 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
91436 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
91437 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
91438 + return -EOPNOTSUPP;
91439 + if (size > 8)
91440 + return -EINVAL;
91441 + }
91442 +#endif
91443 +
91444 return simple_xattr_set(&info->xattrs, name, value, size, flags);
91445 }
91446
91447 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
91448 int err = -ENOMEM;
91449
91450 /* Round up to L1_CACHE_BYTES to resist false sharing */
91451 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
91452 - L1_CACHE_BYTES), GFP_KERNEL);
91453 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
91454 if (!sbinfo)
91455 return -ENOMEM;
91456
91457 diff --git a/mm/slab.c b/mm/slab.c
91458 index 2580db0..0523956 100644
91459 --- a/mm/slab.c
91460 +++ b/mm/slab.c
91461 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
91462 if ((x)->max_freeable < i) \
91463 (x)->max_freeable = i; \
91464 } while (0)
91465 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
91466 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
91467 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
91468 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
91469 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
91470 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
91471 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
91472 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
91473 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
91474 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
91475 #else
91476 #define STATS_INC_ACTIVE(x) do { } while (0)
91477 #define STATS_DEC_ACTIVE(x) do { } while (0)
91478 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
91479 #define STATS_INC_ALLOCMISS(x) do { } while (0)
91480 #define STATS_INC_FREEHIT(x) do { } while (0)
91481 #define STATS_INC_FREEMISS(x) do { } while (0)
91482 +#define STATS_INC_SANITIZED(x) do { } while (0)
91483 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
91484 #endif
91485
91486 #if DEBUG
91487 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
91488 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
91489 */
91490 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
91491 - const struct slab *slab, void *obj)
91492 + const struct slab *slab, const void *obj)
91493 {
91494 u32 offset = (obj - slab->s_mem);
91495 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
91496 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
91497 */
91498
91499 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
91500 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
91501 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
91502
91503 if (INDEX_AC != INDEX_NODE)
91504 kmalloc_caches[INDEX_NODE] =
91505 create_kmalloc_cache("kmalloc-node",
91506 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
91507 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
91508
91509 slab_early_init = 0;
91510
91511 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
91512 struct array_cache *ac = cpu_cache_get(cachep);
91513
91514 check_irq_off();
91515 +
91516 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91517 + if (pax_sanitize_slab) {
91518 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
91519 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
91520 +
91521 + if (cachep->ctor)
91522 + cachep->ctor(objp);
91523 +
91524 + STATS_INC_SANITIZED(cachep);
91525 + } else
91526 + STATS_INC_NOT_SANITIZED(cachep);
91527 + }
91528 +#endif
91529 +
91530 kmemleak_free_recursive(objp, cachep->flags);
91531 objp = cache_free_debugcheck(cachep, objp, caller);
91532
91533 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
91534
91535 if (unlikely(ZERO_OR_NULL_PTR(objp)))
91536 return;
91537 + VM_BUG_ON(!virt_addr_valid(objp));
91538 local_irq_save(flags);
91539 kfree_debugcheck(objp);
91540 c = virt_to_cache(objp);
91541 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
91542 }
91543 /* cpu stats */
91544 {
91545 - unsigned long allochit = atomic_read(&cachep->allochit);
91546 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
91547 - unsigned long freehit = atomic_read(&cachep->freehit);
91548 - unsigned long freemiss = atomic_read(&cachep->freemiss);
91549 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
91550 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
91551 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
91552 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
91553
91554 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
91555 allochit, allocmiss, freehit, freemiss);
91556 }
91557 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91558 + {
91559 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
91560 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
91561 +
91562 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
91563 + }
91564 +#endif
91565 #endif
91566 }
91567
91568 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
91569 static int __init slab_proc_init(void)
91570 {
91571 #ifdef CONFIG_DEBUG_SLAB_LEAK
91572 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
91573 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
91574 #endif
91575 return 0;
91576 }
91577 module_init(slab_proc_init);
91578 #endif
91579
91580 +bool is_usercopy_object(const void *ptr)
91581 +{
91582 + struct page *page;
91583 + struct kmem_cache *cachep;
91584 +
91585 + if (ZERO_OR_NULL_PTR(ptr))
91586 + return false;
91587 +
91588 + if (!slab_is_available())
91589 + return false;
91590 +
91591 + if (!virt_addr_valid(ptr))
91592 + return false;
91593 +
91594 + page = virt_to_head_page(ptr);
91595 +
91596 + if (!PageSlab(page))
91597 + return false;
91598 +
91599 + cachep = page->slab_cache;
91600 + return cachep->flags & SLAB_USERCOPY;
91601 +}
91602 +
91603 +#ifdef CONFIG_PAX_USERCOPY
91604 +const char *check_heap_object(const void *ptr, unsigned long n)
91605 +{
91606 + struct page *page;
91607 + struct kmem_cache *cachep;
91608 + struct slab *slabp;
91609 + unsigned int objnr;
91610 + unsigned long offset;
91611 +
91612 + if (ZERO_OR_NULL_PTR(ptr))
91613 + return "<null>";
91614 +
91615 + if (!virt_addr_valid(ptr))
91616 + return NULL;
91617 +
91618 + page = virt_to_head_page(ptr);
91619 +
91620 + if (!PageSlab(page))
91621 + return NULL;
91622 +
91623 + cachep = page->slab_cache;
91624 + if (!(cachep->flags & SLAB_USERCOPY))
91625 + return cachep->name;
91626 +
91627 + slabp = page->slab_page;
91628 + objnr = obj_to_index(cachep, slabp, ptr);
91629 + BUG_ON(objnr >= cachep->num);
91630 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
91631 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
91632 + return NULL;
91633 +
91634 + return cachep->name;
91635 +}
91636 +#endif
91637 +
91638 /**
91639 * ksize - get the actual amount of memory allocated for a given object
91640 * @objp: Pointer to the object
91641 diff --git a/mm/slab.h b/mm/slab.h
91642 index a535033..2f98fe5 100644
91643 --- a/mm/slab.h
91644 +++ b/mm/slab.h
91645 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
91646 /* The slab cache that manages slab cache information */
91647 extern struct kmem_cache *kmem_cache;
91648
91649 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91650 +#ifdef CONFIG_X86_64
91651 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
91652 +#else
91653 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
91654 +#endif
91655 +extern bool pax_sanitize_slab;
91656 +#endif
91657 +
91658 unsigned long calculate_alignment(unsigned long flags,
91659 unsigned long align, unsigned long size);
91660
91661 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
91662
91663 /* Legal flag mask for kmem_cache_create(), for various configurations */
91664 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
91665 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
91666 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
91667 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
91668
91669 #if defined(CONFIG_DEBUG_SLAB)
91670 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
91671 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
91672 return s;
91673
91674 page = virt_to_head_page(x);
91675 +
91676 + BUG_ON(!PageSlab(page));
91677 +
91678 cachep = page->slab_cache;
91679 if (slab_equal_or_root(cachep, s))
91680 return cachep;
91681 diff --git a/mm/slab_common.c b/mm/slab_common.c
91682 index e2e98af..3b1a163 100644
91683 --- a/mm/slab_common.c
91684 +++ b/mm/slab_common.c
91685 @@ -23,11 +23,22 @@
91686
91687 #include "slab.h"
91688
91689 -enum slab_state slab_state;
91690 +enum slab_state slab_state __read_only;
91691 LIST_HEAD(slab_caches);
91692 DEFINE_MUTEX(slab_mutex);
91693 struct kmem_cache *kmem_cache;
91694
91695 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91696 +bool pax_sanitize_slab __read_only = true;
91697 +static int __init pax_sanitize_slab_setup(char *str)
91698 +{
91699 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
91700 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
91701 + return 1;
91702 +}
91703 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
91704 +#endif
91705 +
91706 #ifdef CONFIG_DEBUG_VM
91707 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
91708 size_t size)
91709 @@ -212,7 +223,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
91710
91711 err = __kmem_cache_create(s, flags);
91712 if (!err) {
91713 - s->refcount = 1;
91714 + atomic_set(&s->refcount, 1);
91715 list_add(&s->list, &slab_caches);
91716 memcg_cache_list_add(memcg, s);
91717 } else {
91718 @@ -258,8 +269,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
91719
91720 get_online_cpus();
91721 mutex_lock(&slab_mutex);
91722 - s->refcount--;
91723 - if (!s->refcount) {
91724 + if (atomic_dec_and_test(&s->refcount)) {
91725 list_del(&s->list);
91726
91727 if (!__kmem_cache_shutdown(s)) {
91728 @@ -305,7 +315,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
91729 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
91730 name, size, err);
91731
91732 - s->refcount = -1; /* Exempt from merging for now */
91733 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
91734 }
91735
91736 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
91737 @@ -318,7 +328,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
91738
91739 create_boot_cache(s, name, size, flags);
91740 list_add(&s->list, &slab_caches);
91741 - s->refcount = 1;
91742 + atomic_set(&s->refcount, 1);
91743 return s;
91744 }
91745
91746 @@ -330,6 +340,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
91747 EXPORT_SYMBOL(kmalloc_dma_caches);
91748 #endif
91749
91750 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91751 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
91752 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
91753 +#endif
91754 +
91755 /*
91756 * Conversion table for small slabs sizes / 8 to the index in the
91757 * kmalloc array. This is necessary for slabs < 192 since we have non power
91758 @@ -394,6 +409,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
91759 return kmalloc_dma_caches[index];
91760
91761 #endif
91762 +
91763 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91764 + if (unlikely((flags & GFP_USERCOPY)))
91765 + return kmalloc_usercopy_caches[index];
91766 +
91767 +#endif
91768 +
91769 return kmalloc_caches[index];
91770 }
91771
91772 @@ -450,7 +472,7 @@ void __init create_kmalloc_caches(unsigned long flags)
91773 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
91774 if (!kmalloc_caches[i]) {
91775 kmalloc_caches[i] = create_kmalloc_cache(NULL,
91776 - 1 << i, flags);
91777 + 1 << i, SLAB_USERCOPY | flags);
91778 }
91779
91780 /*
91781 @@ -459,10 +481,10 @@ void __init create_kmalloc_caches(unsigned long flags)
91782 * earlier power of two caches
91783 */
91784 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
91785 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
91786 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
91787
91788 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
91789 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
91790 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
91791 }
91792
91793 /* Kmalloc array is now usable */
91794 @@ -495,6 +517,23 @@ void __init create_kmalloc_caches(unsigned long flags)
91795 }
91796 }
91797 #endif
91798 +
91799 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91800 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
91801 + struct kmem_cache *s = kmalloc_caches[i];
91802 +
91803 + if (s) {
91804 + int size = kmalloc_size(i);
91805 + char *n = kasprintf(GFP_NOWAIT,
91806 + "usercopy-kmalloc-%d", size);
91807 +
91808 + BUG_ON(!n);
91809 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
91810 + size, SLAB_USERCOPY | flags);
91811 + }
91812 + }
91813 +#endif
91814 +
91815 }
91816 #endif /* !CONFIG_SLOB */
91817
91818 @@ -535,6 +574,9 @@ void print_slabinfo_header(struct seq_file *m)
91819 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
91820 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
91821 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
91822 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91823 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
91824 +#endif
91825 #endif
91826 seq_putc(m, '\n');
91827 }
91828 diff --git a/mm/slob.c b/mm/slob.c
91829 index 4bf8809..98a6914 100644
91830 --- a/mm/slob.c
91831 +++ b/mm/slob.c
91832 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
91833 /*
91834 * Return the size of a slob block.
91835 */
91836 -static slobidx_t slob_units(slob_t *s)
91837 +static slobidx_t slob_units(const slob_t *s)
91838 {
91839 if (s->units > 0)
91840 return s->units;
91841 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
91842 /*
91843 * Return the next free slob block pointer after this one.
91844 */
91845 -static slob_t *slob_next(slob_t *s)
91846 +static slob_t *slob_next(const slob_t *s)
91847 {
91848 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
91849 slobidx_t next;
91850 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
91851 /*
91852 * Returns true if s is the last free block in its page.
91853 */
91854 -static int slob_last(slob_t *s)
91855 +static int slob_last(const slob_t *s)
91856 {
91857 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
91858 }
91859
91860 -static void *slob_new_pages(gfp_t gfp, int order, int node)
91861 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
91862 {
91863 - void *page;
91864 + struct page *page;
91865
91866 #ifdef CONFIG_NUMA
91867 if (node != NUMA_NO_NODE)
91868 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
91869 if (!page)
91870 return NULL;
91871
91872 - return page_address(page);
91873 + __SetPageSlab(page);
91874 + return page;
91875 }
91876
91877 -static void slob_free_pages(void *b, int order)
91878 +static void slob_free_pages(struct page *sp, int order)
91879 {
91880 if (current->reclaim_state)
91881 current->reclaim_state->reclaimed_slab += 1 << order;
91882 - free_pages((unsigned long)b, order);
91883 + __ClearPageSlab(sp);
91884 + page_mapcount_reset(sp);
91885 + sp->private = 0;
91886 + __free_pages(sp, order);
91887 }
91888
91889 /*
91890 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
91891
91892 /* Not enough space: must allocate a new page */
91893 if (!b) {
91894 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
91895 - if (!b)
91896 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
91897 + if (!sp)
91898 return NULL;
91899 - sp = virt_to_page(b);
91900 - __SetPageSlab(sp);
91901 + b = page_address(sp);
91902
91903 spin_lock_irqsave(&slob_lock, flags);
91904 sp->units = SLOB_UNITS(PAGE_SIZE);
91905 sp->freelist = b;
91906 + sp->private = 0;
91907 INIT_LIST_HEAD(&sp->list);
91908 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
91909 set_slob_page_free(sp, slob_list);
91910 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
91911 if (slob_page_free(sp))
91912 clear_slob_page_free(sp);
91913 spin_unlock_irqrestore(&slob_lock, flags);
91914 - __ClearPageSlab(sp);
91915 - page_mapcount_reset(sp);
91916 - slob_free_pages(b, 0);
91917 + slob_free_pages(sp, 0);
91918 return;
91919 }
91920
91921 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91922 + if (pax_sanitize_slab)
91923 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
91924 +#endif
91925 +
91926 if (!slob_page_free(sp)) {
91927 /* This slob page is about to become partially free. Easy! */
91928 sp->units = units;
91929 @@ -424,11 +431,10 @@ out:
91930 */
91931
91932 static __always_inline void *
91933 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91934 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
91935 {
91936 - unsigned int *m;
91937 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91938 - void *ret;
91939 + slob_t *m;
91940 + void *ret = NULL;
91941
91942 gfp &= gfp_allowed_mask;
91943
91944 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91945
91946 if (!m)
91947 return NULL;
91948 - *m = size;
91949 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
91950 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
91951 + m[0].units = size;
91952 + m[1].units = align;
91953 ret = (void *)m + align;
91954
91955 trace_kmalloc_node(caller, ret,
91956 size, size + align, gfp, node);
91957 } else {
91958 unsigned int order = get_order(size);
91959 + struct page *page;
91960
91961 if (likely(order))
91962 gfp |= __GFP_COMP;
91963 - ret = slob_new_pages(gfp, order, node);
91964 + page = slob_new_pages(gfp, order, node);
91965 + if (page) {
91966 + ret = page_address(page);
91967 + page->private = size;
91968 + }
91969
91970 trace_kmalloc_node(caller, ret,
91971 size, PAGE_SIZE << order, gfp, node);
91972 }
91973
91974 - kmemleak_alloc(ret, size, 1, gfp);
91975 + return ret;
91976 +}
91977 +
91978 +static __always_inline void *
91979 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91980 +{
91981 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91982 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
91983 +
91984 + if (!ZERO_OR_NULL_PTR(ret))
91985 + kmemleak_alloc(ret, size, 1, gfp);
91986 return ret;
91987 }
91988
91989 @@ -493,34 +517,112 @@ void kfree(const void *block)
91990 return;
91991 kmemleak_free(block);
91992
91993 + VM_BUG_ON(!virt_addr_valid(block));
91994 sp = virt_to_page(block);
91995 - if (PageSlab(sp)) {
91996 + VM_BUG_ON(!PageSlab(sp));
91997 + if (!sp->private) {
91998 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91999 - unsigned int *m = (unsigned int *)(block - align);
92000 - slob_free(m, *m + align);
92001 - } else
92002 + slob_t *m = (slob_t *)(block - align);
92003 + slob_free(m, m[0].units + align);
92004 + } else {
92005 + __ClearPageSlab(sp);
92006 + page_mapcount_reset(sp);
92007 + sp->private = 0;
92008 __free_pages(sp, compound_order(sp));
92009 + }
92010 }
92011 EXPORT_SYMBOL(kfree);
92012
92013 +bool is_usercopy_object(const void *ptr)
92014 +{
92015 + if (!slab_is_available())
92016 + return false;
92017 +
92018 + // PAX: TODO
92019 +
92020 + return false;
92021 +}
92022 +
92023 +#ifdef CONFIG_PAX_USERCOPY
92024 +const char *check_heap_object(const void *ptr, unsigned long n)
92025 +{
92026 + struct page *page;
92027 + const slob_t *free;
92028 + const void *base;
92029 + unsigned long flags;
92030 +
92031 + if (ZERO_OR_NULL_PTR(ptr))
92032 + return "<null>";
92033 +
92034 + if (!virt_addr_valid(ptr))
92035 + return NULL;
92036 +
92037 + page = virt_to_head_page(ptr);
92038 + if (!PageSlab(page))
92039 + return NULL;
92040 +
92041 + if (page->private) {
92042 + base = page;
92043 + if (base <= ptr && n <= page->private - (ptr - base))
92044 + return NULL;
92045 + return "<slob>";
92046 + }
92047 +
92048 + /* some tricky double walking to find the chunk */
92049 + spin_lock_irqsave(&slob_lock, flags);
92050 + base = (void *)((unsigned long)ptr & PAGE_MASK);
92051 + free = page->freelist;
92052 +
92053 + while (!slob_last(free) && (void *)free <= ptr) {
92054 + base = free + slob_units(free);
92055 + free = slob_next(free);
92056 + }
92057 +
92058 + while (base < (void *)free) {
92059 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
92060 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
92061 + int offset;
92062 +
92063 + if (ptr < base + align)
92064 + break;
92065 +
92066 + offset = ptr - base - align;
92067 + if (offset >= m) {
92068 + base += size;
92069 + continue;
92070 + }
92071 +
92072 + if (n > m - offset)
92073 + break;
92074 +
92075 + spin_unlock_irqrestore(&slob_lock, flags);
92076 + return NULL;
92077 + }
92078 +
92079 + spin_unlock_irqrestore(&slob_lock, flags);
92080 + return "<slob>";
92081 +}
92082 +#endif
92083 +
92084 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
92085 size_t ksize(const void *block)
92086 {
92087 struct page *sp;
92088 int align;
92089 - unsigned int *m;
92090 + slob_t *m;
92091
92092 BUG_ON(!block);
92093 if (unlikely(block == ZERO_SIZE_PTR))
92094 return 0;
92095
92096 sp = virt_to_page(block);
92097 - if (unlikely(!PageSlab(sp)))
92098 - return PAGE_SIZE << compound_order(sp);
92099 + VM_BUG_ON(!PageSlab(sp));
92100 + if (sp->private)
92101 + return sp->private;
92102
92103 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
92104 - m = (unsigned int *)(block - align);
92105 - return SLOB_UNITS(*m) * SLOB_UNIT;
92106 + m = (slob_t *)(block - align);
92107 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
92108 }
92109 EXPORT_SYMBOL(ksize);
92110
92111 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
92112
92113 void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
92114 {
92115 - void *b;
92116 + void *b = NULL;
92117
92118 flags &= gfp_allowed_mask;
92119
92120 lockdep_trace_alloc(flags);
92121
92122 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92123 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
92124 +#else
92125 if (c->size < PAGE_SIZE) {
92126 b = slob_alloc(c->size, flags, c->align, node);
92127 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
92128 SLOB_UNITS(c->size) * SLOB_UNIT,
92129 flags, node);
92130 } else {
92131 - b = slob_new_pages(flags, get_order(c->size), node);
92132 + struct page *sp;
92133 +
92134 + sp = slob_new_pages(flags, get_order(c->size), node);
92135 + if (sp) {
92136 + b = page_address(sp);
92137 + sp->private = c->size;
92138 + }
92139 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
92140 PAGE_SIZE << get_order(c->size),
92141 flags, node);
92142 }
92143 +#endif
92144
92145 if (b && c->ctor)
92146 c->ctor(b);
92147 @@ -584,10 +696,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
92148
92149 static void __kmem_cache_free(void *b, int size)
92150 {
92151 - if (size < PAGE_SIZE)
92152 + struct page *sp;
92153 +
92154 + sp = virt_to_page(b);
92155 + BUG_ON(!PageSlab(sp));
92156 + if (!sp->private)
92157 slob_free(b, size);
92158 else
92159 - slob_free_pages(b, get_order(size));
92160 + slob_free_pages(sp, get_order(size));
92161 }
92162
92163 static void kmem_rcu_free(struct rcu_head *head)
92164 @@ -600,17 +716,31 @@ static void kmem_rcu_free(struct rcu_head *head)
92165
92166 void kmem_cache_free(struct kmem_cache *c, void *b)
92167 {
92168 + int size = c->size;
92169 +
92170 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92171 + if (size + c->align < PAGE_SIZE) {
92172 + size += c->align;
92173 + b -= c->align;
92174 + }
92175 +#endif
92176 +
92177 kmemleak_free_recursive(b, c->flags);
92178 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
92179 struct slob_rcu *slob_rcu;
92180 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
92181 - slob_rcu->size = c->size;
92182 + slob_rcu = b + (size - sizeof(struct slob_rcu));
92183 + slob_rcu->size = size;
92184 call_rcu(&slob_rcu->head, kmem_rcu_free);
92185 } else {
92186 - __kmem_cache_free(b, c->size);
92187 + __kmem_cache_free(b, size);
92188 }
92189
92190 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92191 + trace_kfree(_RET_IP_, b);
92192 +#else
92193 trace_kmem_cache_free(_RET_IP_, b);
92194 +#endif
92195 +
92196 }
92197 EXPORT_SYMBOL(kmem_cache_free);
92198
92199 diff --git a/mm/slub.c b/mm/slub.c
92200 index 96f2169..9111a59 100644
92201 --- a/mm/slub.c
92202 +++ b/mm/slub.c
92203 @@ -207,7 +207,7 @@ struct track {
92204
92205 enum track_item { TRACK_ALLOC, TRACK_FREE };
92206
92207 -#ifdef CONFIG_SYSFS
92208 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92209 static int sysfs_slab_add(struct kmem_cache *);
92210 static int sysfs_slab_alias(struct kmem_cache *, const char *);
92211 static void sysfs_slab_remove(struct kmem_cache *);
92212 @@ -530,7 +530,7 @@ static void print_track(const char *s, struct track *t)
92213 if (!t->addr)
92214 return;
92215
92216 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
92217 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
92218 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
92219 #ifdef CONFIG_STACKTRACE
92220 {
92221 @@ -2616,6 +2616,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
92222
92223 slab_free_hook(s, x);
92224
92225 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
92226 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
92227 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
92228 + if (s->ctor)
92229 + s->ctor(x);
92230 + }
92231 +#endif
92232 +
92233 redo:
92234 /*
92235 * Determine the currently cpus per cpu slab.
92236 @@ -2683,7 +2691,7 @@ static int slub_min_objects;
92237 * Merge control. If this is set then no merging of slab caches will occur.
92238 * (Could be removed. This was introduced to pacify the merge skeptics.)
92239 */
92240 -static int slub_nomerge;
92241 +static int slub_nomerge = 1;
92242
92243 /*
92244 * Calculate the order of allocation given an slab object size.
92245 @@ -2960,6 +2968,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
92246 s->inuse = size;
92247
92248 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
92249 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
92250 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
92251 +#endif
92252 s->ctor)) {
92253 /*
92254 * Relocate free pointer after the object if it is not
92255 @@ -3305,6 +3316,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
92256 EXPORT_SYMBOL(__kmalloc_node);
92257 #endif
92258
92259 +bool is_usercopy_object(const void *ptr)
92260 +{
92261 + struct page *page;
92262 + struct kmem_cache *s;
92263 +
92264 + if (ZERO_OR_NULL_PTR(ptr))
92265 + return false;
92266 +
92267 + if (!slab_is_available())
92268 + return false;
92269 +
92270 + if (!virt_addr_valid(ptr))
92271 + return false;
92272 +
92273 + page = virt_to_head_page(ptr);
92274 +
92275 + if (!PageSlab(page))
92276 + return false;
92277 +
92278 + s = page->slab_cache;
92279 + return s->flags & SLAB_USERCOPY;
92280 +}
92281 +
92282 +#ifdef CONFIG_PAX_USERCOPY
92283 +const char *check_heap_object(const void *ptr, unsigned long n)
92284 +{
92285 + struct page *page;
92286 + struct kmem_cache *s;
92287 + unsigned long offset;
92288 +
92289 + if (ZERO_OR_NULL_PTR(ptr))
92290 + return "<null>";
92291 +
92292 + if (!virt_addr_valid(ptr))
92293 + return NULL;
92294 +
92295 + page = virt_to_head_page(ptr);
92296 +
92297 + if (!PageSlab(page))
92298 + return NULL;
92299 +
92300 + s = page->slab_cache;
92301 + if (!(s->flags & SLAB_USERCOPY))
92302 + return s->name;
92303 +
92304 + offset = (ptr - page_address(page)) % s->size;
92305 + if (offset <= s->object_size && n <= s->object_size - offset)
92306 + return NULL;
92307 +
92308 + return s->name;
92309 +}
92310 +#endif
92311 +
92312 size_t ksize(const void *object)
92313 {
92314 struct page *page;
92315 @@ -3333,6 +3397,7 @@ void kfree(const void *x)
92316 if (unlikely(ZERO_OR_NULL_PTR(x)))
92317 return;
92318
92319 + VM_BUG_ON(!virt_addr_valid(x));
92320 page = virt_to_head_page(x);
92321 if (unlikely(!PageSlab(page))) {
92322 BUG_ON(!PageCompound(page));
92323 @@ -3638,7 +3703,7 @@ static int slab_unmergeable(struct kmem_cache *s)
92324 /*
92325 * We may have set a slab to be unmergeable during bootstrap.
92326 */
92327 - if (s->refcount < 0)
92328 + if (atomic_read(&s->refcount) < 0)
92329 return 1;
92330
92331 return 0;
92332 @@ -3696,7 +3761,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
92333
92334 s = find_mergeable(memcg, size, align, flags, name, ctor);
92335 if (s) {
92336 - s->refcount++;
92337 + atomic_inc(&s->refcount);
92338 /*
92339 * Adjust the object sizes so that we clear
92340 * the complete object on kzalloc.
92341 @@ -3705,7 +3770,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
92342 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
92343
92344 if (sysfs_slab_alias(s, name)) {
92345 - s->refcount--;
92346 + atomic_dec(&s->refcount);
92347 s = NULL;
92348 }
92349 }
92350 @@ -3825,7 +3890,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
92351 }
92352 #endif
92353
92354 -#ifdef CONFIG_SYSFS
92355 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92356 static int count_inuse(struct page *page)
92357 {
92358 return page->inuse;
92359 @@ -4214,12 +4279,12 @@ static void resiliency_test(void)
92360 validate_slab_cache(kmalloc_caches[9]);
92361 }
92362 #else
92363 -#ifdef CONFIG_SYSFS
92364 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92365 static void resiliency_test(void) {};
92366 #endif
92367 #endif
92368
92369 -#ifdef CONFIG_SYSFS
92370 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92371 enum slab_stat_type {
92372 SL_ALL, /* All slabs */
92373 SL_PARTIAL, /* Only partially allocated slabs */
92374 @@ -4459,7 +4524,7 @@ SLAB_ATTR_RO(ctor);
92375
92376 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
92377 {
92378 - return sprintf(buf, "%d\n", s->refcount - 1);
92379 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
92380 }
92381 SLAB_ATTR_RO(aliases);
92382
92383 @@ -4547,6 +4612,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
92384 SLAB_ATTR_RO(cache_dma);
92385 #endif
92386
92387 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92388 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
92389 +{
92390 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
92391 +}
92392 +SLAB_ATTR_RO(usercopy);
92393 +#endif
92394 +
92395 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
92396 {
92397 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
92398 @@ -4881,6 +4954,9 @@ static struct attribute *slab_attrs[] = {
92399 #ifdef CONFIG_ZONE_DMA
92400 &cache_dma_attr.attr,
92401 #endif
92402 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92403 + &usercopy_attr.attr,
92404 +#endif
92405 #ifdef CONFIG_NUMA
92406 &remote_node_defrag_ratio_attr.attr,
92407 #endif
92408 @@ -5113,6 +5189,7 @@ static char *create_unique_id(struct kmem_cache *s)
92409 return name;
92410 }
92411
92412 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92413 static int sysfs_slab_add(struct kmem_cache *s)
92414 {
92415 int err;
92416 @@ -5136,7 +5213,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
92417 }
92418
92419 s->kobj.kset = slab_kset;
92420 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
92421 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
92422 if (err) {
92423 kobject_put(&s->kobj);
92424 return err;
92425 @@ -5170,6 +5247,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
92426 kobject_del(&s->kobj);
92427 kobject_put(&s->kobj);
92428 }
92429 +#endif
92430
92431 /*
92432 * Need to buffer aliases during bootup until sysfs becomes
92433 @@ -5183,6 +5261,7 @@ struct saved_alias {
92434
92435 static struct saved_alias *alias_list;
92436
92437 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92438 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
92439 {
92440 struct saved_alias *al;
92441 @@ -5205,6 +5284,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
92442 alias_list = al;
92443 return 0;
92444 }
92445 +#endif
92446
92447 static int __init slab_sysfs_init(void)
92448 {
92449 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
92450 index 27eeab3..7c3f7f2 100644
92451 --- a/mm/sparse-vmemmap.c
92452 +++ b/mm/sparse-vmemmap.c
92453 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
92454 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
92455 if (!p)
92456 return NULL;
92457 - pud_populate(&init_mm, pud, p);
92458 + pud_populate_kernel(&init_mm, pud, p);
92459 }
92460 return pud;
92461 }
92462 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
92463 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
92464 if (!p)
92465 return NULL;
92466 - pgd_populate(&init_mm, pgd, p);
92467 + pgd_populate_kernel(&init_mm, pgd, p);
92468 }
92469 return pgd;
92470 }
92471 diff --git a/mm/sparse.c b/mm/sparse.c
92472 index 4ac1d7e..bbfcb1f 100644
92473 --- a/mm/sparse.c
92474 +++ b/mm/sparse.c
92475 @@ -745,7 +745,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
92476
92477 for (i = 0; i < PAGES_PER_SECTION; i++) {
92478 if (PageHWPoison(&memmap[i])) {
92479 - atomic_long_sub(1, &num_poisoned_pages);
92480 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
92481 ClearPageHWPoison(&memmap[i]);
92482 }
92483 }
92484 diff --git a/mm/swap.c b/mm/swap.c
92485 index 759c3ca..7c1a5b4 100644
92486 --- a/mm/swap.c
92487 +++ b/mm/swap.c
92488 @@ -77,6 +77,8 @@ static void __put_compound_page(struct page *page)
92489
92490 __page_cache_release(page);
92491 dtor = get_compound_page_dtor(page);
92492 + if (!PageHuge(page))
92493 + BUG_ON(dtor != free_compound_page);
92494 (*dtor)(page);
92495 }
92496
92497 diff --git a/mm/swapfile.c b/mm/swapfile.c
92498 index de7c904..c84bf11 100644
92499 --- a/mm/swapfile.c
92500 +++ b/mm/swapfile.c
92501 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
92502
92503 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
92504 /* Activity counter to indicate that a swapon or swapoff has occurred */
92505 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
92506 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
92507
92508 static inline unsigned char swap_count(unsigned char ent)
92509 {
92510 @@ -1949,7 +1949,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
92511 }
92512 filp_close(swap_file, NULL);
92513 err = 0;
92514 - atomic_inc(&proc_poll_event);
92515 + atomic_inc_unchecked(&proc_poll_event);
92516 wake_up_interruptible(&proc_poll_wait);
92517
92518 out_dput:
92519 @@ -1966,8 +1966,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
92520
92521 poll_wait(file, &proc_poll_wait, wait);
92522
92523 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
92524 - seq->poll_event = atomic_read(&proc_poll_event);
92525 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
92526 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
92527 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
92528 }
92529
92530 @@ -2065,7 +2065,7 @@ static int swaps_open(struct inode *inode, struct file *file)
92531 return ret;
92532
92533 seq = file->private_data;
92534 - seq->poll_event = atomic_read(&proc_poll_event);
92535 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
92536 return 0;
92537 }
92538
92539 @@ -2524,7 +2524,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
92540 (frontswap_map) ? "FS" : "");
92541
92542 mutex_unlock(&swapon_mutex);
92543 - atomic_inc(&proc_poll_event);
92544 + atomic_inc_unchecked(&proc_poll_event);
92545 wake_up_interruptible(&proc_poll_wait);
92546
92547 if (S_ISREG(inode->i_mode))
92548 diff --git a/mm/util.c b/mm/util.c
92549 index eaf63fc2..32b2629 100644
92550 --- a/mm/util.c
92551 +++ b/mm/util.c
92552 @@ -294,6 +294,12 @@ done:
92553 void arch_pick_mmap_layout(struct mm_struct *mm)
92554 {
92555 mm->mmap_base = TASK_UNMAPPED_BASE;
92556 +
92557 +#ifdef CONFIG_PAX_RANDMMAP
92558 + if (mm->pax_flags & MF_PAX_RANDMMAP)
92559 + mm->mmap_base += mm->delta_mmap;
92560 +#endif
92561 +
92562 mm->get_unmapped_area = arch_get_unmapped_area;
92563 }
92564 #endif
92565 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
92566 index 1074543..136dbe0 100644
92567 --- a/mm/vmalloc.c
92568 +++ b/mm/vmalloc.c
92569 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
92570
92571 pte = pte_offset_kernel(pmd, addr);
92572 do {
92573 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
92574 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
92575 +
92576 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
92577 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
92578 + BUG_ON(!pte_exec(*pte));
92579 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
92580 + continue;
92581 + }
92582 +#endif
92583 +
92584 + {
92585 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
92586 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
92587 + }
92588 } while (pte++, addr += PAGE_SIZE, addr != end);
92589 }
92590
92591 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
92592 pte = pte_alloc_kernel(pmd, addr);
92593 if (!pte)
92594 return -ENOMEM;
92595 +
92596 + pax_open_kernel();
92597 do {
92598 struct page *page = pages[*nr];
92599
92600 - if (WARN_ON(!pte_none(*pte)))
92601 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
92602 + if (pgprot_val(prot) & _PAGE_NX)
92603 +#endif
92604 +
92605 + if (!pte_none(*pte)) {
92606 + pax_close_kernel();
92607 + WARN_ON(1);
92608 return -EBUSY;
92609 - if (WARN_ON(!page))
92610 + }
92611 + if (!page) {
92612 + pax_close_kernel();
92613 + WARN_ON(1);
92614 return -ENOMEM;
92615 + }
92616 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
92617 (*nr)++;
92618 } while (pte++, addr += PAGE_SIZE, addr != end);
92619 + pax_close_kernel();
92620 return 0;
92621 }
92622
92623 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
92624 pmd_t *pmd;
92625 unsigned long next;
92626
92627 - pmd = pmd_alloc(&init_mm, pud, addr);
92628 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
92629 if (!pmd)
92630 return -ENOMEM;
92631 do {
92632 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
92633 pud_t *pud;
92634 unsigned long next;
92635
92636 - pud = pud_alloc(&init_mm, pgd, addr);
92637 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
92638 if (!pud)
92639 return -ENOMEM;
92640 do {
92641 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
92642 if (addr >= MODULES_VADDR && addr < MODULES_END)
92643 return 1;
92644 #endif
92645 +
92646 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
92647 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
92648 + return 1;
92649 +#endif
92650 +
92651 return is_vmalloc_addr(x);
92652 }
92653
92654 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
92655
92656 if (!pgd_none(*pgd)) {
92657 pud_t *pud = pud_offset(pgd, addr);
92658 +#ifdef CONFIG_X86
92659 + if (!pud_large(*pud))
92660 +#endif
92661 if (!pud_none(*pud)) {
92662 pmd_t *pmd = pmd_offset(pud, addr);
92663 +#ifdef CONFIG_X86
92664 + if (!pmd_large(*pmd))
92665 +#endif
92666 if (!pmd_none(*pmd)) {
92667 pte_t *ptep, pte;
92668
92669 @@ -1303,6 +1339,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
92670 struct vm_struct *area;
92671
92672 BUG_ON(in_interrupt());
92673 +
92674 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
92675 + if (flags & VM_KERNEXEC) {
92676 + if (start != VMALLOC_START || end != VMALLOC_END)
92677 + return NULL;
92678 + start = (unsigned long)MODULES_EXEC_VADDR;
92679 + end = (unsigned long)MODULES_EXEC_END;
92680 + }
92681 +#endif
92682 +
92683 if (flags & VM_IOREMAP)
92684 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
92685
92686 @@ -1528,6 +1574,11 @@ void *vmap(struct page **pages, unsigned int count,
92687 if (count > totalram_pages)
92688 return NULL;
92689
92690 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
92691 + if (!(pgprot_val(prot) & _PAGE_NX))
92692 + flags |= VM_KERNEXEC;
92693 +#endif
92694 +
92695 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
92696 __builtin_return_address(0));
92697 if (!area)
92698 @@ -1629,6 +1680,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
92699 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
92700 goto fail;
92701
92702 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
92703 + if (!(pgprot_val(prot) & _PAGE_NX))
92704 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
92705 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
92706 + else
92707 +#endif
92708 +
92709 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
92710 start, end, node, gfp_mask, caller);
92711 if (!area)
92712 @@ -1805,10 +1863,9 @@ EXPORT_SYMBOL(vzalloc_node);
92713 * For tight control over page level allocator and protection flags
92714 * use __vmalloc() instead.
92715 */
92716 -
92717 void *vmalloc_exec(unsigned long size)
92718 {
92719 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
92720 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
92721 NUMA_NO_NODE, __builtin_return_address(0));
92722 }
92723
92724 @@ -2115,6 +2172,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
92725 {
92726 struct vm_struct *area;
92727
92728 + BUG_ON(vma->vm_mirror);
92729 +
92730 size = PAGE_ALIGN(size);
92731
92732 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
92733 @@ -2600,7 +2659,11 @@ static int s_show(struct seq_file *m, void *p)
92734 v->addr, v->addr + v->size, v->size);
92735
92736 if (v->caller)
92737 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92738 + seq_printf(m, " %pK", v->caller);
92739 +#else
92740 seq_printf(m, " %pS", v->caller);
92741 +#endif
92742
92743 if (v->nr_pages)
92744 seq_printf(m, " pages=%d", v->nr_pages);
92745 diff --git a/mm/vmstat.c b/mm/vmstat.c
92746 index 5a442a7..dbbda4a 100644
92747 --- a/mm/vmstat.c
92748 +++ b/mm/vmstat.c
92749 @@ -20,6 +20,7 @@
92750 #include <linux/writeback.h>
92751 #include <linux/compaction.h>
92752 #include <linux/mm_inline.h>
92753 +#include <linux/grsecurity.h>
92754
92755 #include "internal.h"
92756
92757 @@ -79,7 +80,7 @@ void vm_events_fold_cpu(int cpu)
92758 *
92759 * vm_stat contains the global counters
92760 */
92761 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
92762 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
92763 EXPORT_SYMBOL(vm_stat);
92764
92765 #ifdef CONFIG_SMP
92766 @@ -423,7 +424,7 @@ static inline void fold_diff(int *diff)
92767
92768 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
92769 if (diff[i])
92770 - atomic_long_add(diff[i], &vm_stat[i]);
92771 + atomic_long_add_unchecked(diff[i], &vm_stat[i]);
92772 }
92773
92774 /*
92775 @@ -455,7 +456,7 @@ static void refresh_cpu_vm_stats(void)
92776 v = this_cpu_xchg(p->vm_stat_diff[i], 0);
92777 if (v) {
92778
92779 - atomic_long_add(v, &zone->vm_stat[i]);
92780 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
92781 global_diff[i] += v;
92782 #ifdef CONFIG_NUMA
92783 /* 3 seconds idle till flush */
92784 @@ -517,7 +518,7 @@ void cpu_vm_stats_fold(int cpu)
92785
92786 v = p->vm_stat_diff[i];
92787 p->vm_stat_diff[i] = 0;
92788 - atomic_long_add(v, &zone->vm_stat[i]);
92789 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
92790 global_diff[i] += v;
92791 }
92792 }
92793 @@ -537,8 +538,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
92794 if (pset->vm_stat_diff[i]) {
92795 int v = pset->vm_stat_diff[i];
92796 pset->vm_stat_diff[i] = 0;
92797 - atomic_long_add(v, &zone->vm_stat[i]);
92798 - atomic_long_add(v, &vm_stat[i]);
92799 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
92800 + atomic_long_add_unchecked(v, &vm_stat[i]);
92801 }
92802 }
92803 #endif
92804 @@ -1148,10 +1149,22 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos)
92805 stat_items_size += sizeof(struct vm_event_state);
92806 #endif
92807
92808 - v = kmalloc(stat_items_size, GFP_KERNEL);
92809 + v = kzalloc(stat_items_size, GFP_KERNEL);
92810 m->private = v;
92811 if (!v)
92812 return ERR_PTR(-ENOMEM);
92813 +
92814 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
92815 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
92816 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)
92817 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
92818 + && !in_group_p(grsec_proc_gid)
92819 +#endif
92820 + )
92821 + return (unsigned long *)m->private + *pos;
92822 +#endif
92823 +#endif
92824 +
92825 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
92826 v[i] = global_page_state(i);
92827 v += NR_VM_ZONE_STAT_ITEMS;
92828 @@ -1281,10 +1294,16 @@ static int __init setup_vmstat(void)
92829 start_cpu_timer(cpu);
92830 #endif
92831 #ifdef CONFIG_PROC_FS
92832 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
92833 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
92834 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
92835 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
92836 + {
92837 + mode_t gr_mode = S_IRUGO;
92838 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
92839 + gr_mode = S_IRUSR;
92840 +#endif
92841 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
92842 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
92843 + proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
92844 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
92845 + }
92846 #endif
92847 return 0;
92848 }
92849 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
92850 index 61fc573..b5e47d0 100644
92851 --- a/net/8021q/vlan.c
92852 +++ b/net/8021q/vlan.c
92853 @@ -472,7 +472,7 @@ out:
92854 return NOTIFY_DONE;
92855 }
92856
92857 -static struct notifier_block vlan_notifier_block __read_mostly = {
92858 +static struct notifier_block vlan_notifier_block = {
92859 .notifier_call = vlan_device_event,
92860 };
92861
92862 @@ -547,8 +547,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
92863 err = -EPERM;
92864 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
92865 break;
92866 - if ((args.u.name_type >= 0) &&
92867 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
92868 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
92869 struct vlan_net *vn;
92870
92871 vn = net_generic(net, vlan_net_id);
92872 diff --git a/net/9p/mod.c b/net/9p/mod.c
92873 index 6ab36ae..6f1841b 100644
92874 --- a/net/9p/mod.c
92875 +++ b/net/9p/mod.c
92876 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
92877 void v9fs_register_trans(struct p9_trans_module *m)
92878 {
92879 spin_lock(&v9fs_trans_lock);
92880 - list_add_tail(&m->list, &v9fs_trans_list);
92881 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
92882 spin_unlock(&v9fs_trans_lock);
92883 }
92884 EXPORT_SYMBOL(v9fs_register_trans);
92885 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
92886 void v9fs_unregister_trans(struct p9_trans_module *m)
92887 {
92888 spin_lock(&v9fs_trans_lock);
92889 - list_del_init(&m->list);
92890 + pax_list_del_init((struct list_head *)&m->list);
92891 spin_unlock(&v9fs_trans_lock);
92892 }
92893 EXPORT_SYMBOL(v9fs_unregister_trans);
92894 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
92895 index 3ffda1b..fceac96 100644
92896 --- a/net/9p/trans_fd.c
92897 +++ b/net/9p/trans_fd.c
92898 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
92899 oldfs = get_fs();
92900 set_fs(get_ds());
92901 /* The cast to a user pointer is valid due to the set_fs() */
92902 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
92903 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
92904 set_fs(oldfs);
92905
92906 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
92907 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
92908 index 876fbe8..8bbea9f 100644
92909 --- a/net/atm/atm_misc.c
92910 +++ b/net/atm/atm_misc.c
92911 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
92912 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
92913 return 1;
92914 atm_return(vcc, truesize);
92915 - atomic_inc(&vcc->stats->rx_drop);
92916 + atomic_inc_unchecked(&vcc->stats->rx_drop);
92917 return 0;
92918 }
92919 EXPORT_SYMBOL(atm_charge);
92920 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
92921 }
92922 }
92923 atm_return(vcc, guess);
92924 - atomic_inc(&vcc->stats->rx_drop);
92925 + atomic_inc_unchecked(&vcc->stats->rx_drop);
92926 return NULL;
92927 }
92928 EXPORT_SYMBOL(atm_alloc_charge);
92929 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
92930
92931 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
92932 {
92933 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
92934 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
92935 __SONET_ITEMS
92936 #undef __HANDLE_ITEM
92937 }
92938 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
92939
92940 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
92941 {
92942 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
92943 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
92944 __SONET_ITEMS
92945 #undef __HANDLE_ITEM
92946 }
92947 diff --git a/net/atm/lec.h b/net/atm/lec.h
92948 index 4149db1..f2ab682 100644
92949 --- a/net/atm/lec.h
92950 +++ b/net/atm/lec.h
92951 @@ -48,7 +48,7 @@ struct lane2_ops {
92952 const u8 *tlvs, u32 sizeoftlvs);
92953 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
92954 const u8 *tlvs, u32 sizeoftlvs);
92955 -};
92956 +} __no_const;
92957
92958 /*
92959 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
92960 diff --git a/net/atm/proc.c b/net/atm/proc.c
92961 index bbb6461..cf04016 100644
92962 --- a/net/atm/proc.c
92963 +++ b/net/atm/proc.c
92964 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
92965 const struct k_atm_aal_stats *stats)
92966 {
92967 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
92968 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
92969 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
92970 - atomic_read(&stats->rx_drop));
92971 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
92972 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
92973 + atomic_read_unchecked(&stats->rx_drop));
92974 }
92975
92976 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
92977 diff --git a/net/atm/resources.c b/net/atm/resources.c
92978 index 0447d5d..3cf4728 100644
92979 --- a/net/atm/resources.c
92980 +++ b/net/atm/resources.c
92981 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
92982 static void copy_aal_stats(struct k_atm_aal_stats *from,
92983 struct atm_aal_stats *to)
92984 {
92985 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
92986 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
92987 __AAL_STAT_ITEMS
92988 #undef __HANDLE_ITEM
92989 }
92990 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
92991 static void subtract_aal_stats(struct k_atm_aal_stats *from,
92992 struct atm_aal_stats *to)
92993 {
92994 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
92995 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
92996 __AAL_STAT_ITEMS
92997 #undef __HANDLE_ITEM
92998 }
92999 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
93000 index 919a5ce..cc6b444 100644
93001 --- a/net/ax25/sysctl_net_ax25.c
93002 +++ b/net/ax25/sysctl_net_ax25.c
93003 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
93004 {
93005 char path[sizeof("net/ax25/") + IFNAMSIZ];
93006 int k;
93007 - struct ctl_table *table;
93008 + ctl_table_no_const *table;
93009
93010 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
93011 if (!table)
93012 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
93013 index 0a8a80c..f7e89aa 100644
93014 --- a/net/batman-adv/bat_iv_ogm.c
93015 +++ b/net/batman-adv/bat_iv_ogm.c
93016 @@ -121,7 +121,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
93017
93018 /* randomize initial seqno to avoid collision */
93019 get_random_bytes(&random_seqno, sizeof(random_seqno));
93020 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
93021 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
93022
93023 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
93024 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
93025 @@ -703,9 +703,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
93026 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
93027
93028 /* change sequence number to network order */
93029 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
93030 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
93031 batadv_ogm_packet->seqno = htonl(seqno);
93032 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
93033 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
93034
93035 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
93036 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
93037 @@ -1111,7 +1111,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
93038 return;
93039
93040 /* could be changed by schedule_own_packet() */
93041 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
93042 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
93043
93044 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
93045 has_directlink_flag = 1;
93046 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
93047 index c478e6b..469fd2f 100644
93048 --- a/net/batman-adv/hard-interface.c
93049 +++ b/net/batman-adv/hard-interface.c
93050 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
93051 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
93052 dev_add_pack(&hard_iface->batman_adv_ptype);
93053
93054 - atomic_set(&hard_iface->frag_seqno, 1);
93055 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
93056 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
93057 hard_iface->net_dev->name);
93058
93059 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
93060 index 813db4e..847edac 100644
93061 --- a/net/batman-adv/soft-interface.c
93062 +++ b/net/batman-adv/soft-interface.c
93063 @@ -263,7 +263,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
93064 primary_if->net_dev->dev_addr, ETH_ALEN);
93065
93066 /* set broadcast sequence number */
93067 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
93068 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
93069 bcast_packet->seqno = htonl(seqno);
93070
93071 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
93072 @@ -483,7 +483,7 @@ static int batadv_softif_init_late(struct net_device *dev)
93073 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
93074
93075 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
93076 - atomic_set(&bat_priv->bcast_seqno, 1);
93077 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
93078 atomic_set(&bat_priv->tt.vn, 0);
93079 atomic_set(&bat_priv->tt.local_changes, 0);
93080 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
93081 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
93082 index b2c94e1..3d47e07 100644
93083 --- a/net/batman-adv/types.h
93084 +++ b/net/batman-adv/types.h
93085 @@ -51,7 +51,7 @@
93086 struct batadv_hard_iface_bat_iv {
93087 unsigned char *ogm_buff;
93088 int ogm_buff_len;
93089 - atomic_t ogm_seqno;
93090 + atomic_unchecked_t ogm_seqno;
93091 };
93092
93093 /**
93094 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
93095 int16_t if_num;
93096 char if_status;
93097 struct net_device *net_dev;
93098 - atomic_t frag_seqno;
93099 + atomic_unchecked_t frag_seqno;
93100 uint8_t num_bcasts;
93101 struct kobject *hardif_obj;
93102 atomic_t refcount;
93103 @@ -560,7 +560,7 @@ struct batadv_priv {
93104 #ifdef CONFIG_BATMAN_ADV_DEBUG
93105 atomic_t log_level;
93106 #endif
93107 - atomic_t bcast_seqno;
93108 + atomic_unchecked_t bcast_seqno;
93109 atomic_t bcast_queue_left;
93110 atomic_t batman_queue_left;
93111 char num_ifaces;
93112 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
93113 index 48b31d3..62a0bcb 100644
93114 --- a/net/batman-adv/unicast.c
93115 +++ b/net/batman-adv/unicast.c
93116 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
93117 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
93118 frag2->flags = large_tail;
93119
93120 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
93121 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
93122 frag1->seqno = htons(seqno - 1);
93123 frag2->seqno = htons(seqno);
93124
93125 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
93126 index fa4bf66..e92948f 100644
93127 --- a/net/bluetooth/hci_sock.c
93128 +++ b/net/bluetooth/hci_sock.c
93129 @@ -932,7 +932,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
93130 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
93131 }
93132
93133 - len = min_t(unsigned int, len, sizeof(uf));
93134 + len = min((size_t)len, sizeof(uf));
93135 if (copy_from_user(&uf, optval, len)) {
93136 err = -EFAULT;
93137 break;
93138 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
93139 index 63fa111..b166ec6 100644
93140 --- a/net/bluetooth/l2cap_core.c
93141 +++ b/net/bluetooth/l2cap_core.c
93142 @@ -3511,8 +3511,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
93143 break;
93144
93145 case L2CAP_CONF_RFC:
93146 - if (olen == sizeof(rfc))
93147 - memcpy(&rfc, (void *)val, olen);
93148 + if (olen != sizeof(rfc))
93149 + break;
93150 +
93151 + memcpy(&rfc, (void *)val, olen);
93152
93153 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
93154 rfc.mode != chan->mode)
93155 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
93156 index 0098af8..fb5a31f 100644
93157 --- a/net/bluetooth/l2cap_sock.c
93158 +++ b/net/bluetooth/l2cap_sock.c
93159 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
93160 struct sock *sk = sock->sk;
93161 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
93162 struct l2cap_options opts;
93163 - int len, err = 0;
93164 + int err = 0;
93165 + size_t len = optlen;
93166 u32 opt;
93167
93168 BT_DBG("sk %p", sk);
93169 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
93170 opts.max_tx = chan->max_tx;
93171 opts.txwin_size = chan->tx_win;
93172
93173 - len = min_t(unsigned int, sizeof(opts), optlen);
93174 + len = min(sizeof(opts), len);
93175 if (copy_from_user((char *) &opts, optval, len)) {
93176 err = -EFAULT;
93177 break;
93178 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
93179 struct bt_security sec;
93180 struct bt_power pwr;
93181 struct l2cap_conn *conn;
93182 - int len, err = 0;
93183 + int err = 0;
93184 + size_t len = optlen;
93185 u32 opt;
93186
93187 BT_DBG("sk %p", sk);
93188 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
93189
93190 sec.level = BT_SECURITY_LOW;
93191
93192 - len = min_t(unsigned int, sizeof(sec), optlen);
93193 + len = min(sizeof(sec), len);
93194 if (copy_from_user((char *) &sec, optval, len)) {
93195 err = -EFAULT;
93196 break;
93197 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
93198
93199 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
93200
93201 - len = min_t(unsigned int, sizeof(pwr), optlen);
93202 + len = min(sizeof(pwr), len);
93203 if (copy_from_user((char *) &pwr, optval, len)) {
93204 err = -EFAULT;
93205 break;
93206 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
93207 index c1c6028..17e8dcc 100644
93208 --- a/net/bluetooth/rfcomm/sock.c
93209 +++ b/net/bluetooth/rfcomm/sock.c
93210 @@ -665,7 +665,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
93211 struct sock *sk = sock->sk;
93212 struct bt_security sec;
93213 int err = 0;
93214 - size_t len;
93215 + size_t len = optlen;
93216 u32 opt;
93217
93218 BT_DBG("sk %p", sk);
93219 @@ -687,7 +687,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
93220
93221 sec.level = BT_SECURITY_LOW;
93222
93223 - len = min_t(unsigned int, sizeof(sec), optlen);
93224 + len = min(sizeof(sec), len);
93225 if (copy_from_user((char *) &sec, optval, len)) {
93226 err = -EFAULT;
93227 break;
93228 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
93229 index 84fcf9f..e389b27 100644
93230 --- a/net/bluetooth/rfcomm/tty.c
93231 +++ b/net/bluetooth/rfcomm/tty.c
93232 @@ -684,7 +684,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
93233 BT_DBG("tty %p id %d", tty, tty->index);
93234
93235 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
93236 - dev->channel, dev->port.count);
93237 + dev->channel, atomic_read(&dev->port.count));
93238
93239 err = tty_port_open(&dev->port, tty, filp);
93240 if (err)
93241 @@ -707,7 +707,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
93242 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
93243
93244 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
93245 - dev->port.count);
93246 + atomic_read(&dev->port.count));
93247
93248 tty_port_close(&dev->port, tty, filp);
93249 }
93250 diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
93251 index 5180938..7c470c3 100644
93252 --- a/net/bridge/netfilter/ebt_ulog.c
93253 +++ b/net/bridge/netfilter/ebt_ulog.c
93254 @@ -181,6 +181,7 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
93255 ub->qlen++;
93256
93257 pm = nlmsg_data(nlh);
93258 + memset(pm, 0, sizeof(*pm));
93259
93260 /* Fill in the ulog data */
93261 pm->version = EBT_ULOG_VERSION;
93262 @@ -193,8 +194,6 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
93263 pm->hook = hooknr;
93264 if (uloginfo->prefix != NULL)
93265 strcpy(pm->prefix, uloginfo->prefix);
93266 - else
93267 - *(pm->prefix) = '\0';
93268
93269 if (in) {
93270 strcpy(pm->physindev, in->name);
93271 @@ -204,16 +203,14 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
93272 strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
93273 else
93274 strcpy(pm->indev, in->name);
93275 - } else
93276 - pm->indev[0] = pm->physindev[0] = '\0';
93277 + }
93278
93279 if (out) {
93280 /* If out exists, then out is a bridge port */
93281 strcpy(pm->physoutdev, out->name);
93282 /* rcu_read_lock()ed by nf_hook_slow */
93283 strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
93284 - } else
93285 - pm->outdev[0] = pm->physoutdev[0] = '\0';
93286 + }
93287
93288 if (skb_copy_bits(skb, -ETH_HLEN, pm->data, copy_len) < 0)
93289 BUG();
93290 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
93291 index ac78024..161a80c 100644
93292 --- a/net/bridge/netfilter/ebtables.c
93293 +++ b/net/bridge/netfilter/ebtables.c
93294 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93295 tmp.valid_hooks = t->table->valid_hooks;
93296 }
93297 mutex_unlock(&ebt_mutex);
93298 - if (copy_to_user(user, &tmp, *len) != 0){
93299 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
93300 BUGPRINT("c2u Didn't work\n");
93301 ret = -EFAULT;
93302 break;
93303 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
93304 goto out;
93305 tmp.valid_hooks = t->valid_hooks;
93306
93307 - if (copy_to_user(user, &tmp, *len) != 0) {
93308 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
93309 ret = -EFAULT;
93310 break;
93311 }
93312 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
93313 tmp.entries_size = t->table->entries_size;
93314 tmp.valid_hooks = t->table->valid_hooks;
93315
93316 - if (copy_to_user(user, &tmp, *len) != 0) {
93317 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
93318 ret = -EFAULT;
93319 break;
93320 }
93321 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
93322 index 0f45522..dab651f 100644
93323 --- a/net/caif/cfctrl.c
93324 +++ b/net/caif/cfctrl.c
93325 @@ -10,6 +10,7 @@
93326 #include <linux/spinlock.h>
93327 #include <linux/slab.h>
93328 #include <linux/pkt_sched.h>
93329 +#include <linux/sched.h>
93330 #include <net/caif/caif_layer.h>
93331 #include <net/caif/cfpkt.h>
93332 #include <net/caif/cfctrl.h>
93333 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
93334 memset(&dev_info, 0, sizeof(dev_info));
93335 dev_info.id = 0xff;
93336 cfsrvl_init(&this->serv, 0, &dev_info, false);
93337 - atomic_set(&this->req_seq_no, 1);
93338 - atomic_set(&this->rsp_seq_no, 1);
93339 + atomic_set_unchecked(&this->req_seq_no, 1);
93340 + atomic_set_unchecked(&this->rsp_seq_no, 1);
93341 this->serv.layer.receive = cfctrl_recv;
93342 sprintf(this->serv.layer.name, "ctrl");
93343 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
93344 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
93345 struct cfctrl_request_info *req)
93346 {
93347 spin_lock_bh(&ctrl->info_list_lock);
93348 - atomic_inc(&ctrl->req_seq_no);
93349 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
93350 + atomic_inc_unchecked(&ctrl->req_seq_no);
93351 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
93352 list_add_tail(&req->list, &ctrl->list);
93353 spin_unlock_bh(&ctrl->info_list_lock);
93354 }
93355 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
93356 if (p != first)
93357 pr_warn("Requests are not received in order\n");
93358
93359 - atomic_set(&ctrl->rsp_seq_no,
93360 + atomic_set_unchecked(&ctrl->rsp_seq_no,
93361 p->sequence_no);
93362 list_del(&p->list);
93363 goto out;
93364 diff --git a/net/can/af_can.c b/net/can/af_can.c
93365 index 3ab8dd2..b9aef13 100644
93366 --- a/net/can/af_can.c
93367 +++ b/net/can/af_can.c
93368 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
93369 };
93370
93371 /* notifier block for netdevice event */
93372 -static struct notifier_block can_netdev_notifier __read_mostly = {
93373 +static struct notifier_block can_netdev_notifier = {
93374 .notifier_call = can_notifier,
93375 };
93376
93377 diff --git a/net/can/gw.c b/net/can/gw.c
93378 index 3f9b0f3..fc6d4fa 100644
93379 --- a/net/can/gw.c
93380 +++ b/net/can/gw.c
93381 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
93382 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
93383
93384 static HLIST_HEAD(cgw_list);
93385 -static struct notifier_block notifier;
93386
93387 static struct kmem_cache *cgw_cache __read_mostly;
93388
93389 @@ -954,6 +953,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
93390 return err;
93391 }
93392
93393 +static struct notifier_block notifier = {
93394 + .notifier_call = cgw_notifier
93395 +};
93396 +
93397 static __init int cgw_module_init(void)
93398 {
93399 /* sanitize given module parameter */
93400 @@ -969,7 +972,6 @@ static __init int cgw_module_init(void)
93401 return -ENOMEM;
93402
93403 /* set notifier */
93404 - notifier.notifier_call = cgw_notifier;
93405 register_netdevice_notifier(&notifier);
93406
93407 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
93408 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
93409 index 4a5df7b..9ad1f1d 100644
93410 --- a/net/ceph/messenger.c
93411 +++ b/net/ceph/messenger.c
93412 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
93413 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
93414
93415 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
93416 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
93417 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
93418
93419 static struct page *zero_page; /* used in certain error cases */
93420
93421 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
93422 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
93423 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
93424
93425 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
93426 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
93427 s = addr_str[i];
93428
93429 switch (ss->ss_family) {
93430 diff --git a/net/compat.c b/net/compat.c
93431 index dd32e34..6066f87 100644
93432 --- a/net/compat.c
93433 +++ b/net/compat.c
93434 @@ -73,9 +73,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
93435 return -EFAULT;
93436 if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
93437 kmsg->msg_namelen = sizeof(struct sockaddr_storage);
93438 - kmsg->msg_name = compat_ptr(tmp1);
93439 - kmsg->msg_iov = compat_ptr(tmp2);
93440 - kmsg->msg_control = compat_ptr(tmp3);
93441 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
93442 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
93443 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
93444 return 0;
93445 }
93446
93447 @@ -87,7 +87,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
93448
93449 if (kern_msg->msg_namelen) {
93450 if (mode == VERIFY_READ) {
93451 - int err = move_addr_to_kernel(kern_msg->msg_name,
93452 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
93453 kern_msg->msg_namelen,
93454 kern_address);
93455 if (err < 0)
93456 @@ -99,7 +99,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
93457 kern_msg->msg_name = NULL;
93458
93459 tot_len = iov_from_user_compat_to_kern(kern_iov,
93460 - (struct compat_iovec __user *)kern_msg->msg_iov,
93461 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
93462 kern_msg->msg_iovlen);
93463 if (tot_len >= 0)
93464 kern_msg->msg_iov = kern_iov;
93465 @@ -119,20 +119,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
93466
93467 #define CMSG_COMPAT_FIRSTHDR(msg) \
93468 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
93469 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
93470 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
93471 (struct compat_cmsghdr __user *)NULL)
93472
93473 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
93474 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
93475 (ucmlen) <= (unsigned long) \
93476 ((mhdr)->msg_controllen - \
93477 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
93478 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
93479
93480 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
93481 struct compat_cmsghdr __user *cmsg, int cmsg_len)
93482 {
93483 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
93484 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
93485 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
93486 msg->msg_controllen)
93487 return NULL;
93488 return (struct compat_cmsghdr __user *)ptr;
93489 @@ -222,7 +222,7 @@ Efault:
93490
93491 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
93492 {
93493 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
93494 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
93495 struct compat_cmsghdr cmhdr;
93496 struct compat_timeval ctv;
93497 struct compat_timespec cts[3];
93498 @@ -278,7 +278,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
93499
93500 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
93501 {
93502 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
93503 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
93504 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
93505 int fdnum = scm->fp->count;
93506 struct file **fp = scm->fp->fp;
93507 @@ -366,7 +366,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
93508 return -EFAULT;
93509 old_fs = get_fs();
93510 set_fs(KERNEL_DS);
93511 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
93512 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
93513 set_fs(old_fs);
93514
93515 return err;
93516 @@ -427,7 +427,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
93517 len = sizeof(ktime);
93518 old_fs = get_fs();
93519 set_fs(KERNEL_DS);
93520 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
93521 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
93522 set_fs(old_fs);
93523
93524 if (!err) {
93525 @@ -570,7 +570,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
93526 case MCAST_JOIN_GROUP:
93527 case MCAST_LEAVE_GROUP:
93528 {
93529 - struct compat_group_req __user *gr32 = (void *)optval;
93530 + struct compat_group_req __user *gr32 = (void __user *)optval;
93531 struct group_req __user *kgr =
93532 compat_alloc_user_space(sizeof(struct group_req));
93533 u32 interface;
93534 @@ -591,7 +591,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
93535 case MCAST_BLOCK_SOURCE:
93536 case MCAST_UNBLOCK_SOURCE:
93537 {
93538 - struct compat_group_source_req __user *gsr32 = (void *)optval;
93539 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
93540 struct group_source_req __user *kgsr = compat_alloc_user_space(
93541 sizeof(struct group_source_req));
93542 u32 interface;
93543 @@ -612,7 +612,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
93544 }
93545 case MCAST_MSFILTER:
93546 {
93547 - struct compat_group_filter __user *gf32 = (void *)optval;
93548 + struct compat_group_filter __user *gf32 = (void __user *)optval;
93549 struct group_filter __user *kgf;
93550 u32 interface, fmode, numsrc;
93551
93552 @@ -650,7 +650,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
93553 char __user *optval, int __user *optlen,
93554 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
93555 {
93556 - struct compat_group_filter __user *gf32 = (void *)optval;
93557 + struct compat_group_filter __user *gf32 = (void __user *)optval;
93558 struct group_filter __user *kgf;
93559 int __user *koptlen;
93560 u32 interface, fmode, numsrc;
93561 @@ -808,7 +808,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
93562
93563 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
93564 return -EINVAL;
93565 - if (copy_from_user(a, args, nas[call]))
93566 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
93567 return -EFAULT;
93568 a0 = a[0];
93569 a1 = a[1];
93570 diff --git a/net/core/datagram.c b/net/core/datagram.c
93571 index af814e7..3d761de 100644
93572 --- a/net/core/datagram.c
93573 +++ b/net/core/datagram.c
93574 @@ -301,7 +301,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
93575 }
93576
93577 kfree_skb(skb);
93578 - atomic_inc(&sk->sk_drops);
93579 + atomic_inc_unchecked(&sk->sk_drops);
93580 sk_mem_reclaim_partial(sk);
93581
93582 return err;
93583 diff --git a/net/core/dev.c b/net/core/dev.c
93584 index 3d13874..6e78dc7 100644
93585 --- a/net/core/dev.c
93586 +++ b/net/core/dev.c
93587 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
93588 {
93589 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
93590 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
93591 - atomic_long_inc(&dev->rx_dropped);
93592 + atomic_long_inc_unchecked(&dev->rx_dropped);
93593 kfree_skb(skb);
93594 return NET_RX_DROP;
93595 }
93596 }
93597
93598 if (unlikely(!is_skb_forwardable(dev, skb))) {
93599 - atomic_long_inc(&dev->rx_dropped);
93600 + atomic_long_inc_unchecked(&dev->rx_dropped);
93601 kfree_skb(skb);
93602 return NET_RX_DROP;
93603 }
93604 @@ -2428,7 +2428,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
93605
93606 struct dev_gso_cb {
93607 void (*destructor)(struct sk_buff *skb);
93608 -};
93609 +} __no_const;
93610
93611 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
93612
93613 @@ -3203,7 +3203,7 @@ enqueue:
93614
93615 local_irq_restore(flags);
93616
93617 - atomic_long_inc(&skb->dev->rx_dropped);
93618 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
93619 kfree_skb(skb);
93620 return NET_RX_DROP;
93621 }
93622 @@ -3275,7 +3275,7 @@ int netif_rx_ni(struct sk_buff *skb)
93623 }
93624 EXPORT_SYMBOL(netif_rx_ni);
93625
93626 -static void net_tx_action(struct softirq_action *h)
93627 +static __latent_entropy void net_tx_action(void)
93628 {
93629 struct softnet_data *sd = &__get_cpu_var(softnet_data);
93630
93631 @@ -3609,7 +3609,7 @@ ncls:
93632 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
93633 } else {
93634 drop:
93635 - atomic_long_inc(&skb->dev->rx_dropped);
93636 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
93637 kfree_skb(skb);
93638 /* Jamal, now you will not able to escape explaining
93639 * me how you were going to use this. :-)
93640 @@ -4269,7 +4269,7 @@ void netif_napi_del(struct napi_struct *napi)
93641 }
93642 EXPORT_SYMBOL(netif_napi_del);
93643
93644 -static void net_rx_action(struct softirq_action *h)
93645 +static __latent_entropy void net_rx_action(void)
93646 {
93647 struct softnet_data *sd = &__get_cpu_var(softnet_data);
93648 unsigned long time_limit = jiffies + 2;
93649 @@ -5973,7 +5973,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
93650 } else {
93651 netdev_stats_to_stats64(storage, &dev->stats);
93652 }
93653 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
93654 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
93655 return storage;
93656 }
93657 EXPORT_SYMBOL(dev_get_stats);
93658 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
93659 index 5b7d0e1..cb960fc 100644
93660 --- a/net/core/dev_ioctl.c
93661 +++ b/net/core/dev_ioctl.c
93662 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
93663 if (no_module && capable(CAP_NET_ADMIN))
93664 no_module = request_module("netdev-%s", name);
93665 if (no_module && capable(CAP_SYS_MODULE)) {
93666 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
93667 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
93668 +#else
93669 if (!request_module("%s", name))
93670 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
93671 name);
93672 +#endif
93673 }
93674 }
93675 EXPORT_SYMBOL(dev_load);
93676 diff --git a/net/core/flow.c b/net/core/flow.c
93677 index dfa602c..3103d88 100644
93678 --- a/net/core/flow.c
93679 +++ b/net/core/flow.c
93680 @@ -61,7 +61,7 @@ struct flow_cache {
93681 struct timer_list rnd_timer;
93682 };
93683
93684 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
93685 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
93686 EXPORT_SYMBOL(flow_cache_genid);
93687 static struct flow_cache flow_cache_global;
93688 static struct kmem_cache *flow_cachep __read_mostly;
93689 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
93690
93691 static int flow_entry_valid(struct flow_cache_entry *fle)
93692 {
93693 - if (atomic_read(&flow_cache_genid) != fle->genid)
93694 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
93695 return 0;
93696 if (fle->object && !fle->object->ops->check(fle->object))
93697 return 0;
93698 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
93699 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
93700 fcp->hash_count++;
93701 }
93702 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
93703 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
93704 flo = fle->object;
93705 if (!flo)
93706 goto ret_object;
93707 @@ -279,7 +279,7 @@ nocache:
93708 }
93709 flo = resolver(net, key, family, dir, flo, ctx);
93710 if (fle) {
93711 - fle->genid = atomic_read(&flow_cache_genid);
93712 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
93713 if (!IS_ERR(flo))
93714 fle->object = flo;
93715 else
93716 diff --git a/net/core/iovec.c b/net/core/iovec.c
93717 index 7d84ea1..55385ae 100644
93718 --- a/net/core/iovec.c
93719 +++ b/net/core/iovec.c
93720 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
93721 if (m->msg_namelen) {
93722 if (mode == VERIFY_READ) {
93723 void __user *namep;
93724 - namep = (void __user __force *) m->msg_name;
93725 + namep = (void __force_user *) m->msg_name;
93726 err = move_addr_to_kernel(namep, m->msg_namelen,
93727 address);
93728 if (err < 0)
93729 @@ -55,7 +55,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
93730 }
93731
93732 size = m->msg_iovlen * sizeof(struct iovec);
93733 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
93734 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
93735 return -EFAULT;
93736
93737 m->msg_iov = iov;
93738 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
93739 index 11af243..7357d84 100644
93740 --- a/net/core/neighbour.c
93741 +++ b/net/core/neighbour.c
93742 @@ -2774,7 +2774,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
93743 void __user *buffer, size_t *lenp, loff_t *ppos)
93744 {
93745 int size, ret;
93746 - struct ctl_table tmp = *ctl;
93747 + ctl_table_no_const tmp = *ctl;
93748
93749 tmp.extra1 = &zero;
93750 tmp.extra2 = &unres_qlen_max;
93751 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
93752 index 2bf8329..7960607 100644
93753 --- a/net/core/net-procfs.c
93754 +++ b/net/core/net-procfs.c
93755 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
93756 else
93757 seq_printf(seq, "%04x", ntohs(pt->type));
93758
93759 +#ifdef CONFIG_GRKERNSEC_HIDESYM
93760 + seq_printf(seq, " %-8s %pf\n",
93761 + pt->dev ? pt->dev->name : "", NULL);
93762 +#else
93763 seq_printf(seq, " %-8s %pf\n",
93764 pt->dev ? pt->dev->name : "", pt->func);
93765 +#endif
93766 }
93767
93768 return 0;
93769 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
93770 index d954b56..b0a0f7a 100644
93771 --- a/net/core/net-sysfs.c
93772 +++ b/net/core/net-sysfs.c
93773 @@ -1356,7 +1356,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
93774 }
93775 EXPORT_SYMBOL(netdev_class_remove_file);
93776
93777 -int netdev_kobject_init(void)
93778 +int __init netdev_kobject_init(void)
93779 {
93780 kobj_ns_type_register(&net_ns_type_operations);
93781 return class_register(&net_class);
93782 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
93783 index 81d3a9a..a0bd7a8 100644
93784 --- a/net/core/net_namespace.c
93785 +++ b/net/core/net_namespace.c
93786 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
93787 int error;
93788 LIST_HEAD(net_exit_list);
93789
93790 - list_add_tail(&ops->list, list);
93791 + pax_list_add_tail((struct list_head *)&ops->list, list);
93792 if (ops->init || (ops->id && ops->size)) {
93793 for_each_net(net) {
93794 error = ops_init(ops, net);
93795 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
93796
93797 out_undo:
93798 /* If I have an error cleanup all namespaces I initialized */
93799 - list_del(&ops->list);
93800 + pax_list_del((struct list_head *)&ops->list);
93801 ops_exit_list(ops, &net_exit_list);
93802 ops_free_list(ops, &net_exit_list);
93803 return error;
93804 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
93805 struct net *net;
93806 LIST_HEAD(net_exit_list);
93807
93808 - list_del(&ops->list);
93809 + pax_list_del((struct list_head *)&ops->list);
93810 for_each_net(net)
93811 list_add_tail(&net->exit_list, &net_exit_list);
93812 ops_exit_list(ops, &net_exit_list);
93813 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
93814 mutex_lock(&net_mutex);
93815 error = register_pernet_operations(&pernet_list, ops);
93816 if (!error && (first_device == &pernet_list))
93817 - first_device = &ops->list;
93818 + first_device = (struct list_head *)&ops->list;
93819 mutex_unlock(&net_mutex);
93820 return error;
93821 }
93822 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
93823 index 0c1482c..f7ae314 100644
93824 --- a/net/core/netpoll.c
93825 +++ b/net/core/netpoll.c
93826 @@ -435,7 +435,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
93827 struct udphdr *udph;
93828 struct iphdr *iph;
93829 struct ethhdr *eth;
93830 - static atomic_t ip_ident;
93831 + static atomic_unchecked_t ip_ident;
93832 struct ipv6hdr *ip6h;
93833
93834 udp_len = len + sizeof(*udph);
93835 @@ -506,7 +506,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
93836 put_unaligned(0x45, (unsigned char *)iph);
93837 iph->tos = 0;
93838 put_unaligned(htons(ip_len), &(iph->tot_len));
93839 - iph->id = htons(atomic_inc_return(&ip_ident));
93840 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
93841 iph->frag_off = 0;
93842 iph->ttl = 64;
93843 iph->protocol = IPPROTO_UDP;
93844 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
93845 index 2a0e21d..6ad7642 100644
93846 --- a/net/core/rtnetlink.c
93847 +++ b/net/core/rtnetlink.c
93848 @@ -58,7 +58,7 @@ struct rtnl_link {
93849 rtnl_doit_func doit;
93850 rtnl_dumpit_func dumpit;
93851 rtnl_calcit_func calcit;
93852 -};
93853 +} __no_const;
93854
93855 static DEFINE_MUTEX(rtnl_mutex);
93856
93857 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
93858 if (rtnl_link_ops_get(ops->kind))
93859 return -EEXIST;
93860
93861 - if (!ops->dellink)
93862 - ops->dellink = unregister_netdevice_queue;
93863 + if (!ops->dellink) {
93864 + pax_open_kernel();
93865 + *(void **)&ops->dellink = unregister_netdevice_queue;
93866 + pax_close_kernel();
93867 + }
93868
93869 - list_add_tail(&ops->list, &link_ops);
93870 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
93871 return 0;
93872 }
93873 EXPORT_SYMBOL_GPL(__rtnl_link_register);
93874 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
93875 for_each_net(net) {
93876 __rtnl_kill_links(net, ops);
93877 }
93878 - list_del(&ops->list);
93879 + pax_list_del((struct list_head *)&ops->list);
93880 }
93881 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
93882
93883 diff --git a/net/core/scm.c b/net/core/scm.c
93884 index b442e7e..6f5b5a2 100644
93885 --- a/net/core/scm.c
93886 +++ b/net/core/scm.c
93887 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
93888 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
93889 {
93890 struct cmsghdr __user *cm
93891 - = (__force struct cmsghdr __user *)msg->msg_control;
93892 + = (struct cmsghdr __force_user *)msg->msg_control;
93893 struct cmsghdr cmhdr;
93894 int cmlen = CMSG_LEN(len);
93895 int err;
93896 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
93897 err = -EFAULT;
93898 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
93899 goto out;
93900 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
93901 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
93902 goto out;
93903 cmlen = CMSG_SPACE(len);
93904 if (msg->msg_controllen < cmlen)
93905 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
93906 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
93907 {
93908 struct cmsghdr __user *cm
93909 - = (__force struct cmsghdr __user*)msg->msg_control;
93910 + = (struct cmsghdr __force_user *)msg->msg_control;
93911
93912 int fdmax = 0;
93913 int fdnum = scm->fp->count;
93914 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
93915 if (fdnum < fdmax)
93916 fdmax = fdnum;
93917
93918 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
93919 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
93920 i++, cmfptr++)
93921 {
93922 struct socket *sock;
93923 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
93924 index 743e6eb..a399a6d 100644
93925 --- a/net/core/skbuff.c
93926 +++ b/net/core/skbuff.c
93927 @@ -3104,13 +3104,15 @@ void __init skb_init(void)
93928 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
93929 sizeof(struct sk_buff),
93930 0,
93931 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
93932 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
93933 + SLAB_NO_SANITIZE,
93934 NULL);
93935 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
93936 (2*sizeof(struct sk_buff)) +
93937 sizeof(atomic_t),
93938 0,
93939 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
93940 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
93941 + SLAB_NO_SANITIZE,
93942 NULL);
93943 }
93944
93945 diff --git a/net/core/sock.c b/net/core/sock.c
93946 index 5cec994..81aa1dd 100644
93947 --- a/net/core/sock.c
93948 +++ b/net/core/sock.c
93949 @@ -393,7 +393,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93950 struct sk_buff_head *list = &sk->sk_receive_queue;
93951
93952 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
93953 - atomic_inc(&sk->sk_drops);
93954 + atomic_inc_unchecked(&sk->sk_drops);
93955 trace_sock_rcvqueue_full(sk, skb);
93956 return -ENOMEM;
93957 }
93958 @@ -403,7 +403,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93959 return err;
93960
93961 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
93962 - atomic_inc(&sk->sk_drops);
93963 + atomic_inc_unchecked(&sk->sk_drops);
93964 return -ENOBUFS;
93965 }
93966
93967 @@ -423,7 +423,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93968 skb_dst_force(skb);
93969
93970 spin_lock_irqsave(&list->lock, flags);
93971 - skb->dropcount = atomic_read(&sk->sk_drops);
93972 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
93973 __skb_queue_tail(list, skb);
93974 spin_unlock_irqrestore(&list->lock, flags);
93975
93976 @@ -443,7 +443,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
93977 skb->dev = NULL;
93978
93979 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
93980 - atomic_inc(&sk->sk_drops);
93981 + atomic_inc_unchecked(&sk->sk_drops);
93982 goto discard_and_relse;
93983 }
93984 if (nested)
93985 @@ -461,7 +461,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
93986 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
93987 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
93988 bh_unlock_sock(sk);
93989 - atomic_inc(&sk->sk_drops);
93990 + atomic_inc_unchecked(&sk->sk_drops);
93991 goto discard_and_relse;
93992 }
93993
93994 @@ -949,12 +949,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
93995 struct timeval tm;
93996 } v;
93997
93998 - int lv = sizeof(int);
93999 - int len;
94000 + unsigned int lv = sizeof(int);
94001 + unsigned int len;
94002
94003 if (get_user(len, optlen))
94004 return -EFAULT;
94005 - if (len < 0)
94006 + if (len > INT_MAX)
94007 return -EINVAL;
94008
94009 memset(&v, 0, sizeof(v));
94010 @@ -1106,11 +1106,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
94011
94012 case SO_PEERNAME:
94013 {
94014 - char address[128];
94015 + char address[_K_SS_MAXSIZE];
94016
94017 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
94018 return -ENOTCONN;
94019 - if (lv < len)
94020 + if (lv < len || sizeof address < len)
94021 return -EINVAL;
94022 if (copy_to_user(optval, address, len))
94023 return -EFAULT;
94024 @@ -1183,7 +1183,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
94025
94026 if (len > lv)
94027 len = lv;
94028 - if (copy_to_user(optval, &v, len))
94029 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
94030 return -EFAULT;
94031 lenout:
94032 if (put_user(len, optlen))
94033 @@ -2326,7 +2326,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
94034 */
94035 smp_wmb();
94036 atomic_set(&sk->sk_refcnt, 1);
94037 - atomic_set(&sk->sk_drops, 0);
94038 + atomic_set_unchecked(&sk->sk_drops, 0);
94039 }
94040 EXPORT_SYMBOL(sock_init_data);
94041
94042 @@ -2451,6 +2451,7 @@ void sock_enable_timestamp(struct sock *sk, int flag)
94043 int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
94044 int level, int type)
94045 {
94046 + struct sock_extended_err ee;
94047 struct sock_exterr_skb *serr;
94048 struct sk_buff *skb, *skb2;
94049 int copied, err;
94050 @@ -2472,7 +2473,8 @@ int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
94051 sock_recv_timestamp(msg, sk, skb);
94052
94053 serr = SKB_EXT_ERR(skb);
94054 - put_cmsg(msg, level, type, sizeof(serr->ee), &serr->ee);
94055 + ee = serr->ee;
94056 + put_cmsg(msg, level, type, sizeof ee, &ee);
94057
94058 msg->msg_flags |= MSG_ERRQUEUE;
94059 err = copied;
94060 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
94061 index a0e9cf6..ef7f9ed 100644
94062 --- a/net/core/sock_diag.c
94063 +++ b/net/core/sock_diag.c
94064 @@ -9,26 +9,33 @@
94065 #include <linux/inet_diag.h>
94066 #include <linux/sock_diag.h>
94067
94068 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
94069 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
94070 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
94071 static DEFINE_MUTEX(sock_diag_table_mutex);
94072
94073 int sock_diag_check_cookie(void *sk, __u32 *cookie)
94074 {
94075 +#ifndef CONFIG_GRKERNSEC_HIDESYM
94076 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
94077 cookie[1] != INET_DIAG_NOCOOKIE) &&
94078 ((u32)(unsigned long)sk != cookie[0] ||
94079 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
94080 return -ESTALE;
94081 else
94082 +#endif
94083 return 0;
94084 }
94085 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
94086
94087 void sock_diag_save_cookie(void *sk, __u32 *cookie)
94088 {
94089 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94090 + cookie[0] = 0;
94091 + cookie[1] = 0;
94092 +#else
94093 cookie[0] = (u32)(unsigned long)sk;
94094 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
94095 +#endif
94096 }
94097 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
94098
94099 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
94100 mutex_lock(&sock_diag_table_mutex);
94101 if (sock_diag_handlers[hndl->family])
94102 err = -EBUSY;
94103 - else
94104 + else {
94105 + pax_open_kernel();
94106 sock_diag_handlers[hndl->family] = hndl;
94107 + pax_close_kernel();
94108 + }
94109 mutex_unlock(&sock_diag_table_mutex);
94110
94111 return err;
94112 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
94113
94114 mutex_lock(&sock_diag_table_mutex);
94115 BUG_ON(sock_diag_handlers[family] != hnld);
94116 + pax_open_kernel();
94117 sock_diag_handlers[family] = NULL;
94118 + pax_close_kernel();
94119 mutex_unlock(&sock_diag_table_mutex);
94120 }
94121 EXPORT_SYMBOL_GPL(sock_diag_unregister);
94122 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
94123 index cca4441..5e616de 100644
94124 --- a/net/core/sysctl_net_core.c
94125 +++ b/net/core/sysctl_net_core.c
94126 @@ -32,7 +32,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
94127 {
94128 unsigned int orig_size, size;
94129 int ret, i;
94130 - struct ctl_table tmp = {
94131 + ctl_table_no_const tmp = {
94132 .data = &size,
94133 .maxlen = sizeof(size),
94134 .mode = table->mode
94135 @@ -199,7 +199,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
94136 void __user *buffer, size_t *lenp, loff_t *ppos)
94137 {
94138 char id[IFNAMSIZ];
94139 - struct ctl_table tbl = {
94140 + ctl_table_no_const tbl = {
94141 .data = id,
94142 .maxlen = IFNAMSIZ,
94143 };
94144 @@ -378,13 +378,12 @@ static struct ctl_table netns_core_table[] = {
94145
94146 static __net_init int sysctl_core_net_init(struct net *net)
94147 {
94148 - struct ctl_table *tbl;
94149 + ctl_table_no_const *tbl = NULL;
94150
94151 net->core.sysctl_somaxconn = SOMAXCONN;
94152
94153 - tbl = netns_core_table;
94154 if (!net_eq(net, &init_net)) {
94155 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
94156 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
94157 if (tbl == NULL)
94158 goto err_dup;
94159
94160 @@ -394,17 +393,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
94161 if (net->user_ns != &init_user_ns) {
94162 tbl[0].procname = NULL;
94163 }
94164 - }
94165 -
94166 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
94167 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
94168 + } else
94169 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
94170 if (net->core.sysctl_hdr == NULL)
94171 goto err_reg;
94172
94173 return 0;
94174
94175 err_reg:
94176 - if (tbl != netns_core_table)
94177 - kfree(tbl);
94178 + kfree(tbl);
94179 err_dup:
94180 return -ENOMEM;
94181 }
94182 @@ -419,7 +417,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
94183 kfree(tbl);
94184 }
94185
94186 -static __net_initdata struct pernet_operations sysctl_core_ops = {
94187 +static __net_initconst struct pernet_operations sysctl_core_ops = {
94188 .init = sysctl_core_net_init,
94189 .exit = sysctl_core_net_exit,
94190 };
94191 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
94192 index dd4d506..fb2fb87 100644
94193 --- a/net/decnet/af_decnet.c
94194 +++ b/net/decnet/af_decnet.c
94195 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
94196 .sysctl_rmem = sysctl_decnet_rmem,
94197 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
94198 .obj_size = sizeof(struct dn_sock),
94199 + .slab_flags = SLAB_USERCOPY,
94200 };
94201
94202 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
94203 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
94204 index 5325b54..a0d4d69 100644
94205 --- a/net/decnet/sysctl_net_decnet.c
94206 +++ b/net/decnet/sysctl_net_decnet.c
94207 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
94208
94209 if (len > *lenp) len = *lenp;
94210
94211 - if (copy_to_user(buffer, addr, len))
94212 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
94213 return -EFAULT;
94214
94215 *lenp = len;
94216 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
94217
94218 if (len > *lenp) len = *lenp;
94219
94220 - if (copy_to_user(buffer, devname, len))
94221 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
94222 return -EFAULT;
94223
94224 *lenp = len;
94225 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
94226 index 008f337..b03b8c9 100644
94227 --- a/net/ieee802154/6lowpan.c
94228 +++ b/net/ieee802154/6lowpan.c
94229 @@ -548,7 +548,7 @@ static int lowpan_header_create(struct sk_buff *skb,
94230 hc06_ptr += 3;
94231 } else {
94232 /* compress nothing */
94233 - memcpy(hc06_ptr, &hdr, 4);
94234 + memcpy(hc06_ptr, hdr, 4);
94235 /* replace the top byte with new ECN | DSCP format */
94236 *hc06_ptr = tmp;
94237 hc06_ptr += 4;
94238 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
94239 index cfeb85c..385989a 100644
94240 --- a/net/ipv4/af_inet.c
94241 +++ b/net/ipv4/af_inet.c
94242 @@ -1675,13 +1675,9 @@ static int __init inet_init(void)
94243
94244 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
94245
94246 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
94247 - if (!sysctl_local_reserved_ports)
94248 - goto out;
94249 -
94250 rc = proto_register(&tcp_prot, 1);
94251 if (rc)
94252 - goto out_free_reserved_ports;
94253 + goto out;
94254
94255 rc = proto_register(&udp_prot, 1);
94256 if (rc)
94257 @@ -1790,8 +1786,6 @@ out_unregister_udp_proto:
94258 proto_unregister(&udp_prot);
94259 out_unregister_tcp_proto:
94260 proto_unregister(&tcp_prot);
94261 -out_free_reserved_ports:
94262 - kfree(sysctl_local_reserved_ports);
94263 goto out;
94264 }
94265
94266 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
94267 index a1b5bcb..62ec5c6 100644
94268 --- a/net/ipv4/devinet.c
94269 +++ b/net/ipv4/devinet.c
94270 @@ -1533,7 +1533,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
94271 idx = 0;
94272 head = &net->dev_index_head[h];
94273 rcu_read_lock();
94274 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
94275 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
94276 net->dev_base_seq;
94277 hlist_for_each_entry_rcu(dev, head, index_hlist) {
94278 if (idx < s_idx)
94279 @@ -1844,7 +1844,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
94280 idx = 0;
94281 head = &net->dev_index_head[h];
94282 rcu_read_lock();
94283 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
94284 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
94285 net->dev_base_seq;
94286 hlist_for_each_entry_rcu(dev, head, index_hlist) {
94287 if (idx < s_idx)
94288 @@ -2069,7 +2069,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
94289 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
94290 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
94291
94292 -static struct devinet_sysctl_table {
94293 +static const struct devinet_sysctl_table {
94294 struct ctl_table_header *sysctl_header;
94295 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
94296 } devinet_sysctl = {
94297 @@ -2191,7 +2191,7 @@ static __net_init int devinet_init_net(struct net *net)
94298 int err;
94299 struct ipv4_devconf *all, *dflt;
94300 #ifdef CONFIG_SYSCTL
94301 - struct ctl_table *tbl = ctl_forward_entry;
94302 + ctl_table_no_const *tbl = NULL;
94303 struct ctl_table_header *forw_hdr;
94304 #endif
94305
94306 @@ -2209,7 +2209,7 @@ static __net_init int devinet_init_net(struct net *net)
94307 goto err_alloc_dflt;
94308
94309 #ifdef CONFIG_SYSCTL
94310 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
94311 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
94312 if (tbl == NULL)
94313 goto err_alloc_ctl;
94314
94315 @@ -2229,7 +2229,10 @@ static __net_init int devinet_init_net(struct net *net)
94316 goto err_reg_dflt;
94317
94318 err = -ENOMEM;
94319 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
94320 + if (!net_eq(net, &init_net))
94321 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
94322 + else
94323 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
94324 if (forw_hdr == NULL)
94325 goto err_reg_ctl;
94326 net->ipv4.forw_hdr = forw_hdr;
94327 @@ -2245,8 +2248,7 @@ err_reg_ctl:
94328 err_reg_dflt:
94329 __devinet_sysctl_unregister(all);
94330 err_reg_all:
94331 - if (tbl != ctl_forward_entry)
94332 - kfree(tbl);
94333 + kfree(tbl);
94334 err_alloc_ctl:
94335 #endif
94336 if (dflt != &ipv4_devconf_dflt)
94337 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
94338 index b3f627a..b0f3e99 100644
94339 --- a/net/ipv4/fib_frontend.c
94340 +++ b/net/ipv4/fib_frontend.c
94341 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
94342 #ifdef CONFIG_IP_ROUTE_MULTIPATH
94343 fib_sync_up(dev);
94344 #endif
94345 - atomic_inc(&net->ipv4.dev_addr_genid);
94346 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
94347 rt_cache_flush(dev_net(dev));
94348 break;
94349 case NETDEV_DOWN:
94350 fib_del_ifaddr(ifa, NULL);
94351 - atomic_inc(&net->ipv4.dev_addr_genid);
94352 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
94353 if (ifa->ifa_dev->ifa_list == NULL) {
94354 /* Last address was deleted from this interface.
94355 * Disable IP.
94356 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
94357 #ifdef CONFIG_IP_ROUTE_MULTIPATH
94358 fib_sync_up(dev);
94359 #endif
94360 - atomic_inc(&net->ipv4.dev_addr_genid);
94361 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
94362 rt_cache_flush(net);
94363 break;
94364 case NETDEV_DOWN:
94365 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
94366 index d5dbca5..6251d5f 100644
94367 --- a/net/ipv4/fib_semantics.c
94368 +++ b/net/ipv4/fib_semantics.c
94369 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
94370 nh->nh_saddr = inet_select_addr(nh->nh_dev,
94371 nh->nh_gw,
94372 nh->nh_parent->fib_scope);
94373 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
94374 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
94375
94376 return nh->nh_saddr;
94377 }
94378 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
94379 index 6acb541..9ea617d 100644
94380 --- a/net/ipv4/inet_connection_sock.c
94381 +++ b/net/ipv4/inet_connection_sock.c
94382 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
94383 .range = { 32768, 61000 },
94384 };
94385
94386 -unsigned long *sysctl_local_reserved_ports;
94387 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
94388 EXPORT_SYMBOL(sysctl_local_reserved_ports);
94389
94390 void inet_get_local_port_range(int *low, int *high)
94391 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
94392 index 96da9c7..b956690 100644
94393 --- a/net/ipv4/inet_hashtables.c
94394 +++ b/net/ipv4/inet_hashtables.c
94395 @@ -18,12 +18,15 @@
94396 #include <linux/sched.h>
94397 #include <linux/slab.h>
94398 #include <linux/wait.h>
94399 +#include <linux/security.h>
94400
94401 #include <net/inet_connection_sock.h>
94402 #include <net/inet_hashtables.h>
94403 #include <net/secure_seq.h>
94404 #include <net/ip.h>
94405
94406 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
94407 +
94408 /*
94409 * Allocate and initialize a new local port bind bucket.
94410 * The bindhash mutex for snum's hash chain must be held here.
94411 @@ -554,6 +557,8 @@ ok:
94412 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
94413 spin_unlock(&head->lock);
94414
94415 + gr_update_task_in_ip_table(current, inet_sk(sk));
94416 +
94417 if (tw) {
94418 inet_twsk_deschedule(tw, death_row);
94419 while (twrefcnt) {
94420 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
94421 index 33d5537..da337a4 100644
94422 --- a/net/ipv4/inetpeer.c
94423 +++ b/net/ipv4/inetpeer.c
94424 @@ -503,8 +503,8 @@ relookup:
94425 if (p) {
94426 p->daddr = *daddr;
94427 atomic_set(&p->refcnt, 1);
94428 - atomic_set(&p->rid, 0);
94429 - atomic_set(&p->ip_id_count,
94430 + atomic_set_unchecked(&p->rid, 0);
94431 + atomic_set_unchecked(&p->ip_id_count,
94432 (daddr->family == AF_INET) ?
94433 secure_ip_id(daddr->addr.a4) :
94434 secure_ipv6_id(daddr->addr.a6));
94435 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
94436 index b66910a..cfe416e 100644
94437 --- a/net/ipv4/ip_fragment.c
94438 +++ b/net/ipv4/ip_fragment.c
94439 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
94440 return 0;
94441
94442 start = qp->rid;
94443 - end = atomic_inc_return(&peer->rid);
94444 + end = atomic_inc_return_unchecked(&peer->rid);
94445 qp->rid = end;
94446
94447 rc = qp->q.fragments && (end - start) > max;
94448 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
94449
94450 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
94451 {
94452 - struct ctl_table *table;
94453 + ctl_table_no_const *table = NULL;
94454 struct ctl_table_header *hdr;
94455
94456 - table = ip4_frags_ns_ctl_table;
94457 if (!net_eq(net, &init_net)) {
94458 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
94459 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
94460 if (table == NULL)
94461 goto err_alloc;
94462
94463 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
94464 /* Don't export sysctls to unprivileged users */
94465 if (net->user_ns != &init_user_ns)
94466 table[0].procname = NULL;
94467 - }
94468 + hdr = register_net_sysctl(net, "net/ipv4", table);
94469 + } else
94470 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
94471
94472 - hdr = register_net_sysctl(net, "net/ipv4", table);
94473 if (hdr == NULL)
94474 goto err_reg;
94475
94476 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
94477 return 0;
94478
94479 err_reg:
94480 - if (!net_eq(net, &init_net))
94481 - kfree(table);
94482 + kfree(table);
94483 err_alloc:
94484 return -ENOMEM;
94485 }
94486 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
94487 index e560ef3..218c5c5 100644
94488 --- a/net/ipv4/ip_gre.c
94489 +++ b/net/ipv4/ip_gre.c
94490 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
94491 module_param(log_ecn_error, bool, 0644);
94492 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
94493
94494 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
94495 +static struct rtnl_link_ops ipgre_link_ops;
94496 static int ipgre_tunnel_init(struct net_device *dev);
94497
94498 static int ipgre_net_id __read_mostly;
94499 @@ -732,7 +732,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
94500 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
94501 };
94502
94503 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
94504 +static struct rtnl_link_ops ipgre_link_ops = {
94505 .kind = "gre",
94506 .maxtype = IFLA_GRE_MAX,
94507 .policy = ipgre_policy,
94508 @@ -746,7 +746,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
94509 .fill_info = ipgre_fill_info,
94510 };
94511
94512 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
94513 +static struct rtnl_link_ops ipgre_tap_ops = {
94514 .kind = "gretap",
94515 .maxtype = IFLA_GRE_MAX,
94516 .policy = ipgre_policy,
94517 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
94518 index 23e6ab0..be67a57 100644
94519 --- a/net/ipv4/ip_sockglue.c
94520 +++ b/net/ipv4/ip_sockglue.c
94521 @@ -1153,7 +1153,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
94522 len = min_t(unsigned int, len, opt->optlen);
94523 if (put_user(len, optlen))
94524 return -EFAULT;
94525 - if (copy_to_user(optval, opt->__data, len))
94526 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
94527 + copy_to_user(optval, opt->__data, len))
94528 return -EFAULT;
94529 return 0;
94530 }
94531 @@ -1284,7 +1285,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
94532 if (sk->sk_type != SOCK_STREAM)
94533 return -ENOPROTOOPT;
94534
94535 - msg.msg_control = optval;
94536 + msg.msg_control = (void __force_kernel *)optval;
94537 msg.msg_controllen = len;
94538 msg.msg_flags = flags;
94539
94540 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
94541 index 26847e1..75d2d2f 100644
94542 --- a/net/ipv4/ip_vti.c
94543 +++ b/net/ipv4/ip_vti.c
94544 @@ -44,7 +44,7 @@
94545 #include <net/net_namespace.h>
94546 #include <net/netns/generic.h>
94547
94548 -static struct rtnl_link_ops vti_link_ops __read_mostly;
94549 +static struct rtnl_link_ops vti_link_ops;
94550
94551 static int vti_net_id __read_mostly;
94552 static int vti_tunnel_init(struct net_device *dev);
94553 @@ -425,7 +425,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
94554 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
94555 };
94556
94557 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
94558 +static struct rtnl_link_ops vti_link_ops = {
94559 .kind = "vti",
94560 .maxtype = IFLA_VTI_MAX,
94561 .policy = vti_policy,
94562 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
94563 index efa1138..20dbba0 100644
94564 --- a/net/ipv4/ipconfig.c
94565 +++ b/net/ipv4/ipconfig.c
94566 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
94567
94568 mm_segment_t oldfs = get_fs();
94569 set_fs(get_ds());
94570 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
94571 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
94572 set_fs(oldfs);
94573 return res;
94574 }
94575 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
94576
94577 mm_segment_t oldfs = get_fs();
94578 set_fs(get_ds());
94579 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
94580 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
94581 set_fs(oldfs);
94582 return res;
94583 }
94584 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
94585
94586 mm_segment_t oldfs = get_fs();
94587 set_fs(get_ds());
94588 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
94589 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
94590 set_fs(oldfs);
94591 return res;
94592 }
94593 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
94594 index 7f80fb4..b0328f6 100644
94595 --- a/net/ipv4/ipip.c
94596 +++ b/net/ipv4/ipip.c
94597 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
94598 static int ipip_net_id __read_mostly;
94599
94600 static int ipip_tunnel_init(struct net_device *dev);
94601 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
94602 +static struct rtnl_link_ops ipip_link_ops;
94603
94604 static int ipip_err(struct sk_buff *skb, u32 info)
94605 {
94606 @@ -408,7 +408,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
94607 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
94608 };
94609
94610 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
94611 +static struct rtnl_link_ops ipip_link_ops = {
94612 .kind = "ipip",
94613 .maxtype = IFLA_IPTUN_MAX,
94614 .policy = ipip_policy,
94615 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
94616 index 85a4f21..1beb1f5 100644
94617 --- a/net/ipv4/netfilter/arp_tables.c
94618 +++ b/net/ipv4/netfilter/arp_tables.c
94619 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
94620 #endif
94621
94622 static int get_info(struct net *net, void __user *user,
94623 - const int *len, int compat)
94624 + int len, int compat)
94625 {
94626 char name[XT_TABLE_MAXNAMELEN];
94627 struct xt_table *t;
94628 int ret;
94629
94630 - if (*len != sizeof(struct arpt_getinfo)) {
94631 - duprintf("length %u != %Zu\n", *len,
94632 + if (len != sizeof(struct arpt_getinfo)) {
94633 + duprintf("length %u != %Zu\n", len,
94634 sizeof(struct arpt_getinfo));
94635 return -EINVAL;
94636 }
94637 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
94638 info.size = private->size;
94639 strcpy(info.name, name);
94640
94641 - if (copy_to_user(user, &info, *len) != 0)
94642 + if (copy_to_user(user, &info, len) != 0)
94643 ret = -EFAULT;
94644 else
94645 ret = 0;
94646 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
94647
94648 switch (cmd) {
94649 case ARPT_SO_GET_INFO:
94650 - ret = get_info(sock_net(sk), user, len, 1);
94651 + ret = get_info(sock_net(sk), user, *len, 1);
94652 break;
94653 case ARPT_SO_GET_ENTRIES:
94654 ret = compat_get_entries(sock_net(sk), user, len);
94655 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
94656
94657 switch (cmd) {
94658 case ARPT_SO_GET_INFO:
94659 - ret = get_info(sock_net(sk), user, len, 0);
94660 + ret = get_info(sock_net(sk), user, *len, 0);
94661 break;
94662
94663 case ARPT_SO_GET_ENTRIES:
94664 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
94665 index d23118d..6ad7277 100644
94666 --- a/net/ipv4/netfilter/ip_tables.c
94667 +++ b/net/ipv4/netfilter/ip_tables.c
94668 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
94669 #endif
94670
94671 static int get_info(struct net *net, void __user *user,
94672 - const int *len, int compat)
94673 + int len, int compat)
94674 {
94675 char name[XT_TABLE_MAXNAMELEN];
94676 struct xt_table *t;
94677 int ret;
94678
94679 - if (*len != sizeof(struct ipt_getinfo)) {
94680 - duprintf("length %u != %zu\n", *len,
94681 + if (len != sizeof(struct ipt_getinfo)) {
94682 + duprintf("length %u != %zu\n", len,
94683 sizeof(struct ipt_getinfo));
94684 return -EINVAL;
94685 }
94686 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
94687 info.size = private->size;
94688 strcpy(info.name, name);
94689
94690 - if (copy_to_user(user, &info, *len) != 0)
94691 + if (copy_to_user(user, &info, len) != 0)
94692 ret = -EFAULT;
94693 else
94694 ret = 0;
94695 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94696
94697 switch (cmd) {
94698 case IPT_SO_GET_INFO:
94699 - ret = get_info(sock_net(sk), user, len, 1);
94700 + ret = get_info(sock_net(sk), user, *len, 1);
94701 break;
94702 case IPT_SO_GET_ENTRIES:
94703 ret = compat_get_entries(sock_net(sk), user, len);
94704 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94705
94706 switch (cmd) {
94707 case IPT_SO_GET_INFO:
94708 - ret = get_info(sock_net(sk), user, len, 0);
94709 + ret = get_info(sock_net(sk), user, *len, 0);
94710 break;
94711
94712 case IPT_SO_GET_ENTRIES:
94713 diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
94714 index cbc2215..9cb993c 100644
94715 --- a/net/ipv4/netfilter/ipt_ULOG.c
94716 +++ b/net/ipv4/netfilter/ipt_ULOG.c
94717 @@ -220,6 +220,7 @@ static void ipt_ulog_packet(struct net *net,
94718 ub->qlen++;
94719
94720 pm = nlmsg_data(nlh);
94721 + memset(pm, 0, sizeof(*pm));
94722
94723 /* We might not have a timestamp, get one */
94724 if (skb->tstamp.tv64 == 0)
94725 @@ -238,8 +239,6 @@ static void ipt_ulog_packet(struct net *net,
94726 }
94727 else if (loginfo->prefix[0] != '\0')
94728 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
94729 - else
94730 - *(pm->prefix) = '\0';
94731
94732 if (in && in->hard_header_len > 0 &&
94733 skb->mac_header != skb->network_header &&
94734 @@ -251,13 +250,9 @@ static void ipt_ulog_packet(struct net *net,
94735
94736 if (in)
94737 strncpy(pm->indev_name, in->name, sizeof(pm->indev_name));
94738 - else
94739 - pm->indev_name[0] = '\0';
94740
94741 if (out)
94742 strncpy(pm->outdev_name, out->name, sizeof(pm->outdev_name));
94743 - else
94744 - pm->outdev_name[0] = '\0';
94745
94746 /* copy_len <= skb->len, so can't fail. */
94747 if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
94748 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
94749 index c482f7c..2784262 100644
94750 --- a/net/ipv4/ping.c
94751 +++ b/net/ipv4/ping.c
94752 @@ -55,7 +55,7 @@
94753
94754
94755 struct ping_table ping_table;
94756 -struct pingv6_ops pingv6_ops;
94757 +struct pingv6_ops *pingv6_ops;
94758 EXPORT_SYMBOL_GPL(pingv6_ops);
94759
94760 static u16 ping_port_rover;
94761 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
94762 return -ENODEV;
94763 }
94764 }
94765 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
94766 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
94767 scoped);
94768 rcu_read_unlock();
94769
94770 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
94771 }
94772 #if IS_ENABLED(CONFIG_IPV6)
94773 } else if (skb->protocol == htons(ETH_P_IPV6)) {
94774 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
94775 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
94776 #endif
94777 }
94778
94779 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
94780 info, (u8 *)icmph);
94781 #if IS_ENABLED(CONFIG_IPV6)
94782 } else if (family == AF_INET6) {
94783 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
94784 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
94785 info, (u8 *)icmph);
94786 #endif
94787 }
94788 @@ -841,7 +841,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
94789 return ip_recv_error(sk, msg, len, addr_len);
94790 #if IS_ENABLED(CONFIG_IPV6)
94791 } else if (family == AF_INET6) {
94792 - return pingv6_ops.ipv6_recv_error(sk, msg, len,
94793 + return pingv6_ops->ipv6_recv_error(sk, msg, len,
94794 addr_len);
94795 #endif
94796 }
94797 @@ -900,7 +900,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
94798 }
94799
94800 if (inet6_sk(sk)->rxopt.all)
94801 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
94802 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
94803 #endif
94804 } else {
94805 BUG();
94806 @@ -1090,7 +1090,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
94807 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
94808 0, sock_i_ino(sp),
94809 atomic_read(&sp->sk_refcnt), sp,
94810 - atomic_read(&sp->sk_drops), len);
94811 + atomic_read_unchecked(&sp->sk_drops), len);
94812 }
94813
94814 static int ping_v4_seq_show(struct seq_file *seq, void *v)
94815 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
94816 index 7d3db78..9fd511d 100644
94817 --- a/net/ipv4/raw.c
94818 +++ b/net/ipv4/raw.c
94819 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
94820 int raw_rcv(struct sock *sk, struct sk_buff *skb)
94821 {
94822 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
94823 - atomic_inc(&sk->sk_drops);
94824 + atomic_inc_unchecked(&sk->sk_drops);
94825 kfree_skb(skb);
94826 return NET_RX_DROP;
94827 }
94828 @@ -746,16 +746,20 @@ static int raw_init(struct sock *sk)
94829
94830 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
94831 {
94832 + struct icmp_filter filter;
94833 +
94834 if (optlen > sizeof(struct icmp_filter))
94835 optlen = sizeof(struct icmp_filter);
94836 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
94837 + if (copy_from_user(&filter, optval, optlen))
94838 return -EFAULT;
94839 + raw_sk(sk)->filter = filter;
94840 return 0;
94841 }
94842
94843 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
94844 {
94845 int len, ret = -EFAULT;
94846 + struct icmp_filter filter;
94847
94848 if (get_user(len, optlen))
94849 goto out;
94850 @@ -765,8 +769,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
94851 if (len > sizeof(struct icmp_filter))
94852 len = sizeof(struct icmp_filter);
94853 ret = -EFAULT;
94854 - if (put_user(len, optlen) ||
94855 - copy_to_user(optval, &raw_sk(sk)->filter, len))
94856 + filter = raw_sk(sk)->filter;
94857 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
94858 goto out;
94859 ret = 0;
94860 out: return ret;
94861 @@ -995,7 +999,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
94862 0, 0L, 0,
94863 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
94864 0, sock_i_ino(sp),
94865 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
94866 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
94867 }
94868
94869 static int raw_seq_show(struct seq_file *seq, void *v)
94870 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
94871 index 62290b5..f0d944f 100644
94872 --- a/net/ipv4/route.c
94873 +++ b/net/ipv4/route.c
94874 @@ -2617,34 +2617,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
94875 .maxlen = sizeof(int),
94876 .mode = 0200,
94877 .proc_handler = ipv4_sysctl_rtcache_flush,
94878 + .extra1 = &init_net,
94879 },
94880 { },
94881 };
94882
94883 static __net_init int sysctl_route_net_init(struct net *net)
94884 {
94885 - struct ctl_table *tbl;
94886 + ctl_table_no_const *tbl = NULL;
94887
94888 - tbl = ipv4_route_flush_table;
94889 if (!net_eq(net, &init_net)) {
94890 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
94891 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
94892 if (tbl == NULL)
94893 goto err_dup;
94894
94895 /* Don't export sysctls to unprivileged users */
94896 if (net->user_ns != &init_user_ns)
94897 tbl[0].procname = NULL;
94898 - }
94899 - tbl[0].extra1 = net;
94900 + tbl[0].extra1 = net;
94901 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
94902 + } else
94903 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
94904
94905 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
94906 if (net->ipv4.route_hdr == NULL)
94907 goto err_reg;
94908 return 0;
94909
94910 err_reg:
94911 - if (tbl != ipv4_route_flush_table)
94912 - kfree(tbl);
94913 + kfree(tbl);
94914 err_dup:
94915 return -ENOMEM;
94916 }
94917 @@ -2667,8 +2667,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
94918
94919 static __net_init int rt_genid_init(struct net *net)
94920 {
94921 - atomic_set(&net->ipv4.rt_genid, 0);
94922 - atomic_set(&net->fnhe_genid, 0);
94923 + atomic_set_unchecked(&net->ipv4.rt_genid, 0);
94924 + atomic_set_unchecked(&net->fnhe_genid, 0);
94925 get_random_bytes(&net->ipv4.dev_addr_genid,
94926 sizeof(net->ipv4.dev_addr_genid));
94927 return 0;
94928 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
94929 index 540279f..9855b16 100644
94930 --- a/net/ipv4/sysctl_net_ipv4.c
94931 +++ b/net/ipv4/sysctl_net_ipv4.c
94932 @@ -58,7 +58,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
94933 {
94934 int ret;
94935 int range[2];
94936 - struct ctl_table tmp = {
94937 + ctl_table_no_const tmp = {
94938 .data = &range,
94939 .maxlen = sizeof(range),
94940 .mode = table->mode,
94941 @@ -111,7 +111,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
94942 int ret;
94943 gid_t urange[2];
94944 kgid_t low, high;
94945 - struct ctl_table tmp = {
94946 + ctl_table_no_const tmp = {
94947 .data = &urange,
94948 .maxlen = sizeof(urange),
94949 .mode = table->mode,
94950 @@ -142,7 +142,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
94951 void __user *buffer, size_t *lenp, loff_t *ppos)
94952 {
94953 char val[TCP_CA_NAME_MAX];
94954 - struct ctl_table tbl = {
94955 + ctl_table_no_const tbl = {
94956 .data = val,
94957 .maxlen = TCP_CA_NAME_MAX,
94958 };
94959 @@ -161,7 +161,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
94960 void __user *buffer, size_t *lenp,
94961 loff_t *ppos)
94962 {
94963 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
94964 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
94965 int ret;
94966
94967 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
94968 @@ -178,7 +178,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
94969 void __user *buffer, size_t *lenp,
94970 loff_t *ppos)
94971 {
94972 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
94973 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
94974 int ret;
94975
94976 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
94977 @@ -204,15 +204,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
94978 struct mem_cgroup *memcg;
94979 #endif
94980
94981 - struct ctl_table tmp = {
94982 + ctl_table_no_const tmp = {
94983 .data = &vec,
94984 .maxlen = sizeof(vec),
94985 .mode = ctl->mode,
94986 };
94987
94988 if (!write) {
94989 - ctl->data = &net->ipv4.sysctl_tcp_mem;
94990 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
94991 + ctl_table_no_const tcp_mem = *ctl;
94992 +
94993 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
94994 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
94995 }
94996
94997 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
94998 @@ -240,7 +242,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
94999 void __user *buffer, size_t *lenp,
95000 loff_t *ppos)
95001 {
95002 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
95003 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
95004 struct tcp_fastopen_context *ctxt;
95005 int ret;
95006 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
95007 @@ -483,7 +485,7 @@ static struct ctl_table ipv4_table[] = {
95008 },
95009 {
95010 .procname = "ip_local_reserved_ports",
95011 - .data = NULL, /* initialized in sysctl_ipv4_init */
95012 + .data = sysctl_local_reserved_ports,
95013 .maxlen = 65536,
95014 .mode = 0644,
95015 .proc_handler = proc_do_large_bitmap,
95016 @@ -864,11 +866,10 @@ static struct ctl_table ipv4_net_table[] = {
95017
95018 static __net_init int ipv4_sysctl_init_net(struct net *net)
95019 {
95020 - struct ctl_table *table;
95021 + ctl_table_no_const *table = NULL;
95022
95023 - table = ipv4_net_table;
95024 if (!net_eq(net, &init_net)) {
95025 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
95026 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
95027 if (table == NULL)
95028 goto err_alloc;
95029
95030 @@ -903,15 +904,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
95031
95032 tcp_init_mem(net);
95033
95034 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
95035 + if (!net_eq(net, &init_net))
95036 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
95037 + else
95038 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
95039 if (net->ipv4.ipv4_hdr == NULL)
95040 goto err_reg;
95041
95042 return 0;
95043
95044 err_reg:
95045 - if (!net_eq(net, &init_net))
95046 - kfree(table);
95047 + kfree(table);
95048 err_alloc:
95049 return -ENOMEM;
95050 }
95051 @@ -933,16 +936,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
95052 static __init int sysctl_ipv4_init(void)
95053 {
95054 struct ctl_table_header *hdr;
95055 - struct ctl_table *i;
95056 -
95057 - for (i = ipv4_table; i->procname; i++) {
95058 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
95059 - i->data = sysctl_local_reserved_ports;
95060 - break;
95061 - }
95062 - }
95063 - if (!i->procname)
95064 - return -EINVAL;
95065
95066 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
95067 if (hdr == NULL)
95068 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
95069 index 068c8fb..a755c52 100644
95070 --- a/net/ipv4/tcp_input.c
95071 +++ b/net/ipv4/tcp_input.c
95072 @@ -4435,7 +4435,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
95073 * simplifies code)
95074 */
95075 static void
95076 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
95077 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
95078 struct sk_buff *head, struct sk_buff *tail,
95079 u32 start, u32 end)
95080 {
95081 @@ -5520,6 +5520,7 @@ discard:
95082 tcp_paws_reject(&tp->rx_opt, 0))
95083 goto discard_and_undo;
95084
95085 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
95086 if (th->syn) {
95087 /* We see SYN without ACK. It is attempt of
95088 * simultaneous connect with crossed SYNs.
95089 @@ -5570,6 +5571,7 @@ discard:
95090 goto discard;
95091 #endif
95092 }
95093 +#endif
95094 /* "fifth, if neither of the SYN or RST bits is set then
95095 * drop the segment and return."
95096 */
95097 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
95098 goto discard;
95099
95100 if (th->syn) {
95101 - if (th->fin)
95102 + if (th->fin || th->urg || th->psh)
95103 goto discard;
95104 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
95105 return 1;
95106 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
95107 index 5031f68..91569e2 100644
95108 --- a/net/ipv4/tcp_ipv4.c
95109 +++ b/net/ipv4/tcp_ipv4.c
95110 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
95111 EXPORT_SYMBOL(sysctl_tcp_low_latency);
95112
95113
95114 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95115 +extern int grsec_enable_blackhole;
95116 +#endif
95117 +
95118 #ifdef CONFIG_TCP_MD5SIG
95119 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
95120 __be32 daddr, __be32 saddr, const struct tcphdr *th);
95121 @@ -1829,6 +1833,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
95122 return 0;
95123
95124 reset:
95125 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95126 + if (!grsec_enable_blackhole)
95127 +#endif
95128 tcp_v4_send_reset(rsk, skb);
95129 discard:
95130 kfree_skb(skb);
95131 @@ -1974,12 +1981,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
95132 TCP_SKB_CB(skb)->sacked = 0;
95133
95134 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
95135 - if (!sk)
95136 + if (!sk) {
95137 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95138 + ret = 1;
95139 +#endif
95140 goto no_tcp_socket;
95141 -
95142 + }
95143 process:
95144 - if (sk->sk_state == TCP_TIME_WAIT)
95145 + if (sk->sk_state == TCP_TIME_WAIT) {
95146 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95147 + ret = 2;
95148 +#endif
95149 goto do_time_wait;
95150 + }
95151
95152 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
95153 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
95154 @@ -2033,6 +2047,10 @@ csum_error:
95155 bad_packet:
95156 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
95157 } else {
95158 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95159 + if (!grsec_enable_blackhole || (ret == 1 &&
95160 + (skb->dev->flags & IFF_LOOPBACK)))
95161 +#endif
95162 tcp_v4_send_reset(NULL, skb);
95163 }
95164
95165 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
95166 index 58a3e69..7f0626e 100644
95167 --- a/net/ipv4/tcp_minisocks.c
95168 +++ b/net/ipv4/tcp_minisocks.c
95169 @@ -27,6 +27,10 @@
95170 #include <net/inet_common.h>
95171 #include <net/xfrm.h>
95172
95173 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95174 +extern int grsec_enable_blackhole;
95175 +#endif
95176 +
95177 int sysctl_tcp_syncookies __read_mostly = 1;
95178 EXPORT_SYMBOL(sysctl_tcp_syncookies);
95179
95180 @@ -711,7 +715,10 @@ embryonic_reset:
95181 * avoid becoming vulnerable to outside attack aiming at
95182 * resetting legit local connections.
95183 */
95184 - req->rsk_ops->send_reset(sk, skb);
95185 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95186 + if (!grsec_enable_blackhole)
95187 +#endif
95188 + req->rsk_ops->send_reset(sk, skb);
95189 } else if (fastopen) { /* received a valid RST pkt */
95190 reqsk_fastopen_remove(sk, req, true);
95191 tcp_reset(sk);
95192 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
95193 index 611beab..c4b6e1d 100644
95194 --- a/net/ipv4/tcp_probe.c
95195 +++ b/net/ipv4/tcp_probe.c
95196 @@ -245,7 +245,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
95197 if (cnt + width >= len)
95198 break;
95199
95200 - if (copy_to_user(buf + cnt, tbuf, width))
95201 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
95202 return -EFAULT;
95203 cnt += width;
95204 }
95205 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
95206 index 4b85e6f..22f9ac9 100644
95207 --- a/net/ipv4/tcp_timer.c
95208 +++ b/net/ipv4/tcp_timer.c
95209 @@ -22,6 +22,10 @@
95210 #include <linux/gfp.h>
95211 #include <net/tcp.h>
95212
95213 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95214 +extern int grsec_lastack_retries;
95215 +#endif
95216 +
95217 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
95218 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
95219 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
95220 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
95221 }
95222 }
95223
95224 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95225 + if ((sk->sk_state == TCP_LAST_ACK) &&
95226 + (grsec_lastack_retries > 0) &&
95227 + (grsec_lastack_retries < retry_until))
95228 + retry_until = grsec_lastack_retries;
95229 +#endif
95230 +
95231 if (retransmits_timed_out(sk, retry_until,
95232 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
95233 /* Has it gone just too far? */
95234 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
95235 index 6ca9907..a1e6c00 100644
95236 --- a/net/ipv4/udp.c
95237 +++ b/net/ipv4/udp.c
95238 @@ -87,6 +87,7 @@
95239 #include <linux/types.h>
95240 #include <linux/fcntl.h>
95241 #include <linux/module.h>
95242 +#include <linux/security.h>
95243 #include <linux/socket.h>
95244 #include <linux/sockios.h>
95245 #include <linux/igmp.h>
95246 @@ -112,6 +113,10 @@
95247 #include <net/busy_poll.h>
95248 #include "udp_impl.h"
95249
95250 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95251 +extern int grsec_enable_blackhole;
95252 +#endif
95253 +
95254 struct udp_table udp_table __read_mostly;
95255 EXPORT_SYMBOL(udp_table);
95256
95257 @@ -595,6 +600,9 @@ found:
95258 return s;
95259 }
95260
95261 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
95262 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
95263 +
95264 /*
95265 * This routine is called by the ICMP module when it gets some
95266 * sort of error condition. If err < 0 then the socket should
95267 @@ -892,9 +900,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
95268 dport = usin->sin_port;
95269 if (dport == 0)
95270 return -EINVAL;
95271 +
95272 + err = gr_search_udp_sendmsg(sk, usin);
95273 + if (err)
95274 + return err;
95275 } else {
95276 if (sk->sk_state != TCP_ESTABLISHED)
95277 return -EDESTADDRREQ;
95278 +
95279 + err = gr_search_udp_sendmsg(sk, NULL);
95280 + if (err)
95281 + return err;
95282 +
95283 daddr = inet->inet_daddr;
95284 dport = inet->inet_dport;
95285 /* Open fast path for connected socket.
95286 @@ -1141,7 +1158,7 @@ static unsigned int first_packet_length(struct sock *sk)
95287 IS_UDPLITE(sk));
95288 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
95289 IS_UDPLITE(sk));
95290 - atomic_inc(&sk->sk_drops);
95291 + atomic_inc_unchecked(&sk->sk_drops);
95292 __skb_unlink(skb, rcvq);
95293 __skb_queue_tail(&list_kill, skb);
95294 }
95295 @@ -1221,6 +1238,10 @@ try_again:
95296 if (!skb)
95297 goto out;
95298
95299 + err = gr_search_udp_recvmsg(sk, skb);
95300 + if (err)
95301 + goto out_free;
95302 +
95303 ulen = skb->len - sizeof(struct udphdr);
95304 copied = len;
95305 if (copied > ulen)
95306 @@ -1254,7 +1275,7 @@ try_again:
95307 if (unlikely(err)) {
95308 trace_kfree_skb(skb, udp_recvmsg);
95309 if (!peeked) {
95310 - atomic_inc(&sk->sk_drops);
95311 + atomic_inc_unchecked(&sk->sk_drops);
95312 UDP_INC_STATS_USER(sock_net(sk),
95313 UDP_MIB_INERRORS, is_udplite);
95314 }
95315 @@ -1542,7 +1563,7 @@ csum_error:
95316 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
95317 drop:
95318 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
95319 - atomic_inc(&sk->sk_drops);
95320 + atomic_inc_unchecked(&sk->sk_drops);
95321 kfree_skb(skb);
95322 return -1;
95323 }
95324 @@ -1561,7 +1582,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
95325 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
95326
95327 if (!skb1) {
95328 - atomic_inc(&sk->sk_drops);
95329 + atomic_inc_unchecked(&sk->sk_drops);
95330 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
95331 IS_UDPLITE(sk));
95332 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
95333 @@ -1733,6 +1754,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
95334 goto csum_error;
95335
95336 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
95337 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95338 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
95339 +#endif
95340 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
95341
95342 /*
95343 @@ -2165,7 +2189,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
95344 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
95345 0, sock_i_ino(sp),
95346 atomic_read(&sp->sk_refcnt), sp,
95347 - atomic_read(&sp->sk_drops), len);
95348 + atomic_read_unchecked(&sp->sk_drops), len);
95349 }
95350
95351 int udp4_seq_show(struct seq_file *seq, void *v)
95352 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
95353 index adf9983..8e45d0a 100644
95354 --- a/net/ipv4/xfrm4_policy.c
95355 +++ b/net/ipv4/xfrm4_policy.c
95356 @@ -186,11 +186,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
95357 fl4->flowi4_tos = iph->tos;
95358 }
95359
95360 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
95361 +static int xfrm4_garbage_collect(struct dst_ops *ops)
95362 {
95363 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
95364
95365 - xfrm4_policy_afinfo.garbage_collect(net);
95366 + xfrm_garbage_collect_deferred(net);
95367 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
95368 }
95369
95370 @@ -269,19 +269,18 @@ static struct ctl_table xfrm4_policy_table[] = {
95371
95372 static int __net_init xfrm4_net_init(struct net *net)
95373 {
95374 - struct ctl_table *table;
95375 + ctl_table_no_const *table = NULL;
95376 struct ctl_table_header *hdr;
95377
95378 - table = xfrm4_policy_table;
95379 if (!net_eq(net, &init_net)) {
95380 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
95381 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
95382 if (!table)
95383 goto err_alloc;
95384
95385 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
95386 - }
95387 -
95388 - hdr = register_net_sysctl(net, "net/ipv4", table);
95389 + hdr = register_net_sysctl(net, "net/ipv4", table);
95390 + } else
95391 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
95392 if (!hdr)
95393 goto err_reg;
95394
95395 @@ -289,8 +288,7 @@ static int __net_init xfrm4_net_init(struct net *net)
95396 return 0;
95397
95398 err_reg:
95399 - if (!net_eq(net, &init_net))
95400 - kfree(table);
95401 + kfree(table);
95402 err_alloc:
95403 return -ENOMEM;
95404 }
95405 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
95406 index cd3fb30..b7dfef7 100644
95407 --- a/net/ipv6/addrconf.c
95408 +++ b/net/ipv6/addrconf.c
95409 @@ -586,7 +586,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
95410 idx = 0;
95411 head = &net->dev_index_head[h];
95412 rcu_read_lock();
95413 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
95414 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
95415 net->dev_base_seq;
95416 hlist_for_each_entry_rcu(dev, head, index_hlist) {
95417 if (idx < s_idx)
95418 @@ -2364,7 +2364,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
95419 p.iph.ihl = 5;
95420 p.iph.protocol = IPPROTO_IPV6;
95421 p.iph.ttl = 64;
95422 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
95423 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
95424
95425 if (ops->ndo_do_ioctl) {
95426 mm_segment_t oldfs = get_fs();
95427 @@ -3977,7 +3977,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
95428 s_ip_idx = ip_idx = cb->args[2];
95429
95430 rcu_read_lock();
95431 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
95432 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
95433 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
95434 idx = 0;
95435 head = &net->dev_index_head[h];
95436 @@ -4603,7 +4603,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
95437 dst_free(&ifp->rt->dst);
95438 break;
95439 }
95440 - atomic_inc(&net->ipv6.dev_addr_genid);
95441 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
95442 rt_genid_bump_ipv6(net);
95443 }
95444
95445 @@ -4624,7 +4624,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
95446 int *valp = ctl->data;
95447 int val = *valp;
95448 loff_t pos = *ppos;
95449 - struct ctl_table lctl;
95450 + ctl_table_no_const lctl;
95451 int ret;
95452
95453 /*
95454 @@ -4709,7 +4709,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
95455 int *valp = ctl->data;
95456 int val = *valp;
95457 loff_t pos = *ppos;
95458 - struct ctl_table lctl;
95459 + ctl_table_no_const lctl;
95460 int ret;
95461
95462 /*
95463 diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
95464 index 8132b44..b8eca70 100644
95465 --- a/net/ipv6/af_inet6.c
95466 +++ b/net/ipv6/af_inet6.c
95467 @@ -767,7 +767,7 @@ static int __net_init inet6_net_init(struct net *net)
95468
95469 net->ipv6.sysctl.bindv6only = 0;
95470 net->ipv6.sysctl.icmpv6_time = 1*HZ;
95471 - atomic_set(&net->ipv6.rt_genid, 0);
95472 + atomic_set_unchecked(&net->ipv6.rt_genid, 0);
95473
95474 err = ipv6_init_mibs(net);
95475 if (err)
95476 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
95477 index c66c6df..f375d3c 100644
95478 --- a/net/ipv6/datagram.c
95479 +++ b/net/ipv6/datagram.c
95480 @@ -908,5 +908,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
95481 0,
95482 sock_i_ino(sp),
95483 atomic_read(&sp->sk_refcnt), sp,
95484 - atomic_read(&sp->sk_drops));
95485 + atomic_read_unchecked(&sp->sk_drops));
95486 }
95487 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
95488 index eef8d94..cfa1852 100644
95489 --- a/net/ipv6/icmp.c
95490 +++ b/net/ipv6/icmp.c
95491 @@ -997,7 +997,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
95492
95493 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
95494 {
95495 - struct ctl_table *table;
95496 + ctl_table_no_const *table;
95497
95498 table = kmemdup(ipv6_icmp_table_template,
95499 sizeof(ipv6_icmp_table_template),
95500 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
95501 index bf4a9a0..e5f6ac5 100644
95502 --- a/net/ipv6/ip6_gre.c
95503 +++ b/net/ipv6/ip6_gre.c
95504 @@ -74,7 +74,7 @@ struct ip6gre_net {
95505 struct net_device *fb_tunnel_dev;
95506 };
95507
95508 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
95509 +static struct rtnl_link_ops ip6gre_link_ops;
95510 static int ip6gre_tunnel_init(struct net_device *dev);
95511 static void ip6gre_tunnel_setup(struct net_device *dev);
95512 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
95513 @@ -1286,7 +1286,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
95514 }
95515
95516
95517 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
95518 +static struct inet6_protocol ip6gre_protocol = {
95519 .handler = ip6gre_rcv,
95520 .err_handler = ip6gre_err,
95521 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
95522 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
95523 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
95524 };
95525
95526 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
95527 +static struct rtnl_link_ops ip6gre_link_ops = {
95528 .kind = "ip6gre",
95529 .maxtype = IFLA_GRE_MAX,
95530 .policy = ip6gre_policy,
95531 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
95532 .fill_info = ip6gre_fill_info,
95533 };
95534
95535 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
95536 +static struct rtnl_link_ops ip6gre_tap_ops = {
95537 .kind = "ip6gretap",
95538 .maxtype = IFLA_GRE_MAX,
95539 .policy = ip6gre_policy,
95540 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
95541 index c1e11b5..568e633 100644
95542 --- a/net/ipv6/ip6_tunnel.c
95543 +++ b/net/ipv6/ip6_tunnel.c
95544 @@ -89,7 +89,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
95545
95546 static int ip6_tnl_dev_init(struct net_device *dev);
95547 static void ip6_tnl_dev_setup(struct net_device *dev);
95548 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
95549 +static struct rtnl_link_ops ip6_link_ops;
95550
95551 static int ip6_tnl_net_id __read_mostly;
95552 struct ip6_tnl_net {
95553 @@ -1699,7 +1699,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
95554 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
95555 };
95556
95557 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
95558 +static struct rtnl_link_ops ip6_link_ops = {
95559 .kind = "ip6tnl",
95560 .maxtype = IFLA_IPTUN_MAX,
95561 .policy = ip6_tnl_policy,
95562 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
95563 index d1e2e8e..51c19ae 100644
95564 --- a/net/ipv6/ipv6_sockglue.c
95565 +++ b/net/ipv6/ipv6_sockglue.c
95566 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
95567 if (sk->sk_type != SOCK_STREAM)
95568 return -ENOPROTOOPT;
95569
95570 - msg.msg_control = optval;
95571 + msg.msg_control = (void __force_kernel *)optval;
95572 msg.msg_controllen = len;
95573 msg.msg_flags = flags;
95574
95575 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
95576 index 44400c2..8e11f52 100644
95577 --- a/net/ipv6/netfilter/ip6_tables.c
95578 +++ b/net/ipv6/netfilter/ip6_tables.c
95579 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
95580 #endif
95581
95582 static int get_info(struct net *net, void __user *user,
95583 - const int *len, int compat)
95584 + int len, int compat)
95585 {
95586 char name[XT_TABLE_MAXNAMELEN];
95587 struct xt_table *t;
95588 int ret;
95589
95590 - if (*len != sizeof(struct ip6t_getinfo)) {
95591 - duprintf("length %u != %zu\n", *len,
95592 + if (len != sizeof(struct ip6t_getinfo)) {
95593 + duprintf("length %u != %zu\n", len,
95594 sizeof(struct ip6t_getinfo));
95595 return -EINVAL;
95596 }
95597 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
95598 info.size = private->size;
95599 strcpy(info.name, name);
95600
95601 - if (copy_to_user(user, &info, *len) != 0)
95602 + if (copy_to_user(user, &info, len) != 0)
95603 ret = -EFAULT;
95604 else
95605 ret = 0;
95606 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
95607
95608 switch (cmd) {
95609 case IP6T_SO_GET_INFO:
95610 - ret = get_info(sock_net(sk), user, len, 1);
95611 + ret = get_info(sock_net(sk), user, *len, 1);
95612 break;
95613 case IP6T_SO_GET_ENTRIES:
95614 ret = compat_get_entries(sock_net(sk), user, len);
95615 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
95616
95617 switch (cmd) {
95618 case IP6T_SO_GET_INFO:
95619 - ret = get_info(sock_net(sk), user, len, 0);
95620 + ret = get_info(sock_net(sk), user, *len, 0);
95621 break;
95622
95623 case IP6T_SO_GET_ENTRIES:
95624 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
95625 index 253566a..9fa50c7 100644
95626 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
95627 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
95628 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
95629
95630 static int nf_ct_frag6_sysctl_register(struct net *net)
95631 {
95632 - struct ctl_table *table;
95633 + ctl_table_no_const *table = NULL;
95634 struct ctl_table_header *hdr;
95635
95636 - table = nf_ct_frag6_sysctl_table;
95637 if (!net_eq(net, &init_net)) {
95638 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
95639 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
95640 GFP_KERNEL);
95641 if (table == NULL)
95642 goto err_alloc;
95643 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
95644 table[0].data = &net->nf_frag.frags.timeout;
95645 table[1].data = &net->nf_frag.frags.low_thresh;
95646 table[2].data = &net->nf_frag.frags.high_thresh;
95647 - }
95648 -
95649 - hdr = register_net_sysctl(net, "net/netfilter", table);
95650 + hdr = register_net_sysctl(net, "net/netfilter", table);
95651 + } else
95652 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
95653 if (hdr == NULL)
95654 goto err_reg;
95655
95656 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
95657 return 0;
95658
95659 err_reg:
95660 - if (!net_eq(net, &init_net))
95661 - kfree(table);
95662 + kfree(table);
95663 err_alloc:
95664 return -ENOMEM;
95665 }
95666 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
95667 index 827f795..7e28e82 100644
95668 --- a/net/ipv6/output_core.c
95669 +++ b/net/ipv6/output_core.c
95670 @@ -9,8 +9,8 @@
95671
95672 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
95673 {
95674 - static atomic_t ipv6_fragmentation_id;
95675 - int old, new;
95676 + static atomic_unchecked_t ipv6_fragmentation_id;
95677 + int id;
95678
95679 #if IS_ENABLED(CONFIG_IPV6)
95680 if (rt && !(rt->dst.flags & DST_NOPEER)) {
95681 @@ -26,13 +26,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
95682 }
95683 }
95684 #endif
95685 - do {
95686 - old = atomic_read(&ipv6_fragmentation_id);
95687 - new = old + 1;
95688 - if (!new)
95689 - new = 1;
95690 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
95691 - fhdr->identification = htonl(new);
95692 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
95693 + if (!id)
95694 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
95695 + fhdr->identification = htonl(id);
95696 }
95697 EXPORT_SYMBOL(ipv6_select_ident);
95698
95699 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
95700 index 7856e96..75ebc7f 100644
95701 --- a/net/ipv6/ping.c
95702 +++ b/net/ipv6/ping.c
95703 @@ -246,6 +246,22 @@ static struct pernet_operations ping_v6_net_ops = {
95704 };
95705 #endif
95706
95707 +static struct pingv6_ops real_pingv6_ops = {
95708 + .ipv6_recv_error = ipv6_recv_error,
95709 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
95710 + .icmpv6_err_convert = icmpv6_err_convert,
95711 + .ipv6_icmp_error = ipv6_icmp_error,
95712 + .ipv6_chk_addr = ipv6_chk_addr,
95713 +};
95714 +
95715 +static struct pingv6_ops dummy_pingv6_ops = {
95716 + .ipv6_recv_error = dummy_ipv6_recv_error,
95717 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
95718 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
95719 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
95720 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
95721 +};
95722 +
95723 int __init pingv6_init(void)
95724 {
95725 #ifdef CONFIG_PROC_FS
95726 @@ -253,11 +269,7 @@ int __init pingv6_init(void)
95727 if (ret)
95728 return ret;
95729 #endif
95730 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
95731 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
95732 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
95733 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
95734 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
95735 + pingv6_ops = &real_pingv6_ops;
95736 return inet6_register_protosw(&pingv6_protosw);
95737 }
95738
95739 @@ -266,11 +278,7 @@ int __init pingv6_init(void)
95740 */
95741 void pingv6_exit(void)
95742 {
95743 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
95744 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
95745 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
95746 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
95747 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
95748 + pingv6_ops = &dummy_pingv6_ops;
95749 #ifdef CONFIG_PROC_FS
95750 unregister_pernet_subsys(&ping_v6_net_ops);
95751 #endif
95752 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
95753 index 430067c..4adf088 100644
95754 --- a/net/ipv6/raw.c
95755 +++ b/net/ipv6/raw.c
95756 @@ -385,7 +385,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
95757 {
95758 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
95759 skb_checksum_complete(skb)) {
95760 - atomic_inc(&sk->sk_drops);
95761 + atomic_inc_unchecked(&sk->sk_drops);
95762 kfree_skb(skb);
95763 return NET_RX_DROP;
95764 }
95765 @@ -413,7 +413,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
95766 struct raw6_sock *rp = raw6_sk(sk);
95767
95768 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
95769 - atomic_inc(&sk->sk_drops);
95770 + atomic_inc_unchecked(&sk->sk_drops);
95771 kfree_skb(skb);
95772 return NET_RX_DROP;
95773 }
95774 @@ -437,7 +437,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
95775
95776 if (inet->hdrincl) {
95777 if (skb_checksum_complete(skb)) {
95778 - atomic_inc(&sk->sk_drops);
95779 + atomic_inc_unchecked(&sk->sk_drops);
95780 kfree_skb(skb);
95781 return NET_RX_DROP;
95782 }
95783 @@ -607,7 +607,7 @@ out:
95784 return err;
95785 }
95786
95787 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
95788 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
95789 struct flowi6 *fl6, struct dst_entry **dstp,
95790 unsigned int flags)
95791 {
95792 @@ -920,12 +920,15 @@ do_confirm:
95793 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
95794 char __user *optval, int optlen)
95795 {
95796 + struct icmp6_filter filter;
95797 +
95798 switch (optname) {
95799 case ICMPV6_FILTER:
95800 if (optlen > sizeof(struct icmp6_filter))
95801 optlen = sizeof(struct icmp6_filter);
95802 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
95803 + if (copy_from_user(&filter, optval, optlen))
95804 return -EFAULT;
95805 + raw6_sk(sk)->filter = filter;
95806 return 0;
95807 default:
95808 return -ENOPROTOOPT;
95809 @@ -938,6 +941,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
95810 char __user *optval, int __user *optlen)
95811 {
95812 int len;
95813 + struct icmp6_filter filter;
95814
95815 switch (optname) {
95816 case ICMPV6_FILTER:
95817 @@ -949,7 +953,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
95818 len = sizeof(struct icmp6_filter);
95819 if (put_user(len, optlen))
95820 return -EFAULT;
95821 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
95822 + filter = raw6_sk(sk)->filter;
95823 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
95824 return -EFAULT;
95825 return 0;
95826 default:
95827 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
95828 index 1aeb473..bea761c 100644
95829 --- a/net/ipv6/reassembly.c
95830 +++ b/net/ipv6/reassembly.c
95831 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
95832
95833 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
95834 {
95835 - struct ctl_table *table;
95836 + ctl_table_no_const *table = NULL;
95837 struct ctl_table_header *hdr;
95838
95839 - table = ip6_frags_ns_ctl_table;
95840 if (!net_eq(net, &init_net)) {
95841 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
95842 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
95843 if (table == NULL)
95844 goto err_alloc;
95845
95846 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
95847 /* Don't export sysctls to unprivileged users */
95848 if (net->user_ns != &init_user_ns)
95849 table[0].procname = NULL;
95850 - }
95851 + hdr = register_net_sysctl(net, "net/ipv6", table);
95852 + } else
95853 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
95854
95855 - hdr = register_net_sysctl(net, "net/ipv6", table);
95856 if (hdr == NULL)
95857 goto err_reg;
95858
95859 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
95860 return 0;
95861
95862 err_reg:
95863 - if (!net_eq(net, &init_net))
95864 - kfree(table);
95865 + kfree(table);
95866 err_alloc:
95867 return -ENOMEM;
95868 }
95869 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
95870 index 0accb13..f793130 100644
95871 --- a/net/ipv6/route.c
95872 +++ b/net/ipv6/route.c
95873 @@ -3003,7 +3003,7 @@ struct ctl_table ipv6_route_table_template[] = {
95874
95875 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
95876 {
95877 - struct ctl_table *table;
95878 + ctl_table_no_const *table;
95879
95880 table = kmemdup(ipv6_route_table_template,
95881 sizeof(ipv6_route_table_template),
95882 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
95883 index b433884..3875266 100644
95884 --- a/net/ipv6/sit.c
95885 +++ b/net/ipv6/sit.c
95886 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
95887 static void ipip6_dev_free(struct net_device *dev);
95888 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
95889 __be32 *v4dst);
95890 -static struct rtnl_link_ops sit_link_ops __read_mostly;
95891 +static struct rtnl_link_ops sit_link_ops;
95892
95893 static int sit_net_id __read_mostly;
95894 struct sit_net {
95895 @@ -1603,7 +1603,7 @@ static void ipip6_dellink(struct net_device *dev, struct list_head *head)
95896 unregister_netdevice_queue(dev, head);
95897 }
95898
95899 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
95900 +static struct rtnl_link_ops sit_link_ops = {
95901 .kind = "sit",
95902 .maxtype = IFLA_IPTUN_MAX,
95903 .policy = ipip6_policy,
95904 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
95905 index 107b2f1..72741a9 100644
95906 --- a/net/ipv6/sysctl_net_ipv6.c
95907 +++ b/net/ipv6/sysctl_net_ipv6.c
95908 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
95909
95910 static int __net_init ipv6_sysctl_net_init(struct net *net)
95911 {
95912 - struct ctl_table *ipv6_table;
95913 + ctl_table_no_const *ipv6_table;
95914 struct ctl_table *ipv6_route_table;
95915 struct ctl_table *ipv6_icmp_table;
95916 int err;
95917 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
95918 index 5c71501..7e8d5d3 100644
95919 --- a/net/ipv6/tcp_ipv6.c
95920 +++ b/net/ipv6/tcp_ipv6.c
95921 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
95922 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
95923 }
95924
95925 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95926 +extern int grsec_enable_blackhole;
95927 +#endif
95928 +
95929 static void tcp_v6_hash(struct sock *sk)
95930 {
95931 if (sk->sk_state != TCP_CLOSE) {
95932 @@ -1397,6 +1401,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
95933 return 0;
95934
95935 reset:
95936 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95937 + if (!grsec_enable_blackhole)
95938 +#endif
95939 tcp_v6_send_reset(sk, skb);
95940 discard:
95941 if (opt_skb)
95942 @@ -1479,12 +1486,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
95943 TCP_SKB_CB(skb)->sacked = 0;
95944
95945 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
95946 - if (!sk)
95947 + if (!sk) {
95948 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95949 + ret = 1;
95950 +#endif
95951 goto no_tcp_socket;
95952 + }
95953
95954 process:
95955 - if (sk->sk_state == TCP_TIME_WAIT)
95956 + if (sk->sk_state == TCP_TIME_WAIT) {
95957 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95958 + ret = 2;
95959 +#endif
95960 goto do_time_wait;
95961 + }
95962
95963 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
95964 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
95965 @@ -1536,6 +1551,10 @@ csum_error:
95966 bad_packet:
95967 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
95968 } else {
95969 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95970 + if (!grsec_enable_blackhole || (ret == 1 &&
95971 + (skb->dev->flags & IFF_LOOPBACK)))
95972 +#endif
95973 tcp_v6_send_reset(NULL, skb);
95974 }
95975
95976 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
95977 index 3d2758d..626c422 100644
95978 --- a/net/ipv6/udp.c
95979 +++ b/net/ipv6/udp.c
95980 @@ -53,6 +53,10 @@
95981 #include <trace/events/skb.h>
95982 #include "udp_impl.h"
95983
95984 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95985 +extern int grsec_enable_blackhole;
95986 +#endif
95987 +
95988 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
95989 {
95990 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
95991 @@ -417,7 +421,7 @@ try_again:
95992 if (unlikely(err)) {
95993 trace_kfree_skb(skb, udpv6_recvmsg);
95994 if (!peeked) {
95995 - atomic_inc(&sk->sk_drops);
95996 + atomic_inc_unchecked(&sk->sk_drops);
95997 if (is_udp4)
95998 UDP_INC_STATS_USER(sock_net(sk),
95999 UDP_MIB_INERRORS,
96000 @@ -665,7 +669,7 @@ csum_error:
96001 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
96002 drop:
96003 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
96004 - atomic_inc(&sk->sk_drops);
96005 + atomic_inc_unchecked(&sk->sk_drops);
96006 kfree_skb(skb);
96007 return -1;
96008 }
96009 @@ -723,7 +727,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
96010 if (likely(skb1 == NULL))
96011 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
96012 if (!skb1) {
96013 - atomic_inc(&sk->sk_drops);
96014 + atomic_inc_unchecked(&sk->sk_drops);
96015 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
96016 IS_UDPLITE(sk));
96017 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
96018 @@ -863,6 +867,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
96019 goto csum_error;
96020
96021 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
96022 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96023 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
96024 +#endif
96025 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
96026
96027 kfree_skb(skb);
96028 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
96029 index 550b195..6acea83 100644
96030 --- a/net/ipv6/xfrm6_policy.c
96031 +++ b/net/ipv6/xfrm6_policy.c
96032 @@ -212,11 +212,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
96033 }
96034 }
96035
96036 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
96037 +static int xfrm6_garbage_collect(struct dst_ops *ops)
96038 {
96039 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
96040
96041 - xfrm6_policy_afinfo.garbage_collect(net);
96042 + xfrm_garbage_collect_deferred(net);
96043 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
96044 }
96045
96046 @@ -329,19 +329,19 @@ static struct ctl_table xfrm6_policy_table[] = {
96047
96048 static int __net_init xfrm6_net_init(struct net *net)
96049 {
96050 - struct ctl_table *table;
96051 + ctl_table_no_const *table = NULL;
96052 struct ctl_table_header *hdr;
96053
96054 - table = xfrm6_policy_table;
96055 if (!net_eq(net, &init_net)) {
96056 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
96057 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
96058 if (!table)
96059 goto err_alloc;
96060
96061 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
96062 - }
96063 + hdr = register_net_sysctl(net, "net/ipv6", table);
96064 + } else
96065 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
96066
96067 - hdr = register_net_sysctl(net, "net/ipv6", table);
96068 if (!hdr)
96069 goto err_reg;
96070
96071 @@ -349,8 +349,7 @@ static int __net_init xfrm6_net_init(struct net *net)
96072 return 0;
96073
96074 err_reg:
96075 - if (!net_eq(net, &init_net))
96076 - kfree(table);
96077 + kfree(table);
96078 err_alloc:
96079 return -ENOMEM;
96080 }
96081 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
96082 index 41ac7938..75e3bb1 100644
96083 --- a/net/irda/ircomm/ircomm_tty.c
96084 +++ b/net/irda/ircomm/ircomm_tty.c
96085 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
96086 add_wait_queue(&port->open_wait, &wait);
96087
96088 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
96089 - __FILE__, __LINE__, tty->driver->name, port->count);
96090 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
96091
96092 spin_lock_irqsave(&port->lock, flags);
96093 if (!tty_hung_up_p(filp))
96094 - port->count--;
96095 + atomic_dec(&port->count);
96096 port->blocked_open++;
96097 spin_unlock_irqrestore(&port->lock, flags);
96098
96099 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
96100 }
96101
96102 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
96103 - __FILE__, __LINE__, tty->driver->name, port->count);
96104 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
96105
96106 schedule();
96107 }
96108 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
96109
96110 spin_lock_irqsave(&port->lock, flags);
96111 if (!tty_hung_up_p(filp))
96112 - port->count++;
96113 + atomic_inc(&port->count);
96114 port->blocked_open--;
96115 spin_unlock_irqrestore(&port->lock, flags);
96116
96117 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
96118 - __FILE__, __LINE__, tty->driver->name, port->count);
96119 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
96120
96121 if (!retval)
96122 port->flags |= ASYNC_NORMAL_ACTIVE;
96123 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
96124
96125 /* ++ is not atomic, so this should be protected - Jean II */
96126 spin_lock_irqsave(&self->port.lock, flags);
96127 - self->port.count++;
96128 + atomic_inc(&self->port.count);
96129 spin_unlock_irqrestore(&self->port.lock, flags);
96130 tty_port_tty_set(&self->port, tty);
96131
96132 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
96133 - self->line, self->port.count);
96134 + self->line, atomic_read(&self->port.count));
96135
96136 /* Not really used by us, but lets do it anyway */
96137 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
96138 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
96139 tty_kref_put(port->tty);
96140 }
96141 port->tty = NULL;
96142 - port->count = 0;
96143 + atomic_set(&port->count, 0);
96144 spin_unlock_irqrestore(&port->lock, flags);
96145
96146 wake_up_interruptible(&port->open_wait);
96147 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
96148 seq_putc(m, '\n');
96149
96150 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
96151 - seq_printf(m, "Open count: %d\n", self->port.count);
96152 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
96153 seq_printf(m, "Max data size: %d\n", self->max_data_size);
96154 seq_printf(m, "Max header size: %d\n", self->max_header_size);
96155
96156 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
96157 index c4b7218..3e83259 100644
96158 --- a/net/iucv/af_iucv.c
96159 +++ b/net/iucv/af_iucv.c
96160 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
96161
96162 write_lock_bh(&iucv_sk_list.lock);
96163
96164 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
96165 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
96166 while (__iucv_get_sock_by_name(name)) {
96167 sprintf(name, "%08x",
96168 - atomic_inc_return(&iucv_sk_list.autobind_name));
96169 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
96170 }
96171
96172 write_unlock_bh(&iucv_sk_list.lock);
96173 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
96174 index cd5b8ec..f205e6b 100644
96175 --- a/net/iucv/iucv.c
96176 +++ b/net/iucv/iucv.c
96177 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
96178 return NOTIFY_OK;
96179 }
96180
96181 -static struct notifier_block __refdata iucv_cpu_notifier = {
96182 +static struct notifier_block iucv_cpu_notifier = {
96183 .notifier_call = iucv_cpu_notify,
96184 };
96185
96186 diff --git a/net/key/af_key.c b/net/key/af_key.c
96187 index 545f047..9757a9d 100644
96188 --- a/net/key/af_key.c
96189 +++ b/net/key/af_key.c
96190 @@ -3041,10 +3041,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
96191 static u32 get_acqseq(void)
96192 {
96193 u32 res;
96194 - static atomic_t acqseq;
96195 + static atomic_unchecked_t acqseq;
96196
96197 do {
96198 - res = atomic_inc_return(&acqseq);
96199 + res = atomic_inc_return_unchecked(&acqseq);
96200 } while (!res);
96201 return res;
96202 }
96203 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
96204 index 9903ee5..18978be 100644
96205 --- a/net/mac80211/cfg.c
96206 +++ b/net/mac80211/cfg.c
96207 @@ -826,7 +826,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
96208 ret = ieee80211_vif_use_channel(sdata, chandef,
96209 IEEE80211_CHANCTX_EXCLUSIVE);
96210 }
96211 - } else if (local->open_count == local->monitors) {
96212 + } else if (local_read(&local->open_count) == local->monitors) {
96213 local->_oper_chandef = *chandef;
96214 ieee80211_hw_config(local, 0);
96215 }
96216 @@ -3124,7 +3124,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
96217 else
96218 local->probe_req_reg--;
96219
96220 - if (!local->open_count)
96221 + if (!local_read(&local->open_count))
96222 break;
96223
96224 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
96225 @@ -3587,8 +3587,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
96226 if (chanctx_conf) {
96227 *chandef = chanctx_conf->def;
96228 ret = 0;
96229 - } else if (local->open_count > 0 &&
96230 - local->open_count == local->monitors &&
96231 + } else if (local_read(&local->open_count) > 0 &&
96232 + local_read(&local->open_count) == local->monitors &&
96233 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
96234 if (local->use_chanctx)
96235 *chandef = local->monitor_chandef;
96236 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
96237 index 611abfc..8c2c7e4 100644
96238 --- a/net/mac80211/ieee80211_i.h
96239 +++ b/net/mac80211/ieee80211_i.h
96240 @@ -28,6 +28,7 @@
96241 #include <net/ieee80211_radiotap.h>
96242 #include <net/cfg80211.h>
96243 #include <net/mac80211.h>
96244 +#include <asm/local.h>
96245 #include "key.h"
96246 #include "sta_info.h"
96247 #include "debug.h"
96248 @@ -945,7 +946,7 @@ struct ieee80211_local {
96249 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
96250 spinlock_t queue_stop_reason_lock;
96251
96252 - int open_count;
96253 + local_t open_count;
96254 int monitors, cooked_mntrs;
96255 /* number of interfaces with corresponding FIF_ flags */
96256 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
96257 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
96258 index fcecd63..a404454 100644
96259 --- a/net/mac80211/iface.c
96260 +++ b/net/mac80211/iface.c
96261 @@ -519,7 +519,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
96262 break;
96263 }
96264
96265 - if (local->open_count == 0) {
96266 + if (local_read(&local->open_count) == 0) {
96267 res = drv_start(local);
96268 if (res)
96269 goto err_del_bss;
96270 @@ -566,7 +566,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
96271 res = drv_add_interface(local, sdata);
96272 if (res)
96273 goto err_stop;
96274 - } else if (local->monitors == 0 && local->open_count == 0) {
96275 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
96276 res = ieee80211_add_virtual_monitor(local);
96277 if (res)
96278 goto err_stop;
96279 @@ -675,7 +675,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
96280 atomic_inc(&local->iff_promiscs);
96281
96282 if (coming_up)
96283 - local->open_count++;
96284 + local_inc(&local->open_count);
96285
96286 if (hw_reconf_flags)
96287 ieee80211_hw_config(local, hw_reconf_flags);
96288 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
96289 err_del_interface:
96290 drv_remove_interface(local, sdata);
96291 err_stop:
96292 - if (!local->open_count)
96293 + if (!local_read(&local->open_count))
96294 drv_stop(local);
96295 err_del_bss:
96296 sdata->bss = NULL;
96297 @@ -852,7 +852,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
96298 }
96299
96300 if (going_down)
96301 - local->open_count--;
96302 + local_dec(&local->open_count);
96303
96304 switch (sdata->vif.type) {
96305 case NL80211_IFTYPE_AP_VLAN:
96306 @@ -919,7 +919,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
96307 }
96308 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
96309
96310 - if (local->open_count == 0)
96311 + if (local_read(&local->open_count) == 0)
96312 ieee80211_clear_tx_pending(local);
96313
96314 /*
96315 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
96316
96317 ieee80211_recalc_ps(local, -1);
96318
96319 - if (local->open_count == 0) {
96320 + if (local_read(&local->open_count) == 0) {
96321 ieee80211_stop_device(local);
96322
96323 /* no reconfiguring after stop! */
96324 @@ -970,7 +970,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
96325 ieee80211_configure_filter(local);
96326 ieee80211_hw_config(local, hw_reconf_flags);
96327
96328 - if (local->monitors == local->open_count)
96329 + if (local->monitors == local_read(&local->open_count))
96330 ieee80211_add_virtual_monitor(local);
96331 }
96332
96333 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
96334 index e765f77..dfd72e7 100644
96335 --- a/net/mac80211/main.c
96336 +++ b/net/mac80211/main.c
96337 @@ -172,7 +172,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
96338 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
96339 IEEE80211_CONF_CHANGE_POWER);
96340
96341 - if (changed && local->open_count) {
96342 + if (changed && local_read(&local->open_count)) {
96343 ret = drv_config(local, changed);
96344 /*
96345 * Goal:
96346 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
96347 index 3401262..d5cd68d 100644
96348 --- a/net/mac80211/pm.c
96349 +++ b/net/mac80211/pm.c
96350 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
96351 struct ieee80211_sub_if_data *sdata;
96352 struct sta_info *sta;
96353
96354 - if (!local->open_count)
96355 + if (!local_read(&local->open_count))
96356 goto suspend;
96357
96358 ieee80211_scan_cancel(local);
96359 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
96360 cancel_work_sync(&local->dynamic_ps_enable_work);
96361 del_timer_sync(&local->dynamic_ps_timer);
96362
96363 - local->wowlan = wowlan && local->open_count;
96364 + local->wowlan = wowlan && local_read(&local->open_count);
96365 if (local->wowlan) {
96366 int err = drv_suspend(local, wowlan);
96367 if (err < 0) {
96368 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
96369 WARN_ON(!list_empty(&local->chanctx_list));
96370
96371 /* stop hardware - this must stop RX */
96372 - if (local->open_count)
96373 + if (local_read(&local->open_count))
96374 ieee80211_stop_device(local);
96375
96376 suspend:
96377 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
96378 index e126605..73d2c39 100644
96379 --- a/net/mac80211/rate.c
96380 +++ b/net/mac80211/rate.c
96381 @@ -725,7 +725,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
96382
96383 ASSERT_RTNL();
96384
96385 - if (local->open_count)
96386 + if (local_read(&local->open_count))
96387 return -EBUSY;
96388
96389 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
96390 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
96391 index c97a065..ff61928 100644
96392 --- a/net/mac80211/rc80211_pid_debugfs.c
96393 +++ b/net/mac80211/rc80211_pid_debugfs.c
96394 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
96395
96396 spin_unlock_irqrestore(&events->lock, status);
96397
96398 - if (copy_to_user(buf, pb, p))
96399 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
96400 return -EFAULT;
96401
96402 return p;
96403 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
96404 index 69e4ef5..e8e4b92 100644
96405 --- a/net/mac80211/util.c
96406 +++ b/net/mac80211/util.c
96407 @@ -1470,7 +1470,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
96408 }
96409 #endif
96410 /* everything else happens only if HW was up & running */
96411 - if (!local->open_count)
96412 + if (!local_read(&local->open_count))
96413 goto wake_up;
96414
96415 /*
96416 @@ -1695,7 +1695,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
96417 local->in_reconfig = false;
96418 barrier();
96419
96420 - if (local->monitors == local->open_count && local->monitors > 0)
96421 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
96422 ieee80211_add_virtual_monitor(local);
96423
96424 /*
96425 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
96426 index 6e839b6..002a233 100644
96427 --- a/net/netfilter/Kconfig
96428 +++ b/net/netfilter/Kconfig
96429 @@ -950,6 +950,16 @@ config NETFILTER_XT_MATCH_ESP
96430
96431 To compile it as a module, choose M here. If unsure, say N.
96432
96433 +config NETFILTER_XT_MATCH_GRADM
96434 + tristate '"gradm" match support'
96435 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
96436 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
96437 + ---help---
96438 + The gradm match allows to match on grsecurity RBAC being enabled.
96439 + It is useful when iptables rules are applied early on bootup to
96440 + prevent connections to the machine (except from a trusted host)
96441 + while the RBAC system is disabled.
96442 +
96443 config NETFILTER_XT_MATCH_HASHLIMIT
96444 tristate '"hashlimit" match support'
96445 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
96446 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
96447 index c3a0a12..90b587f 100644
96448 --- a/net/netfilter/Makefile
96449 +++ b/net/netfilter/Makefile
96450 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
96451 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
96452 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
96453 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
96454 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
96455 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
96456 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
96457 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
96458 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
96459 index f2e30fb..f131862 100644
96460 --- a/net/netfilter/ipset/ip_set_core.c
96461 +++ b/net/netfilter/ipset/ip_set_core.c
96462 @@ -1819,7 +1819,7 @@ done:
96463 return ret;
96464 }
96465
96466 -static struct nf_sockopt_ops so_set __read_mostly = {
96467 +static struct nf_sockopt_ops so_set = {
96468 .pf = PF_INET,
96469 .get_optmin = SO_IP_SET,
96470 .get_optmax = SO_IP_SET + 1,
96471 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
96472 index 4c8e5c0..5a79b4d 100644
96473 --- a/net/netfilter/ipvs/ip_vs_conn.c
96474 +++ b/net/netfilter/ipvs/ip_vs_conn.c
96475 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
96476 /* Increase the refcnt counter of the dest */
96477 ip_vs_dest_hold(dest);
96478
96479 - conn_flags = atomic_read(&dest->conn_flags);
96480 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
96481 if (cp->protocol != IPPROTO_UDP)
96482 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
96483 flags = cp->flags;
96484 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
96485
96486 cp->control = NULL;
96487 atomic_set(&cp->n_control, 0);
96488 - atomic_set(&cp->in_pkts, 0);
96489 + atomic_set_unchecked(&cp->in_pkts, 0);
96490
96491 cp->packet_xmit = NULL;
96492 cp->app = NULL;
96493 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
96494
96495 /* Don't drop the entry if its number of incoming packets is not
96496 located in [0, 8] */
96497 - i = atomic_read(&cp->in_pkts);
96498 + i = atomic_read_unchecked(&cp->in_pkts);
96499 if (i > 8 || i < 0) return 0;
96500
96501 if (!todrop_rate[i]) return 0;
96502 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
96503 index 3581736..c0453e9 100644
96504 --- a/net/netfilter/ipvs/ip_vs_core.c
96505 +++ b/net/netfilter/ipvs/ip_vs_core.c
96506 @@ -567,7 +567,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
96507 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
96508 /* do not touch skb anymore */
96509
96510 - atomic_inc(&cp->in_pkts);
96511 + atomic_inc_unchecked(&cp->in_pkts);
96512 ip_vs_conn_put(cp);
96513 return ret;
96514 }
96515 @@ -1706,7 +1706,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
96516 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
96517 pkts = sysctl_sync_threshold(ipvs);
96518 else
96519 - pkts = atomic_add_return(1, &cp->in_pkts);
96520 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
96521
96522 if (ipvs->sync_state & IP_VS_STATE_MASTER)
96523 ip_vs_sync_conn(net, cp, pkts);
96524 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
96525 index a3df9bd..895ae09 100644
96526 --- a/net/netfilter/ipvs/ip_vs_ctl.c
96527 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
96528 @@ -794,7 +794,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
96529 */
96530 ip_vs_rs_hash(ipvs, dest);
96531 }
96532 - atomic_set(&dest->conn_flags, conn_flags);
96533 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
96534
96535 /* bind the service */
96536 old_svc = rcu_dereference_protected(dest->svc, 1);
96537 @@ -1641,7 +1641,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
96538 * align with netns init in ip_vs_control_net_init()
96539 */
96540
96541 -static struct ctl_table vs_vars[] = {
96542 +static ctl_table_no_const vs_vars[] __read_only = {
96543 {
96544 .procname = "amemthresh",
96545 .maxlen = sizeof(int),
96546 @@ -2062,7 +2062,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
96547 " %-7s %-6d %-10d %-10d\n",
96548 &dest->addr.in6,
96549 ntohs(dest->port),
96550 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
96551 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
96552 atomic_read(&dest->weight),
96553 atomic_read(&dest->activeconns),
96554 atomic_read(&dest->inactconns));
96555 @@ -2073,7 +2073,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
96556 "%-7s %-6d %-10d %-10d\n",
96557 ntohl(dest->addr.ip),
96558 ntohs(dest->port),
96559 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
96560 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
96561 atomic_read(&dest->weight),
96562 atomic_read(&dest->activeconns),
96563 atomic_read(&dest->inactconns));
96564 @@ -2551,7 +2551,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
96565
96566 entry.addr = dest->addr.ip;
96567 entry.port = dest->port;
96568 - entry.conn_flags = atomic_read(&dest->conn_flags);
96569 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
96570 entry.weight = atomic_read(&dest->weight);
96571 entry.u_threshold = dest->u_threshold;
96572 entry.l_threshold = dest->l_threshold;
96573 @@ -3094,7 +3094,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
96574 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
96575 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
96576 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
96577 - (atomic_read(&dest->conn_flags) &
96578 + (atomic_read_unchecked(&dest->conn_flags) &
96579 IP_VS_CONN_F_FWD_MASK)) ||
96580 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
96581 atomic_read(&dest->weight)) ||
96582 @@ -3684,7 +3684,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
96583 {
96584 int idx;
96585 struct netns_ipvs *ipvs = net_ipvs(net);
96586 - struct ctl_table *tbl;
96587 + ctl_table_no_const *tbl;
96588
96589 atomic_set(&ipvs->dropentry, 0);
96590 spin_lock_init(&ipvs->dropentry_lock);
96591 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
96592 index eff13c9..c1aab3e 100644
96593 --- a/net/netfilter/ipvs/ip_vs_lblc.c
96594 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
96595 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
96596 * IPVS LBLC sysctl table
96597 */
96598 #ifdef CONFIG_SYSCTL
96599 -static struct ctl_table vs_vars_table[] = {
96600 +static ctl_table_no_const vs_vars_table[] __read_only = {
96601 {
96602 .procname = "lblc_expiration",
96603 .data = NULL,
96604 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
96605 index 0b85500..8513fa5 100644
96606 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
96607 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
96608 @@ -289,7 +289,7 @@ struct ip_vs_lblcr_table {
96609 * IPVS LBLCR sysctl table
96610 */
96611
96612 -static struct ctl_table vs_vars_table[] = {
96613 +static ctl_table_no_const vs_vars_table[] __read_only = {
96614 {
96615 .procname = "lblcr_expiration",
96616 .data = NULL,
96617 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
96618 index f448471..995f131 100644
96619 --- a/net/netfilter/ipvs/ip_vs_sync.c
96620 +++ b/net/netfilter/ipvs/ip_vs_sync.c
96621 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
96622 cp = cp->control;
96623 if (cp) {
96624 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
96625 - pkts = atomic_add_return(1, &cp->in_pkts);
96626 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
96627 else
96628 pkts = sysctl_sync_threshold(ipvs);
96629 ip_vs_sync_conn(net, cp->control, pkts);
96630 @@ -771,7 +771,7 @@ control:
96631 if (!cp)
96632 return;
96633 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
96634 - pkts = atomic_add_return(1, &cp->in_pkts);
96635 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
96636 else
96637 pkts = sysctl_sync_threshold(ipvs);
96638 goto sloop;
96639 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
96640
96641 if (opt)
96642 memcpy(&cp->in_seq, opt, sizeof(*opt));
96643 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
96644 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
96645 cp->state = state;
96646 cp->old_state = cp->state;
96647 /*
96648 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
96649 index c47444e..b0961c6 100644
96650 --- a/net/netfilter/ipvs/ip_vs_xmit.c
96651 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
96652 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
96653 else
96654 rc = NF_ACCEPT;
96655 /* do not touch skb anymore */
96656 - atomic_inc(&cp->in_pkts);
96657 + atomic_inc_unchecked(&cp->in_pkts);
96658 goto out;
96659 }
96660
96661 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
96662 else
96663 rc = NF_ACCEPT;
96664 /* do not touch skb anymore */
96665 - atomic_inc(&cp->in_pkts);
96666 + atomic_inc_unchecked(&cp->in_pkts);
96667 goto out;
96668 }
96669
96670 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
96671 index 2d3030a..7ba1c0a 100644
96672 --- a/net/netfilter/nf_conntrack_acct.c
96673 +++ b/net/netfilter/nf_conntrack_acct.c
96674 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
96675 #ifdef CONFIG_SYSCTL
96676 static int nf_conntrack_acct_init_sysctl(struct net *net)
96677 {
96678 - struct ctl_table *table;
96679 + ctl_table_no_const *table;
96680
96681 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
96682 GFP_KERNEL);
96683 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
96684 index 5d892fe..d2fc9d8 100644
96685 --- a/net/netfilter/nf_conntrack_core.c
96686 +++ b/net/netfilter/nf_conntrack_core.c
96687 @@ -1600,6 +1600,10 @@ void nf_conntrack_init_end(void)
96688 #define DYING_NULLS_VAL ((1<<30)+1)
96689 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
96690
96691 +#ifdef CONFIG_GRKERNSEC_HIDESYM
96692 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
96693 +#endif
96694 +
96695 int nf_conntrack_init_net(struct net *net)
96696 {
96697 int ret;
96698 @@ -1614,7 +1618,11 @@ int nf_conntrack_init_net(struct net *net)
96699 goto err_stat;
96700 }
96701
96702 +#ifdef CONFIG_GRKERNSEC_HIDESYM
96703 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
96704 +#else
96705 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
96706 +#endif
96707 if (!net->ct.slabname) {
96708 ret = -ENOMEM;
96709 goto err_slabname;
96710 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
96711 index 1df1761..ce8b88a 100644
96712 --- a/net/netfilter/nf_conntrack_ecache.c
96713 +++ b/net/netfilter/nf_conntrack_ecache.c
96714 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
96715 #ifdef CONFIG_SYSCTL
96716 static int nf_conntrack_event_init_sysctl(struct net *net)
96717 {
96718 - struct ctl_table *table;
96719 + ctl_table_no_const *table;
96720
96721 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
96722 GFP_KERNEL);
96723 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
96724 index 974a2a4..52cc6ff 100644
96725 --- a/net/netfilter/nf_conntrack_helper.c
96726 +++ b/net/netfilter/nf_conntrack_helper.c
96727 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
96728
96729 static int nf_conntrack_helper_init_sysctl(struct net *net)
96730 {
96731 - struct ctl_table *table;
96732 + ctl_table_no_const *table;
96733
96734 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
96735 GFP_KERNEL);
96736 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
96737 index ce30041..3861b5d 100644
96738 --- a/net/netfilter/nf_conntrack_proto.c
96739 +++ b/net/netfilter/nf_conntrack_proto.c
96740 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
96741
96742 static void
96743 nf_ct_unregister_sysctl(struct ctl_table_header **header,
96744 - struct ctl_table **table,
96745 + ctl_table_no_const **table,
96746 unsigned int users)
96747 {
96748 if (users > 0)
96749 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
96750 index a99b6c3..cb372f9 100644
96751 --- a/net/netfilter/nf_conntrack_proto_dccp.c
96752 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
96753 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
96754 const char *msg;
96755 u_int8_t state;
96756
96757 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
96758 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
96759 BUG_ON(dh == NULL);
96760
96761 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
96762 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
96763 out_invalid:
96764 if (LOG_INVALID(net, IPPROTO_DCCP))
96765 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
96766 - NULL, msg);
96767 + NULL, "%s", msg);
96768 return false;
96769 }
96770
96771 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
96772 u_int8_t type, old_state, new_state;
96773 enum ct_dccp_roles role;
96774
96775 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
96776 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
96777 BUG_ON(dh == NULL);
96778 type = dh->dccph_type;
96779
96780 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
96781 unsigned int cscov;
96782 const char *msg;
96783
96784 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
96785 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
96786 if (dh == NULL) {
96787 msg = "nf_ct_dccp: short packet ";
96788 goto out_invalid;
96789 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
96790
96791 out_invalid:
96792 if (LOG_INVALID(net, IPPROTO_DCCP))
96793 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
96794 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
96795 return -NF_ACCEPT;
96796 }
96797
96798 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
96799 index f641751..d3c5b51 100644
96800 --- a/net/netfilter/nf_conntrack_standalone.c
96801 +++ b/net/netfilter/nf_conntrack_standalone.c
96802 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
96803
96804 static int nf_conntrack_standalone_init_sysctl(struct net *net)
96805 {
96806 - struct ctl_table *table;
96807 + ctl_table_no_const *table;
96808
96809 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
96810 GFP_KERNEL);
96811 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
96812 index 902fb0a..87f7fdb 100644
96813 --- a/net/netfilter/nf_conntrack_timestamp.c
96814 +++ b/net/netfilter/nf_conntrack_timestamp.c
96815 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
96816 #ifdef CONFIG_SYSCTL
96817 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
96818 {
96819 - struct ctl_table *table;
96820 + ctl_table_no_const *table;
96821
96822 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
96823 GFP_KERNEL);
96824 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
96825 index 85296d4..8becdec 100644
96826 --- a/net/netfilter/nf_log.c
96827 +++ b/net/netfilter/nf_log.c
96828 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
96829
96830 #ifdef CONFIG_SYSCTL
96831 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
96832 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
96833 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
96834
96835 static int nf_log_proc_dostring(struct ctl_table *table, int write,
96836 void __user *buffer, size_t *lenp, loff_t *ppos)
96837 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
96838 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
96839 mutex_unlock(&nf_log_mutex);
96840 } else {
96841 + ctl_table_no_const nf_log_table = *table;
96842 +
96843 mutex_lock(&nf_log_mutex);
96844 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
96845 lockdep_is_held(&nf_log_mutex));
96846 if (!logger)
96847 - table->data = "NONE";
96848 + nf_log_table.data = "NONE";
96849 else
96850 - table->data = logger->name;
96851 - r = proc_dostring(table, write, buffer, lenp, ppos);
96852 + nf_log_table.data = logger->name;
96853 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
96854 mutex_unlock(&nf_log_mutex);
96855 }
96856
96857 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
96858 index f042ae5..30ea486 100644
96859 --- a/net/netfilter/nf_sockopt.c
96860 +++ b/net/netfilter/nf_sockopt.c
96861 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
96862 }
96863 }
96864
96865 - list_add(&reg->list, &nf_sockopts);
96866 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
96867 out:
96868 mutex_unlock(&nf_sockopt_mutex);
96869 return ret;
96870 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
96871 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
96872 {
96873 mutex_lock(&nf_sockopt_mutex);
96874 - list_del(&reg->list);
96875 + pax_list_del((struct list_head *)&reg->list);
96876 mutex_unlock(&nf_sockopt_mutex);
96877 }
96878 EXPORT_SYMBOL(nf_unregister_sockopt);
96879 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
96880 index d92cc31..e46f350 100644
96881 --- a/net/netfilter/nfnetlink_log.c
96882 +++ b/net/netfilter/nfnetlink_log.c
96883 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
96884 struct nfnl_log_net {
96885 spinlock_t instances_lock;
96886 struct hlist_head instance_table[INSTANCE_BUCKETS];
96887 - atomic_t global_seq;
96888 + atomic_unchecked_t global_seq;
96889 };
96890
96891 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
96892 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
96893 /* global sequence number */
96894 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
96895 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
96896 - htonl(atomic_inc_return(&log->global_seq))))
96897 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
96898 goto nla_put_failure;
96899
96900 if (data_len) {
96901 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
96902 new file mode 100644
96903 index 0000000..c566332
96904 --- /dev/null
96905 +++ b/net/netfilter/xt_gradm.c
96906 @@ -0,0 +1,51 @@
96907 +/*
96908 + * gradm match for netfilter
96909 + * Copyright © Zbigniew Krzystolik, 2010
96910 + *
96911 + * This program is free software; you can redistribute it and/or modify
96912 + * it under the terms of the GNU General Public License; either version
96913 + * 2 or 3 as published by the Free Software Foundation.
96914 + */
96915 +#include <linux/module.h>
96916 +#include <linux/moduleparam.h>
96917 +#include <linux/skbuff.h>
96918 +#include <linux/netfilter/x_tables.h>
96919 +#include <linux/grsecurity.h>
96920 +#include <linux/netfilter/xt_gradm.h>
96921 +
96922 +static bool
96923 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
96924 +{
96925 + const struct xt_gradm_mtinfo *info = par->matchinfo;
96926 + bool retval = false;
96927 + if (gr_acl_is_enabled())
96928 + retval = true;
96929 + return retval ^ info->invflags;
96930 +}
96931 +
96932 +static struct xt_match gradm_mt_reg __read_mostly = {
96933 + .name = "gradm",
96934 + .revision = 0,
96935 + .family = NFPROTO_UNSPEC,
96936 + .match = gradm_mt,
96937 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
96938 + .me = THIS_MODULE,
96939 +};
96940 +
96941 +static int __init gradm_mt_init(void)
96942 +{
96943 + return xt_register_match(&gradm_mt_reg);
96944 +}
96945 +
96946 +static void __exit gradm_mt_exit(void)
96947 +{
96948 + xt_unregister_match(&gradm_mt_reg);
96949 +}
96950 +
96951 +module_init(gradm_mt_init);
96952 +module_exit(gradm_mt_exit);
96953 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
96954 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
96955 +MODULE_LICENSE("GPL");
96956 +MODULE_ALIAS("ipt_gradm");
96957 +MODULE_ALIAS("ip6t_gradm");
96958 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
96959 index 4fe4fb4..87a89e5 100644
96960 --- a/net/netfilter/xt_statistic.c
96961 +++ b/net/netfilter/xt_statistic.c
96962 @@ -19,7 +19,7 @@
96963 #include <linux/module.h>
96964
96965 struct xt_statistic_priv {
96966 - atomic_t count;
96967 + atomic_unchecked_t count;
96968 } ____cacheline_aligned_in_smp;
96969
96970 MODULE_LICENSE("GPL");
96971 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
96972 break;
96973 case XT_STATISTIC_MODE_NTH:
96974 do {
96975 - oval = atomic_read(&info->master->count);
96976 + oval = atomic_read_unchecked(&info->master->count);
96977 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
96978 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
96979 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
96980 if (nval == 0)
96981 ret = !ret;
96982 break;
96983 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
96984 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
96985 if (info->master == NULL)
96986 return -ENOMEM;
96987 - atomic_set(&info->master->count, info->u.nth.count);
96988 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
96989
96990 return 0;
96991 }
96992 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
96993 index 6135635..5bdc54a 100644
96994 --- a/net/netlink/af_netlink.c
96995 +++ b/net/netlink/af_netlink.c
96996 @@ -249,7 +249,7 @@ static void netlink_overrun(struct sock *sk)
96997 sk->sk_error_report(sk);
96998 }
96999 }
97000 - atomic_inc(&sk->sk_drops);
97001 + atomic_inc_unchecked(&sk->sk_drops);
97002 }
97003
97004 static void netlink_rcv_wake(struct sock *sk)
97005 @@ -2940,7 +2940,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
97006 sk_wmem_alloc_get(s),
97007 nlk->cb_running,
97008 atomic_read(&s->sk_refcnt),
97009 - atomic_read(&s->sk_drops),
97010 + atomic_read_unchecked(&s->sk_drops),
97011 sock_i_ino(s)
97012 );
97013
97014 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
97015 index 0c741ce..f8c8ca7 100644
97016 --- a/net/netlink/genetlink.c
97017 +++ b/net/netlink/genetlink.c
97018 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
97019 goto errout;
97020 }
97021
97022 + pax_open_kernel();
97023 if (ops->dumpit)
97024 - ops->flags |= GENL_CMD_CAP_DUMP;
97025 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
97026 if (ops->doit)
97027 - ops->flags |= GENL_CMD_CAP_DO;
97028 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
97029 if (ops->policy)
97030 - ops->flags |= GENL_CMD_CAP_HASPOL;
97031 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
97032 + pax_close_kernel();
97033
97034 genl_lock_all();
97035 - list_add_tail(&ops->ops_list, &family->ops_list);
97036 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
97037 genl_unlock_all();
97038
97039 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
97040 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
97041 err = 0;
97042 errout:
97043 return err;
97044 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
97045 genl_lock_all();
97046 list_for_each_entry(rc, &family->ops_list, ops_list) {
97047 if (rc == ops) {
97048 - list_del(&ops->ops_list);
97049 + pax_list_del((struct list_head *)&ops->ops_list);
97050 genl_unlock_all();
97051 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
97052 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
97053 return 0;
97054 }
97055 }
97056 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
97057 index 53c19a3..b0ac04a 100644
97058 --- a/net/netrom/af_netrom.c
97059 +++ b/net/netrom/af_netrom.c
97060 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
97061 *uaddr_len = sizeof(struct full_sockaddr_ax25);
97062 } else {
97063 sax->fsa_ax25.sax25_family = AF_NETROM;
97064 - sax->fsa_ax25.sax25_ndigis = 0;
97065 sax->fsa_ax25.sax25_call = nr->source_addr;
97066 *uaddr_len = sizeof(struct sockaddr_ax25);
97067 }
97068 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
97069 index 88cfbc1..05d73f5 100644
97070 --- a/net/packet/af_packet.c
97071 +++ b/net/packet/af_packet.c
97072 @@ -1720,7 +1720,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
97073
97074 spin_lock(&sk->sk_receive_queue.lock);
97075 po->stats.stats1.tp_packets++;
97076 - skb->dropcount = atomic_read(&sk->sk_drops);
97077 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
97078 __skb_queue_tail(&sk->sk_receive_queue, skb);
97079 spin_unlock(&sk->sk_receive_queue.lock);
97080 sk->sk_data_ready(sk, skb->len);
97081 @@ -1729,7 +1729,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
97082 drop_n_acct:
97083 spin_lock(&sk->sk_receive_queue.lock);
97084 po->stats.stats1.tp_drops++;
97085 - atomic_inc(&sk->sk_drops);
97086 + atomic_inc_unchecked(&sk->sk_drops);
97087 spin_unlock(&sk->sk_receive_queue.lock);
97088
97089 drop_n_restore:
97090 @@ -3275,7 +3275,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
97091 case PACKET_HDRLEN:
97092 if (len > sizeof(int))
97093 len = sizeof(int);
97094 - if (copy_from_user(&val, optval, len))
97095 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
97096 return -EFAULT;
97097 switch (val) {
97098 case TPACKET_V1:
97099 @@ -3318,7 +3318,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
97100 len = lv;
97101 if (put_user(len, optlen))
97102 return -EFAULT;
97103 - if (copy_to_user(optval, data, len))
97104 + if (len > sizeof(st) || copy_to_user(optval, data, len))
97105 return -EFAULT;
97106 return 0;
97107 }
97108 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
97109 index e774117..900b8b7 100644
97110 --- a/net/phonet/pep.c
97111 +++ b/net/phonet/pep.c
97112 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
97113
97114 case PNS_PEP_CTRL_REQ:
97115 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
97116 - atomic_inc(&sk->sk_drops);
97117 + atomic_inc_unchecked(&sk->sk_drops);
97118 break;
97119 }
97120 __skb_pull(skb, 4);
97121 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
97122 }
97123
97124 if (pn->rx_credits == 0) {
97125 - atomic_inc(&sk->sk_drops);
97126 + atomic_inc_unchecked(&sk->sk_drops);
97127 err = -ENOBUFS;
97128 break;
97129 }
97130 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
97131 }
97132
97133 if (pn->rx_credits == 0) {
97134 - atomic_inc(&sk->sk_drops);
97135 + atomic_inc_unchecked(&sk->sk_drops);
97136 err = NET_RX_DROP;
97137 break;
97138 }
97139 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
97140 index 77e38f7..f4ef5c3 100644
97141 --- a/net/phonet/socket.c
97142 +++ b/net/phonet/socket.c
97143 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
97144 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
97145 sock_i_ino(sk),
97146 atomic_read(&sk->sk_refcnt), sk,
97147 - atomic_read(&sk->sk_drops), &len);
97148 + atomic_read_unchecked(&sk->sk_drops), &len);
97149 }
97150 seq_printf(seq, "%*s\n", 127 - len, "");
97151 return 0;
97152 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
97153 index c02a8c4..3c5b600 100644
97154 --- a/net/phonet/sysctl.c
97155 +++ b/net/phonet/sysctl.c
97156 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
97157 {
97158 int ret;
97159 int range[2] = {local_port_range[0], local_port_range[1]};
97160 - struct ctl_table tmp = {
97161 + ctl_table_no_const tmp = {
97162 .data = &range,
97163 .maxlen = sizeof(range),
97164 .mode = table->mode,
97165 diff --git a/net/rds/cong.c b/net/rds/cong.c
97166 index e5b65ac..f3b6fb7 100644
97167 --- a/net/rds/cong.c
97168 +++ b/net/rds/cong.c
97169 @@ -78,7 +78,7 @@
97170 * finds that the saved generation number is smaller than the global generation
97171 * number, it wakes up the process.
97172 */
97173 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
97174 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
97175
97176 /*
97177 * Congestion monitoring
97178 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
97179 rdsdebug("waking map %p for %pI4\n",
97180 map, &map->m_addr);
97181 rds_stats_inc(s_cong_update_received);
97182 - atomic_inc(&rds_cong_generation);
97183 + atomic_inc_unchecked(&rds_cong_generation);
97184 if (waitqueue_active(&map->m_waitq))
97185 wake_up(&map->m_waitq);
97186 if (waitqueue_active(&rds_poll_waitq))
97187 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
97188
97189 int rds_cong_updated_since(unsigned long *recent)
97190 {
97191 - unsigned long gen = atomic_read(&rds_cong_generation);
97192 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
97193
97194 if (likely(*recent == gen))
97195 return 0;
97196 diff --git a/net/rds/ib.h b/net/rds/ib.h
97197 index 7280ab8..e04f4ea 100644
97198 --- a/net/rds/ib.h
97199 +++ b/net/rds/ib.h
97200 @@ -128,7 +128,7 @@ struct rds_ib_connection {
97201 /* sending acks */
97202 unsigned long i_ack_flags;
97203 #ifdef KERNEL_HAS_ATOMIC64
97204 - atomic64_t i_ack_next; /* next ACK to send */
97205 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
97206 #else
97207 spinlock_t i_ack_lock; /* protect i_ack_next */
97208 u64 i_ack_next; /* next ACK to send */
97209 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
97210 index 31b74f5..dc1fbfa 100644
97211 --- a/net/rds/ib_cm.c
97212 +++ b/net/rds/ib_cm.c
97213 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
97214 /* Clear the ACK state */
97215 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
97216 #ifdef KERNEL_HAS_ATOMIC64
97217 - atomic64_set(&ic->i_ack_next, 0);
97218 + atomic64_set_unchecked(&ic->i_ack_next, 0);
97219 #else
97220 ic->i_ack_next = 0;
97221 #endif
97222 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
97223 index 8eb9501..0c386ff 100644
97224 --- a/net/rds/ib_recv.c
97225 +++ b/net/rds/ib_recv.c
97226 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
97227 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
97228 int ack_required)
97229 {
97230 - atomic64_set(&ic->i_ack_next, seq);
97231 + atomic64_set_unchecked(&ic->i_ack_next, seq);
97232 if (ack_required) {
97233 smp_mb__before_clear_bit();
97234 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
97235 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
97236 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
97237 smp_mb__after_clear_bit();
97238
97239 - return atomic64_read(&ic->i_ack_next);
97240 + return atomic64_read_unchecked(&ic->i_ack_next);
97241 }
97242 #endif
97243
97244 diff --git a/net/rds/iw.h b/net/rds/iw.h
97245 index 04ce3b1..48119a6 100644
97246 --- a/net/rds/iw.h
97247 +++ b/net/rds/iw.h
97248 @@ -134,7 +134,7 @@ struct rds_iw_connection {
97249 /* sending acks */
97250 unsigned long i_ack_flags;
97251 #ifdef KERNEL_HAS_ATOMIC64
97252 - atomic64_t i_ack_next; /* next ACK to send */
97253 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
97254 #else
97255 spinlock_t i_ack_lock; /* protect i_ack_next */
97256 u64 i_ack_next; /* next ACK to send */
97257 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
97258 index a91e1db..cf3053f 100644
97259 --- a/net/rds/iw_cm.c
97260 +++ b/net/rds/iw_cm.c
97261 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
97262 /* Clear the ACK state */
97263 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
97264 #ifdef KERNEL_HAS_ATOMIC64
97265 - atomic64_set(&ic->i_ack_next, 0);
97266 + atomic64_set_unchecked(&ic->i_ack_next, 0);
97267 #else
97268 ic->i_ack_next = 0;
97269 #endif
97270 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
97271 index 4503335..db566b4 100644
97272 --- a/net/rds/iw_recv.c
97273 +++ b/net/rds/iw_recv.c
97274 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
97275 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
97276 int ack_required)
97277 {
97278 - atomic64_set(&ic->i_ack_next, seq);
97279 + atomic64_set_unchecked(&ic->i_ack_next, seq);
97280 if (ack_required) {
97281 smp_mb__before_clear_bit();
97282 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
97283 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
97284 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
97285 smp_mb__after_clear_bit();
97286
97287 - return atomic64_read(&ic->i_ack_next);
97288 + return atomic64_read_unchecked(&ic->i_ack_next);
97289 }
97290 #endif
97291
97292 diff --git a/net/rds/rds.h b/net/rds/rds.h
97293 index ec1d731..90a3a8d 100644
97294 --- a/net/rds/rds.h
97295 +++ b/net/rds/rds.h
97296 @@ -449,7 +449,7 @@ struct rds_transport {
97297 void (*sync_mr)(void *trans_private, int direction);
97298 void (*free_mr)(void *trans_private, int invalidate);
97299 void (*flush_mrs)(void);
97300 -};
97301 +} __do_const;
97302
97303 struct rds_sock {
97304 struct sock rs_sk;
97305 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
97306 index edac9ef..16bcb98 100644
97307 --- a/net/rds/tcp.c
97308 +++ b/net/rds/tcp.c
97309 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
97310 int val = 1;
97311
97312 set_fs(KERNEL_DS);
97313 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
97314 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
97315 sizeof(val));
97316 set_fs(oldfs);
97317 }
97318 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
97319 index 81cf5a4..b5826ff 100644
97320 --- a/net/rds/tcp_send.c
97321 +++ b/net/rds/tcp_send.c
97322 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
97323
97324 oldfs = get_fs();
97325 set_fs(KERNEL_DS);
97326 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
97327 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
97328 sizeof(val));
97329 set_fs(oldfs);
97330 }
97331 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
97332 index e61aa60..f07cc89 100644
97333 --- a/net/rxrpc/af_rxrpc.c
97334 +++ b/net/rxrpc/af_rxrpc.c
97335 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
97336 __be32 rxrpc_epoch;
97337
97338 /* current debugging ID */
97339 -atomic_t rxrpc_debug_id;
97340 +atomic_unchecked_t rxrpc_debug_id;
97341
97342 /* count of skbs currently in use */
97343 atomic_t rxrpc_n_skbs;
97344 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
97345 index e4d9cbc..b229649 100644
97346 --- a/net/rxrpc/ar-ack.c
97347 +++ b/net/rxrpc/ar-ack.c
97348 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
97349
97350 _enter("{%d,%d,%d,%d},",
97351 call->acks_hard, call->acks_unacked,
97352 - atomic_read(&call->sequence),
97353 + atomic_read_unchecked(&call->sequence),
97354 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
97355
97356 stop = 0;
97357 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
97358
97359 /* each Tx packet has a new serial number */
97360 sp->hdr.serial =
97361 - htonl(atomic_inc_return(&call->conn->serial));
97362 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
97363
97364 hdr = (struct rxrpc_header *) txb->head;
97365 hdr->serial = sp->hdr.serial;
97366 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
97367 */
97368 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
97369 {
97370 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
97371 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
97372 }
97373
97374 /*
97375 @@ -629,7 +629,7 @@ process_further:
97376
97377 latest = ntohl(sp->hdr.serial);
97378 hard = ntohl(ack.firstPacket);
97379 - tx = atomic_read(&call->sequence);
97380 + tx = atomic_read_unchecked(&call->sequence);
97381
97382 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
97383 latest,
97384 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
97385 goto maybe_reschedule;
97386
97387 send_ACK_with_skew:
97388 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
97389 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
97390 ntohl(ack.serial));
97391 send_ACK:
97392 mtu = call->conn->trans->peer->if_mtu;
97393 @@ -1173,7 +1173,7 @@ send_ACK:
97394 ackinfo.rxMTU = htonl(5692);
97395 ackinfo.jumbo_max = htonl(4);
97396
97397 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
97398 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
97399 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
97400 ntohl(hdr.serial),
97401 ntohs(ack.maxSkew),
97402 @@ -1191,7 +1191,7 @@ send_ACK:
97403 send_message:
97404 _debug("send message");
97405
97406 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
97407 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
97408 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
97409 send_message_2:
97410
97411 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
97412 index a3bbb36..3341fb9 100644
97413 --- a/net/rxrpc/ar-call.c
97414 +++ b/net/rxrpc/ar-call.c
97415 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
97416 spin_lock_init(&call->lock);
97417 rwlock_init(&call->state_lock);
97418 atomic_set(&call->usage, 1);
97419 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
97420 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97421 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
97422
97423 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
97424 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
97425 index 4106ca9..a338d7a 100644
97426 --- a/net/rxrpc/ar-connection.c
97427 +++ b/net/rxrpc/ar-connection.c
97428 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
97429 rwlock_init(&conn->lock);
97430 spin_lock_init(&conn->state_lock);
97431 atomic_set(&conn->usage, 1);
97432 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
97433 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97434 conn->avail_calls = RXRPC_MAXCALLS;
97435 conn->size_align = 4;
97436 conn->header_size = sizeof(struct rxrpc_header);
97437 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
97438 index e7ed43a..6afa140 100644
97439 --- a/net/rxrpc/ar-connevent.c
97440 +++ b/net/rxrpc/ar-connevent.c
97441 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
97442
97443 len = iov[0].iov_len + iov[1].iov_len;
97444
97445 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
97446 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
97447 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
97448
97449 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
97450 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
97451 index 529572f..c758ca7 100644
97452 --- a/net/rxrpc/ar-input.c
97453 +++ b/net/rxrpc/ar-input.c
97454 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
97455 /* track the latest serial number on this connection for ACK packet
97456 * information */
97457 serial = ntohl(sp->hdr.serial);
97458 - hi_serial = atomic_read(&call->conn->hi_serial);
97459 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
97460 while (serial > hi_serial)
97461 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
97462 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
97463 serial);
97464
97465 /* request ACK generation for any ACK or DATA packet that requests
97466 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
97467 index a693aca..81e7293 100644
97468 --- a/net/rxrpc/ar-internal.h
97469 +++ b/net/rxrpc/ar-internal.h
97470 @@ -272,8 +272,8 @@ struct rxrpc_connection {
97471 int error; /* error code for local abort */
97472 int debug_id; /* debug ID for printks */
97473 unsigned int call_counter; /* call ID counter */
97474 - atomic_t serial; /* packet serial number counter */
97475 - atomic_t hi_serial; /* highest serial number received */
97476 + atomic_unchecked_t serial; /* packet serial number counter */
97477 + atomic_unchecked_t hi_serial; /* highest serial number received */
97478 u8 avail_calls; /* number of calls available */
97479 u8 size_align; /* data size alignment (for security) */
97480 u8 header_size; /* rxrpc + security header size */
97481 @@ -346,7 +346,7 @@ struct rxrpc_call {
97482 spinlock_t lock;
97483 rwlock_t state_lock; /* lock for state transition */
97484 atomic_t usage;
97485 - atomic_t sequence; /* Tx data packet sequence counter */
97486 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
97487 u32 abort_code; /* local/remote abort code */
97488 enum { /* current state of call */
97489 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
97490 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
97491 */
97492 extern atomic_t rxrpc_n_skbs;
97493 extern __be32 rxrpc_epoch;
97494 -extern atomic_t rxrpc_debug_id;
97495 +extern atomic_unchecked_t rxrpc_debug_id;
97496 extern struct workqueue_struct *rxrpc_workqueue;
97497
97498 /*
97499 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
97500 index 87f7135..74d3703 100644
97501 --- a/net/rxrpc/ar-local.c
97502 +++ b/net/rxrpc/ar-local.c
97503 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
97504 spin_lock_init(&local->lock);
97505 rwlock_init(&local->services_lock);
97506 atomic_set(&local->usage, 1);
97507 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
97508 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97509 memcpy(&local->srx, srx, sizeof(*srx));
97510 }
97511
97512 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
97513 index e1ac183..b43e10e 100644
97514 --- a/net/rxrpc/ar-output.c
97515 +++ b/net/rxrpc/ar-output.c
97516 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
97517 sp->hdr.cid = call->cid;
97518 sp->hdr.callNumber = call->call_id;
97519 sp->hdr.seq =
97520 - htonl(atomic_inc_return(&call->sequence));
97521 + htonl(atomic_inc_return_unchecked(&call->sequence));
97522 sp->hdr.serial =
97523 - htonl(atomic_inc_return(&conn->serial));
97524 + htonl(atomic_inc_return_unchecked(&conn->serial));
97525 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
97526 sp->hdr.userStatus = 0;
97527 sp->hdr.securityIndex = conn->security_ix;
97528 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
97529 index bebaa43..2644591 100644
97530 --- a/net/rxrpc/ar-peer.c
97531 +++ b/net/rxrpc/ar-peer.c
97532 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
97533 INIT_LIST_HEAD(&peer->error_targets);
97534 spin_lock_init(&peer->lock);
97535 atomic_set(&peer->usage, 1);
97536 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
97537 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97538 memcpy(&peer->srx, srx, sizeof(*srx));
97539
97540 rxrpc_assess_MTU_size(peer);
97541 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
97542 index 38047f7..9f48511 100644
97543 --- a/net/rxrpc/ar-proc.c
97544 +++ b/net/rxrpc/ar-proc.c
97545 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
97546 atomic_read(&conn->usage),
97547 rxrpc_conn_states[conn->state],
97548 key_serial(conn->key),
97549 - atomic_read(&conn->serial),
97550 - atomic_read(&conn->hi_serial));
97551 + atomic_read_unchecked(&conn->serial),
97552 + atomic_read_unchecked(&conn->hi_serial));
97553
97554 return 0;
97555 }
97556 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
97557 index 92df566..87ec1bf 100644
97558 --- a/net/rxrpc/ar-transport.c
97559 +++ b/net/rxrpc/ar-transport.c
97560 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
97561 spin_lock_init(&trans->client_lock);
97562 rwlock_init(&trans->conn_lock);
97563 atomic_set(&trans->usage, 1);
97564 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
97565 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97566
97567 if (peer->srx.transport.family == AF_INET) {
97568 switch (peer->srx.transport_type) {
97569 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
97570 index f226709..0e735a8 100644
97571 --- a/net/rxrpc/rxkad.c
97572 +++ b/net/rxrpc/rxkad.c
97573 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
97574
97575 len = iov[0].iov_len + iov[1].iov_len;
97576
97577 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
97578 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
97579 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
97580
97581 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
97582 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
97583
97584 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
97585
97586 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
97587 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
97588 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
97589
97590 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
97591 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
97592 index e7b2d4f..bb1efd0 100644
97593 --- a/net/sctp/ipv6.c
97594 +++ b/net/sctp/ipv6.c
97595 @@ -962,7 +962,7 @@ static const struct inet6_protocol sctpv6_protocol = {
97596 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
97597 };
97598
97599 -static struct sctp_af sctp_af_inet6 = {
97600 +static struct sctp_af sctp_af_inet6 __read_only = {
97601 .sa_family = AF_INET6,
97602 .sctp_xmit = sctp_v6_xmit,
97603 .setsockopt = ipv6_setsockopt,
97604 @@ -994,7 +994,7 @@ static struct sctp_af sctp_af_inet6 = {
97605 #endif
97606 };
97607
97608 -static struct sctp_pf sctp_pf_inet6 = {
97609 +static struct sctp_pf sctp_pf_inet6 __read_only = {
97610 .event_msgname = sctp_inet6_event_msgname,
97611 .skb_msgname = sctp_inet6_skb_msgname,
97612 .af_supported = sctp_inet6_af_supported,
97613 @@ -1019,7 +1019,7 @@ void sctp_v6_pf_init(void)
97614
97615 void sctp_v6_pf_exit(void)
97616 {
97617 - list_del(&sctp_af_inet6.list);
97618 + pax_list_del(&sctp_af_inet6.list);
97619 }
97620
97621 /* Initialize IPv6 support and register with socket layer. */
97622 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
97623 index 5e17092..19be1d4 100644
97624 --- a/net/sctp/protocol.c
97625 +++ b/net/sctp/protocol.c
97626 @@ -832,8 +832,10 @@ int sctp_register_af(struct sctp_af *af)
97627 return 0;
97628 }
97629
97630 + pax_open_kernel();
97631 INIT_LIST_HEAD(&af->list);
97632 - list_add_tail(&af->list, &sctp_address_families);
97633 + pax_close_kernel();
97634 + pax_list_add_tail(&af->list, &sctp_address_families);
97635 return 1;
97636 }
97637
97638 @@ -963,7 +965,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
97639
97640 static struct sctp_af sctp_af_inet;
97641
97642 -static struct sctp_pf sctp_pf_inet = {
97643 +static struct sctp_pf sctp_pf_inet __read_only = {
97644 .event_msgname = sctp_inet_event_msgname,
97645 .skb_msgname = sctp_inet_skb_msgname,
97646 .af_supported = sctp_inet_af_supported,
97647 @@ -1034,7 +1036,7 @@ static const struct net_protocol sctp_protocol = {
97648 };
97649
97650 /* IPv4 address related functions. */
97651 -static struct sctp_af sctp_af_inet = {
97652 +static struct sctp_af sctp_af_inet __read_only = {
97653 .sa_family = AF_INET,
97654 .sctp_xmit = sctp_v4_xmit,
97655 .setsockopt = ip_setsockopt,
97656 @@ -1119,7 +1121,7 @@ static void sctp_v4_pf_init(void)
97657
97658 static void sctp_v4_pf_exit(void)
97659 {
97660 - list_del(&sctp_af_inet.list);
97661 + pax_list_del(&sctp_af_inet.list);
97662 }
97663
97664 static int sctp_v4_protosw_init(void)
97665 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
97666 index 1a6eef3..17e898f 100644
97667 --- a/net/sctp/sm_sideeffect.c
97668 +++ b/net/sctp/sm_sideeffect.c
97669 @@ -440,7 +440,7 @@ static void sctp_generate_sack_event(unsigned long data)
97670 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
97671 }
97672
97673 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
97674 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
97675 NULL,
97676 sctp_generate_t1_cookie_event,
97677 sctp_generate_t1_init_event,
97678 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
97679 index 911b71b..90ade0a 100644
97680 --- a/net/sctp/socket.c
97681 +++ b/net/sctp/socket.c
97682 @@ -2153,11 +2153,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
97683 {
97684 struct sctp_association *asoc;
97685 struct sctp_ulpevent *event;
97686 + struct sctp_event_subscribe subscribe;
97687
97688 if (optlen > sizeof(struct sctp_event_subscribe))
97689 return -EINVAL;
97690 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
97691 + if (copy_from_user(&subscribe, optval, optlen))
97692 return -EFAULT;
97693 + sctp_sk(sk)->subscribe = subscribe;
97694
97695 /*
97696 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
97697 @@ -4213,13 +4215,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
97698 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
97699 int __user *optlen)
97700 {
97701 + struct sctp_event_subscribe subscribe;
97702 +
97703 if (len <= 0)
97704 return -EINVAL;
97705 if (len > sizeof(struct sctp_event_subscribe))
97706 len = sizeof(struct sctp_event_subscribe);
97707 if (put_user(len, optlen))
97708 return -EFAULT;
97709 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
97710 + subscribe = sctp_sk(sk)->subscribe;
97711 + if (copy_to_user(optval, &subscribe, len))
97712 return -EFAULT;
97713 return 0;
97714 }
97715 @@ -4237,6 +4242,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
97716 */
97717 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
97718 {
97719 + __u32 autoclose;
97720 +
97721 /* Applicable to UDP-style socket only */
97722 if (sctp_style(sk, TCP))
97723 return -EOPNOTSUPP;
97724 @@ -4245,7 +4252,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
97725 len = sizeof(int);
97726 if (put_user(len, optlen))
97727 return -EFAULT;
97728 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
97729 + autoclose = sctp_sk(sk)->autoclose;
97730 + if (copy_to_user(optval, &autoclose, sizeof(int)))
97731 return -EFAULT;
97732 return 0;
97733 }
97734 @@ -4617,12 +4625,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
97735 */
97736 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
97737 {
97738 + struct sctp_initmsg initmsg;
97739 +
97740 if (len < sizeof(struct sctp_initmsg))
97741 return -EINVAL;
97742 len = sizeof(struct sctp_initmsg);
97743 if (put_user(len, optlen))
97744 return -EFAULT;
97745 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
97746 + initmsg = sctp_sk(sk)->initmsg;
97747 + if (copy_to_user(optval, &initmsg, len))
97748 return -EFAULT;
97749 return 0;
97750 }
97751 @@ -4663,6 +4674,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
97752 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
97753 if (space_left < addrlen)
97754 return -ENOMEM;
97755 + if (addrlen > sizeof(temp) || addrlen < 0)
97756 + return -EFAULT;
97757 if (copy_to_user(to, &temp, addrlen))
97758 return -EFAULT;
97759 to += addrlen;
97760 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
97761 index 6b36561..4f21064 100644
97762 --- a/net/sctp/sysctl.c
97763 +++ b/net/sctp/sysctl.c
97764 @@ -301,7 +301,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
97765 {
97766 struct net *net = current->nsproxy->net_ns;
97767 char tmp[8];
97768 - struct ctl_table tbl;
97769 + ctl_table_no_const tbl;
97770 int ret;
97771 int changed = 0;
97772 char *none = "none";
97773 @@ -344,7 +344,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
97774
97775 int sctp_sysctl_net_register(struct net *net)
97776 {
97777 - struct ctl_table *table;
97778 + ctl_table_no_const *table;
97779 int i;
97780
97781 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
97782 diff --git a/net/socket.c b/net/socket.c
97783 index e83c416..9169305 100644
97784 --- a/net/socket.c
97785 +++ b/net/socket.c
97786 @@ -88,6 +88,7 @@
97787 #include <linux/magic.h>
97788 #include <linux/slab.h>
97789 #include <linux/xattr.h>
97790 +#include <linux/in.h>
97791
97792 #include <asm/uaccess.h>
97793 #include <asm/unistd.h>
97794 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
97795 unsigned int sysctl_net_busy_poll __read_mostly;
97796 #endif
97797
97798 +#include <linux/grsock.h>
97799 +
97800 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
97801 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
97802 unsigned long nr_segs, loff_t pos);
97803 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
97804 */
97805
97806 static DEFINE_SPINLOCK(net_family_lock);
97807 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
97808 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
97809
97810 /*
97811 * Statistics counters of the socket lists
97812 @@ -328,7 +331,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
97813 &sockfs_dentry_operations, SOCKFS_MAGIC);
97814 }
97815
97816 -static struct vfsmount *sock_mnt __read_mostly;
97817 +struct vfsmount *sock_mnt __read_mostly;
97818
97819 static struct file_system_type sock_fs_type = {
97820 .name = "sockfs",
97821 @@ -1255,6 +1258,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
97822 return -EAFNOSUPPORT;
97823 if (type < 0 || type >= SOCK_MAX)
97824 return -EINVAL;
97825 + if (protocol < 0)
97826 + return -EINVAL;
97827
97828 /* Compatibility.
97829
97830 @@ -1275,6 +1280,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
97831 if (err)
97832 return err;
97833
97834 + if(!kern && !gr_search_socket(family, type, protocol)) {
97835 + if (rcu_access_pointer(net_families[family]) == NULL)
97836 + return -EAFNOSUPPORT;
97837 + else
97838 + return -EACCES;
97839 + }
97840 +
97841 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
97842 + if (rcu_access_pointer(net_families[family]) == NULL)
97843 + return -EAFNOSUPPORT;
97844 + else
97845 + return -EACCES;
97846 + }
97847 +
97848 /*
97849 * Allocate the socket and allow the family to set things up. if
97850 * the protocol is 0, the family is instructed to select an appropriate
97851 @@ -1513,6 +1532,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
97852 if (sock) {
97853 err = move_addr_to_kernel(umyaddr, addrlen, &address);
97854 if (err >= 0) {
97855 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
97856 + err = -EACCES;
97857 + goto error;
97858 + }
97859 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
97860 + if (err)
97861 + goto error;
97862 +
97863 err = security_socket_bind(sock,
97864 (struct sockaddr *)&address,
97865 addrlen);
97866 @@ -1521,6 +1548,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
97867 (struct sockaddr *)
97868 &address, addrlen);
97869 }
97870 +error:
97871 fput_light(sock->file, fput_needed);
97872 }
97873 return err;
97874 @@ -1544,10 +1572,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
97875 if ((unsigned int)backlog > somaxconn)
97876 backlog = somaxconn;
97877
97878 + if (gr_handle_sock_server_other(sock->sk)) {
97879 + err = -EPERM;
97880 + goto error;
97881 + }
97882 +
97883 + err = gr_search_listen(sock);
97884 + if (err)
97885 + goto error;
97886 +
97887 err = security_socket_listen(sock, backlog);
97888 if (!err)
97889 err = sock->ops->listen(sock, backlog);
97890
97891 +error:
97892 fput_light(sock->file, fput_needed);
97893 }
97894 return err;
97895 @@ -1591,6 +1629,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
97896 newsock->type = sock->type;
97897 newsock->ops = sock->ops;
97898
97899 + if (gr_handle_sock_server_other(sock->sk)) {
97900 + err = -EPERM;
97901 + sock_release(newsock);
97902 + goto out_put;
97903 + }
97904 +
97905 + err = gr_search_accept(sock);
97906 + if (err) {
97907 + sock_release(newsock);
97908 + goto out_put;
97909 + }
97910 +
97911 /*
97912 * We don't need try_module_get here, as the listening socket (sock)
97913 * has the protocol module (sock->ops->owner) held.
97914 @@ -1636,6 +1686,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
97915 fd_install(newfd, newfile);
97916 err = newfd;
97917
97918 + gr_attach_curr_ip(newsock->sk);
97919 +
97920 out_put:
97921 fput_light(sock->file, fput_needed);
97922 out:
97923 @@ -1668,6 +1720,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
97924 int, addrlen)
97925 {
97926 struct socket *sock;
97927 + struct sockaddr *sck;
97928 struct sockaddr_storage address;
97929 int err, fput_needed;
97930
97931 @@ -1678,6 +1731,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
97932 if (err < 0)
97933 goto out_put;
97934
97935 + sck = (struct sockaddr *)&address;
97936 +
97937 + if (gr_handle_sock_client(sck)) {
97938 + err = -EACCES;
97939 + goto out_put;
97940 + }
97941 +
97942 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
97943 + if (err)
97944 + goto out_put;
97945 +
97946 err =
97947 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
97948 if (err)
97949 @@ -1759,6 +1823,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
97950 * the protocol.
97951 */
97952
97953 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
97954 +
97955 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
97956 unsigned int, flags, struct sockaddr __user *, addr,
97957 int, addr_len)
97958 @@ -1825,7 +1891,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
97959 struct socket *sock;
97960 struct iovec iov;
97961 struct msghdr msg;
97962 - struct sockaddr_storage address;
97963 + struct sockaddr_storage address = { };
97964 int err, err2;
97965 int fput_needed;
97966
97967 @@ -2047,7 +2113,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
97968 * checking falls down on this.
97969 */
97970 if (copy_from_user(ctl_buf,
97971 - (void __user __force *)msg_sys->msg_control,
97972 + (void __force_user *)msg_sys->msg_control,
97973 ctl_len))
97974 goto out_freectl;
97975 msg_sys->msg_control = ctl_buf;
97976 @@ -2198,7 +2264,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
97977 int err, total_len, len;
97978
97979 /* kernel mode address */
97980 - struct sockaddr_storage addr;
97981 + struct sockaddr_storage addr = { };
97982
97983 /* user mode address pointers */
97984 struct sockaddr __user *uaddr;
97985 @@ -2227,7 +2293,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
97986 /* Save the user-mode address (verify_iovec will change the
97987 * kernel msghdr to use the kernel address space)
97988 */
97989 - uaddr = (__force void __user *)msg_sys->msg_name;
97990 + uaddr = (void __force_user *)msg_sys->msg_name;
97991 uaddr_len = COMPAT_NAMELEN(msg);
97992 if (MSG_CMSG_COMPAT & flags)
97993 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
97994 @@ -2985,7 +3051,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
97995 old_fs = get_fs();
97996 set_fs(KERNEL_DS);
97997 err = dev_ioctl(net, cmd,
97998 - (struct ifreq __user __force *) &kifr);
97999 + (struct ifreq __force_user *) &kifr);
98000 set_fs(old_fs);
98001
98002 return err;
98003 @@ -3094,7 +3160,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
98004
98005 old_fs = get_fs();
98006 set_fs(KERNEL_DS);
98007 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
98008 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
98009 set_fs(old_fs);
98010
98011 if (cmd == SIOCGIFMAP && !err) {
98012 @@ -3199,7 +3265,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
98013 ret |= get_user(rtdev, &(ur4->rt_dev));
98014 if (rtdev) {
98015 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
98016 - r4.rt_dev = (char __user __force *)devname;
98017 + r4.rt_dev = (char __force_user *)devname;
98018 devname[15] = 0;
98019 } else
98020 r4.rt_dev = NULL;
98021 @@ -3425,8 +3491,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
98022 int __user *uoptlen;
98023 int err;
98024
98025 - uoptval = (char __user __force *) optval;
98026 - uoptlen = (int __user __force *) optlen;
98027 + uoptval = (char __force_user *) optval;
98028 + uoptlen = (int __force_user *) optlen;
98029
98030 set_fs(KERNEL_DS);
98031 if (level == SOL_SOCKET)
98032 @@ -3446,7 +3512,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
98033 char __user *uoptval;
98034 int err;
98035
98036 - uoptval = (char __user __force *) optval;
98037 + uoptval = (char __force_user *) optval;
98038
98039 set_fs(KERNEL_DS);
98040 if (level == SOL_SOCKET)
98041 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
98042 index 09fb638..2e6a5c5 100644
98043 --- a/net/sunrpc/auth_gss/svcauth_gss.c
98044 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
98045 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
98046 uint64_t *handle)
98047 {
98048 struct rsc rsci, *rscp = NULL;
98049 - static atomic64_t ctxhctr;
98050 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
98051 long long ctxh;
98052 struct gss_api_mech *gm = NULL;
98053 time_t expiry;
98054 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
98055 status = -ENOMEM;
98056 /* the handle needs to be just a unique id,
98057 * use a static counter */
98058 - ctxh = atomic64_inc_return(&ctxhctr);
98059 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
98060
98061 /* make a copy for the caller */
98062 *handle = ctxh;
98063 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
98064 index 941d19f..c85ff07 100644
98065 --- a/net/sunrpc/clnt.c
98066 +++ b/net/sunrpc/clnt.c
98067 @@ -1319,7 +1319,9 @@ call_start(struct rpc_task *task)
98068 (RPC_IS_ASYNC(task) ? "async" : "sync"));
98069
98070 /* Increment call count */
98071 - task->tk_msg.rpc_proc->p_count++;
98072 + pax_open_kernel();
98073 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
98074 + pax_close_kernel();
98075 clnt->cl_stats->rpccnt++;
98076 task->tk_action = call_reserve;
98077 }
98078 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
98079 index ff3cc4b..7612a9e 100644
98080 --- a/net/sunrpc/sched.c
98081 +++ b/net/sunrpc/sched.c
98082 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
98083 #if defined(RPC_DEBUG) || defined(RPC_TRACEPOINTS)
98084 static void rpc_task_set_debuginfo(struct rpc_task *task)
98085 {
98086 - static atomic_t rpc_pid;
98087 + static atomic_unchecked_t rpc_pid;
98088
98089 - task->tk_pid = atomic_inc_return(&rpc_pid);
98090 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
98091 }
98092 #else
98093 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
98094 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
98095 index b974571..678ed90 100644
98096 --- a/net/sunrpc/svc.c
98097 +++ b/net/sunrpc/svc.c
98098 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
98099 svc_putnl(resv, RPC_SUCCESS);
98100
98101 /* Bump per-procedure stats counter */
98102 - procp->pc_count++;
98103 + pax_open_kernel();
98104 + (*(unsigned int *)&procp->pc_count)++;
98105 + pax_close_kernel();
98106
98107 /* Initialize storage for argp and resp */
98108 memset(rqstp->rq_argp, 0, procp->pc_argsize);
98109 diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
98110 index 621ca7b..59421dd 100644
98111 --- a/net/sunrpc/svcauth_unix.c
98112 +++ b/net/sunrpc/svcauth_unix.c
98113 @@ -414,7 +414,7 @@ struct unix_gid {
98114 struct group_info *gi;
98115 };
98116
98117 -static int unix_gid_hash(kuid_t uid)
98118 +static int __intentional_overflow(-1) unix_gid_hash(kuid_t uid)
98119 {
98120 return hash_long(from_kuid(&init_user_ns, uid), GID_HASHBITS);
98121 }
98122 @@ -470,7 +470,7 @@ static void unix_gid_request(struct cache_detail *cd,
98123 (*bpp)[-1] = '\n';
98124 }
98125
98126 -static struct unix_gid *unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
98127 +static struct unix_gid * __intentional_overflow(-1) unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
98128
98129 static int unix_gid_parse(struct cache_detail *cd,
98130 char *mesg, int mlen)
98131 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
98132 index c1b6270..05089c1 100644
98133 --- a/net/sunrpc/xprtrdma/svc_rdma.c
98134 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
98135 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
98136 static unsigned int min_max_inline = 4096;
98137 static unsigned int max_max_inline = 65536;
98138
98139 -atomic_t rdma_stat_recv;
98140 -atomic_t rdma_stat_read;
98141 -atomic_t rdma_stat_write;
98142 -atomic_t rdma_stat_sq_starve;
98143 -atomic_t rdma_stat_rq_starve;
98144 -atomic_t rdma_stat_rq_poll;
98145 -atomic_t rdma_stat_rq_prod;
98146 -atomic_t rdma_stat_sq_poll;
98147 -atomic_t rdma_stat_sq_prod;
98148 +atomic_unchecked_t rdma_stat_recv;
98149 +atomic_unchecked_t rdma_stat_read;
98150 +atomic_unchecked_t rdma_stat_write;
98151 +atomic_unchecked_t rdma_stat_sq_starve;
98152 +atomic_unchecked_t rdma_stat_rq_starve;
98153 +atomic_unchecked_t rdma_stat_rq_poll;
98154 +atomic_unchecked_t rdma_stat_rq_prod;
98155 +atomic_unchecked_t rdma_stat_sq_poll;
98156 +atomic_unchecked_t rdma_stat_sq_prod;
98157
98158 /* Temporary NFS request map and context caches */
98159 struct kmem_cache *svc_rdma_map_cachep;
98160 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
98161 len -= *ppos;
98162 if (len > *lenp)
98163 len = *lenp;
98164 - if (len && copy_to_user(buffer, str_buf, len))
98165 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
98166 return -EFAULT;
98167 *lenp = len;
98168 *ppos += len;
98169 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
98170 {
98171 .procname = "rdma_stat_read",
98172 .data = &rdma_stat_read,
98173 - .maxlen = sizeof(atomic_t),
98174 + .maxlen = sizeof(atomic_unchecked_t),
98175 .mode = 0644,
98176 .proc_handler = read_reset_stat,
98177 },
98178 {
98179 .procname = "rdma_stat_recv",
98180 .data = &rdma_stat_recv,
98181 - .maxlen = sizeof(atomic_t),
98182 + .maxlen = sizeof(atomic_unchecked_t),
98183 .mode = 0644,
98184 .proc_handler = read_reset_stat,
98185 },
98186 {
98187 .procname = "rdma_stat_write",
98188 .data = &rdma_stat_write,
98189 - .maxlen = sizeof(atomic_t),
98190 + .maxlen = sizeof(atomic_unchecked_t),
98191 .mode = 0644,
98192 .proc_handler = read_reset_stat,
98193 },
98194 {
98195 .procname = "rdma_stat_sq_starve",
98196 .data = &rdma_stat_sq_starve,
98197 - .maxlen = sizeof(atomic_t),
98198 + .maxlen = sizeof(atomic_unchecked_t),
98199 .mode = 0644,
98200 .proc_handler = read_reset_stat,
98201 },
98202 {
98203 .procname = "rdma_stat_rq_starve",
98204 .data = &rdma_stat_rq_starve,
98205 - .maxlen = sizeof(atomic_t),
98206 + .maxlen = sizeof(atomic_unchecked_t),
98207 .mode = 0644,
98208 .proc_handler = read_reset_stat,
98209 },
98210 {
98211 .procname = "rdma_stat_rq_poll",
98212 .data = &rdma_stat_rq_poll,
98213 - .maxlen = sizeof(atomic_t),
98214 + .maxlen = sizeof(atomic_unchecked_t),
98215 .mode = 0644,
98216 .proc_handler = read_reset_stat,
98217 },
98218 {
98219 .procname = "rdma_stat_rq_prod",
98220 .data = &rdma_stat_rq_prod,
98221 - .maxlen = sizeof(atomic_t),
98222 + .maxlen = sizeof(atomic_unchecked_t),
98223 .mode = 0644,
98224 .proc_handler = read_reset_stat,
98225 },
98226 {
98227 .procname = "rdma_stat_sq_poll",
98228 .data = &rdma_stat_sq_poll,
98229 - .maxlen = sizeof(atomic_t),
98230 + .maxlen = sizeof(atomic_unchecked_t),
98231 .mode = 0644,
98232 .proc_handler = read_reset_stat,
98233 },
98234 {
98235 .procname = "rdma_stat_sq_prod",
98236 .data = &rdma_stat_sq_prod,
98237 - .maxlen = sizeof(atomic_t),
98238 + .maxlen = sizeof(atomic_unchecked_t),
98239 .mode = 0644,
98240 .proc_handler = read_reset_stat,
98241 },
98242 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
98243 index 0ce7552..d074459 100644
98244 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
98245 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
98246 @@ -501,7 +501,7 @@ next_sge:
98247 svc_rdma_put_context(ctxt, 0);
98248 goto out;
98249 }
98250 - atomic_inc(&rdma_stat_read);
98251 + atomic_inc_unchecked(&rdma_stat_read);
98252
98253 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
98254 chl_map->ch[ch_no].count -= read_wr.num_sge;
98255 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
98256 dto_q);
98257 list_del_init(&ctxt->dto_q);
98258 } else {
98259 - atomic_inc(&rdma_stat_rq_starve);
98260 + atomic_inc_unchecked(&rdma_stat_rq_starve);
98261 clear_bit(XPT_DATA, &xprt->xpt_flags);
98262 ctxt = NULL;
98263 }
98264 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
98265 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
98266 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
98267 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
98268 - atomic_inc(&rdma_stat_recv);
98269 + atomic_inc_unchecked(&rdma_stat_recv);
98270
98271 /* Build up the XDR from the receive buffers. */
98272 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
98273 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
98274 index c1d124d..acfc59e 100644
98275 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
98276 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
98277 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
98278 write_wr.wr.rdma.remote_addr = to;
98279
98280 /* Post It */
98281 - atomic_inc(&rdma_stat_write);
98282 + atomic_inc_unchecked(&rdma_stat_write);
98283 if (svc_rdma_send(xprt, &write_wr))
98284 goto err;
98285 return 0;
98286 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
98287 index 62e4f9b..dd3f2d7 100644
98288 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
98289 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
98290 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
98291 return;
98292
98293 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
98294 - atomic_inc(&rdma_stat_rq_poll);
98295 + atomic_inc_unchecked(&rdma_stat_rq_poll);
98296
98297 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
98298 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
98299 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
98300 }
98301
98302 if (ctxt)
98303 - atomic_inc(&rdma_stat_rq_prod);
98304 + atomic_inc_unchecked(&rdma_stat_rq_prod);
98305
98306 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
98307 /*
98308 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
98309 return;
98310
98311 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
98312 - atomic_inc(&rdma_stat_sq_poll);
98313 + atomic_inc_unchecked(&rdma_stat_sq_poll);
98314 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
98315 if (wc.status != IB_WC_SUCCESS)
98316 /* Close the transport */
98317 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
98318 }
98319
98320 if (ctxt)
98321 - atomic_inc(&rdma_stat_sq_prod);
98322 + atomic_inc_unchecked(&rdma_stat_sq_prod);
98323 }
98324
98325 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
98326 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
98327 spin_lock_bh(&xprt->sc_lock);
98328 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
98329 spin_unlock_bh(&xprt->sc_lock);
98330 - atomic_inc(&rdma_stat_sq_starve);
98331 + atomic_inc_unchecked(&rdma_stat_sq_starve);
98332
98333 /* See if we can opportunistically reap SQ WR to make room */
98334 sq_cq_reap(xprt);
98335 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
98336 index e7000be..e3b0ba7 100644
98337 --- a/net/sysctl_net.c
98338 +++ b/net/sysctl_net.c
98339 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
98340 kgid_t root_gid = make_kgid(net->user_ns, 0);
98341
98342 /* Allow network administrator to have same access as root. */
98343 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
98344 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
98345 uid_eq(root_uid, current_euid())) {
98346 int mode = (table->mode >> 6) & 7;
98347 return (mode << 6) | (mode << 3) | mode;
98348 diff --git a/net/tipc/link.c b/net/tipc/link.c
98349 index 0cc3d90..cc42021 100644
98350 --- a/net/tipc/link.c
98351 +++ b/net/tipc/link.c
98352 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
98353 struct tipc_msg fragm_hdr;
98354 struct sk_buff *buf, *buf_chain, *prev;
98355 u32 fragm_crs, fragm_rest, hsz, sect_rest;
98356 - const unchar *sect_crs;
98357 + const unchar __user *sect_crs;
98358 int curr_sect;
98359 u32 fragm_no;
98360 int res = 0;
98361 @@ -1207,7 +1207,7 @@ again:
98362
98363 if (!sect_rest) {
98364 sect_rest = msg_sect[++curr_sect].iov_len;
98365 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
98366 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
98367 }
98368
98369 if (sect_rest < fragm_rest)
98370 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
98371 index ced60e2..54eab6c 100644
98372 --- a/net/tipc/msg.c
98373 +++ b/net/tipc/msg.c
98374 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
98375 skb_copy_to_linear_data(*buf, hdr, hsz);
98376 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
98377 skb_copy_to_linear_data_offset(*buf, pos,
98378 - msg_sect[cnt].iov_base,
98379 + (const void __force_kernel *)msg_sect[cnt].iov_base,
98380 msg_sect[cnt].iov_len);
98381 pos += msg_sect[cnt].iov_len;
98382 }
98383 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
98384 index d38bb45..4fd6ac6 100644
98385 --- a/net/tipc/subscr.c
98386 +++ b/net/tipc/subscr.c
98387 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
98388 struct kvec msg_sect;
98389 int ret;
98390
98391 - msg_sect.iov_base = (void *)&sub->evt;
98392 + msg_sect.iov_base = (void __force_user *)&sub->evt;
98393 msg_sect.iov_len = sizeof(struct tipc_event);
98394
98395 sub->evt.event = htohl(event, sub->swap);
98396 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
98397 index a427623..387c80b 100644
98398 --- a/net/unix/af_unix.c
98399 +++ b/net/unix/af_unix.c
98400 @@ -790,6 +790,12 @@ static struct sock *unix_find_other(struct net *net,
98401 err = -ECONNREFUSED;
98402 if (!S_ISSOCK(inode->i_mode))
98403 goto put_fail;
98404 +
98405 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
98406 + err = -EACCES;
98407 + goto put_fail;
98408 + }
98409 +
98410 u = unix_find_socket_byinode(inode);
98411 if (!u)
98412 goto put_fail;
98413 @@ -810,6 +816,13 @@ static struct sock *unix_find_other(struct net *net,
98414 if (u) {
98415 struct dentry *dentry;
98416 dentry = unix_sk(u)->path.dentry;
98417 +
98418 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
98419 + err = -EPERM;
98420 + sock_put(u);
98421 + goto fail;
98422 + }
98423 +
98424 if (dentry)
98425 touch_atime(&unix_sk(u)->path);
98426 } else
98427 @@ -843,12 +856,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
98428 */
98429 err = security_path_mknod(&path, dentry, mode, 0);
98430 if (!err) {
98431 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
98432 + err = -EACCES;
98433 + goto out;
98434 + }
98435 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
98436 if (!err) {
98437 res->mnt = mntget(path.mnt);
98438 res->dentry = dget(dentry);
98439 + gr_handle_create(dentry, path.mnt);
98440 }
98441 }
98442 +out:
98443 done_path_create(&path, dentry);
98444 return err;
98445 }
98446 @@ -2336,9 +2355,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
98447 seq_puts(seq, "Num RefCount Protocol Flags Type St "
98448 "Inode Path\n");
98449 else {
98450 - struct sock *s = v;
98451 + struct sock *s = v, *peer;
98452 struct unix_sock *u = unix_sk(s);
98453 unix_state_lock(s);
98454 + peer = unix_peer(s);
98455 + unix_state_unlock(s);
98456 +
98457 + unix_state_double_lock(s, peer);
98458
98459 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
98460 s,
98461 @@ -2365,8 +2388,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
98462 }
98463 for ( ; i < len; i++)
98464 seq_putc(seq, u->addr->name->sun_path[i]);
98465 - }
98466 - unix_state_unlock(s);
98467 + } else if (peer)
98468 + seq_printf(seq, " P%lu", sock_i_ino(peer));
98469 +
98470 + unix_state_double_unlock(s, peer);
98471 seq_putc(seq, '\n');
98472 }
98473
98474 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
98475 index b3d5150..ff3a837 100644
98476 --- a/net/unix/sysctl_net_unix.c
98477 +++ b/net/unix/sysctl_net_unix.c
98478 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
98479
98480 int __net_init unix_sysctl_register(struct net *net)
98481 {
98482 - struct ctl_table *table;
98483 + ctl_table_no_const *table;
98484
98485 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
98486 if (table == NULL)
98487 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
98488 index c8717c1..08539f5 100644
98489 --- a/net/wireless/wext-core.c
98490 +++ b/net/wireless/wext-core.c
98491 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
98492 */
98493
98494 /* Support for very large requests */
98495 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
98496 - (user_length > descr->max_tokens)) {
98497 + if (user_length > descr->max_tokens) {
98498 /* Allow userspace to GET more than max so
98499 * we can support any size GET requests.
98500 * There is still a limit : -ENOMEM.
98501 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
98502 }
98503 }
98504
98505 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
98506 - /*
98507 - * If this is a GET, but not NOMAX, it means that the extra
98508 - * data is not bounded by userspace, but by max_tokens. Thus
98509 - * set the length to max_tokens. This matches the extra data
98510 - * allocation.
98511 - * The driver should fill it with the number of tokens it
98512 - * provided, and it may check iwp->length rather than having
98513 - * knowledge of max_tokens. If the driver doesn't change the
98514 - * iwp->length, this ioctl just copies back max_token tokens
98515 - * filled with zeroes. Hopefully the driver isn't claiming
98516 - * them to be valid data.
98517 - */
98518 - iwp->length = descr->max_tokens;
98519 - }
98520 -
98521 err = handler(dev, info, (union iwreq_data *) iwp, extra);
98522
98523 iwp->length += essid_compat;
98524 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
98525 index 76e1873..4a12664 100644
98526 --- a/net/xfrm/xfrm_policy.c
98527 +++ b/net/xfrm/xfrm_policy.c
98528 @@ -332,7 +332,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
98529 {
98530 policy->walk.dead = 1;
98531
98532 - atomic_inc(&policy->genid);
98533 + atomic_inc_unchecked(&policy->genid);
98534
98535 if (del_timer(&policy->polq.hold_timer))
98536 xfrm_pol_put(policy);
98537 @@ -660,7 +660,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
98538 hlist_add_head(&policy->bydst, chain);
98539 xfrm_pol_hold(policy);
98540 net->xfrm.policy_count[dir]++;
98541 - atomic_inc(&flow_cache_genid);
98542 + atomic_inc_unchecked(&flow_cache_genid);
98543
98544 /* After previous checking, family can either be AF_INET or AF_INET6 */
98545 if (policy->family == AF_INET)
98546 @@ -1636,7 +1636,7 @@ free_dst:
98547 goto out;
98548 }
98549
98550 -static int inline
98551 +static inline int
98552 xfrm_dst_alloc_copy(void **target, const void *src, int size)
98553 {
98554 if (!*target) {
98555 @@ -1648,7 +1648,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
98556 return 0;
98557 }
98558
98559 -static int inline
98560 +static inline int
98561 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
98562 {
98563 #ifdef CONFIG_XFRM_SUB_POLICY
98564 @@ -1660,7 +1660,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
98565 #endif
98566 }
98567
98568 -static int inline
98569 +static inline int
98570 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
98571 {
98572 #ifdef CONFIG_XFRM_SUB_POLICY
98573 @@ -1754,7 +1754,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
98574
98575 xdst->num_pols = num_pols;
98576 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
98577 - xdst->policy_genid = atomic_read(&pols[0]->genid);
98578 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
98579
98580 return xdst;
98581 }
98582 @@ -2575,11 +2575,12 @@ void xfrm_garbage_collect(struct net *net)
98583 }
98584 EXPORT_SYMBOL(xfrm_garbage_collect);
98585
98586 -static void xfrm_garbage_collect_deferred(struct net *net)
98587 +void xfrm_garbage_collect_deferred(struct net *net)
98588 {
98589 flow_cache_flush_deferred();
98590 __xfrm_garbage_collect(net);
98591 }
98592 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
98593
98594 static void xfrm_init_pmtu(struct dst_entry *dst)
98595 {
98596 @@ -2629,7 +2630,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
98597 if (xdst->xfrm_genid != dst->xfrm->genid)
98598 return 0;
98599 if (xdst->num_pols > 0 &&
98600 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
98601 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
98602 return 0;
98603
98604 mtu = dst_mtu(dst->child);
98605 @@ -2717,8 +2718,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
98606 dst_ops->link_failure = xfrm_link_failure;
98607 if (likely(dst_ops->neigh_lookup == NULL))
98608 dst_ops->neigh_lookup = xfrm_neigh_lookup;
98609 - if (likely(afinfo->garbage_collect == NULL))
98610 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
98611 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
98612 }
98613 spin_unlock(&xfrm_policy_afinfo_lock);
98614 @@ -2772,7 +2771,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
98615 dst_ops->check = NULL;
98616 dst_ops->negative_advice = NULL;
98617 dst_ops->link_failure = NULL;
98618 - afinfo->garbage_collect = NULL;
98619 }
98620 return err;
98621 }
98622 @@ -3155,7 +3153,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
98623 sizeof(pol->xfrm_vec[i].saddr));
98624 pol->xfrm_vec[i].encap_family = mp->new_family;
98625 /* flush bundles */
98626 - atomic_inc(&pol->genid);
98627 + atomic_inc_unchecked(&pol->genid);
98628 }
98629 }
98630
98631 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
98632 index b9c3f9e..4767526 100644
98633 --- a/net/xfrm/xfrm_state.c
98634 +++ b/net/xfrm/xfrm_state.c
98635 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
98636
98637 if (unlikely(afinfo == NULL))
98638 return -EAFNOSUPPORT;
98639 - typemap = afinfo->type_map;
98640 + typemap = (const struct xfrm_type **)afinfo->type_map;
98641 spin_lock_bh(&xfrm_type_lock);
98642
98643 - if (likely(typemap[type->proto] == NULL))
98644 + if (likely(typemap[type->proto] == NULL)) {
98645 + pax_open_kernel();
98646 typemap[type->proto] = type;
98647 - else
98648 + pax_close_kernel();
98649 + } else
98650 err = -EEXIST;
98651 spin_unlock_bh(&xfrm_type_lock);
98652 xfrm_state_put_afinfo(afinfo);
98653 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
98654
98655 if (unlikely(afinfo == NULL))
98656 return -EAFNOSUPPORT;
98657 - typemap = afinfo->type_map;
98658 + typemap = (const struct xfrm_type **)afinfo->type_map;
98659 spin_lock_bh(&xfrm_type_lock);
98660
98661 if (unlikely(typemap[type->proto] != type))
98662 err = -ENOENT;
98663 - else
98664 + else {
98665 + pax_open_kernel();
98666 typemap[type->proto] = NULL;
98667 + pax_close_kernel();
98668 + }
98669 spin_unlock_bh(&xfrm_type_lock);
98670 xfrm_state_put_afinfo(afinfo);
98671 return err;
98672 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
98673 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
98674 {
98675 struct xfrm_state_afinfo *afinfo;
98676 - const struct xfrm_type **typemap;
98677 const struct xfrm_type *type;
98678 int modload_attempted = 0;
98679
98680 @@ -219,9 +223,8 @@ retry:
98681 afinfo = xfrm_state_get_afinfo(family);
98682 if (unlikely(afinfo == NULL))
98683 return NULL;
98684 - typemap = afinfo->type_map;
98685
98686 - type = typemap[proto];
98687 + type = afinfo->type_map[proto];
98688 if (unlikely(type && !try_module_get(type->owner)))
98689 type = NULL;
98690 if (!type && !modload_attempted) {
98691 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
98692 return -EAFNOSUPPORT;
98693
98694 err = -EEXIST;
98695 - modemap = afinfo->mode_map;
98696 + modemap = (struct xfrm_mode **)afinfo->mode_map;
98697 spin_lock_bh(&xfrm_mode_lock);
98698 if (modemap[mode->encap])
98699 goto out;
98700 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
98701 if (!try_module_get(afinfo->owner))
98702 goto out;
98703
98704 - mode->afinfo = afinfo;
98705 + pax_open_kernel();
98706 + *(const void **)&mode->afinfo = afinfo;
98707 modemap[mode->encap] = mode;
98708 + pax_close_kernel();
98709 err = 0;
98710
98711 out:
98712 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
98713 return -EAFNOSUPPORT;
98714
98715 err = -ENOENT;
98716 - modemap = afinfo->mode_map;
98717 + modemap = (struct xfrm_mode **)afinfo->mode_map;
98718 spin_lock_bh(&xfrm_mode_lock);
98719 if (likely(modemap[mode->encap] == mode)) {
98720 + pax_open_kernel();
98721 modemap[mode->encap] = NULL;
98722 + pax_close_kernel();
98723 module_put(mode->afinfo->owner);
98724 err = 0;
98725 }
98726 @@ -1486,10 +1493,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
98727 u32 xfrm_get_acqseq(void)
98728 {
98729 u32 res;
98730 - static atomic_t acqseq;
98731 + static atomic_unchecked_t acqseq;
98732
98733 do {
98734 - res = atomic_inc_return(&acqseq);
98735 + res = atomic_inc_return_unchecked(&acqseq);
98736 } while (!res);
98737
98738 return res;
98739 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
98740 index 05a6e3d..6716ec9 100644
98741 --- a/net/xfrm/xfrm_sysctl.c
98742 +++ b/net/xfrm/xfrm_sysctl.c
98743 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
98744
98745 int __net_init xfrm_sysctl_init(struct net *net)
98746 {
98747 - struct ctl_table *table;
98748 + ctl_table_no_const *table;
98749
98750 __xfrm_sysctl_init(net);
98751
98752 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
98753 index d5d859c..781cbcb 100644
98754 --- a/scripts/Makefile.build
98755 +++ b/scripts/Makefile.build
98756 @@ -111,7 +111,7 @@ endif
98757 endif
98758
98759 # Do not include host rules unless needed
98760 -ifneq ($(hostprogs-y)$(hostprogs-m),)
98761 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
98762 include scripts/Makefile.host
98763 endif
98764
98765 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
98766 index 686cb0d..9d653bf 100644
98767 --- a/scripts/Makefile.clean
98768 +++ b/scripts/Makefile.clean
98769 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
98770 __clean-files := $(extra-y) $(always) \
98771 $(targets) $(clean-files) \
98772 $(host-progs) \
98773 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
98774 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
98775 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
98776
98777 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
98778
98779 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
98780 index 1ac414f..38575f7 100644
98781 --- a/scripts/Makefile.host
98782 +++ b/scripts/Makefile.host
98783 @@ -31,6 +31,8 @@
98784 # Note: Shared libraries consisting of C++ files are not supported
98785
98786 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
98787 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
98788 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
98789
98790 # C code
98791 # Executables compiled from a single .c file
98792 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
98793 # Shared libaries (only .c supported)
98794 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
98795 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
98796 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
98797 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
98798 # Remove .so files from "xxx-objs"
98799 host-cobjs := $(filter-out %.so,$(host-cobjs))
98800 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
98801
98802 -#Object (.o) files used by the shared libaries
98803 +# Object (.o) files used by the shared libaries
98804 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
98805 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
98806
98807 # output directory for programs/.o files
98808 # hostprogs-y := tools/build may have been specified. Retrieve directory
98809 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
98810 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
98811 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
98812 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
98813 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
98814 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
98815 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
98816 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
98817
98818 obj-dirs += $(host-objdirs)
98819 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
98820 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
98821 $(call if_changed_dep,host-cshobjs)
98822
98823 +# Compile .c file, create position independent .o file
98824 +# host-cxxshobjs -> .o
98825 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
98826 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
98827 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
98828 + $(call if_changed_dep,host-cxxshobjs)
98829 +
98830 # Link a shared library, based on position independent .o files
98831 # *.o -> .so shared library (host-cshlib)
98832 quiet_cmd_host-cshlib = HOSTLLD -shared $@
98833 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
98834 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
98835 $(call if_changed,host-cshlib)
98836
98837 +# Link a shared library, based on position independent .o files
98838 +# *.o -> .so shared library (host-cxxshlib)
98839 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
98840 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
98841 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
98842 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
98843 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
98844 + $(call if_changed,host-cxxshlib)
98845 +
98846 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
98847 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
98848 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
98849
98850 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
98851 index 078fe1d..fbdb363 100644
98852 --- a/scripts/basic/fixdep.c
98853 +++ b/scripts/basic/fixdep.c
98854 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
98855 /*
98856 * Lookup a value in the configuration string.
98857 */
98858 -static int is_defined_config(const char *name, int len, unsigned int hash)
98859 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
98860 {
98861 struct item *aux;
98862
98863 @@ -211,10 +211,10 @@ static void clear_config(void)
98864 /*
98865 * Record the use of a CONFIG_* word.
98866 */
98867 -static void use_config(const char *m, int slen)
98868 +static void use_config(const char *m, unsigned int slen)
98869 {
98870 unsigned int hash = strhash(m, slen);
98871 - int c, i;
98872 + unsigned int c, i;
98873
98874 if (is_defined_config(m, slen, hash))
98875 return;
98876 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
98877
98878 static void parse_config_file(const char *map, size_t len)
98879 {
98880 - const int *end = (const int *) (map + len);
98881 + const unsigned int *end = (const unsigned int *) (map + len);
98882 /* start at +1, so that p can never be < map */
98883 - const int *m = (const int *) map + 1;
98884 + const unsigned int *m = (const unsigned int *) map + 1;
98885 const char *p, *q;
98886
98887 for (; m < end; m++) {
98888 @@ -435,7 +435,7 @@ static void print_deps(void)
98889 static void traps(void)
98890 {
98891 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
98892 - int *p = (int *)test;
98893 + unsigned int *p = (unsigned int *)test;
98894
98895 if (*p != INT_CONF) {
98896 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
98897 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
98898 new file mode 100644
98899 index 0000000..5e0222d
98900 --- /dev/null
98901 +++ b/scripts/gcc-plugin.sh
98902 @@ -0,0 +1,17 @@
98903 +#!/bin/bash
98904 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
98905 +#include "gcc-plugin.h"
98906 +#include "tree.h"
98907 +#include "tm.h"
98908 +#include "rtl.h"
98909 +#ifdef ENABLE_BUILD_WITH_CXX
98910 +#warning $2
98911 +#else
98912 +#warning $1
98913 +#endif
98914 +EOF`
98915 +if [ $? -eq 0 ]
98916 +then
98917 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
98918 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
98919 +fi
98920 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
98921 index 5de5660..d3deb89 100644
98922 --- a/scripts/headers_install.sh
98923 +++ b/scripts/headers_install.sh
98924 @@ -32,6 +32,7 @@ do
98925 FILE="$(basename "$i")"
98926 sed -r \
98927 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
98928 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
98929 -e 's/__attribute_const__([ \t]|$)/\1/g' \
98930 -e 's@^#include <linux/compiler.h>@@' \
98931 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
98932 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
98933 index 2dcb377..a82c500 100644
98934 --- a/scripts/link-vmlinux.sh
98935 +++ b/scripts/link-vmlinux.sh
98936 @@ -162,7 +162,7 @@ else
98937 fi;
98938
98939 # final build of init/
98940 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
98941 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
98942
98943 kallsymso=""
98944 kallsyms_vmlinux=""
98945 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
98946 index 2370863..212fbca 100644
98947 --- a/scripts/mod/file2alias.c
98948 +++ b/scripts/mod/file2alias.c
98949 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
98950 unsigned long size, unsigned long id_size,
98951 void *symval)
98952 {
98953 - int i;
98954 + unsigned int i;
98955
98956 if (size % id_size || size < id_size) {
98957 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
98958 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
98959 /* USB is special because the bcdDevice can be matched against a numeric range */
98960 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
98961 static void do_usb_entry(void *symval,
98962 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
98963 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
98964 unsigned char range_lo, unsigned char range_hi,
98965 unsigned char max, struct module *mod)
98966 {
98967 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
98968 {
98969 unsigned int devlo, devhi;
98970 unsigned char chi, clo, max;
98971 - int ndigits;
98972 + unsigned int ndigits;
98973
98974 DEF_FIELD(symval, usb_device_id, match_flags);
98975 DEF_FIELD(symval, usb_device_id, idVendor);
98976 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
98977 for (i = 0; i < count; i++) {
98978 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
98979 char acpi_id[sizeof(*id)];
98980 - int j;
98981 + unsigned int j;
98982
98983 buf_printf(&mod->dev_table_buf,
98984 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
98985 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
98986
98987 for (j = 0; j < PNP_MAX_DEVICES; j++) {
98988 const char *id = (char *)(*devs)[j].id;
98989 - int i2, j2;
98990 + unsigned int i2, j2;
98991 int dup = 0;
98992
98993 if (!id[0])
98994 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
98995 /* add an individual alias for every device entry */
98996 if (!dup) {
98997 char acpi_id[PNP_ID_LEN];
98998 - int k;
98999 + unsigned int k;
99000
99001 buf_printf(&mod->dev_table_buf,
99002 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
99003 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
99004 static int do_dmi_entry(const char *filename, void *symval,
99005 char *alias)
99006 {
99007 - int i, j;
99008 + unsigned int i, j;
99009 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
99010 sprintf(alias, "dmi*");
99011
99012 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
99013 index 8247979..815ec76 100644
99014 --- a/scripts/mod/modpost.c
99015 +++ b/scripts/mod/modpost.c
99016 @@ -931,6 +931,7 @@ enum mismatch {
99017 ANY_INIT_TO_ANY_EXIT,
99018 ANY_EXIT_TO_ANY_INIT,
99019 EXPORT_TO_INIT_EXIT,
99020 + DATA_TO_TEXT
99021 };
99022
99023 struct sectioncheck {
99024 @@ -1017,6 +1018,12 @@ const struct sectioncheck sectioncheck[] = {
99025 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
99026 .mismatch = EXPORT_TO_INIT_EXIT,
99027 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
99028 +},
99029 +/* Do not reference code from writable data */
99030 +{
99031 + .fromsec = { DATA_SECTIONS, NULL },
99032 + .tosec = { TEXT_SECTIONS, NULL },
99033 + .mismatch = DATA_TO_TEXT
99034 }
99035 };
99036
99037 @@ -1137,10 +1144,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
99038 continue;
99039 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
99040 continue;
99041 - if (sym->st_value == addr)
99042 - return sym;
99043 /* Find a symbol nearby - addr are maybe negative */
99044 d = sym->st_value - addr;
99045 + if (d == 0)
99046 + return sym;
99047 if (d < 0)
99048 d = addr - sym->st_value;
99049 if (d < distance) {
99050 @@ -1418,6 +1425,14 @@ static void report_sec_mismatch(const char *modname,
99051 tosym, prl_to, prl_to, tosym);
99052 free(prl_to);
99053 break;
99054 + case DATA_TO_TEXT:
99055 +#if 0
99056 + fprintf(stderr,
99057 + "The %s %s:%s references\n"
99058 + "the %s %s:%s%s\n",
99059 + from, fromsec, fromsym, to, tosec, tosym, to_p);
99060 +#endif
99061 + break;
99062 }
99063 fprintf(stderr, "\n");
99064 }
99065 @@ -1652,7 +1667,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
99066 static void check_sec_ref(struct module *mod, const char *modname,
99067 struct elf_info *elf)
99068 {
99069 - int i;
99070 + unsigned int i;
99071 Elf_Shdr *sechdrs = elf->sechdrs;
99072
99073 /* Walk through all sections */
99074 @@ -1771,7 +1786,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
99075 va_end(ap);
99076 }
99077
99078 -void buf_write(struct buffer *buf, const char *s, int len)
99079 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
99080 {
99081 if (buf->size - buf->pos < len) {
99082 buf->size += len + SZ;
99083 @@ -1990,7 +2005,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
99084 if (fstat(fileno(file), &st) < 0)
99085 goto close_write;
99086
99087 - if (st.st_size != b->pos)
99088 + if (st.st_size != (off_t)b->pos)
99089 goto close_write;
99090
99091 tmp = NOFAIL(malloc(b->pos));
99092 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
99093 index 51207e4..f7d603d 100644
99094 --- a/scripts/mod/modpost.h
99095 +++ b/scripts/mod/modpost.h
99096 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
99097
99098 struct buffer {
99099 char *p;
99100 - int pos;
99101 - int size;
99102 + unsigned int pos;
99103 + unsigned int size;
99104 };
99105
99106 void __attribute__((format(printf, 2, 3)))
99107 buf_printf(struct buffer *buf, const char *fmt, ...);
99108
99109 void
99110 -buf_write(struct buffer *buf, const char *s, int len);
99111 +buf_write(struct buffer *buf, const char *s, unsigned int len);
99112
99113 struct module {
99114 struct module *next;
99115 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
99116 index 9dfcd6d..099068e 100644
99117 --- a/scripts/mod/sumversion.c
99118 +++ b/scripts/mod/sumversion.c
99119 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
99120 goto out;
99121 }
99122
99123 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
99124 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
99125 warn("writing sum in %s failed: %s\n",
99126 filename, strerror(errno));
99127 goto out;
99128 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
99129 index 0865b3e..7235dd4 100644
99130 --- a/scripts/module-common.lds
99131 +++ b/scripts/module-common.lds
99132 @@ -6,6 +6,10 @@
99133 SECTIONS {
99134 /DISCARD/ : { *(.discard) }
99135
99136 + .rodata : {
99137 + *(.rodata) *(.rodata.*)
99138 + *(.data..read_only)
99139 + }
99140 __ksymtab : { *(SORT(___ksymtab+*)) }
99141 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
99142 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
99143 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
99144 index 90e521f..e9eaf8f 100644
99145 --- a/scripts/package/builddeb
99146 +++ b/scripts/package/builddeb
99147 @@ -281,6 +281,7 @@ fi
99148 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
99149 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
99150 (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
99151 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
99152 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
99153 mkdir -p "$destdir"
99154 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
99155 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
99156 index 68bb4ef..2f419e1 100644
99157 --- a/scripts/pnmtologo.c
99158 +++ b/scripts/pnmtologo.c
99159 @@ -244,14 +244,14 @@ static void write_header(void)
99160 fprintf(out, " * Linux logo %s\n", logoname);
99161 fputs(" */\n\n", out);
99162 fputs("#include <linux/linux_logo.h>\n\n", out);
99163 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
99164 + fprintf(out, "static unsigned char %s_data[] = {\n",
99165 logoname);
99166 }
99167
99168 static void write_footer(void)
99169 {
99170 fputs("\n};\n\n", out);
99171 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
99172 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
99173 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
99174 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
99175 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
99176 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
99177 fputs("\n};\n\n", out);
99178
99179 /* write logo clut */
99180 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
99181 + fprintf(out, "static unsigned char %s_clut[] = {\n",
99182 logoname);
99183 write_hex_cnt = 0;
99184 for (i = 0; i < logo_clutsize; i++) {
99185 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
99186 index f5eb43d..1814de8 100644
99187 --- a/scripts/sortextable.h
99188 +++ b/scripts/sortextable.h
99189 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
99190 const char *secstrtab;
99191 const char *strtab;
99192 char *extab_image;
99193 - int extab_index = 0;
99194 - int i;
99195 - int idx;
99196 + unsigned int extab_index = 0;
99197 + unsigned int i;
99198 + unsigned int idx;
99199
99200 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
99201 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
99202 diff --git a/security/Kconfig b/security/Kconfig
99203 index e9c6ac7..9551ea7 100644
99204 --- a/security/Kconfig
99205 +++ b/security/Kconfig
99206 @@ -4,6 +4,958 @@
99207
99208 menu "Security options"
99209
99210 +menu "Grsecurity"
99211 +
99212 + config ARCH_TRACK_EXEC_LIMIT
99213 + bool
99214 +
99215 + config PAX_KERNEXEC_PLUGIN
99216 + bool
99217 +
99218 + config PAX_PER_CPU_PGD
99219 + bool
99220 +
99221 + config TASK_SIZE_MAX_SHIFT
99222 + int
99223 + depends on X86_64
99224 + default 47 if !PAX_PER_CPU_PGD
99225 + default 42 if PAX_PER_CPU_PGD
99226 +
99227 + config PAX_ENABLE_PAE
99228 + bool
99229 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
99230 +
99231 + config PAX_USERCOPY_SLABS
99232 + bool
99233 +
99234 +config GRKERNSEC
99235 + bool "Grsecurity"
99236 + select CRYPTO
99237 + select CRYPTO_SHA256
99238 + select PROC_FS
99239 + select STOP_MACHINE
99240 + select TTY
99241 + select DEBUG_LIST
99242 + help
99243 + If you say Y here, you will be able to configure many features
99244 + that will enhance the security of your system. It is highly
99245 + recommended that you say Y here and read through the help
99246 + for each option so that you fully understand the features and
99247 + can evaluate their usefulness for your machine.
99248 +
99249 +choice
99250 + prompt "Configuration Method"
99251 + depends on GRKERNSEC
99252 + default GRKERNSEC_CONFIG_CUSTOM
99253 + help
99254 +
99255 +config GRKERNSEC_CONFIG_AUTO
99256 + bool "Automatic"
99257 + help
99258 + If you choose this configuration method, you'll be able to answer a small
99259 + number of simple questions about how you plan to use this kernel.
99260 + The settings of grsecurity and PaX will be automatically configured for
99261 + the highest commonly-used settings within the provided constraints.
99262 +
99263 + If you require additional configuration, custom changes can still be made
99264 + from the "custom configuration" menu.
99265 +
99266 +config GRKERNSEC_CONFIG_CUSTOM
99267 + bool "Custom"
99268 + help
99269 + If you choose this configuration method, you'll be able to configure all
99270 + grsecurity and PaX settings manually. Via this method, no options are
99271 + automatically enabled.
99272 +
99273 +endchoice
99274 +
99275 +choice
99276 + prompt "Usage Type"
99277 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
99278 + default GRKERNSEC_CONFIG_SERVER
99279 + help
99280 +
99281 +config GRKERNSEC_CONFIG_SERVER
99282 + bool "Server"
99283 + help
99284 + Choose this option if you plan to use this kernel on a server.
99285 +
99286 +config GRKERNSEC_CONFIG_DESKTOP
99287 + bool "Desktop"
99288 + help
99289 + Choose this option if you plan to use this kernel on a desktop.
99290 +
99291 +endchoice
99292 +
99293 +choice
99294 + prompt "Virtualization Type"
99295 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
99296 + default GRKERNSEC_CONFIG_VIRT_NONE
99297 + help
99298 +
99299 +config GRKERNSEC_CONFIG_VIRT_NONE
99300 + bool "None"
99301 + help
99302 + Choose this option if this kernel will be run on bare metal.
99303 +
99304 +config GRKERNSEC_CONFIG_VIRT_GUEST
99305 + bool "Guest"
99306 + help
99307 + Choose this option if this kernel will be run as a VM guest.
99308 +
99309 +config GRKERNSEC_CONFIG_VIRT_HOST
99310 + bool "Host"
99311 + help
99312 + Choose this option if this kernel will be run as a VM host.
99313 +
99314 +endchoice
99315 +
99316 +choice
99317 + prompt "Virtualization Hardware"
99318 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
99319 + help
99320 +
99321 +config GRKERNSEC_CONFIG_VIRT_EPT
99322 + bool "EPT/RVI Processor Support"
99323 + depends on X86
99324 + help
99325 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
99326 + hardware virtualization. This allows for additional kernel hardening protections
99327 + to operate without additional performance impact.
99328 +
99329 + To see if your Intel processor supports EPT, see:
99330 + http://ark.intel.com/Products/VirtualizationTechnology
99331 + (Most Core i3/5/7 support EPT)
99332 +
99333 + To see if your AMD processor supports RVI, see:
99334 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
99335 +
99336 +config GRKERNSEC_CONFIG_VIRT_SOFT
99337 + bool "First-gen/No Hardware Virtualization"
99338 + help
99339 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
99340 + support hardware virtualization or doesn't support the EPT/RVI extensions.
99341 +
99342 +endchoice
99343 +
99344 +choice
99345 + prompt "Virtualization Software"
99346 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
99347 + help
99348 +
99349 +config GRKERNSEC_CONFIG_VIRT_XEN
99350 + bool "Xen"
99351 + help
99352 + Choose this option if this kernel is running as a Xen guest or host.
99353 +
99354 +config GRKERNSEC_CONFIG_VIRT_VMWARE
99355 + bool "VMWare"
99356 + help
99357 + Choose this option if this kernel is running as a VMWare guest or host.
99358 +
99359 +config GRKERNSEC_CONFIG_VIRT_KVM
99360 + bool "KVM"
99361 + help
99362 + Choose this option if this kernel is running as a KVM guest or host.
99363 +
99364 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
99365 + bool "VirtualBox"
99366 + help
99367 + Choose this option if this kernel is running as a VirtualBox guest or host.
99368 +
99369 +endchoice
99370 +
99371 +choice
99372 + prompt "Required Priorities"
99373 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
99374 + default GRKERNSEC_CONFIG_PRIORITY_PERF
99375 + help
99376 +
99377 +config GRKERNSEC_CONFIG_PRIORITY_PERF
99378 + bool "Performance"
99379 + help
99380 + Choose this option if performance is of highest priority for this deployment
99381 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
99382 + clearing of structures intended for userland, and freed memory sanitizing will
99383 + be disabled.
99384 +
99385 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
99386 + bool "Security"
99387 + help
99388 + Choose this option if security is of highest priority for this deployment of
99389 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
99390 + for userland, and freed memory sanitizing will be enabled for this kernel.
99391 + In a worst-case scenario, these features can introduce a 20% performance hit
99392 + (UDEREF on x64 contributing half of this hit).
99393 +
99394 +endchoice
99395 +
99396 +menu "Default Special Groups"
99397 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
99398 +
99399 +config GRKERNSEC_PROC_GID
99400 + int "GID exempted from /proc restrictions"
99401 + default 1001
99402 + help
99403 + Setting this GID determines which group will be exempted from
99404 + grsecurity's /proc restrictions, allowing users of the specified
99405 + group to view network statistics and the existence of other users'
99406 + processes on the system. This GID may also be chosen at boot time
99407 + via "grsec_proc_gid=" on the kernel commandline.
99408 +
99409 +config GRKERNSEC_TPE_UNTRUSTED_GID
99410 + int "GID for TPE-untrusted users"
99411 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
99412 + default 1005
99413 + help
99414 + Setting this GID determines which group untrusted users should
99415 + be added to. These users will be placed under grsecurity's Trusted Path
99416 + Execution mechanism, preventing them from executing their own binaries.
99417 + The users will only be able to execute binaries in directories owned and
99418 + writable only by the root user. If the sysctl option is enabled, a sysctl
99419 + option with name "tpe_gid" is created.
99420 +
99421 +config GRKERNSEC_TPE_TRUSTED_GID
99422 + int "GID for TPE-trusted users"
99423 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
99424 + default 1005
99425 + help
99426 + Setting this GID determines what group TPE restrictions will be
99427 + *disabled* for. If the sysctl option is enabled, a sysctl option
99428 + with name "tpe_gid" is created.
99429 +
99430 +config GRKERNSEC_SYMLINKOWN_GID
99431 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
99432 + depends on GRKERNSEC_CONFIG_SERVER
99433 + default 1006
99434 + help
99435 + Setting this GID determines what group kernel-enforced
99436 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
99437 + is enabled, a sysctl option with name "symlinkown_gid" is created.
99438 +
99439 +
99440 +endmenu
99441 +
99442 +menu "Customize Configuration"
99443 +depends on GRKERNSEC
99444 +
99445 +menu "PaX"
99446 +
99447 +config PAX
99448 + bool "Enable various PaX features"
99449 + default y if GRKERNSEC_CONFIG_AUTO
99450 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
99451 + help
99452 + This allows you to enable various PaX features. PaX adds
99453 + intrusion prevention mechanisms to the kernel that reduce
99454 + the risks posed by exploitable memory corruption bugs.
99455 +
99456 +menu "PaX Control"
99457 + depends on PAX
99458 +
99459 +config PAX_SOFTMODE
99460 + bool 'Support soft mode'
99461 + help
99462 + Enabling this option will allow you to run PaX in soft mode, that
99463 + is, PaX features will not be enforced by default, only on executables
99464 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
99465 + support as they are the only way to mark executables for soft mode use.
99466 +
99467 + Soft mode can be activated by using the "pax_softmode=1" kernel command
99468 + line option on boot. Furthermore you can control various PaX features
99469 + at runtime via the entries in /proc/sys/kernel/pax.
99470 +
99471 +config PAX_EI_PAX
99472 + bool 'Use legacy ELF header marking'
99473 + default y if GRKERNSEC_CONFIG_AUTO
99474 + help
99475 + Enabling this option will allow you to control PaX features on
99476 + a per executable basis via the 'chpax' utility available at
99477 + http://pax.grsecurity.net/. The control flags will be read from
99478 + an otherwise reserved part of the ELF header. This marking has
99479 + numerous drawbacks (no support for soft-mode, toolchain does not
99480 + know about the non-standard use of the ELF header) therefore it
99481 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
99482 + support.
99483 +
99484 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
99485 + support as well, they will override the legacy EI_PAX marks.
99486 +
99487 + If you enable none of the marking options then all applications
99488 + will run with PaX enabled on them by default.
99489 +
99490 +config PAX_PT_PAX_FLAGS
99491 + bool 'Use ELF program header marking'
99492 + default y if GRKERNSEC_CONFIG_AUTO
99493 + help
99494 + Enabling this option will allow you to control PaX features on
99495 + a per executable basis via the 'paxctl' utility available at
99496 + http://pax.grsecurity.net/. The control flags will be read from
99497 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
99498 + has the benefits of supporting both soft mode and being fully
99499 + integrated into the toolchain (the binutils patch is available
99500 + from http://pax.grsecurity.net).
99501 +
99502 + Note that if you enable the legacy EI_PAX marking support as well,
99503 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
99504 +
99505 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
99506 + must make sure that the marks are the same if a binary has both marks.
99507 +
99508 + If you enable none of the marking options then all applications
99509 + will run with PaX enabled on them by default.
99510 +
99511 +config PAX_XATTR_PAX_FLAGS
99512 + bool 'Use filesystem extended attributes marking'
99513 + default y if GRKERNSEC_CONFIG_AUTO
99514 + select CIFS_XATTR if CIFS
99515 + select EXT2_FS_XATTR if EXT2_FS
99516 + select EXT3_FS_XATTR if EXT3_FS
99517 + select JFFS2_FS_XATTR if JFFS2_FS
99518 + select REISERFS_FS_XATTR if REISERFS_FS
99519 + select SQUASHFS_XATTR if SQUASHFS
99520 + select TMPFS_XATTR if TMPFS
99521 + select UBIFS_FS_XATTR if UBIFS_FS
99522 + help
99523 + Enabling this option will allow you to control PaX features on
99524 + a per executable basis via the 'setfattr' utility. The control
99525 + flags will be read from the user.pax.flags extended attribute of
99526 + the file. This marking has the benefit of supporting binary-only
99527 + applications that self-check themselves (e.g., skype) and would
99528 + not tolerate chpax/paxctl changes. The main drawback is that
99529 + extended attributes are not supported by some filesystems (e.g.,
99530 + isofs, udf, vfat) so copying files through such filesystems will
99531 + lose the extended attributes and these PaX markings.
99532 +
99533 + Note that if you enable the legacy EI_PAX marking support as well,
99534 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
99535 +
99536 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
99537 + must make sure that the marks are the same if a binary has both marks.
99538 +
99539 + If you enable none of the marking options then all applications
99540 + will run with PaX enabled on them by default.
99541 +
99542 +choice
99543 + prompt 'MAC system integration'
99544 + default PAX_HAVE_ACL_FLAGS
99545 + help
99546 + Mandatory Access Control systems have the option of controlling
99547 + PaX flags on a per executable basis, choose the method supported
99548 + by your particular system.
99549 +
99550 + - "none": if your MAC system does not interact with PaX,
99551 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
99552 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
99553 +
99554 + NOTE: this option is for developers/integrators only.
99555 +
99556 + config PAX_NO_ACL_FLAGS
99557 + bool 'none'
99558 +
99559 + config PAX_HAVE_ACL_FLAGS
99560 + bool 'direct'
99561 +
99562 + config PAX_HOOK_ACL_FLAGS
99563 + bool 'hook'
99564 +endchoice
99565 +
99566 +endmenu
99567 +
99568 +menu "Non-executable pages"
99569 + depends on PAX
99570 +
99571 +config PAX_NOEXEC
99572 + bool "Enforce non-executable pages"
99573 + default y if GRKERNSEC_CONFIG_AUTO
99574 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
99575 + help
99576 + By design some architectures do not allow for protecting memory
99577 + pages against execution or even if they do, Linux does not make
99578 + use of this feature. In practice this means that if a page is
99579 + readable (such as the stack or heap) it is also executable.
99580 +
99581 + There is a well known exploit technique that makes use of this
99582 + fact and a common programming mistake where an attacker can
99583 + introduce code of his choice somewhere in the attacked program's
99584 + memory (typically the stack or the heap) and then execute it.
99585 +
99586 + If the attacked program was running with different (typically
99587 + higher) privileges than that of the attacker, then he can elevate
99588 + his own privilege level (e.g. get a root shell, write to files for
99589 + which he does not have write access to, etc).
99590 +
99591 + Enabling this option will let you choose from various features
99592 + that prevent the injection and execution of 'foreign' code in
99593 + a program.
99594 +
99595 + This will also break programs that rely on the old behaviour and
99596 + expect that dynamically allocated memory via the malloc() family
99597 + of functions is executable (which it is not). Notable examples
99598 + are the XFree86 4.x server, the java runtime and wine.
99599 +
99600 +config PAX_PAGEEXEC
99601 + bool "Paging based non-executable pages"
99602 + default y if GRKERNSEC_CONFIG_AUTO
99603 + 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)
99604 + select ARCH_TRACK_EXEC_LIMIT if X86_32
99605 + help
99606 + This implementation is based on the paging feature of the CPU.
99607 + On i386 without hardware non-executable bit support there is a
99608 + variable but usually low performance impact, however on Intel's
99609 + P4 core based CPUs it is very high so you should not enable this
99610 + for kernels meant to be used on such CPUs.
99611 +
99612 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
99613 + with hardware non-executable bit support there is no performance
99614 + impact, on ppc the impact is negligible.
99615 +
99616 + Note that several architectures require various emulations due to
99617 + badly designed userland ABIs, this will cause a performance impact
99618 + but will disappear as soon as userland is fixed. For example, ppc
99619 + userland MUST have been built with secure-plt by a recent toolchain.
99620 +
99621 +config PAX_SEGMEXEC
99622 + bool "Segmentation based non-executable pages"
99623 + default y if GRKERNSEC_CONFIG_AUTO
99624 + depends on PAX_NOEXEC && X86_32
99625 + help
99626 + This implementation is based on the segmentation feature of the
99627 + CPU and has a very small performance impact, however applications
99628 + will be limited to a 1.5 GB address space instead of the normal
99629 + 3 GB.
99630 +
99631 +config PAX_EMUTRAMP
99632 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
99633 + default y if PARISC
99634 + help
99635 + There are some programs and libraries that for one reason or
99636 + another attempt to execute special small code snippets from
99637 + non-executable memory pages. Most notable examples are the
99638 + signal handler return code generated by the kernel itself and
99639 + the GCC trampolines.
99640 +
99641 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
99642 + such programs will no longer work under your kernel.
99643 +
99644 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
99645 + utilities to enable trampoline emulation for the affected programs
99646 + yet still have the protection provided by the non-executable pages.
99647 +
99648 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
99649 + your system will not even boot.
99650 +
99651 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
99652 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
99653 + for the affected files.
99654 +
99655 + NOTE: enabling this feature *may* open up a loophole in the
99656 + protection provided by non-executable pages that an attacker
99657 + could abuse. Therefore the best solution is to not have any
99658 + files on your system that would require this option. This can
99659 + be achieved by not using libc5 (which relies on the kernel
99660 + signal handler return code) and not using or rewriting programs
99661 + that make use of the nested function implementation of GCC.
99662 + Skilled users can just fix GCC itself so that it implements
99663 + nested function calls in a way that does not interfere with PaX.
99664 +
99665 +config PAX_EMUSIGRT
99666 + bool "Automatically emulate sigreturn trampolines"
99667 + depends on PAX_EMUTRAMP && PARISC
99668 + default y
99669 + help
99670 + Enabling this option will have the kernel automatically detect
99671 + and emulate signal return trampolines executing on the stack
99672 + that would otherwise lead to task termination.
99673 +
99674 + This solution is intended as a temporary one for users with
99675 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
99676 + Modula-3 runtime, etc) or executables linked to such, basically
99677 + everything that does not specify its own SA_RESTORER function in
99678 + normal executable memory like glibc 2.1+ does.
99679 +
99680 + On parisc you MUST enable this option, otherwise your system will
99681 + not even boot.
99682 +
99683 + NOTE: this feature cannot be disabled on a per executable basis
99684 + and since it *does* open up a loophole in the protection provided
99685 + by non-executable pages, the best solution is to not have any
99686 + files on your system that would require this option.
99687 +
99688 +config PAX_MPROTECT
99689 + bool "Restrict mprotect()"
99690 + default y if GRKERNSEC_CONFIG_AUTO
99691 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
99692 + help
99693 + Enabling this option will prevent programs from
99694 + - changing the executable status of memory pages that were
99695 + not originally created as executable,
99696 + - making read-only executable pages writable again,
99697 + - creating executable pages from anonymous memory,
99698 + - making read-only-after-relocations (RELRO) data pages writable again.
99699 +
99700 + You should say Y here to complete the protection provided by
99701 + the enforcement of non-executable pages.
99702 +
99703 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
99704 + this feature on a per file basis.
99705 +
99706 +config PAX_MPROTECT_COMPAT
99707 + bool "Use legacy/compat protection demoting (read help)"
99708 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
99709 + depends on PAX_MPROTECT
99710 + help
99711 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
99712 + by sending the proper error code to the application. For some broken
99713 + userland, this can cause problems with Python or other applications. The
99714 + current implementation however allows for applications like clamav to
99715 + detect if JIT compilation/execution is allowed and to fall back gracefully
99716 + to an interpreter-based mode if it does not. While we encourage everyone
99717 + to use the current implementation as-is and push upstream to fix broken
99718 + userland (note that the RWX logging option can assist with this), in some
99719 + environments this may not be possible. Having to disable MPROTECT
99720 + completely on certain binaries reduces the security benefit of PaX,
99721 + so this option is provided for those environments to revert to the old
99722 + behavior.
99723 +
99724 +config PAX_ELFRELOCS
99725 + bool "Allow ELF text relocations (read help)"
99726 + depends on PAX_MPROTECT
99727 + default n
99728 + help
99729 + Non-executable pages and mprotect() restrictions are effective
99730 + in preventing the introduction of new executable code into an
99731 + attacked task's address space. There remain only two venues
99732 + for this kind of attack: if the attacker can execute already
99733 + existing code in the attacked task then he can either have it
99734 + create and mmap() a file containing his code or have it mmap()
99735 + an already existing ELF library that does not have position
99736 + independent code in it and use mprotect() on it to make it
99737 + writable and copy his code there. While protecting against
99738 + the former approach is beyond PaX, the latter can be prevented
99739 + by having only PIC ELF libraries on one's system (which do not
99740 + need to relocate their code). If you are sure this is your case,
99741 + as is the case with all modern Linux distributions, then leave
99742 + this option disabled. You should say 'n' here.
99743 +
99744 +config PAX_ETEXECRELOCS
99745 + bool "Allow ELF ET_EXEC text relocations"
99746 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
99747 + select PAX_ELFRELOCS
99748 + default y
99749 + help
99750 + On some architectures there are incorrectly created applications
99751 + that require text relocations and would not work without enabling
99752 + this option. If you are an alpha, ia64 or parisc user, you should
99753 + enable this option and disable it once you have made sure that
99754 + none of your applications need it.
99755 +
99756 +config PAX_EMUPLT
99757 + bool "Automatically emulate ELF PLT"
99758 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
99759 + default y
99760 + help
99761 + Enabling this option will have the kernel automatically detect
99762 + and emulate the Procedure Linkage Table entries in ELF files.
99763 + On some architectures such entries are in writable memory, and
99764 + become non-executable leading to task termination. Therefore
99765 + it is mandatory that you enable this option on alpha, parisc,
99766 + sparc and sparc64, otherwise your system would not even boot.
99767 +
99768 + NOTE: this feature *does* open up a loophole in the protection
99769 + provided by the non-executable pages, therefore the proper
99770 + solution is to modify the toolchain to produce a PLT that does
99771 + not need to be writable.
99772 +
99773 +config PAX_DLRESOLVE
99774 + bool 'Emulate old glibc resolver stub'
99775 + depends on PAX_EMUPLT && SPARC
99776 + default n
99777 + help
99778 + This option is needed if userland has an old glibc (before 2.4)
99779 + that puts a 'save' instruction into the runtime generated resolver
99780 + stub that needs special emulation.
99781 +
99782 +config PAX_KERNEXEC
99783 + bool "Enforce non-executable kernel pages"
99784 + default y if GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_NONE || (GRKERNSEC_CONFIG_VIRT_EPT && GRKERNSEC_CONFIG_VIRT_GUEST) || (GRKERNSEC_CONFIG_VIRT_EPT && GRKERNSEC_CONFIG_VIRT_KVM))
99785 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
99786 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
99787 + select PAX_KERNEXEC_PLUGIN if X86_64
99788 + help
99789 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
99790 + that is, enabling this option will make it harder to inject
99791 + and execute 'foreign' code in kernel memory itself.
99792 +
99793 +choice
99794 + prompt "Return Address Instrumentation Method"
99795 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
99796 + depends on PAX_KERNEXEC_PLUGIN
99797 + help
99798 + Select the method used to instrument function pointer dereferences.
99799 + Note that binary modules cannot be instrumented by this approach.
99800 +
99801 + Note that the implementation requires a gcc with plugin support,
99802 + i.e., gcc 4.5 or newer. You may need to install the supporting
99803 + headers explicitly in addition to the normal gcc package.
99804 +
99805 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
99806 + bool "bts"
99807 + help
99808 + This method is compatible with binary only modules but has
99809 + a higher runtime overhead.
99810 +
99811 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
99812 + bool "or"
99813 + depends on !PARAVIRT
99814 + help
99815 + This method is incompatible with binary only modules but has
99816 + a lower runtime overhead.
99817 +endchoice
99818 +
99819 +config PAX_KERNEXEC_PLUGIN_METHOD
99820 + string
99821 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
99822 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
99823 + default ""
99824 +
99825 +config PAX_KERNEXEC_MODULE_TEXT
99826 + int "Minimum amount of memory reserved for module code"
99827 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
99828 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
99829 + depends on PAX_KERNEXEC && X86_32
99830 + help
99831 + Due to implementation details the kernel must reserve a fixed
99832 + amount of memory for runtime allocated code (such as modules)
99833 + at compile time that cannot be changed at runtime. Here you
99834 + can specify the minimum amount in MB that will be reserved.
99835 + Due to the same implementation details this size will always
99836 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
99837 + the actually available memory for runtime allocated code will
99838 + usually be more than this minimum.
99839 +
99840 + The default 4 MB should be enough for most users but if you have
99841 + an excessive number of modules (e.g., most distribution configs
99842 + compile many drivers as modules) or use huge modules such as
99843 + nvidia's kernel driver, you will need to adjust this amount.
99844 + A good rule of thumb is to look at your currently loaded kernel
99845 + modules and add up their sizes.
99846 +
99847 +endmenu
99848 +
99849 +menu "Address Space Layout Randomization"
99850 + depends on PAX
99851 +
99852 +config PAX_ASLR
99853 + bool "Address Space Layout Randomization"
99854 + default y if GRKERNSEC_CONFIG_AUTO
99855 + help
99856 + Many if not most exploit techniques rely on the knowledge of
99857 + certain addresses in the attacked program. The following options
99858 + will allow the kernel to apply a certain amount of randomization
99859 + to specific parts of the program thereby forcing an attacker to
99860 + guess them in most cases. Any failed guess will most likely crash
99861 + the attacked program which allows the kernel to detect such attempts
99862 + and react on them. PaX itself provides no reaction mechanisms,
99863 + instead it is strongly encouraged that you make use of Nergal's
99864 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
99865 + (http://www.grsecurity.net/) built-in crash detection features or
99866 + develop one yourself.
99867 +
99868 + By saying Y here you can choose to randomize the following areas:
99869 + - top of the task's kernel stack
99870 + - top of the task's userland stack
99871 + - base address for mmap() requests that do not specify one
99872 + (this includes all libraries)
99873 + - base address of the main executable
99874 +
99875 + It is strongly recommended to say Y here as address space layout
99876 + randomization has negligible impact on performance yet it provides
99877 + a very effective protection.
99878 +
99879 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
99880 + this feature on a per file basis.
99881 +
99882 +config PAX_RANDKSTACK
99883 + bool "Randomize kernel stack base"
99884 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
99885 + depends on X86_TSC && X86
99886 + help
99887 + By saying Y here the kernel will randomize every task's kernel
99888 + stack on every system call. This will not only force an attacker
99889 + to guess it but also prevent him from making use of possible
99890 + leaked information about it.
99891 +
99892 + Since the kernel stack is a rather scarce resource, randomization
99893 + may cause unexpected stack overflows, therefore you should very
99894 + carefully test your system. Note that once enabled in the kernel
99895 + configuration, this feature cannot be disabled on a per file basis.
99896 +
99897 +config PAX_RANDUSTACK
99898 + bool "Randomize user stack base"
99899 + default y if GRKERNSEC_CONFIG_AUTO
99900 + depends on PAX_ASLR
99901 + help
99902 + By saying Y here the kernel will randomize every task's userland
99903 + stack. The randomization is done in two steps where the second
99904 + one may apply a big amount of shift to the top of the stack and
99905 + cause problems for programs that want to use lots of memory (more
99906 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
99907 + For this reason the second step can be controlled by 'chpax' or
99908 + 'paxctl' on a per file basis.
99909 +
99910 +config PAX_RANDMMAP
99911 + bool "Randomize mmap() base"
99912 + default y if GRKERNSEC_CONFIG_AUTO
99913 + depends on PAX_ASLR
99914 + help
99915 + By saying Y here the kernel will use a randomized base address for
99916 + mmap() requests that do not specify one themselves. As a result
99917 + all dynamically loaded libraries will appear at random addresses
99918 + and therefore be harder to exploit by a technique where an attacker
99919 + attempts to execute library code for his purposes (e.g. spawn a
99920 + shell from an exploited program that is running at an elevated
99921 + privilege level).
99922 +
99923 + Furthermore, if a program is relinked as a dynamic ELF file, its
99924 + base address will be randomized as well, completing the full
99925 + randomization of the address space layout. Attacking such programs
99926 + becomes a guess game. You can find an example of doing this at
99927 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
99928 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
99929 +
99930 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
99931 + feature on a per file basis.
99932 +
99933 +endmenu
99934 +
99935 +menu "Miscellaneous hardening features"
99936 +
99937 +config PAX_MEMORY_SANITIZE
99938 + bool "Sanitize all freed memory"
99939 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99940 + help
99941 + By saying Y here the kernel will erase memory pages and slab objects
99942 + as soon as they are freed. This in turn reduces the lifetime of data
99943 + stored in them, making it less likely that sensitive information such
99944 + as passwords, cryptographic secrets, etc stay in memory for too long.
99945 +
99946 + This is especially useful for programs whose runtime is short, long
99947 + lived processes and the kernel itself benefit from this as long as
99948 + they ensure timely freeing of memory that may hold sensitive
99949 + information.
99950 +
99951 + A nice side effect of the sanitization of slab objects is the
99952 + reduction of possible info leaks caused by padding bytes within the
99953 + leaky structures. Use-after-free bugs for structures containing
99954 + pointers can also be detected as dereferencing the sanitized pointer
99955 + will generate an access violation.
99956 +
99957 + The tradeoff is performance impact, on a single CPU system kernel
99958 + compilation sees a 3% slowdown, other systems and workloads may vary
99959 + and you are advised to test this feature on your expected workload
99960 + before deploying it.
99961 +
99962 + To reduce the performance penalty by sanitizing pages only, albeit
99963 + limiting the effectiveness of this feature at the same time, slab
99964 + sanitization can be disabled with the kernel commandline parameter
99965 + "pax_sanitize_slab=0".
99966 +
99967 + Note that this feature does not protect data stored in live pages,
99968 + e.g., process memory swapped to disk may stay there for a long time.
99969 +
99970 +config PAX_MEMORY_STACKLEAK
99971 + bool "Sanitize kernel stack"
99972 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99973 + depends on X86
99974 + help
99975 + By saying Y here the kernel will erase the kernel stack before it
99976 + returns from a system call. This in turn reduces the information
99977 + that a kernel stack leak bug can reveal.
99978 +
99979 + Note that such a bug can still leak information that was put on
99980 + the stack by the current system call (the one eventually triggering
99981 + the bug) but traces of earlier system calls on the kernel stack
99982 + cannot leak anymore.
99983 +
99984 + The tradeoff is performance impact: on a single CPU system kernel
99985 + compilation sees a 1% slowdown, other systems and workloads may vary
99986 + and you are advised to test this feature on your expected workload
99987 + before deploying it.
99988 +
99989 + Note that the full feature requires a gcc with plugin support,
99990 + i.e., gcc 4.5 or newer. You may need to install the supporting
99991 + headers explicitly in addition to the normal gcc package. Using
99992 + older gcc versions means that functions with large enough stack
99993 + frames may leave uninitialized memory behind that may be exposed
99994 + to a later syscall leaking the stack.
99995 +
99996 +config PAX_MEMORY_STRUCTLEAK
99997 + bool "Forcibly initialize local variables copied to userland"
99998 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99999 + help
100000 + By saying Y here the kernel will zero initialize some local
100001 + variables that are going to be copied to userland. This in
100002 + turn prevents unintended information leakage from the kernel
100003 + stack should later code forget to explicitly set all parts of
100004 + the copied variable.
100005 +
100006 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
100007 + at a much smaller coverage.
100008 +
100009 + Note that the implementation requires a gcc with plugin support,
100010 + i.e., gcc 4.5 or newer. You may need to install the supporting
100011 + headers explicitly in addition to the normal gcc package.
100012 +
100013 +config PAX_MEMORY_UDEREF
100014 + bool "Prevent invalid userland pointer dereference"
100015 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
100016 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
100017 + select PAX_PER_CPU_PGD if X86_64
100018 + help
100019 + By saying Y here the kernel will be prevented from dereferencing
100020 + userland pointers in contexts where the kernel expects only kernel
100021 + pointers. This is both a useful runtime debugging feature and a
100022 + security measure that prevents exploiting a class of kernel bugs.
100023 +
100024 + The tradeoff is that some virtualization solutions may experience
100025 + a huge slowdown and therefore you should not enable this feature
100026 + for kernels meant to run in such environments. Whether a given VM
100027 + solution is affected or not is best determined by simply trying it
100028 + out, the performance impact will be obvious right on boot as this
100029 + mechanism engages from very early on. A good rule of thumb is that
100030 + VMs running on CPUs without hardware virtualization support (i.e.,
100031 + the majority of IA-32 CPUs) will likely experience the slowdown.
100032 +
100033 + On X86_64 the kernel will make use of PCID support when available
100034 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
100035 + or performance impact. Pass pax_weakuderef on the kernel command
100036 + line to choose the latter.
100037 +
100038 +config PAX_REFCOUNT
100039 + bool "Prevent various kernel object reference counter overflows"
100040 + default y if GRKERNSEC_CONFIG_AUTO
100041 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
100042 + help
100043 + By saying Y here the kernel will detect and prevent overflowing
100044 + various (but not all) kinds of object reference counters. Such
100045 + overflows can normally occur due to bugs only and are often, if
100046 + not always, exploitable.
100047 +
100048 + The tradeoff is that data structures protected by an overflowed
100049 + refcount will never be freed and therefore will leak memory. Note
100050 + that this leak also happens even without this protection but in
100051 + that case the overflow can eventually trigger the freeing of the
100052 + data structure while it is still being used elsewhere, resulting
100053 + in the exploitable situation that this feature prevents.
100054 +
100055 + Since this has a negligible performance impact, you should enable
100056 + this feature.
100057 +
100058 +config PAX_CONSTIFY_PLUGIN
100059 + bool "Automatically constify eligible structures"
100060 + default y
100061 + depends on !UML && PAX_KERNEXEC
100062 + help
100063 + By saying Y here the compiler will automatically constify a class
100064 + of types that contain only function pointers. This reduces the
100065 + kernel's attack surface and also produces a better memory layout.
100066 +
100067 + Note that the implementation requires a gcc with plugin support,
100068 + i.e., gcc 4.5 or newer. You may need to install the supporting
100069 + headers explicitly in addition to the normal gcc package.
100070 +
100071 + Note that if some code really has to modify constified variables
100072 + then the source code will have to be patched to allow it. Examples
100073 + can be found in PaX itself (the no_const attribute) and for some
100074 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
100075 +
100076 +config PAX_USERCOPY
100077 + bool "Harden heap object copies between kernel and userland"
100078 + default y if GRKERNSEC_CONFIG_AUTO
100079 + depends on ARM || IA64 || PPC || SPARC || X86
100080 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
100081 + select PAX_USERCOPY_SLABS
100082 + help
100083 + By saying Y here the kernel will enforce the size of heap objects
100084 + when they are copied in either direction between the kernel and
100085 + userland, even if only a part of the heap object is copied.
100086 +
100087 + Specifically, this checking prevents information leaking from the
100088 + kernel heap during kernel to userland copies (if the kernel heap
100089 + object is otherwise fully initialized) and prevents kernel heap
100090 + overflows during userland to kernel copies.
100091 +
100092 + Note that the current implementation provides the strictest bounds
100093 + checks for the SLUB allocator.
100094 +
100095 + Enabling this option also enables per-slab cache protection against
100096 + data in a given cache being copied into/out of via userland
100097 + accessors. Though the whitelist of regions will be reduced over
100098 + time, it notably protects important data structures like task structs.
100099 +
100100 + If frame pointers are enabled on x86, this option will also restrict
100101 + copies into and out of the kernel stack to local variables within a
100102 + single frame.
100103 +
100104 + Since this has a negligible performance impact, you should enable
100105 + this feature.
100106 +
100107 +config PAX_USERCOPY_DEBUG
100108 + bool
100109 + depends on X86 && PAX_USERCOPY
100110 + default n
100111 +
100112 +config PAX_SIZE_OVERFLOW
100113 + bool "Prevent various integer overflows in function size parameters"
100114 + default y if GRKERNSEC_CONFIG_AUTO
100115 + depends on X86
100116 + help
100117 + By saying Y here the kernel recomputes expressions of function
100118 + arguments marked by a size_overflow attribute with double integer
100119 + precision (DImode/TImode for 32/64 bit integer types).
100120 +
100121 + The recomputed argument is checked against TYPE_MAX and an event
100122 + is logged on overflow and the triggering process is killed.
100123 +
100124 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
100125 +
100126 + Note that the implementation requires a gcc with plugin support,
100127 + i.e., gcc 4.5 or newer. You may need to install the supporting
100128 + headers explicitly in addition to the normal gcc package.
100129 +
100130 +config PAX_LATENT_ENTROPY
100131 + bool "Generate some entropy during boot and runtime"
100132 + default y if GRKERNSEC_CONFIG_AUTO
100133 + help
100134 + By saying Y here the kernel will instrument some kernel code to
100135 + extract some entropy from both original and artificially created
100136 + program state. This will help especially embedded systems where
100137 + there is little 'natural' source of entropy normally. The cost
100138 + is some slowdown of the boot process and fork and irq processing.
100139 +
100140 + When pax_extra_latent_entropy is passed on the kernel command line,
100141 + entropy will be extracted from up to the first 4GB of RAM while the
100142 + runtime memory allocator is being initialized. This costs even more
100143 + slowdown of the boot process.
100144 +
100145 + Note that the implementation requires a gcc with plugin support,
100146 + i.e., gcc 4.5 or newer. You may need to install the supporting
100147 + headers explicitly in addition to the normal gcc package.
100148 +
100149 + Note that entropy extracted this way is not cryptographically
100150 + secure!
100151 +
100152 +endmenu
100153 +
100154 +endmenu
100155 +
100156 +source grsecurity/Kconfig
100157 +
100158 +endmenu
100159 +
100160 +endmenu
100161 +
100162 source security/keys/Kconfig
100163
100164 config SECURITY_DMESG_RESTRICT
100165 @@ -103,7 +1055,7 @@ config INTEL_TXT
100166 config LSM_MMAP_MIN_ADDR
100167 int "Low address space for LSM to protect from user allocation"
100168 depends on SECURITY && SECURITY_SELINUX
100169 - default 32768 if ARM
100170 + default 32768 if ALPHA || ARM || PARISC || SPARC32
100171 default 65536
100172 help
100173 This is the portion of low virtual memory which should be protected
100174 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
100175 index fb99e18..b3e0bbb 100644
100176 --- a/security/apparmor/lsm.c
100177 +++ b/security/apparmor/lsm.c
100178 @@ -615,7 +615,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
100179 return error;
100180 }
100181
100182 -static struct security_operations apparmor_ops = {
100183 +static struct security_operations apparmor_ops __read_only = {
100184 .name = "apparmor",
100185
100186 .ptrace_access_check = apparmor_ptrace_access_check,
100187 diff --git a/security/commoncap.c b/security/commoncap.c
100188 index b9d613e..f68305c 100644
100189 --- a/security/commoncap.c
100190 +++ b/security/commoncap.c
100191 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
100192 return 0;
100193 }
100194
100195 +/* returns:
100196 + 1 for suid privilege
100197 + 2 for sgid privilege
100198 + 3 for fscap privilege
100199 +*/
100200 +int is_privileged_binary(const struct dentry *dentry)
100201 +{
100202 + struct cpu_vfs_cap_data capdata;
100203 + struct inode *inode = dentry->d_inode;
100204 +
100205 + if (!inode || S_ISDIR(inode->i_mode))
100206 + return 0;
100207 +
100208 + if (inode->i_mode & S_ISUID)
100209 + return 1;
100210 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
100211 + return 2;
100212 +
100213 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
100214 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
100215 + return 3;
100216 + }
100217 +
100218 + return 0;
100219 +}
100220 +
100221 /*
100222 * Attempt to get the on-exec apply capability sets for an executable file from
100223 * its xattrs and, if present, apply them to the proposed credentials being
100224 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
100225 const struct cred *cred = current_cred();
100226 kuid_t root_uid = make_kuid(cred->user_ns, 0);
100227
100228 + if (gr_acl_enable_at_secure())
100229 + return 1;
100230 +
100231 if (!uid_eq(cred->uid, root_uid)) {
100232 if (bprm->cap_effective)
100233 return 1;
100234 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
100235 index b3dd616..4bb17f3 100644
100236 --- a/security/integrity/ima/ima.h
100237 +++ b/security/integrity/ima/ima.h
100238 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
100239 extern spinlock_t ima_queue_lock;
100240
100241 struct ima_h_table {
100242 - atomic_long_t len; /* number of stored measurements in the list */
100243 - atomic_long_t violations;
100244 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
100245 + atomic_long_unchecked_t violations;
100246 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
100247 };
100248 extern struct ima_h_table ima_htable;
100249 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
100250 index 1c03e8f1..398a941 100644
100251 --- a/security/integrity/ima/ima_api.c
100252 +++ b/security/integrity/ima/ima_api.c
100253 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
100254 int result;
100255
100256 /* can overflow, only indicator */
100257 - atomic_long_inc(&ima_htable.violations);
100258 + atomic_long_inc_unchecked(&ima_htable.violations);
100259
100260 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
100261 if (!entry) {
100262 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
100263 index 38477c9..87a60c7 100644
100264 --- a/security/integrity/ima/ima_fs.c
100265 +++ b/security/integrity/ima/ima_fs.c
100266 @@ -28,12 +28,12 @@
100267 static int valid_policy = 1;
100268 #define TMPBUFLEN 12
100269 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
100270 - loff_t *ppos, atomic_long_t *val)
100271 + loff_t *ppos, atomic_long_unchecked_t *val)
100272 {
100273 char tmpbuf[TMPBUFLEN];
100274 ssize_t len;
100275
100276 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
100277 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
100278 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
100279 }
100280
100281 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
100282 index ff63fe0..809cd96 100644
100283 --- a/security/integrity/ima/ima_queue.c
100284 +++ b/security/integrity/ima/ima_queue.c
100285 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
100286 INIT_LIST_HEAD(&qe->later);
100287 list_add_tail_rcu(&qe->later, &ima_measurements);
100288
100289 - atomic_long_inc(&ima_htable.len);
100290 + atomic_long_inc_unchecked(&ima_htable.len);
100291 key = ima_hash_key(entry->digest);
100292 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
100293 return 0;
100294 diff --git a/security/keys/compat.c b/security/keys/compat.c
100295 index d65fa7f..cbfe366 100644
100296 --- a/security/keys/compat.c
100297 +++ b/security/keys/compat.c
100298 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
100299 if (ret == 0)
100300 goto no_payload_free;
100301
100302 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
100303 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
100304 err:
100305 if (iov != iovstack)
100306 kfree(iov);
100307 diff --git a/security/keys/internal.h b/security/keys/internal.h
100308 index d4f1468..cc52f92 100644
100309 --- a/security/keys/internal.h
100310 +++ b/security/keys/internal.h
100311 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
100312 extern long keyctl_invalidate_key(key_serial_t);
100313
100314 extern long keyctl_instantiate_key_common(key_serial_t,
100315 - const struct iovec *,
100316 + const struct iovec __user *,
100317 unsigned, size_t, key_serial_t);
100318
100319 /*
100320 diff --git a/security/keys/key.c b/security/keys/key.c
100321 index 8fb7c7b..ba3610d 100644
100322 --- a/security/keys/key.c
100323 +++ b/security/keys/key.c
100324 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
100325
100326 atomic_set(&key->usage, 1);
100327 init_rwsem(&key->sem);
100328 - lockdep_set_class(&key->sem, &type->lock_class);
100329 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
100330 key->type = type;
100331 key->user = user;
100332 key->quotalen = quotalen;
100333 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
100334 struct key_type *p;
100335 int ret;
100336
100337 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
100338 + pax_open_kernel();
100339 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
100340 + pax_close_kernel();
100341
100342 ret = -EEXIST;
100343 down_write(&key_types_sem);
100344 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
100345 }
100346
100347 /* store the type */
100348 - list_add(&ktype->link, &key_types_list);
100349 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
100350
100351 pr_notice("Key type %s registered\n", ktype->name);
100352 ret = 0;
100353 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
100354 void unregister_key_type(struct key_type *ktype)
100355 {
100356 down_write(&key_types_sem);
100357 - list_del_init(&ktype->link);
100358 + pax_list_del_init((struct list_head *)&ktype->link);
100359 downgrade_write(&key_types_sem);
100360 key_gc_keytype(ktype);
100361 pr_notice("Key type %s unregistered\n", ktype->name);
100362 @@ -1084,10 +1086,10 @@ void __init key_init(void)
100363 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
100364
100365 /* add the special key types */
100366 - list_add_tail(&key_type_keyring.link, &key_types_list);
100367 - list_add_tail(&key_type_dead.link, &key_types_list);
100368 - list_add_tail(&key_type_user.link, &key_types_list);
100369 - list_add_tail(&key_type_logon.link, &key_types_list);
100370 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
100371 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
100372 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
100373 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
100374
100375 /* record the root user tracking */
100376 rb_link_node(&root_key_user.node,
100377 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
100378 index 33cfd27..842fc5a 100644
100379 --- a/security/keys/keyctl.c
100380 +++ b/security/keys/keyctl.c
100381 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
100382 /*
100383 * Copy the iovec data from userspace
100384 */
100385 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
100386 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
100387 unsigned ioc)
100388 {
100389 for (; ioc > 0; ioc--) {
100390 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
100391 * If successful, 0 will be returned.
100392 */
100393 long keyctl_instantiate_key_common(key_serial_t id,
100394 - const struct iovec *payload_iov,
100395 + const struct iovec __user *payload_iov,
100396 unsigned ioc,
100397 size_t plen,
100398 key_serial_t ringid)
100399 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
100400 [0].iov_len = plen
100401 };
100402
100403 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
100404 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
100405 }
100406
100407 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
100408 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
100409 if (ret == 0)
100410 goto no_payload_free;
100411
100412 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
100413 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
100414 err:
100415 if (iov != iovstack)
100416 kfree(iov);
100417 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
100418 index 6ece7f2..ecdb55c 100644
100419 --- a/security/keys/keyring.c
100420 +++ b/security/keys/keyring.c
100421 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
100422 ret = -EFAULT;
100423
100424 for (loop = 0; loop < klist->nkeys; loop++) {
100425 + key_serial_t serial;
100426 key = rcu_deref_link_locked(klist, loop,
100427 keyring);
100428 + serial = key->serial;
100429
100430 tmp = sizeof(key_serial_t);
100431 if (tmp > buflen)
100432 tmp = buflen;
100433
100434 - if (copy_to_user(buffer,
100435 - &key->serial,
100436 - tmp) != 0)
100437 + if (copy_to_user(buffer, &serial, tmp))
100438 goto error;
100439
100440 buflen -= tmp;
100441 diff --git a/security/min_addr.c b/security/min_addr.c
100442 index f728728..6457a0c 100644
100443 --- a/security/min_addr.c
100444 +++ b/security/min_addr.c
100445 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
100446 */
100447 static void update_mmap_min_addr(void)
100448 {
100449 +#ifndef SPARC
100450 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
100451 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
100452 mmap_min_addr = dac_mmap_min_addr;
100453 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
100454 #else
100455 mmap_min_addr = dac_mmap_min_addr;
100456 #endif
100457 +#endif
100458 }
100459
100460 /*
100461 diff --git a/security/security.c b/security/security.c
100462 index 4dc31f4..eabcf41 100644
100463 --- a/security/security.c
100464 +++ b/security/security.c
100465 @@ -33,8 +33,8 @@
100466 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
100467 CONFIG_DEFAULT_SECURITY;
100468
100469 -static struct security_operations *security_ops;
100470 -static struct security_operations default_security_ops = {
100471 +struct security_operations *security_ops __read_only;
100472 +struct security_operations default_security_ops __read_only = {
100473 .name = "default",
100474 };
100475
100476 @@ -73,11 +73,6 @@ int __init security_init(void)
100477 return 0;
100478 }
100479
100480 -void reset_security_ops(void)
100481 -{
100482 - security_ops = &default_security_ops;
100483 -}
100484 -
100485 /* Save user chosen LSM */
100486 static int __init choose_lsm(char *str)
100487 {
100488 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
100489 index fc3e662..7844c60 100644
100490 --- a/security/selinux/avc.c
100491 +++ b/security/selinux/avc.c
100492 @@ -59,7 +59,7 @@ struct avc_node {
100493 struct avc_cache {
100494 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
100495 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
100496 - atomic_t lru_hint; /* LRU hint for reclaim scan */
100497 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
100498 atomic_t active_nodes;
100499 u32 latest_notif; /* latest revocation notification */
100500 };
100501 @@ -167,7 +167,7 @@ void __init avc_init(void)
100502 spin_lock_init(&avc_cache.slots_lock[i]);
100503 }
100504 atomic_set(&avc_cache.active_nodes, 0);
100505 - atomic_set(&avc_cache.lru_hint, 0);
100506 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
100507
100508 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
100509 0, SLAB_PANIC, NULL);
100510 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
100511 spinlock_t *lock;
100512
100513 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
100514 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
100515 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
100516 head = &avc_cache.slots[hvalue];
100517 lock = &avc_cache.slots_lock[hvalue];
100518
100519 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
100520 index 392a044..5e931be 100644
100521 --- a/security/selinux/hooks.c
100522 +++ b/security/selinux/hooks.c
100523 @@ -5693,7 +5693,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
100524
100525 #endif
100526
100527 -static struct security_operations selinux_ops = {
100528 +static struct security_operations selinux_ops __read_only = {
100529 .name = "selinux",
100530
100531 .ptrace_access_check = selinux_ptrace_access_check,
100532 @@ -6045,6 +6045,9 @@ static void selinux_nf_ip_exit(void)
100533 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
100534 static int selinux_disabled;
100535
100536 +extern struct security_operations *security_ops;
100537 +extern struct security_operations default_security_ops;
100538 +
100539 int selinux_disable(void)
100540 {
100541 if (ss_initialized) {
100542 @@ -6062,7 +6065,9 @@ int selinux_disable(void)
100543 selinux_disabled = 1;
100544 selinux_enabled = 0;
100545
100546 - reset_security_ops();
100547 + pax_open_kernel();
100548 + security_ops = &default_security_ops;
100549 + pax_close_kernel();
100550
100551 /* Try to destroy the avc node cache */
100552 avc_disable();
100553 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
100554 index c1af4e1..bcb003c 100644
100555 --- a/security/selinux/include/xfrm.h
100556 +++ b/security/selinux/include/xfrm.h
100557 @@ -53,7 +53,7 @@ static inline void selinux_xfrm_notify_policyload(void)
100558 {
100559 struct net *net;
100560
100561 - atomic_inc(&flow_cache_genid);
100562 + atomic_inc_unchecked(&flow_cache_genid);
100563 rtnl_lock();
100564 for_each_net(net)
100565 rt_genid_bump_all(net);
100566 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
100567 index 8825375..97a623b 100644
100568 --- a/security/smack/smack_lsm.c
100569 +++ b/security/smack/smack_lsm.c
100570 @@ -3726,7 +3726,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
100571 return 0;
100572 }
100573
100574 -struct security_operations smack_ops = {
100575 +struct security_operations smack_ops __read_only = {
100576 .name = "smack",
100577
100578 .ptrace_access_check = smack_ptrace_access_check,
100579 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
100580 index 390c646..f2f8db3 100644
100581 --- a/security/tomoyo/mount.c
100582 +++ b/security/tomoyo/mount.c
100583 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
100584 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
100585 need_dev = -1; /* dev_name is a directory */
100586 } else {
100587 + if (!capable(CAP_SYS_ADMIN)) {
100588 + error = -EPERM;
100589 + goto out;
100590 + }
100591 fstype = get_fs_type(type);
100592 if (!fstype) {
100593 error = -ENODEV;
100594 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
100595 index f0b756e..b129202 100644
100596 --- a/security/tomoyo/tomoyo.c
100597 +++ b/security/tomoyo/tomoyo.c
100598 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
100599 * tomoyo_security_ops is a "struct security_operations" which is used for
100600 * registering TOMOYO.
100601 */
100602 -static struct security_operations tomoyo_security_ops = {
100603 +static struct security_operations tomoyo_security_ops __read_only = {
100604 .name = "tomoyo",
100605 .cred_alloc_blank = tomoyo_cred_alloc_blank,
100606 .cred_prepare = tomoyo_cred_prepare,
100607 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
100608 index 20ef514..4182bed 100644
100609 --- a/security/yama/Kconfig
100610 +++ b/security/yama/Kconfig
100611 @@ -1,6 +1,6 @@
100612 config SECURITY_YAMA
100613 bool "Yama support"
100614 - depends on SECURITY
100615 + depends on SECURITY && !GRKERNSEC
100616 select SECURITYFS
100617 select SECURITY_PATH
100618 default n
100619 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
100620 index 13c88fbc..f8c115e 100644
100621 --- a/security/yama/yama_lsm.c
100622 +++ b/security/yama/yama_lsm.c
100623 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
100624 }
100625
100626 #ifndef CONFIG_SECURITY_YAMA_STACKED
100627 -static struct security_operations yama_ops = {
100628 +static struct security_operations yama_ops __read_only = {
100629 .name = "yama",
100630
100631 .ptrace_access_check = yama_ptrace_access_check,
100632 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
100633 #endif
100634
100635 #ifdef CONFIG_SYSCTL
100636 +static int zero __read_only;
100637 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
100638 +
100639 static int yama_dointvec_minmax(struct ctl_table *table, int write,
100640 void __user *buffer, size_t *lenp, loff_t *ppos)
100641 {
100642 - int rc;
100643 + ctl_table_no_const yama_table;
100644
100645 if (write && !capable(CAP_SYS_PTRACE))
100646 return -EPERM;
100647
100648 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
100649 - if (rc)
100650 - return rc;
100651 -
100652 + yama_table = *table;
100653 /* Lock the max value if it ever gets set. */
100654 - if (write && *(int *)table->data == *(int *)table->extra2)
100655 - table->extra1 = table->extra2;
100656 -
100657 - return rc;
100658 + if (ptrace_scope == max_scope)
100659 + yama_table.extra1 = &max_scope;
100660 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
100661 }
100662
100663 -static int zero;
100664 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
100665 -
100666 struct ctl_path yama_sysctl_path[] = {
100667 { .procname = "kernel", },
100668 { .procname = "yama", },
100669 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
100670 index 4cedc69..e59d8a3 100644
100671 --- a/sound/aoa/codecs/onyx.c
100672 +++ b/sound/aoa/codecs/onyx.c
100673 @@ -54,7 +54,7 @@ struct onyx {
100674 spdif_locked:1,
100675 analog_locked:1,
100676 original_mute:2;
100677 - int open_count;
100678 + local_t open_count;
100679 struct codec_info *codec_info;
100680
100681 /* mutex serializes concurrent access to the device
100682 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
100683 struct onyx *onyx = cii->codec_data;
100684
100685 mutex_lock(&onyx->mutex);
100686 - onyx->open_count++;
100687 + local_inc(&onyx->open_count);
100688 mutex_unlock(&onyx->mutex);
100689
100690 return 0;
100691 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
100692 struct onyx *onyx = cii->codec_data;
100693
100694 mutex_lock(&onyx->mutex);
100695 - onyx->open_count--;
100696 - if (!onyx->open_count)
100697 + if (local_dec_and_test(&onyx->open_count))
100698 onyx->spdif_locked = onyx->analog_locked = 0;
100699 mutex_unlock(&onyx->mutex);
100700
100701 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
100702 index ffd2025..df062c9 100644
100703 --- a/sound/aoa/codecs/onyx.h
100704 +++ b/sound/aoa/codecs/onyx.h
100705 @@ -11,6 +11,7 @@
100706 #include <linux/i2c.h>
100707 #include <asm/pmac_low_i2c.h>
100708 #include <asm/prom.h>
100709 +#include <asm/local.h>
100710
100711 /* PCM3052 register definitions */
100712
100713 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
100714 index 4c1cc51..16040040 100644
100715 --- a/sound/core/oss/pcm_oss.c
100716 +++ b/sound/core/oss/pcm_oss.c
100717 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
100718 if (in_kernel) {
100719 mm_segment_t fs;
100720 fs = snd_enter_user();
100721 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
100722 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
100723 snd_leave_user(fs);
100724 } else {
100725 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
100726 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
100727 }
100728 if (ret != -EPIPE && ret != -ESTRPIPE)
100729 break;
100730 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
100731 if (in_kernel) {
100732 mm_segment_t fs;
100733 fs = snd_enter_user();
100734 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
100735 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
100736 snd_leave_user(fs);
100737 } else {
100738 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
100739 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
100740 }
100741 if (ret == -EPIPE) {
100742 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
100743 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
100744 struct snd_pcm_plugin_channel *channels;
100745 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
100746 if (!in_kernel) {
100747 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
100748 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
100749 return -EFAULT;
100750 buf = runtime->oss.buffer;
100751 }
100752 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
100753 }
100754 } else {
100755 tmp = snd_pcm_oss_write2(substream,
100756 - (const char __force *)buf,
100757 + (const char __force_kernel *)buf,
100758 runtime->oss.period_bytes, 0);
100759 if (tmp <= 0)
100760 goto err;
100761 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
100762 struct snd_pcm_runtime *runtime = substream->runtime;
100763 snd_pcm_sframes_t frames, frames1;
100764 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
100765 - char __user *final_dst = (char __force __user *)buf;
100766 + char __user *final_dst = (char __force_user *)buf;
100767 if (runtime->oss.plugin_first) {
100768 struct snd_pcm_plugin_channel *channels;
100769 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
100770 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
100771 xfer += tmp;
100772 runtime->oss.buffer_used -= tmp;
100773 } else {
100774 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
100775 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
100776 runtime->oss.period_bytes, 0);
100777 if (tmp <= 0)
100778 goto err;
100779 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
100780 size1);
100781 size1 /= runtime->channels; /* frames */
100782 fs = snd_enter_user();
100783 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
100784 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
100785 snd_leave_user(fs);
100786 }
100787 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
100788 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
100789 index af49721..e85058e 100644
100790 --- a/sound/core/pcm_compat.c
100791 +++ b/sound/core/pcm_compat.c
100792 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
100793 int err;
100794
100795 fs = snd_enter_user();
100796 - err = snd_pcm_delay(substream, &delay);
100797 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
100798 snd_leave_user(fs);
100799 if (err < 0)
100800 return err;
100801 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
100802 index a68d4c6..72af3cf 100644
100803 --- a/sound/core/pcm_native.c
100804 +++ b/sound/core/pcm_native.c
100805 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
100806 switch (substream->stream) {
100807 case SNDRV_PCM_STREAM_PLAYBACK:
100808 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
100809 - (void __user *)arg);
100810 + (void __force_user *)arg);
100811 break;
100812 case SNDRV_PCM_STREAM_CAPTURE:
100813 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
100814 - (void __user *)arg);
100815 + (void __force_user *)arg);
100816 break;
100817 default:
100818 result = -EINVAL;
100819 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
100820 index 040c60e..989a19a 100644
100821 --- a/sound/core/seq/seq_device.c
100822 +++ b/sound/core/seq/seq_device.c
100823 @@ -64,7 +64,7 @@ struct ops_list {
100824 int argsize; /* argument size */
100825
100826 /* operators */
100827 - struct snd_seq_dev_ops ops;
100828 + struct snd_seq_dev_ops *ops;
100829
100830 /* registered devices */
100831 struct list_head dev_list; /* list of devices */
100832 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
100833
100834 mutex_lock(&ops->reg_mutex);
100835 /* copy driver operators */
100836 - ops->ops = *entry;
100837 + ops->ops = entry;
100838 ops->driver |= DRIVER_LOADED;
100839 ops->argsize = argsize;
100840
100841 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
100842 dev->name, ops->id, ops->argsize, dev->argsize);
100843 return -EINVAL;
100844 }
100845 - if (ops->ops.init_device(dev) >= 0) {
100846 + if (ops->ops->init_device(dev) >= 0) {
100847 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
100848 ops->num_init_devices++;
100849 } else {
100850 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
100851 dev->name, ops->id, ops->argsize, dev->argsize);
100852 return -EINVAL;
100853 }
100854 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
100855 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
100856 dev->status = SNDRV_SEQ_DEVICE_FREE;
100857 dev->driver_data = NULL;
100858 ops->num_init_devices--;
100859 diff --git a/sound/core/sound.c b/sound/core/sound.c
100860 index f002bd9..c462985 100644
100861 --- a/sound/core/sound.c
100862 +++ b/sound/core/sound.c
100863 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
100864 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
100865 default: return;
100866 }
100867 - request_module(str);
100868 + request_module("%s", str);
100869 }
100870
100871 #endif /* modular kernel */
100872 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
100873 index 4e0dd22..7a1f32c 100644
100874 --- a/sound/drivers/mts64.c
100875 +++ b/sound/drivers/mts64.c
100876 @@ -29,6 +29,7 @@
100877 #include <sound/initval.h>
100878 #include <sound/rawmidi.h>
100879 #include <sound/control.h>
100880 +#include <asm/local.h>
100881
100882 #define CARD_NAME "Miditerminal 4140"
100883 #define DRIVER_NAME "MTS64"
100884 @@ -67,7 +68,7 @@ struct mts64 {
100885 struct pardevice *pardev;
100886 int pardev_claimed;
100887
100888 - int open_count;
100889 + local_t open_count;
100890 int current_midi_output_port;
100891 int current_midi_input_port;
100892 u8 mode[MTS64_NUM_INPUT_PORTS];
100893 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
100894 {
100895 struct mts64 *mts = substream->rmidi->private_data;
100896
100897 - if (mts->open_count == 0) {
100898 + if (local_read(&mts->open_count) == 0) {
100899 /* We don't need a spinlock here, because this is just called
100900 if the device has not been opened before.
100901 So there aren't any IRQs from the device */
100902 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
100903
100904 msleep(50);
100905 }
100906 - ++(mts->open_count);
100907 + local_inc(&mts->open_count);
100908
100909 return 0;
100910 }
100911 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
100912 struct mts64 *mts = substream->rmidi->private_data;
100913 unsigned long flags;
100914
100915 - --(mts->open_count);
100916 - if (mts->open_count == 0) {
100917 + if (local_dec_return(&mts->open_count) == 0) {
100918 /* We need the spinlock_irqsave here because we can still
100919 have IRQs at this point */
100920 spin_lock_irqsave(&mts->lock, flags);
100921 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
100922
100923 msleep(500);
100924
100925 - } else if (mts->open_count < 0)
100926 - mts->open_count = 0;
100927 + } else if (local_read(&mts->open_count) < 0)
100928 + local_set(&mts->open_count, 0);
100929
100930 return 0;
100931 }
100932 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
100933 index b953fb4..1999c01 100644
100934 --- a/sound/drivers/opl4/opl4_lib.c
100935 +++ b/sound/drivers/opl4/opl4_lib.c
100936 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
100937 MODULE_DESCRIPTION("OPL4 driver");
100938 MODULE_LICENSE("GPL");
100939
100940 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
100941 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
100942 {
100943 int timeout = 10;
100944 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
100945 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
100946 index 991018d..8984740 100644
100947 --- a/sound/drivers/portman2x4.c
100948 +++ b/sound/drivers/portman2x4.c
100949 @@ -48,6 +48,7 @@
100950 #include <sound/initval.h>
100951 #include <sound/rawmidi.h>
100952 #include <sound/control.h>
100953 +#include <asm/local.h>
100954
100955 #define CARD_NAME "Portman 2x4"
100956 #define DRIVER_NAME "portman"
100957 @@ -85,7 +86,7 @@ struct portman {
100958 struct pardevice *pardev;
100959 int pardev_claimed;
100960
100961 - int open_count;
100962 + local_t open_count;
100963 int mode[PORTMAN_NUM_INPUT_PORTS];
100964 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
100965 };
100966 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
100967 index ea995af..f1bfa37 100644
100968 --- a/sound/firewire/amdtp.c
100969 +++ b/sound/firewire/amdtp.c
100970 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
100971 ptr = s->pcm_buffer_pointer + data_blocks;
100972 if (ptr >= pcm->runtime->buffer_size)
100973 ptr -= pcm->runtime->buffer_size;
100974 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
100975 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
100976
100977 s->pcm_period_pointer += data_blocks;
100978 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
100979 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
100980 */
100981 void amdtp_out_stream_update(struct amdtp_out_stream *s)
100982 {
100983 - ACCESS_ONCE(s->source_node_id_field) =
100984 + ACCESS_ONCE_RW(s->source_node_id_field) =
100985 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
100986 }
100987 EXPORT_SYMBOL(amdtp_out_stream_update);
100988 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
100989 index f6103d6..4843fbf 100644
100990 --- a/sound/firewire/amdtp.h
100991 +++ b/sound/firewire/amdtp.h
100992 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
100993 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
100994 struct snd_pcm_substream *pcm)
100995 {
100996 - ACCESS_ONCE(s->pcm) = pcm;
100997 + ACCESS_ONCE_RW(s->pcm) = pcm;
100998 }
100999
101000 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
101001 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
101002 index 58a5afe..af5bd64 100644
101003 --- a/sound/firewire/isight.c
101004 +++ b/sound/firewire/isight.c
101005 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
101006 ptr += count;
101007 if (ptr >= runtime->buffer_size)
101008 ptr -= runtime->buffer_size;
101009 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
101010 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
101011
101012 isight->period_counter += count;
101013 if (isight->period_counter >= runtime->period_size) {
101014 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
101015 if (err < 0)
101016 return err;
101017
101018 - ACCESS_ONCE(isight->pcm_active) = true;
101019 + ACCESS_ONCE_RW(isight->pcm_active) = true;
101020
101021 return 0;
101022 }
101023 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
101024 {
101025 struct isight *isight = substream->private_data;
101026
101027 - ACCESS_ONCE(isight->pcm_active) = false;
101028 + ACCESS_ONCE_RW(isight->pcm_active) = false;
101029
101030 mutex_lock(&isight->mutex);
101031 isight_stop_streaming(isight);
101032 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
101033
101034 switch (cmd) {
101035 case SNDRV_PCM_TRIGGER_START:
101036 - ACCESS_ONCE(isight->pcm_running) = true;
101037 + ACCESS_ONCE_RW(isight->pcm_running) = true;
101038 break;
101039 case SNDRV_PCM_TRIGGER_STOP:
101040 - ACCESS_ONCE(isight->pcm_running) = false;
101041 + ACCESS_ONCE_RW(isight->pcm_running) = false;
101042 break;
101043 default:
101044 return -EINVAL;
101045 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
101046 index 505fc81..62e569e 100644
101047 --- a/sound/firewire/scs1x.c
101048 +++ b/sound/firewire/scs1x.c
101049 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
101050 {
101051 struct scs *scs = stream->rmidi->private_data;
101052
101053 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
101054 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
101055 if (up) {
101056 scs->output_idle = false;
101057 tasklet_schedule(&scs->tasklet);
101058 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
101059 {
101060 struct scs *scs = stream->rmidi->private_data;
101061
101062 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
101063 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
101064 }
101065
101066 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
101067 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
101068
101069 snd_card_disconnect(scs->card);
101070
101071 - ACCESS_ONCE(scs->output) = NULL;
101072 - ACCESS_ONCE(scs->input) = NULL;
101073 + ACCESS_ONCE_RW(scs->output) = NULL;
101074 + ACCESS_ONCE_RW(scs->input) = NULL;
101075
101076 wait_event(scs->idle_wait, scs->output_idle);
101077
101078 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
101079 index 048439a..3be9f6f 100644
101080 --- a/sound/oss/sb_audio.c
101081 +++ b/sound/oss/sb_audio.c
101082 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
101083 buf16 = (signed short *)(localbuf + localoffs);
101084 while (c)
101085 {
101086 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
101087 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
101088 if (copy_from_user(lbuf8,
101089 userbuf+useroffs + p,
101090 locallen))
101091 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
101092 index 7d8803a..559f8d0 100644
101093 --- a/sound/oss/swarm_cs4297a.c
101094 +++ b/sound/oss/swarm_cs4297a.c
101095 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
101096 {
101097 struct cs4297a_state *s;
101098 u32 pwr, id;
101099 - mm_segment_t fs;
101100 int rval;
101101 #ifndef CONFIG_BCM_CS4297A_CSWARM
101102 u64 cfg;
101103 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
101104 if (!rval) {
101105 char *sb1250_duart_present;
101106
101107 +#if 0
101108 + mm_segment_t fs;
101109 fs = get_fs();
101110 set_fs(KERNEL_DS);
101111 -#if 0
101112 val = SOUND_MASK_LINE;
101113 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
101114 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
101115 val = initvol[i].vol;
101116 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
101117 }
101118 + set_fs(fs);
101119 // cs4297a_write_ac97(s, 0x18, 0x0808);
101120 #else
101121 // cs4297a_write_ac97(s, 0x5e, 0x180);
101122 cs4297a_write_ac97(s, 0x02, 0x0808);
101123 cs4297a_write_ac97(s, 0x18, 0x0808);
101124 #endif
101125 - set_fs(fs);
101126
101127 list_add(&s->list, &cs4297a_devs);
101128
101129 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
101130 index e938a68..2a728ad 100644
101131 --- a/sound/pci/hda/hda_codec.c
101132 +++ b/sound/pci/hda/hda_codec.c
101133 @@ -976,14 +976,10 @@ find_codec_preset(struct hda_codec *codec)
101134 mutex_unlock(&preset_mutex);
101135
101136 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
101137 - char name[32];
101138 if (!mod_requested)
101139 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
101140 - codec->vendor_id);
101141 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
101142 else
101143 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
101144 - (codec->vendor_id >> 16) & 0xffff);
101145 - request_module(name);
101146 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
101147 mod_requested++;
101148 goto again;
101149 }
101150 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
101151 index 4631a23..001ae57 100644
101152 --- a/sound/pci/ymfpci/ymfpci.h
101153 +++ b/sound/pci/ymfpci/ymfpci.h
101154 @@ -358,7 +358,7 @@ struct snd_ymfpci {
101155 spinlock_t reg_lock;
101156 spinlock_t voice_lock;
101157 wait_queue_head_t interrupt_sleep;
101158 - atomic_t interrupt_sleep_count;
101159 + atomic_unchecked_t interrupt_sleep_count;
101160 struct snd_info_entry *proc_entry;
101161 const struct firmware *dsp_microcode;
101162 const struct firmware *controller_microcode;
101163 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
101164 index d591c15..8cb8f94 100644
101165 --- a/sound/pci/ymfpci/ymfpci_main.c
101166 +++ b/sound/pci/ymfpci/ymfpci_main.c
101167 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
101168 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
101169 break;
101170 }
101171 - if (atomic_read(&chip->interrupt_sleep_count)) {
101172 - atomic_set(&chip->interrupt_sleep_count, 0);
101173 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
101174 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
101175 wake_up(&chip->interrupt_sleep);
101176 }
101177 __end:
101178 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
101179 continue;
101180 init_waitqueue_entry(&wait, current);
101181 add_wait_queue(&chip->interrupt_sleep, &wait);
101182 - atomic_inc(&chip->interrupt_sleep_count);
101183 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
101184 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
101185 remove_wait_queue(&chip->interrupt_sleep, &wait);
101186 }
101187 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
101188 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
101189 spin_unlock(&chip->reg_lock);
101190
101191 - if (atomic_read(&chip->interrupt_sleep_count)) {
101192 - atomic_set(&chip->interrupt_sleep_count, 0);
101193 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
101194 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
101195 wake_up(&chip->interrupt_sleep);
101196 }
101197 }
101198 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
101199 spin_lock_init(&chip->reg_lock);
101200 spin_lock_init(&chip->voice_lock);
101201 init_waitqueue_head(&chip->interrupt_sleep);
101202 - atomic_set(&chip->interrupt_sleep_count, 0);
101203 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
101204 chip->card = card;
101205 chip->pci = pci;
101206 chip->irq = -1;
101207 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
101208 index 6b81d0c..031c056 100644
101209 --- a/sound/soc/fsl/fsl_ssi.c
101210 +++ b/sound/soc/fsl/fsl_ssi.c
101211 @@ -864,7 +864,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
101212 {
101213 struct fsl_ssi_private *ssi_private;
101214 int ret = 0;
101215 - struct device_attribute *dev_attr = NULL;
101216 + device_attribute_no_const *dev_attr = NULL;
101217 struct device_node *np = pdev->dev.of_node;
101218 const char *p, *sprop;
101219 const uint32_t *iprop;
101220 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
101221 index 1a38be0..66809d1 100644
101222 --- a/sound/soc/soc-core.c
101223 +++ b/sound/soc/soc-core.c
101224 @@ -2248,8 +2248,10 @@ int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
101225 if (ret)
101226 return ret;
101227
101228 - ops->warm_reset = snd_soc_ac97_warm_reset;
101229 - ops->reset = snd_soc_ac97_reset;
101230 + pax_open_kernel();
101231 + *(void **)&ops->warm_reset = snd_soc_ac97_warm_reset;
101232 + *(void **)&ops->reset = snd_soc_ac97_reset;
101233 + pax_close_kernel();
101234
101235 snd_ac97_rst_cfg = cfg;
101236 return 0;
101237 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
101238 new file mode 100644
101239 index 0000000..50f2f2f
101240 --- /dev/null
101241 +++ b/tools/gcc/.gitignore
101242 @@ -0,0 +1 @@
101243 +size_overflow_hash.h
101244 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
101245 new file mode 100644
101246 index 0000000..144dbee
101247 --- /dev/null
101248 +++ b/tools/gcc/Makefile
101249 @@ -0,0 +1,45 @@
101250 +#CC := gcc
101251 +#PLUGIN_SOURCE_FILES := pax_plugin.c
101252 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
101253 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
101254 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
101255 +
101256 +ifeq ($(PLUGINCC),$(HOSTCC))
101257 +HOSTLIBS := hostlibs
101258 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
101259 +else
101260 +HOSTLIBS := hostcxxlibs
101261 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
101262 +endif
101263 +
101264 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
101265 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
101266 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
101267 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
101268 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
101269 +$(HOSTLIBS)-y += colorize_plugin.so
101270 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
101271 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
101272 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
101273 +
101274 +always := $($(HOSTLIBS)-y)
101275 +
101276 +constify_plugin-objs := constify_plugin.o
101277 +stackleak_plugin-objs := stackleak_plugin.o
101278 +kallocstat_plugin-objs := kallocstat_plugin.o
101279 +kernexec_plugin-objs := kernexec_plugin.o
101280 +checker_plugin-objs := checker_plugin.o
101281 +colorize_plugin-objs := colorize_plugin.o
101282 +size_overflow_plugin-objs := size_overflow_plugin.o
101283 +latent_entropy_plugin-objs := latent_entropy_plugin.o
101284 +structleak_plugin-objs := structleak_plugin.o
101285 +
101286 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
101287 +
101288 +quiet_cmd_build_size_overflow_hash = GENHASH $@
101289 + cmd_build_size_overflow_hash = \
101290 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
101291 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
101292 + $(call if_changed,build_size_overflow_hash)
101293 +
101294 +targets += size_overflow_hash.h
101295 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
101296 new file mode 100644
101297 index 0000000..22f03c0
101298 --- /dev/null
101299 +++ b/tools/gcc/checker_plugin.c
101300 @@ -0,0 +1,172 @@
101301 +/*
101302 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
101303 + * Licensed under the GPL v2
101304 + *
101305 + * Note: the choice of the license means that the compilation process is
101306 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101307 + * but for the kernel it doesn't matter since it doesn't link against
101308 + * any of the gcc libraries
101309 + *
101310 + * gcc plugin to implement various sparse (source code checker) features
101311 + *
101312 + * TODO:
101313 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
101314 + *
101315 + * BUGS:
101316 + * - none known
101317 + */
101318 +#include "gcc-plugin.h"
101319 +#include "config.h"
101320 +#include "system.h"
101321 +#include "coretypes.h"
101322 +#include "tree.h"
101323 +#include "tree-pass.h"
101324 +#include "flags.h"
101325 +#include "intl.h"
101326 +#include "toplev.h"
101327 +#include "plugin.h"
101328 +//#include "expr.h" where are you...
101329 +#include "diagnostic.h"
101330 +#include "plugin-version.h"
101331 +#include "tm.h"
101332 +#include "function.h"
101333 +#include "basic-block.h"
101334 +#include "gimple.h"
101335 +#include "rtl.h"
101336 +#include "emit-rtl.h"
101337 +#include "tree-flow.h"
101338 +#include "target.h"
101339 +
101340 +extern void c_register_addr_space (const char *str, addr_space_t as);
101341 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
101342 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
101343 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
101344 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
101345 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
101346 +
101347 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101348 +extern rtx emit_move_insn(rtx x, rtx y);
101349 +
101350 +int plugin_is_GPL_compatible;
101351 +
101352 +static struct plugin_info checker_plugin_info = {
101353 + .version = "201111150100",
101354 + .help = NULL,
101355 +};
101356 +
101357 +#define ADDR_SPACE_KERNEL 0
101358 +#define ADDR_SPACE_FORCE_KERNEL 1
101359 +#define ADDR_SPACE_USER 2
101360 +#define ADDR_SPACE_FORCE_USER 3
101361 +#define ADDR_SPACE_IOMEM 0
101362 +#define ADDR_SPACE_FORCE_IOMEM 0
101363 +#define ADDR_SPACE_PERCPU 0
101364 +#define ADDR_SPACE_FORCE_PERCPU 0
101365 +#define ADDR_SPACE_RCU 0
101366 +#define ADDR_SPACE_FORCE_RCU 0
101367 +
101368 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
101369 +{
101370 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
101371 +}
101372 +
101373 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
101374 +{
101375 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
101376 +}
101377 +
101378 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
101379 +{
101380 + return default_addr_space_valid_pointer_mode(mode, as);
101381 +}
101382 +
101383 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
101384 +{
101385 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
101386 +}
101387 +
101388 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
101389 +{
101390 + return default_addr_space_legitimize_address(x, oldx, mode, as);
101391 +}
101392 +
101393 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
101394 +{
101395 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
101396 + return true;
101397 +
101398 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
101399 + return true;
101400 +
101401 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
101402 + return true;
101403 +
101404 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
101405 + return true;
101406 +
101407 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
101408 + return true;
101409 +
101410 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
101411 + return true;
101412 +
101413 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
101414 + return true;
101415 +
101416 + return subset == superset;
101417 +}
101418 +
101419 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
101420 +{
101421 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
101422 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
101423 +
101424 + return op;
101425 +}
101426 +
101427 +static void register_checker_address_spaces(void *event_data, void *data)
101428 +{
101429 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
101430 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
101431 + c_register_addr_space("__user", ADDR_SPACE_USER);
101432 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
101433 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
101434 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
101435 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
101436 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
101437 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
101438 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
101439 +
101440 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
101441 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
101442 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
101443 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
101444 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
101445 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
101446 + targetm.addr_space.convert = checker_addr_space_convert;
101447 +}
101448 +
101449 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101450 +{
101451 + const char * const plugin_name = plugin_info->base_name;
101452 + const int argc = plugin_info->argc;
101453 + const struct plugin_argument * const argv = plugin_info->argv;
101454 + int i;
101455 +
101456 + if (!plugin_default_version_check(version, &gcc_version)) {
101457 + error(G_("incompatible gcc/plugin versions"));
101458 + return 1;
101459 + }
101460 +
101461 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
101462 +
101463 + for (i = 0; i < argc; ++i)
101464 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101465 +
101466 + if (TARGET_64BIT == 0)
101467 + return 0;
101468 +
101469 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
101470 +
101471 + return 0;
101472 +}
101473 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
101474 new file mode 100644
101475 index 0000000..414fe5e
101476 --- /dev/null
101477 +++ b/tools/gcc/colorize_plugin.c
101478 @@ -0,0 +1,151 @@
101479 +/*
101480 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
101481 + * Licensed under the GPL v2
101482 + *
101483 + * Note: the choice of the license means that the compilation process is
101484 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101485 + * but for the kernel it doesn't matter since it doesn't link against
101486 + * any of the gcc libraries
101487 + *
101488 + * gcc plugin to colorize diagnostic output
101489 + *
101490 + */
101491 +
101492 +#include "gcc-plugin.h"
101493 +#include "config.h"
101494 +#include "system.h"
101495 +#include "coretypes.h"
101496 +#include "tree.h"
101497 +#include "tree-pass.h"
101498 +#include "flags.h"
101499 +#include "intl.h"
101500 +#include "toplev.h"
101501 +#include "plugin.h"
101502 +#include "diagnostic.h"
101503 +#include "plugin-version.h"
101504 +#include "tm.h"
101505 +
101506 +int plugin_is_GPL_compatible;
101507 +
101508 +static struct plugin_info colorize_plugin_info = {
101509 + .version = "201302112000",
101510 + .help = NULL,
101511 +};
101512 +
101513 +#define GREEN "\033[32m\033[2m"
101514 +#define LIGHTGREEN "\033[32m\033[1m"
101515 +#define YELLOW "\033[33m\033[2m"
101516 +#define LIGHTYELLOW "\033[33m\033[1m"
101517 +#define RED "\033[31m\033[2m"
101518 +#define LIGHTRED "\033[31m\033[1m"
101519 +#define BLUE "\033[34m\033[2m"
101520 +#define LIGHTBLUE "\033[34m\033[1m"
101521 +#define BRIGHT "\033[m\033[1m"
101522 +#define NORMAL "\033[m"
101523 +
101524 +static diagnostic_starter_fn old_starter;
101525 +static diagnostic_finalizer_fn old_finalizer;
101526 +
101527 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
101528 +{
101529 + const char *color;
101530 + char *newprefix;
101531 +
101532 + switch (diagnostic->kind) {
101533 + case DK_NOTE:
101534 + color = LIGHTBLUE;
101535 + break;
101536 +
101537 + case DK_PEDWARN:
101538 + case DK_WARNING:
101539 + color = LIGHTYELLOW;
101540 + break;
101541 +
101542 + case DK_ERROR:
101543 + case DK_FATAL:
101544 + case DK_ICE:
101545 + case DK_PERMERROR:
101546 + case DK_SORRY:
101547 + color = LIGHTRED;
101548 + break;
101549 +
101550 + default:
101551 + color = NORMAL;
101552 + }
101553 +
101554 + old_starter(context, diagnostic);
101555 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
101556 + return;
101557 + pp_destroy_prefix(context->printer);
101558 + pp_set_prefix(context->printer, newprefix);
101559 +}
101560 +
101561 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
101562 +{
101563 + old_finalizer(context, diagnostic);
101564 +}
101565 +
101566 +static void colorize_arm(void)
101567 +{
101568 + old_starter = diagnostic_starter(global_dc);
101569 + old_finalizer = diagnostic_finalizer(global_dc);
101570 +
101571 + diagnostic_starter(global_dc) = start_colorize;
101572 + diagnostic_finalizer(global_dc) = finalize_colorize;
101573 +}
101574 +
101575 +static unsigned int execute_colorize_rearm(void)
101576 +{
101577 + if (diagnostic_starter(global_dc) == start_colorize)
101578 + return 0;
101579 +
101580 + colorize_arm();
101581 + return 0;
101582 +}
101583 +
101584 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
101585 + .pass = {
101586 + .type = SIMPLE_IPA_PASS,
101587 + .name = "colorize_rearm",
101588 +#if BUILDING_GCC_VERSION >= 4008
101589 + .optinfo_flags = OPTGROUP_NONE,
101590 +#endif
101591 + .gate = NULL,
101592 + .execute = execute_colorize_rearm,
101593 + .sub = NULL,
101594 + .next = NULL,
101595 + .static_pass_number = 0,
101596 + .tv_id = TV_NONE,
101597 + .properties_required = 0,
101598 + .properties_provided = 0,
101599 + .properties_destroyed = 0,
101600 + .todo_flags_start = 0,
101601 + .todo_flags_finish = 0
101602 + }
101603 +};
101604 +
101605 +static void colorize_start_unit(void *gcc_data, void *user_data)
101606 +{
101607 + colorize_arm();
101608 +}
101609 +
101610 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101611 +{
101612 + const char * const plugin_name = plugin_info->base_name;
101613 + struct register_pass_info colorize_rearm_pass_info = {
101614 + .pass = &pass_ipa_colorize_rearm.pass,
101615 + .reference_pass_name = "*free_lang_data",
101616 + .ref_pass_instance_number = 1,
101617 + .pos_op = PASS_POS_INSERT_AFTER
101618 + };
101619 +
101620 + if (!plugin_default_version_check(version, &gcc_version)) {
101621 + error(G_("incompatible gcc/plugin versions"));
101622 + return 1;
101623 + }
101624 +
101625 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
101626 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
101627 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
101628 + return 0;
101629 +}
101630 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
101631 new file mode 100644
101632 index 0000000..3e46b2f
101633 --- /dev/null
101634 +++ b/tools/gcc/constify_plugin.c
101635 @@ -0,0 +1,559 @@
101636 +/*
101637 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
101638 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
101639 + * Licensed under the GPL v2, or (at your option) v3
101640 + *
101641 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
101642 + *
101643 + * Homepage:
101644 + * http://www.grsecurity.net/~ephox/const_plugin/
101645 + *
101646 + * Usage:
101647 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
101648 + * $ gcc -fplugin=constify_plugin.so test.c -O2
101649 + */
101650 +
101651 +#include "gcc-plugin.h"
101652 +#include "config.h"
101653 +#include "system.h"
101654 +#include "coretypes.h"
101655 +#include "tree.h"
101656 +#include "tree-pass.h"
101657 +#include "flags.h"
101658 +#include "intl.h"
101659 +#include "toplev.h"
101660 +#include "plugin.h"
101661 +#include "diagnostic.h"
101662 +#include "plugin-version.h"
101663 +#include "tm.h"
101664 +#include "function.h"
101665 +#include "basic-block.h"
101666 +#include "gimple.h"
101667 +#include "rtl.h"
101668 +#include "emit-rtl.h"
101669 +#include "tree-flow.h"
101670 +#include "target.h"
101671 +#include "langhooks.h"
101672 +
101673 +// should come from c-tree.h if only it were installed for gcc 4.5...
101674 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
101675 +
101676 +// unused type flag in all versions 4.5-4.8
101677 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
101678 +
101679 +int plugin_is_GPL_compatible;
101680 +
101681 +static struct plugin_info const_plugin_info = {
101682 + .version = "201401121315",
101683 + .help = "no-constify\tturn off constification\n",
101684 +};
101685 +
101686 +typedef struct {
101687 + bool has_fptr_field;
101688 + bool has_writable_field;
101689 + bool has_do_const_field;
101690 + bool has_no_const_field;
101691 +} constify_info;
101692 +
101693 +static const_tree get_field_type(const_tree field)
101694 +{
101695 + return strip_array_types(TREE_TYPE(field));
101696 +}
101697 +
101698 +static bool is_fptr(const_tree field)
101699 +{
101700 + const_tree ptr = get_field_type(field);
101701 +
101702 + if (TREE_CODE(ptr) != POINTER_TYPE)
101703 + return false;
101704 +
101705 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
101706 +}
101707 +
101708 +/*
101709 + * determine whether the given structure type meets the requirements for automatic constification,
101710 + * including the constification attributes on nested structure types
101711 + */
101712 +static void constifiable(const_tree node, constify_info *cinfo)
101713 +{
101714 + const_tree field;
101715 +
101716 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
101717 +
101718 + // e.g., pointer to structure fields while still constructing the structure type
101719 + if (TYPE_FIELDS(node) == NULL_TREE)
101720 + return;
101721 +
101722 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
101723 + const_tree type = get_field_type(field);
101724 + enum tree_code code = TREE_CODE(type);
101725 +
101726 + if (node == type)
101727 + continue;
101728 +
101729 + if (is_fptr(field))
101730 + cinfo->has_fptr_field = true;
101731 + else if (!TREE_READONLY(field))
101732 + cinfo->has_writable_field = true;
101733 +
101734 + if (code == RECORD_TYPE || code == UNION_TYPE) {
101735 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101736 + cinfo->has_do_const_field = true;
101737 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
101738 + cinfo->has_no_const_field = true;
101739 + else
101740 + constifiable(type, cinfo);
101741 + }
101742 + }
101743 +}
101744 +
101745 +static bool constified(const_tree node)
101746 +{
101747 + constify_info cinfo = {
101748 + .has_fptr_field = false,
101749 + .has_writable_field = false,
101750 + .has_do_const_field = false,
101751 + .has_no_const_field = false
101752 + };
101753 +
101754 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
101755 +
101756 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
101757 + gcc_assert(!TYPE_READONLY(node));
101758 + return false;
101759 + }
101760 +
101761 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
101762 + gcc_assert(TYPE_READONLY(node));
101763 + return true;
101764 + }
101765 +
101766 + constifiable(node, &cinfo);
101767 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
101768 + return false;
101769 +
101770 + return TYPE_READONLY(node);
101771 +}
101772 +
101773 +static void deconstify_tree(tree node);
101774 +
101775 +static void deconstify_type(tree type)
101776 +{
101777 + tree field;
101778 +
101779 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
101780 +
101781 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
101782 + const_tree fieldtype = get_field_type(field);
101783 +
101784 + // special case handling of simple ptr-to-same-array-type members
101785 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
101786 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
101787 +
101788 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
101789 + continue;
101790 + if (TREE_TYPE(TREE_TYPE(field)) == type)
101791 + continue;
101792 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
101793 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
101794 + TREE_TYPE(TREE_TYPE(field)) = type;
101795 + }
101796 + continue;
101797 + }
101798 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
101799 + continue;
101800 + if (!constified(fieldtype))
101801 + continue;
101802 +
101803 + deconstify_tree(field);
101804 + TREE_READONLY(field) = 0;
101805 + }
101806 + TYPE_READONLY(type) = 0;
101807 + C_TYPE_FIELDS_READONLY(type) = 0;
101808 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101809 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
101810 +}
101811 +
101812 +static void deconstify_tree(tree node)
101813 +{
101814 + tree old_type, new_type, field;
101815 +
101816 + old_type = TREE_TYPE(node);
101817 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
101818 + node = TREE_TYPE(node) = copy_node(old_type);
101819 + old_type = TREE_TYPE(old_type);
101820 + }
101821 +
101822 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
101823 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
101824 +
101825 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
101826 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
101827 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
101828 + DECL_FIELD_CONTEXT(field) = new_type;
101829 +
101830 + deconstify_type(new_type);
101831 +
101832 + TREE_TYPE(node) = new_type;
101833 +}
101834 +
101835 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101836 +{
101837 + tree type;
101838 + constify_info cinfo = {
101839 + .has_fptr_field = false,
101840 + .has_writable_field = false,
101841 + .has_do_const_field = false,
101842 + .has_no_const_field = false
101843 + };
101844 +
101845 + *no_add_attrs = true;
101846 + if (TREE_CODE(*node) == FUNCTION_DECL) {
101847 + error("%qE attribute does not apply to functions (%qF)", name, *node);
101848 + return NULL_TREE;
101849 + }
101850 +
101851 + if (TREE_CODE(*node) == PARM_DECL) {
101852 + error("%qE attribute does not apply to function parameters (%qD)", name, *node);
101853 + return NULL_TREE;
101854 + }
101855 +
101856 + if (TREE_CODE(*node) == VAR_DECL) {
101857 + error("%qE attribute does not apply to variables (%qD)", name, *node);
101858 + return NULL_TREE;
101859 + }
101860 +
101861 + if (TYPE_P(*node)) {
101862 + type = *node;
101863 + } else {
101864 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
101865 + type = TREE_TYPE(*node);
101866 + }
101867 +
101868 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
101869 + error("%qE attribute used on %qT applies to struct and union types only", name, type);
101870 + return NULL_TREE;
101871 + }
101872 +
101873 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
101874 + error("%qE attribute is already applied to the type %qT", name, type);
101875 + return NULL_TREE;
101876 + }
101877 +
101878 + if (TYPE_P(*node)) {
101879 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101880 + error("%qE attribute used on type %qT is incompatible with 'do_const'", name, type);
101881 + else
101882 + *no_add_attrs = false;
101883 + return NULL_TREE;
101884 + }
101885 +
101886 + constifiable(type, &cinfo);
101887 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
101888 + deconstify_tree(*node);
101889 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
101890 + return NULL_TREE;
101891 + }
101892 +
101893 + error("%qE attribute used on type %qT that is not constified", name, type);
101894 + return NULL_TREE;
101895 +}
101896 +
101897 +static void constify_type(tree type)
101898 +{
101899 + TYPE_READONLY(type) = 1;
101900 + C_TYPE_FIELDS_READONLY(type) = 1;
101901 + TYPE_CONSTIFY_VISITED(type) = 1;
101902 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
101903 +}
101904 +
101905 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101906 +{
101907 + *no_add_attrs = true;
101908 + if (!TYPE_P(*node)) {
101909 + error("%qE attribute applies to types only (%qD)", name, *node);
101910 + return NULL_TREE;
101911 + }
101912 +
101913 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
101914 + error("%qE attribute used on %qT applies to struct and union types only", name, *node);
101915 + return NULL_TREE;
101916 + }
101917 +
101918 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
101919 + error("%qE attribute used on %qT is already applied to the type", name, *node);
101920 + return NULL_TREE;
101921 + }
101922 +
101923 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
101924 + error("%qE attribute used on %qT is incompatible with 'no_const'", name, *node);
101925 + return NULL_TREE;
101926 + }
101927 +
101928 + *no_add_attrs = false;
101929 + return NULL_TREE;
101930 +}
101931 +
101932 +static struct attribute_spec no_const_attr = {
101933 + .name = "no_const",
101934 + .min_length = 0,
101935 + .max_length = 0,
101936 + .decl_required = false,
101937 + .type_required = false,
101938 + .function_type_required = false,
101939 + .handler = handle_no_const_attribute,
101940 +#if BUILDING_GCC_VERSION >= 4007
101941 + .affects_type_identity = true
101942 +#endif
101943 +};
101944 +
101945 +static struct attribute_spec do_const_attr = {
101946 + .name = "do_const",
101947 + .min_length = 0,
101948 + .max_length = 0,
101949 + .decl_required = false,
101950 + .type_required = false,
101951 + .function_type_required = false,
101952 + .handler = handle_do_const_attribute,
101953 +#if BUILDING_GCC_VERSION >= 4007
101954 + .affects_type_identity = true
101955 +#endif
101956 +};
101957 +
101958 +static void register_attributes(void *event_data, void *data)
101959 +{
101960 + register_attribute(&no_const_attr);
101961 + register_attribute(&do_const_attr);
101962 +}
101963 +
101964 +static void finish_type(void *event_data, void *data)
101965 +{
101966 + tree type = (tree)event_data;
101967 + constify_info cinfo = {
101968 + .has_fptr_field = false,
101969 + .has_writable_field = false,
101970 + .has_do_const_field = false,
101971 + .has_no_const_field = false
101972 + };
101973 +
101974 + if (type == NULL_TREE || type == error_mark_node)
101975 + return;
101976 +
101977 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
101978 + return;
101979 +
101980 + constifiable(type, &cinfo);
101981 +
101982 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
101983 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
101984 + deconstify_type(type);
101985 + TYPE_CONSTIFY_VISITED(type) = 1;
101986 + } else
101987 + error("'no_const' attribute used on type %qT that is not constified", type);
101988 + return;
101989 + }
101990 +
101991 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
101992 + if (!cinfo.has_writable_field) {
101993 + error("'do_const' attribute used on type %qT that is%sconstified", type, cinfo.has_fptr_field ? " " : " not ");
101994 + return;
101995 + }
101996 + constify_type(type);
101997 + return;
101998 + }
101999 +
102000 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
102001 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
102002 + error("'do_const' attribute used on type %qT that is constified", type);
102003 + return;
102004 + }
102005 + constify_type(type);
102006 + return;
102007 + }
102008 +
102009 + deconstify_type(type);
102010 + TYPE_CONSTIFY_VISITED(type) = 1;
102011 +}
102012 +
102013 +static void check_global_variables(void)
102014 +{
102015 + struct varpool_node *node;
102016 +
102017 +#if BUILDING_GCC_VERSION <= 4007
102018 + for (node = varpool_nodes; node; node = node->next) {
102019 + tree var = node->decl;
102020 +#else
102021 + FOR_EACH_VARIABLE(node) {
102022 + tree var = node->symbol.decl;
102023 +#endif
102024 + tree type = TREE_TYPE(var);
102025 +
102026 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
102027 + continue;
102028 +
102029 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
102030 + continue;
102031 +
102032 + if (!TYPE_CONSTIFY_VISITED(type))
102033 + continue;
102034 +
102035 + if (DECL_EXTERNAL(var))
102036 + continue;
102037 +
102038 + if (DECL_INITIAL(var))
102039 + continue;
102040 +
102041 + // this works around a gcc bug/feature where uninitialized globals
102042 + // are moved into the .bss section regardless of any constification
102043 + DECL_INITIAL(var) = build_constructor(type, NULL);
102044 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
102045 + }
102046 +}
102047 +
102048 +static unsigned int check_local_variables(void)
102049 +{
102050 + unsigned int ret = 0;
102051 + tree var;
102052 +
102053 +#if BUILDING_GCC_VERSION == 4005
102054 + tree vars;
102055 +#else
102056 + unsigned int i;
102057 +#endif
102058 +
102059 +#if BUILDING_GCC_VERSION == 4005
102060 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
102061 + var = TREE_VALUE(vars);
102062 +#else
102063 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
102064 +#endif
102065 + tree type = TREE_TYPE(var);
102066 +
102067 + gcc_assert(DECL_P(var));
102068 + if (is_global_var(var))
102069 + continue;
102070 +
102071 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
102072 + continue;
102073 +
102074 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
102075 + continue;
102076 +
102077 + if (!TYPE_CONSTIFY_VISITED(type))
102078 + continue;
102079 +
102080 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
102081 + ret = 1;
102082 + }
102083 + return ret;
102084 +}
102085 +
102086 +static unsigned int check_variables(void)
102087 +{
102088 + check_global_variables();
102089 + return check_local_variables();
102090 +}
102091 +
102092 +static struct gimple_opt_pass pass_local_variable = {
102093 + {
102094 + .type = GIMPLE_PASS,
102095 + .name = "check_variables",
102096 +#if BUILDING_GCC_VERSION >= 4008
102097 + .optinfo_flags = OPTGROUP_NONE,
102098 +#endif
102099 + .gate = NULL,
102100 + .execute = check_variables,
102101 + .sub = NULL,
102102 + .next = NULL,
102103 + .static_pass_number = 0,
102104 + .tv_id = TV_NONE,
102105 + .properties_required = 0,
102106 + .properties_provided = 0,
102107 + .properties_destroyed = 0,
102108 + .todo_flags_start = 0,
102109 + .todo_flags_finish = 0
102110 + }
102111 +};
102112 +
102113 +static struct {
102114 + const char *name;
102115 + const char *asm_op;
102116 +} sections[] = {
102117 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
102118 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
102119 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
102120 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
102121 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
102122 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
102123 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
102124 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
102125 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
102126 +};
102127 +
102128 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
102129 +
102130 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
102131 +{
102132 + size_t i;
102133 +
102134 + for (i = 0; i < ARRAY_SIZE(sections); i++)
102135 + if (!strcmp(sections[i].name, name))
102136 + return 0;
102137 + return old_section_type_flags(decl, name, reloc);
102138 +}
102139 +
102140 +static void constify_start_unit(void *gcc_data, void *user_data)
102141 +{
102142 +// size_t i;
102143 +
102144 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
102145 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
102146 +// sections[i].section = get_section(sections[i].name, 0, NULL);
102147 +
102148 + old_section_type_flags = targetm.section_type_flags;
102149 + targetm.section_type_flags = constify_section_type_flags;
102150 +}
102151 +
102152 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102153 +{
102154 + const char * const plugin_name = plugin_info->base_name;
102155 + const int argc = plugin_info->argc;
102156 + const struct plugin_argument * const argv = plugin_info->argv;
102157 + int i;
102158 + bool constify = true;
102159 +
102160 + struct register_pass_info local_variable_pass_info = {
102161 + .pass = &pass_local_variable.pass,
102162 + .reference_pass_name = "ssa",
102163 + .ref_pass_instance_number = 1,
102164 + .pos_op = PASS_POS_INSERT_BEFORE
102165 + };
102166 +
102167 + if (!plugin_default_version_check(version, &gcc_version)) {
102168 + error(G_("incompatible gcc/plugin versions"));
102169 + return 1;
102170 + }
102171 +
102172 + for (i = 0; i < argc; ++i) {
102173 + if (!(strcmp(argv[i].key, "no-constify"))) {
102174 + constify = false;
102175 + continue;
102176 + }
102177 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102178 + }
102179 +
102180 + if (strcmp(lang_hooks.name, "GNU C")) {
102181 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
102182 + constify = false;
102183 + }
102184 +
102185 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
102186 + if (constify) {
102187 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
102188 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
102189 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
102190 + }
102191 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102192 +
102193 + return 0;
102194 +}
102195 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
102196 new file mode 100644
102197 index 0000000..e518932
102198 --- /dev/null
102199 +++ b/tools/gcc/generate_size_overflow_hash.sh
102200 @@ -0,0 +1,94 @@
102201 +#!/bin/bash
102202 +
102203 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
102204 +
102205 +header1="size_overflow_hash.h"
102206 +database="size_overflow_hash.data"
102207 +n=65536
102208 +
102209 +usage() {
102210 +cat <<EOF
102211 +usage: $0 options
102212 +OPTIONS:
102213 + -h|--help help
102214 + -o header file
102215 + -d database file
102216 + -n hash array size
102217 +EOF
102218 + return 0
102219 +}
102220 +
102221 +while true
102222 +do
102223 + case "$1" in
102224 + -h|--help) usage && exit 0;;
102225 + -n) n=$2; shift 2;;
102226 + -o) header1="$2"; shift 2;;
102227 + -d) database="$2"; shift 2;;
102228 + --) shift 1; break ;;
102229 + *) break ;;
102230 + esac
102231 +done
102232 +
102233 +create_defines() {
102234 + for i in `seq 0 31`
102235 + do
102236 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
102237 + done
102238 + echo >> "$header1"
102239 +}
102240 +
102241 +create_structs() {
102242 + rm -f "$header1"
102243 +
102244 + create_defines
102245 +
102246 + cat "$database" | while read data
102247 + do
102248 + data_array=($data)
102249 + struct_hash_name="${data_array[0]}"
102250 + funcn="${data_array[1]}"
102251 + params="${data_array[2]}"
102252 + next="${data_array[4]}"
102253 +
102254 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
102255 +
102256 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
102257 + echo -en "\t.param\t= " >> "$header1"
102258 + line=
102259 + for param_num in ${params//-/ };
102260 + do
102261 + line="${line}PARAM"$param_num"|"
102262 + done
102263 +
102264 + echo -e "${line%?},\n};\n" >> "$header1"
102265 + done
102266 +}
102267 +
102268 +create_headers() {
102269 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
102270 +}
102271 +
102272 +create_array_elements() {
102273 + index=0
102274 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
102275 + do
102276 + data_array=($data)
102277 + i="${data_array[3]}"
102278 + hash="${data_array[0]}"
102279 + while [[ $index -lt $i ]]
102280 + do
102281 + echo -e "\t["$index"]\t= NULL," >> "$header1"
102282 + index=$(($index + 1))
102283 + done
102284 + index=$(($index + 1))
102285 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
102286 + done
102287 + echo '};' >> $header1
102288 +}
102289 +
102290 +create_structs
102291 +create_headers
102292 +create_array_elements
102293 +
102294 +exit 0
102295 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
102296 new file mode 100644
102297 index 0000000..568b360
102298 --- /dev/null
102299 +++ b/tools/gcc/kallocstat_plugin.c
102300 @@ -0,0 +1,170 @@
102301 +/*
102302 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
102303 + * Licensed under the GPL v2
102304 + *
102305 + * Note: the choice of the license means that the compilation process is
102306 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102307 + * but for the kernel it doesn't matter since it doesn't link against
102308 + * any of the gcc libraries
102309 + *
102310 + * gcc plugin to find the distribution of k*alloc sizes
102311 + *
102312 + * TODO:
102313 + *
102314 + * BUGS:
102315 + * - none known
102316 + */
102317 +#include "gcc-plugin.h"
102318 +#include "config.h"
102319 +#include "system.h"
102320 +#include "coretypes.h"
102321 +#include "tree.h"
102322 +#include "tree-pass.h"
102323 +#include "flags.h"
102324 +#include "intl.h"
102325 +#include "toplev.h"
102326 +#include "plugin.h"
102327 +//#include "expr.h" where are you...
102328 +#include "diagnostic.h"
102329 +#include "plugin-version.h"
102330 +#include "tm.h"
102331 +#include "function.h"
102332 +#include "basic-block.h"
102333 +#include "gimple.h"
102334 +#include "rtl.h"
102335 +#include "emit-rtl.h"
102336 +
102337 +extern void print_gimple_stmt(FILE *, gimple, int, int);
102338 +
102339 +int plugin_is_GPL_compatible;
102340 +
102341 +static const char * const kalloc_functions[] = {
102342 + "__kmalloc",
102343 + "kmalloc",
102344 + "kmalloc_large",
102345 + "kmalloc_node",
102346 + "kmalloc_order",
102347 + "kmalloc_order_trace",
102348 + "kmalloc_slab",
102349 + "kzalloc",
102350 + "kzalloc_node",
102351 +};
102352 +
102353 +static struct plugin_info kallocstat_plugin_info = {
102354 + .version = "201302112000",
102355 +};
102356 +
102357 +static unsigned int execute_kallocstat(void);
102358 +
102359 +static struct gimple_opt_pass kallocstat_pass = {
102360 + .pass = {
102361 + .type = GIMPLE_PASS,
102362 + .name = "kallocstat",
102363 +#if BUILDING_GCC_VERSION >= 4008
102364 + .optinfo_flags = OPTGROUP_NONE,
102365 +#endif
102366 + .gate = NULL,
102367 + .execute = execute_kallocstat,
102368 + .sub = NULL,
102369 + .next = NULL,
102370 + .static_pass_number = 0,
102371 + .tv_id = TV_NONE,
102372 + .properties_required = 0,
102373 + .properties_provided = 0,
102374 + .properties_destroyed = 0,
102375 + .todo_flags_start = 0,
102376 + .todo_flags_finish = 0
102377 + }
102378 +};
102379 +
102380 +static bool is_kalloc(const char *fnname)
102381 +{
102382 + size_t i;
102383 +
102384 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
102385 + if (!strcmp(fnname, kalloc_functions[i]))
102386 + return true;
102387 + return false;
102388 +}
102389 +
102390 +static unsigned int execute_kallocstat(void)
102391 +{
102392 + basic_block bb;
102393 +
102394 + // 1. loop through BBs and GIMPLE statements
102395 + FOR_EACH_BB(bb) {
102396 + gimple_stmt_iterator gsi;
102397 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102398 + // gimple match:
102399 + tree fndecl, size;
102400 + gimple call_stmt;
102401 + const char *fnname;
102402 +
102403 + // is it a call
102404 + call_stmt = gsi_stmt(gsi);
102405 + if (!is_gimple_call(call_stmt))
102406 + continue;
102407 + fndecl = gimple_call_fndecl(call_stmt);
102408 + if (fndecl == NULL_TREE)
102409 + continue;
102410 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
102411 + continue;
102412 +
102413 + // is it a call to k*alloc
102414 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
102415 + if (!is_kalloc(fnname))
102416 + continue;
102417 +
102418 + // is the size arg the result of a simple const assignment
102419 + size = gimple_call_arg(call_stmt, 0);
102420 + while (true) {
102421 + gimple def_stmt;
102422 + expanded_location xloc;
102423 + size_t size_val;
102424 +
102425 + if (TREE_CODE(size) != SSA_NAME)
102426 + break;
102427 + def_stmt = SSA_NAME_DEF_STMT(size);
102428 + if (!def_stmt || !is_gimple_assign(def_stmt))
102429 + break;
102430 + if (gimple_num_ops(def_stmt) != 2)
102431 + break;
102432 + size = gimple_assign_rhs1(def_stmt);
102433 + if (!TREE_CONSTANT(size))
102434 + continue;
102435 + xloc = expand_location(gimple_location(def_stmt));
102436 + if (!xloc.file)
102437 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
102438 + size_val = TREE_INT_CST_LOW(size);
102439 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
102440 + break;
102441 + }
102442 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
102443 +//debug_tree(gimple_call_fn(call_stmt));
102444 +//print_node(stderr, "pax", fndecl, 4);
102445 + }
102446 + }
102447 +
102448 + return 0;
102449 +}
102450 +
102451 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102452 +{
102453 + const char * const plugin_name = plugin_info->base_name;
102454 + struct register_pass_info kallocstat_pass_info = {
102455 + .pass = &kallocstat_pass.pass,
102456 + .reference_pass_name = "ssa",
102457 + .ref_pass_instance_number = 1,
102458 + .pos_op = PASS_POS_INSERT_AFTER
102459 + };
102460 +
102461 + if (!plugin_default_version_check(version, &gcc_version)) {
102462 + error(G_("incompatible gcc/plugin versions"));
102463 + return 1;
102464 + }
102465 +
102466 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
102467 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
102468 +
102469 + return 0;
102470 +}
102471 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
102472 new file mode 100644
102473 index 0000000..a25306b
102474 --- /dev/null
102475 +++ b/tools/gcc/kernexec_plugin.c
102476 @@ -0,0 +1,474 @@
102477 +/*
102478 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
102479 + * Licensed under the GPL v2
102480 + *
102481 + * Note: the choice of the license means that the compilation process is
102482 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102483 + * but for the kernel it doesn't matter since it doesn't link against
102484 + * any of the gcc libraries
102485 + *
102486 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
102487 + *
102488 + * TODO:
102489 + *
102490 + * BUGS:
102491 + * - none known
102492 + */
102493 +#include "gcc-plugin.h"
102494 +#include "config.h"
102495 +#include "system.h"
102496 +#include "coretypes.h"
102497 +#include "tree.h"
102498 +#include "tree-pass.h"
102499 +#include "flags.h"
102500 +#include "intl.h"
102501 +#include "toplev.h"
102502 +#include "plugin.h"
102503 +//#include "expr.h" where are you...
102504 +#include "diagnostic.h"
102505 +#include "plugin-version.h"
102506 +#include "tm.h"
102507 +#include "function.h"
102508 +#include "basic-block.h"
102509 +#include "gimple.h"
102510 +#include "rtl.h"
102511 +#include "emit-rtl.h"
102512 +#include "tree-flow.h"
102513 +
102514 +extern void print_gimple_stmt(FILE *, gimple, int, int);
102515 +extern rtx emit_move_insn(rtx x, rtx y);
102516 +
102517 +#if BUILDING_GCC_VERSION <= 4006
102518 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
102519 +#endif
102520 +
102521 +#if BUILDING_GCC_VERSION >= 4008
102522 +#define TODO_dump_func 0
102523 +#endif
102524 +
102525 +int plugin_is_GPL_compatible;
102526 +
102527 +static struct plugin_info kernexec_plugin_info = {
102528 + .version = "201308230150",
102529 + .help = "method=[bts|or]\tinstrumentation method\n"
102530 +};
102531 +
102532 +static unsigned int execute_kernexec_reload(void);
102533 +static unsigned int execute_kernexec_fptr(void);
102534 +static unsigned int execute_kernexec_retaddr(void);
102535 +static bool kernexec_cmodel_check(void);
102536 +
102537 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
102538 +static void (*kernexec_instrument_retaddr)(rtx);
102539 +
102540 +static struct gimple_opt_pass kernexec_reload_pass = {
102541 + .pass = {
102542 + .type = GIMPLE_PASS,
102543 + .name = "kernexec_reload",
102544 +#if BUILDING_GCC_VERSION >= 4008
102545 + .optinfo_flags = OPTGROUP_NONE,
102546 +#endif
102547 + .gate = kernexec_cmodel_check,
102548 + .execute = execute_kernexec_reload,
102549 + .sub = NULL,
102550 + .next = NULL,
102551 + .static_pass_number = 0,
102552 + .tv_id = TV_NONE,
102553 + .properties_required = 0,
102554 + .properties_provided = 0,
102555 + .properties_destroyed = 0,
102556 + .todo_flags_start = 0,
102557 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
102558 + }
102559 +};
102560 +
102561 +static struct gimple_opt_pass kernexec_fptr_pass = {
102562 + .pass = {
102563 + .type = GIMPLE_PASS,
102564 + .name = "kernexec_fptr",
102565 +#if BUILDING_GCC_VERSION >= 4008
102566 + .optinfo_flags = OPTGROUP_NONE,
102567 +#endif
102568 + .gate = kernexec_cmodel_check,
102569 + .execute = execute_kernexec_fptr,
102570 + .sub = NULL,
102571 + .next = NULL,
102572 + .static_pass_number = 0,
102573 + .tv_id = TV_NONE,
102574 + .properties_required = 0,
102575 + .properties_provided = 0,
102576 + .properties_destroyed = 0,
102577 + .todo_flags_start = 0,
102578 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
102579 + }
102580 +};
102581 +
102582 +static struct rtl_opt_pass kernexec_retaddr_pass = {
102583 + .pass = {
102584 + .type = RTL_PASS,
102585 + .name = "kernexec_retaddr",
102586 +#if BUILDING_GCC_VERSION >= 4008
102587 + .optinfo_flags = OPTGROUP_NONE,
102588 +#endif
102589 + .gate = kernexec_cmodel_check,
102590 + .execute = execute_kernexec_retaddr,
102591 + .sub = NULL,
102592 + .next = NULL,
102593 + .static_pass_number = 0,
102594 + .tv_id = TV_NONE,
102595 + .properties_required = 0,
102596 + .properties_provided = 0,
102597 + .properties_destroyed = 0,
102598 + .todo_flags_start = 0,
102599 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
102600 + }
102601 +};
102602 +
102603 +static bool kernexec_cmodel_check(void)
102604 +{
102605 + tree section;
102606 +
102607 + if (ix86_cmodel != CM_KERNEL)
102608 + return false;
102609 +
102610 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
102611 + if (!section || !TREE_VALUE(section))
102612 + return true;
102613 +
102614 + section = TREE_VALUE(TREE_VALUE(section));
102615 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
102616 + return true;
102617 +
102618 + return false;
102619 +}
102620 +
102621 +/*
102622 + * add special KERNEXEC instrumentation: reload %r12 after it has been clobbered
102623 + */
102624 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
102625 +{
102626 + gimple asm_movabs_stmt;
102627 +
102628 + // build asm volatile("movabs $0x8000000000000000, %%r12\n\t" : : : );
102629 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r12\n\t", NULL, NULL, NULL, NULL);
102630 + gimple_asm_set_volatile(asm_movabs_stmt, true);
102631 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
102632 + update_stmt(asm_movabs_stmt);
102633 +}
102634 +
102635 +/*
102636 + * find all asm() stmts that clobber r12 and add a reload of r12
102637 + */
102638 +static unsigned int execute_kernexec_reload(void)
102639 +{
102640 + basic_block bb;
102641 +
102642 + // 1. loop through BBs and GIMPLE statements
102643 + FOR_EACH_BB(bb) {
102644 + gimple_stmt_iterator gsi;
102645 +
102646 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102647 + // gimple match: __asm__ ("" : : : "r12");
102648 + gimple asm_stmt;
102649 + size_t nclobbers;
102650 +
102651 + // is it an asm ...
102652 + asm_stmt = gsi_stmt(gsi);
102653 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
102654 + continue;
102655 +
102656 + // ... clobbering r12
102657 + nclobbers = gimple_asm_nclobbers(asm_stmt);
102658 + while (nclobbers--) {
102659 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
102660 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r12"))
102661 + continue;
102662 + kernexec_reload_fptr_mask(&gsi);
102663 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
102664 + break;
102665 + }
102666 + }
102667 + }
102668 +
102669 + return 0;
102670 +}
102671 +
102672 +/*
102673 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
102674 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
102675 + */
102676 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
102677 +{
102678 + gimple assign_intptr, assign_new_fptr, call_stmt;
102679 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
102680 +
102681 + call_stmt = gsi_stmt(*gsi);
102682 + old_fptr = gimple_call_fn(call_stmt);
102683 +
102684 + // create temporary unsigned long variable used for bitops and cast fptr to it
102685 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
102686 +#if BUILDING_GCC_VERSION <= 4007
102687 + add_referenced_var(intptr);
102688 +#endif
102689 + intptr = make_ssa_name(intptr, NULL);
102690 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
102691 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
102692 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
102693 + update_stmt(assign_intptr);
102694 +
102695 + // apply logical or to temporary unsigned long and bitmask
102696 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
102697 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
102698 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
102699 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
102700 + assign_intptr = gimple_build_assign(intptr, orptr);
102701 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
102702 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
102703 + update_stmt(assign_intptr);
102704 +
102705 + // cast temporary unsigned long back to a temporary fptr variable
102706 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
102707 +#if BUILDING_GCC_VERSION <= 4007
102708 + add_referenced_var(new_fptr);
102709 +#endif
102710 + new_fptr = make_ssa_name(new_fptr, NULL);
102711 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
102712 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
102713 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
102714 + update_stmt(assign_new_fptr);
102715 +
102716 + // replace call stmt fn with the new fptr
102717 + gimple_call_set_fn(call_stmt, new_fptr);
102718 + update_stmt(call_stmt);
102719 +}
102720 +
102721 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
102722 +{
102723 + gimple asm_or_stmt, call_stmt;
102724 + tree old_fptr, new_fptr, input, output;
102725 +#if BUILDING_GCC_VERSION <= 4007
102726 + VEC(tree, gc) *inputs = NULL;
102727 + VEC(tree, gc) *outputs = NULL;
102728 +#else
102729 + vec<tree, va_gc> *inputs = NULL;
102730 + vec<tree, va_gc> *outputs = NULL;
102731 +#endif
102732 +
102733 + call_stmt = gsi_stmt(*gsi);
102734 + old_fptr = gimple_call_fn(call_stmt);
102735 +
102736 + // create temporary fptr variable
102737 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
102738 +#if BUILDING_GCC_VERSION <= 4007
102739 + add_referenced_var(new_fptr);
102740 +#endif
102741 + new_fptr = make_ssa_name(new_fptr, NULL);
102742 +
102743 + // build asm volatile("orq %%r12, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
102744 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
102745 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
102746 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
102747 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
102748 +#if BUILDING_GCC_VERSION <= 4007
102749 + VEC_safe_push(tree, gc, inputs, input);
102750 + VEC_safe_push(tree, gc, outputs, output);
102751 +#else
102752 + vec_safe_push(inputs, input);
102753 + vec_safe_push(outputs, output);
102754 +#endif
102755 + asm_or_stmt = gimple_build_asm_vec("orq %%r12, %0\n\t", inputs, outputs, NULL, NULL);
102756 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
102757 + gimple_asm_set_volatile(asm_or_stmt, true);
102758 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
102759 + update_stmt(asm_or_stmt);
102760 +
102761 + // replace call stmt fn with the new fptr
102762 + gimple_call_set_fn(call_stmt, new_fptr);
102763 + update_stmt(call_stmt);
102764 +}
102765 +
102766 +/*
102767 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
102768 + */
102769 +static unsigned int execute_kernexec_fptr(void)
102770 +{
102771 + basic_block bb;
102772 +
102773 + // 1. loop through BBs and GIMPLE statements
102774 + FOR_EACH_BB(bb) {
102775 + gimple_stmt_iterator gsi;
102776 +
102777 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102778 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
102779 + tree fn;
102780 + gimple call_stmt;
102781 +
102782 + // is it a call ...
102783 + call_stmt = gsi_stmt(gsi);
102784 + if (!is_gimple_call(call_stmt))
102785 + continue;
102786 + fn = gimple_call_fn(call_stmt);
102787 + if (TREE_CODE(fn) == ADDR_EXPR)
102788 + continue;
102789 + if (TREE_CODE(fn) != SSA_NAME)
102790 + gcc_unreachable();
102791 +
102792 + // ... through a function pointer
102793 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
102794 + fn = SSA_NAME_VAR(fn);
102795 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
102796 + debug_tree(fn);
102797 + gcc_unreachable();
102798 + }
102799 + }
102800 + fn = TREE_TYPE(fn);
102801 + if (TREE_CODE(fn) != POINTER_TYPE)
102802 + continue;
102803 + fn = TREE_TYPE(fn);
102804 + if (TREE_CODE(fn) != FUNCTION_TYPE)
102805 + continue;
102806 +
102807 + kernexec_instrument_fptr(&gsi);
102808 +
102809 +//debug_tree(gimple_call_fn(call_stmt));
102810 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
102811 + }
102812 + }
102813 +
102814 + return 0;
102815 +}
102816 +
102817 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
102818 +static void kernexec_instrument_retaddr_bts(rtx insn)
102819 +{
102820 + rtx btsq;
102821 + rtvec argvec, constraintvec, labelvec;
102822 + int line;
102823 +
102824 + // create asm volatile("btsq $63,(%%rsp)":::)
102825 + argvec = rtvec_alloc(0);
102826 + constraintvec = rtvec_alloc(0);
102827 + labelvec = rtvec_alloc(0);
102828 + line = expand_location(RTL_LOCATION(insn)).line;
102829 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
102830 + MEM_VOLATILE_P(btsq) = 1;
102831 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
102832 + emit_insn_before(btsq, insn);
102833 +}
102834 +
102835 +// add special KERNEXEC instrumentation: orq %r12,(%rsp) just before retn
102836 +static void kernexec_instrument_retaddr_or(rtx insn)
102837 +{
102838 + rtx orq;
102839 + rtvec argvec, constraintvec, labelvec;
102840 + int line;
102841 +
102842 + // create asm volatile("orq %%r12,(%%rsp)":::)
102843 + argvec = rtvec_alloc(0);
102844 + constraintvec = rtvec_alloc(0);
102845 + labelvec = rtvec_alloc(0);
102846 + line = expand_location(RTL_LOCATION(insn)).line;
102847 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r12,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
102848 + MEM_VOLATILE_P(orq) = 1;
102849 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
102850 + emit_insn_before(orq, insn);
102851 +}
102852 +
102853 +/*
102854 + * find all asm level function returns and forcibly set the highest bit of the return address
102855 + */
102856 +static unsigned int execute_kernexec_retaddr(void)
102857 +{
102858 + rtx insn;
102859 +
102860 +// if (stack_realign_drap)
102861 +// inform(DECL_SOURCE_LOCATION(current_function_decl), "drap detected in %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
102862 +
102863 + // 1. find function returns
102864 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
102865 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
102866 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
102867 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
102868 + rtx body;
102869 +
102870 + // is it a retn
102871 + if (!JUMP_P(insn))
102872 + continue;
102873 + body = PATTERN(insn);
102874 + if (GET_CODE(body) == PARALLEL)
102875 + body = XVECEXP(body, 0, 0);
102876 + if (!ANY_RETURN_P(body))
102877 + continue;
102878 + kernexec_instrument_retaddr(insn);
102879 + }
102880 +
102881 +// print_simple_rtl(stderr, get_insns());
102882 +// print_rtl(stderr, get_insns());
102883 +
102884 + return 0;
102885 +}
102886 +
102887 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102888 +{
102889 + const char * const plugin_name = plugin_info->base_name;
102890 + const int argc = plugin_info->argc;
102891 + const struct plugin_argument * const argv = plugin_info->argv;
102892 + int i;
102893 + struct register_pass_info kernexec_reload_pass_info = {
102894 + .pass = &kernexec_reload_pass.pass,
102895 + .reference_pass_name = "ssa",
102896 + .ref_pass_instance_number = 1,
102897 + .pos_op = PASS_POS_INSERT_AFTER
102898 + };
102899 + struct register_pass_info kernexec_fptr_pass_info = {
102900 + .pass = &kernexec_fptr_pass.pass,
102901 + .reference_pass_name = "ssa",
102902 + .ref_pass_instance_number = 1,
102903 + .pos_op = PASS_POS_INSERT_AFTER
102904 + };
102905 + struct register_pass_info kernexec_retaddr_pass_info = {
102906 + .pass = &kernexec_retaddr_pass.pass,
102907 + .reference_pass_name = "pro_and_epilogue",
102908 + .ref_pass_instance_number = 1,
102909 + .pos_op = PASS_POS_INSERT_AFTER
102910 + };
102911 +
102912 + if (!plugin_default_version_check(version, &gcc_version)) {
102913 + error(G_("incompatible gcc/plugin versions"));
102914 + return 1;
102915 + }
102916 +
102917 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
102918 +
102919 + if (TARGET_64BIT == 0)
102920 + return 0;
102921 +
102922 + for (i = 0; i < argc; ++i) {
102923 + if (!strcmp(argv[i].key, "method")) {
102924 + if (!argv[i].value) {
102925 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102926 + continue;
102927 + }
102928 + if (!strcmp(argv[i].value, "bts")) {
102929 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
102930 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
102931 + } else if (!strcmp(argv[i].value, "or")) {
102932 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
102933 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
102934 + fix_register("r12", 1, 1);
102935 + } else
102936 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102937 + continue;
102938 + }
102939 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102940 + }
102941 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
102942 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
102943 +
102944 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
102945 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
102946 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
102947 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
102948 +
102949 + return 0;
102950 +}
102951 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
102952 new file mode 100644
102953 index 0000000..679b9ef
102954 --- /dev/null
102955 +++ b/tools/gcc/latent_entropy_plugin.c
102956 @@ -0,0 +1,335 @@
102957 +/*
102958 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
102959 + * Licensed under the GPL v2
102960 + *
102961 + * Note: the choice of the license means that the compilation process is
102962 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102963 + * but for the kernel it doesn't matter since it doesn't link against
102964 + * any of the gcc libraries
102965 + *
102966 + * gcc plugin to help generate a little bit of entropy from program state,
102967 + * used during boot in the kernel
102968 + *
102969 + * TODO:
102970 + * - add ipa pass to identify not explicitly marked candidate functions
102971 + * - mix in more program state (function arguments/return values, loop variables, etc)
102972 + * - more instrumentation control via attribute parameters
102973 + *
102974 + * BUGS:
102975 + * - LTO needs -flto-partition=none for now
102976 + */
102977 +#include "gcc-plugin.h"
102978 +#include "config.h"
102979 +#include "system.h"
102980 +#include "coretypes.h"
102981 +#include "tree.h"
102982 +#include "tree-pass.h"
102983 +#include "flags.h"
102984 +#include "intl.h"
102985 +#include "toplev.h"
102986 +#include "plugin.h"
102987 +//#include "expr.h" where are you...
102988 +#include "diagnostic.h"
102989 +#include "plugin-version.h"
102990 +#include "tm.h"
102991 +#include "function.h"
102992 +#include "basic-block.h"
102993 +#include "gimple.h"
102994 +#include "rtl.h"
102995 +#include "emit-rtl.h"
102996 +#include "tree-flow.h"
102997 +#include "langhooks.h"
102998 +
102999 +#if BUILDING_GCC_VERSION >= 4008
103000 +#define TODO_dump_func 0
103001 +#endif
103002 +
103003 +int plugin_is_GPL_compatible;
103004 +
103005 +static tree latent_entropy_decl;
103006 +
103007 +static struct plugin_info latent_entropy_plugin_info = {
103008 + .version = "201308230230",
103009 + .help = NULL
103010 +};
103011 +
103012 +static unsigned int execute_latent_entropy(void);
103013 +static bool gate_latent_entropy(void);
103014 +
103015 +static struct gimple_opt_pass latent_entropy_pass = {
103016 + .pass = {
103017 + .type = GIMPLE_PASS,
103018 + .name = "latent_entropy",
103019 +#if BUILDING_GCC_VERSION >= 4008
103020 + .optinfo_flags = OPTGROUP_NONE,
103021 +#endif
103022 + .gate = gate_latent_entropy,
103023 + .execute = execute_latent_entropy,
103024 + .sub = NULL,
103025 + .next = NULL,
103026 + .static_pass_number = 0,
103027 + .tv_id = TV_NONE,
103028 + .properties_required = PROP_gimple_leh | PROP_cfg,
103029 + .properties_provided = 0,
103030 + .properties_destroyed = 0,
103031 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
103032 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
103033 + }
103034 +};
103035 +
103036 +static unsigned HOST_WIDE_INT seed;
103037 +static unsigned HOST_WIDE_INT get_random_const(void)
103038 +{
103039 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
103040 + return seed;
103041 +}
103042 +
103043 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
103044 +{
103045 + switch (TREE_CODE(*node)) {
103046 + default:
103047 + *no_add_attrs = true;
103048 + error("%qE attribute only applies to functions and variables", name);
103049 + break;
103050 +
103051 + case VAR_DECL:
103052 + if (DECL_INITIAL(*node)) {
103053 + *no_add_attrs = true;
103054 + error("variable %qD with %qE attribute must not be initialized", *node, name);
103055 + break;
103056 + }
103057 + DECL_INITIAL(*node) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
103058 + break;
103059 +
103060 + case FUNCTION_DECL:
103061 + break;
103062 + }
103063 +
103064 + return NULL_TREE;
103065 +}
103066 +
103067 +static struct attribute_spec latent_entropy_attr = {
103068 + .name = "latent_entropy",
103069 + .min_length = 0,
103070 + .max_length = 0,
103071 + .decl_required = true,
103072 + .type_required = false,
103073 + .function_type_required = false,
103074 + .handler = handle_latent_entropy_attribute,
103075 +#if BUILDING_GCC_VERSION >= 4007
103076 + .affects_type_identity = false
103077 +#endif
103078 +};
103079 +
103080 +static void register_attributes(void *event_data, void *data)
103081 +{
103082 + register_attribute(&latent_entropy_attr);
103083 +}
103084 +
103085 +static bool gate_latent_entropy(void)
103086 +{
103087 + tree latent_entropy_attr;
103088 +
103089 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
103090 + return latent_entropy_attr != NULL_TREE;
103091 +}
103092 +
103093 +static enum tree_code get_op(tree *rhs)
103094 +{
103095 + static enum tree_code op;
103096 + unsigned HOST_WIDE_INT random_const;
103097 +
103098 + random_const = get_random_const();
103099 +
103100 + switch (op) {
103101 + case BIT_XOR_EXPR:
103102 + op = PLUS_EXPR;
103103 + break;
103104 +
103105 + case PLUS_EXPR:
103106 + if (rhs) {
103107 + op = LROTATE_EXPR;
103108 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
103109 + break;
103110 + }
103111 +
103112 + case LROTATE_EXPR:
103113 + default:
103114 + op = BIT_XOR_EXPR;
103115 + break;
103116 + }
103117 + if (rhs)
103118 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
103119 + return op;
103120 +}
103121 +
103122 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
103123 +{
103124 + gimple_stmt_iterator gsi;
103125 + gimple assign;
103126 + tree addxorrol, rhs;
103127 + enum tree_code op;
103128 +
103129 + op = get_op(&rhs);
103130 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
103131 + assign = gimple_build_assign(local_entropy, addxorrol);
103132 + gsi = gsi_after_labels(bb);
103133 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
103134 + update_stmt(assign);
103135 +//debug_bb(bb);
103136 +}
103137 +
103138 +static void perturb_latent_entropy(basic_block bb, tree rhs)
103139 +{
103140 + gimple_stmt_iterator gsi;
103141 + gimple assign;
103142 + tree addxorrol, temp;
103143 +
103144 + // 1. create temporary copy of latent_entropy
103145 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
103146 +#if BUILDING_GCC_VERSION <= 4007
103147 + add_referenced_var(temp);
103148 +#endif
103149 +
103150 + // 2. read...
103151 + temp = make_ssa_name(temp, NULL);
103152 + assign = gimple_build_assign(temp, latent_entropy_decl);
103153 + SSA_NAME_DEF_STMT(temp) = assign;
103154 +#if BUILDING_GCC_VERSION <= 4007
103155 + add_referenced_var(latent_entropy_decl);
103156 +#endif
103157 + gsi = gsi_after_labels(bb);
103158 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
103159 + update_stmt(assign);
103160 +
103161 + // 3. ...modify...
103162 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
103163 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
103164 + assign = gimple_build_assign(temp, addxorrol);
103165 + SSA_NAME_DEF_STMT(temp) = assign;
103166 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
103167 + update_stmt(assign);
103168 +
103169 + // 4. ...write latent_entropy
103170 + assign = gimple_build_assign(latent_entropy_decl, temp);
103171 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
103172 + update_stmt(assign);
103173 +}
103174 +
103175 +static unsigned int execute_latent_entropy(void)
103176 +{
103177 + basic_block bb;
103178 + gimple assign;
103179 + gimple_stmt_iterator gsi;
103180 + tree local_entropy;
103181 +
103182 + if (!latent_entropy_decl) {
103183 + struct varpool_node *node;
103184 +
103185 +#if BUILDING_GCC_VERSION <= 4007
103186 + for (node = varpool_nodes; node; node = node->next) {
103187 + tree var = node->decl;
103188 +#else
103189 + FOR_EACH_VARIABLE(node) {
103190 + tree var = node->symbol.decl;
103191 +#endif
103192 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
103193 + continue;
103194 + latent_entropy_decl = var;
103195 +// debug_tree(var);
103196 + break;
103197 + }
103198 + if (!latent_entropy_decl) {
103199 +// debug_tree(current_function_decl);
103200 + return 0;
103201 + }
103202 + }
103203 +
103204 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
103205 +
103206 + // 1. create local entropy variable
103207 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
103208 +#if BUILDING_GCC_VERSION <= 4007
103209 + add_referenced_var(local_entropy);
103210 + mark_sym_for_renaming(local_entropy);
103211 +#endif
103212 +
103213 + // 2. initialize local entropy variable
103214 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103215 + if (dom_info_available_p(CDI_DOMINATORS))
103216 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103217 + gsi = gsi_start_bb(bb);
103218 +
103219 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
103220 +// gimple_set_location(assign, loc);
103221 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
103222 + update_stmt(assign);
103223 +//debug_bb(bb);
103224 + bb = bb->next_bb;
103225 +
103226 + // 3. instrument each BB with an operation on the local entropy variable
103227 + while (bb != EXIT_BLOCK_PTR) {
103228 + perturb_local_entropy(bb, local_entropy);
103229 +//debug_bb(bb);
103230 + bb = bb->next_bb;
103231 + };
103232 +
103233 + // 4. mix local entropy into the global entropy variable
103234 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
103235 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
103236 + return 0;
103237 +}
103238 +
103239 +static void start_unit_callback(void *gcc_data, void *user_data)
103240 +{
103241 + tree latent_entropy_type;
103242 +
103243 +#if BUILDING_GCC_VERSION >= 4007
103244 + seed = get_random_seed(false);
103245 +#else
103246 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
103247 + seed *= seed;
103248 +#endif
103249 +
103250 + if (in_lto_p)
103251 + return;
103252 +
103253 + // extern volatile u64 latent_entropy
103254 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
103255 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
103256 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
103257 +
103258 + TREE_STATIC(latent_entropy_decl) = 1;
103259 + TREE_PUBLIC(latent_entropy_decl) = 1;
103260 + TREE_USED(latent_entropy_decl) = 1;
103261 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
103262 + DECL_EXTERNAL(latent_entropy_decl) = 1;
103263 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
103264 + lang_hooks.decls.pushdecl(latent_entropy_decl);
103265 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
103266 +// varpool_finalize_decl(latent_entropy_decl);
103267 +// varpool_mark_needed_node(latent_entropy_decl);
103268 +}
103269 +
103270 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103271 +{
103272 + const char * const plugin_name = plugin_info->base_name;
103273 + struct register_pass_info latent_entropy_pass_info = {
103274 + .pass = &latent_entropy_pass.pass,
103275 + .reference_pass_name = "optimized",
103276 + .ref_pass_instance_number = 1,
103277 + .pos_op = PASS_POS_INSERT_BEFORE
103278 + };
103279 +
103280 + if (!plugin_default_version_check(version, &gcc_version)) {
103281 + error(G_("incompatible gcc/plugin versions"));
103282 + return 1;
103283 + }
103284 +
103285 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
103286 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
103287 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
103288 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103289 +
103290 + return 0;
103291 +}
103292 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
103293 new file mode 100644
103294 index 0000000..3d6cc0f
103295 --- /dev/null
103296 +++ b/tools/gcc/size_overflow_hash.data
103297 @@ -0,0 +1,7743 @@
103298 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
103299 +ocfs2_get_refcount_tree_3 ocfs2_get_refcount_tree 0 3 NULL
103300 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
103301 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
103302 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
103303 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
103304 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
103305 +padzero_55 padzero 1 55 &sel_read_policyvers_55
103306 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
103307 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
103308 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
103309 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
103310 +load_msg_95 load_msg 2 95 NULL
103311 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
103312 +write_all_supers_117 write_all_supers 0 117 NULL nohasharray
103313 +ipath_verbs_send_117 ipath_verbs_send 5-3 117 &write_all_supers_117
103314 +init_q_132 init_q 4 132 NULL
103315 +ocfs2_local_alloc_slide_window_134 ocfs2_local_alloc_slide_window 0 134 NULL
103316 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
103317 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
103318 +ping_v6_sendmsg_152 ping_v6_sendmsg 4 152 NULL
103319 +ext4_ext_get_actual_len_153 ext4_ext_get_actual_len 0 153 NULL nohasharray
103320 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 &ext4_ext_get_actual_len_153
103321 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
103322 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
103323 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
103324 +device_add_bin_attributes_205 device_add_bin_attributes 0 205 NULL
103325 +br_port_info_size_268 br_port_info_size 0 268 NULL
103326 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
103327 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
103328 +SYSC_connect_304 SYSC_connect 3 304 NULL
103329 +syslog_print_307 syslog_print 2 307 NULL
103330 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
103331 +next_node_allowed_318 next_node_allowed 1-0 318 NULL
103332 +mlx5_core_access_reg_361 mlx5_core_access_reg 5-3 361 NULL
103333 +xfs_get_blocks_364 xfs_get_blocks 2 364 NULL
103334 +get_more_blocks_367 get_more_blocks 0 367 NULL
103335 +sysfs_create_dir_398 sysfs_create_dir 0 398 NULL
103336 +hw_device_state_409 hw_device_state 0 409 NULL
103337 +aio_read_events_ring_410 aio_read_events_ring 3 410 NULL
103338 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
103339 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
103340 +sparse_index_init_482 sparse_index_init 2 482 NULL
103341 +cfs_trace_set_debug_mb_usrstr_486 cfs_trace_set_debug_mb_usrstr 2 486 NULL
103342 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
103343 +iwl_dbgfs_protection_mode_write_502 iwl_dbgfs_protection_mode_write 3 502 NULL
103344 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
103345 +_snd_pcm_hw_param_first_516 _snd_pcm_hw_param_first 0 516 NULL
103346 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
103347 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
103348 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
103349 +sco_sock_setsockopt_552 sco_sock_setsockopt 5 552 NULL
103350 +lpfc_nlp_state_name_556 lpfc_nlp_state_name 2 556 NULL
103351 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
103352 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
103353 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
103354 +ocfs2_refcounted_xattr_delete_need_584 ocfs2_refcounted_xattr_delete_need 0 584 NULL
103355 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
103356 +cl_page_own0_599 cl_page_own0 0 599 NULL
103357 +btrfs_stack_file_extent_offset_607 btrfs_stack_file_extent_offset 0 607 NULL
103358 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
103359 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
103360 +ptlrpc_lprocfs_nrs_seq_write_621 ptlrpc_lprocfs_nrs_seq_write 3 621 NULL
103361 +viafb_dfpl_proc_write_627 viafb_dfpl_proc_write 3 627 NULL
103362 +ocfs2_num_free_extents_632 ocfs2_num_free_extents 0 632 NULL
103363 +clone_split_bio_633 clone_split_bio 6 633 NULL
103364 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
103365 +remap_to_cache_640 remap_to_cache 3 640 NULL
103366 +cfs_hash_bkt_size_643 cfs_hash_bkt_size 0 643 NULL nohasharray
103367 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 &cfs_hash_bkt_size_643
103368 +unlink_queued_645 unlink_queued 4 645 NULL
103369 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
103370 +div_u64_rem_672 div_u64_rem 0 672 NULL
103371 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
103372 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
103373 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
103374 +disk_max_parts_719 disk_max_parts 0 719 NULL
103375 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
103376 +dvb_video_write_754 dvb_video_write 3 754 NULL
103377 +cfs_trace_allocate_string_buffer_781 cfs_trace_allocate_string_buffer 2 781 NULL
103378 +jbd2_journal_dirty_metadata_784 jbd2_journal_dirty_metadata 0 784 NULL
103379 +ath6kl_disconnect_timeout_write_794 ath6kl_disconnect_timeout_write 3 794 NULL
103380 +__vmalloc_node_range_811 __vmalloc_node_range 7 811 NULL nohasharray
103381 +snd_pcm_drain_811 snd_pcm_drain 0 811 &__vmalloc_node_range_811
103382 +if_writecmd_815 if_writecmd 2 815 NULL
103383 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
103384 +SyS_write_846 SyS_write 3 846 NULL
103385 +um_idi_read_850 um_idi_read 3 850 NULL
103386 +error_state_read_859 error_state_read 6 859 NULL
103387 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
103388 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
103389 +intel_alloc_iova_883 intel_alloc_iova 3 883 NULL
103390 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
103391 +readw_931 readw 0 931 NULL
103392 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
103393 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
103394 +bnx2x_fill_fw_str_968 bnx2x_fill_fw_str 3 968 NULL
103395 +memcmp_990 memcmp 0 990 NULL
103396 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL
103397 +free_ind_block_999 free_ind_block 0 999 NULL
103398 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
103399 +readreg_1017 readreg 0-1 1017 NULL
103400 +_do_truncate_1019 _do_truncate 2 1019 NULL
103401 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
103402 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
103403 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
103404 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
103405 +ext4_orphan_add_1080 ext4_orphan_add 0 1080 NULL
103406 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
103407 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
103408 +inode_ref_info_1094 inode_ref_info 0 1094 NULL nohasharray
103409 +llc_mac_hdr_init_1094 llc_mac_hdr_init 0 1094 &inode_ref_info_1094
103410 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
103411 +utf8s_to_utf16s_1115 utf8s_to_utf16s 0 1115 NULL
103412 +__btrfs_cow_block_1125 __btrfs_cow_block 7-0 1125 NULL nohasharray
103413 +__ext4_journal_stop_1125 __ext4_journal_stop 0 1125 &__btrfs_cow_block_1125
103414 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
103415 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
103416 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
103417 +find_free_extent_1173 find_free_extent 4-0 1173 NULL
103418 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
103419 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
103420 +pstore_ftrace_knob_write_1198 pstore_ftrace_knob_write 3 1198 NULL
103421 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
103422 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
103423 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
103424 +lov_ost_pool_init_1215 lov_ost_pool_init 2 1215 NULL
103425 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
103426 +nested_get_page_1252 nested_get_page 2 1252 NULL
103427 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
103428 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
103429 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
103430 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
103431 +SyS_flistxattr_1287 SyS_flistxattr 3 1287 NULL
103432 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
103433 +ocfs2_append_rec_to_path_1321 ocfs2_append_rec_to_path 0 1321 NULL
103434 +ffs_1322 ffs 0 1322 NULL
103435 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL nohasharray
103436 +push_node_left_1327 push_node_left 0 1327 &qlcnic_pci_sriov_configure_1327
103437 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
103438 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
103439 +btrfs_alloc_logged_file_extent_1354 btrfs_alloc_logged_file_extent 0 1354 NULL
103440 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
103441 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
103442 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
103443 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
103444 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
103445 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
103446 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
103447 +SYSC_io_getevents_1392 SYSC_io_getevents 3 1392 NULL
103448 +zone_page_state_1393 zone_page_state 0 1393 NULL
103449 +file_read_actor_1401 file_read_actor 4 1401 NULL
103450 +vb2_vmalloc_alloc_1402 vb2_vmalloc_alloc 2 1402 NULL
103451 +cfs_trace_copyout_string_1416 cfs_trace_copyout_string 2 1416 NULL
103452 +pq_init_1423 pq_init 1 1423 NULL
103453 +init_rs_internal_1436 init_rs_internal 1 1436 NULL
103454 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
103455 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
103456 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
103457 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
103458 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
103459 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
103460 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
103461 +fpregs_set_1497 fpregs_set 4 1497 NULL
103462 +ocfs2_alloc_dinode_update_counts_1507 ocfs2_alloc_dinode_update_counts 0 1507 NULL
103463 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
103464 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
103465 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
103466 +extent_from_logical_1585 extent_from_logical 0 1585 NULL
103467 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
103468 +ipath_ht_handle_hwerrors_1592 ipath_ht_handle_hwerrors 3 1592 NULL
103469 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
103470 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
103471 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
103472 +run_delayed_extent_op_1637 run_delayed_extent_op 0 1637 NULL
103473 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
103474 +qgroup_rescan_init_1664 qgroup_rescan_init 0 1664 NULL
103475 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
103476 +rmap_add_1677 rmap_add 3 1677 NULL
103477 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
103478 +pdu_write_u_1710 pdu_write_u 3 1710 NULL
103479 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL nohasharray
103480 +gfn_to_hva_prot_1711 gfn_to_hva_prot 2 1711 &coda_psdev_write_1711
103481 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
103482 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
103483 +internal_create_group_1733 internal_create_group 0 1733 NULL
103484 +dev_irnet_read_1741 dev_irnet_read 3 1741 NULL
103485 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
103486 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
103487 +cosa_write_1774 cosa_write 3 1774 NULL
103488 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
103489 +__nodelist_scnprintf_1815 __nodelist_scnprintf 4-2-0 1815 NULL
103490 +sb_issue_zeroout_1884 sb_issue_zeroout 3-0 1884 NULL
103491 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
103492 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
103493 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
103494 +uhid_char_read_1920 uhid_char_read 3 1920 NULL
103495 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
103496 +bdev_erase_1933 bdev_erase 3 1933 NULL
103497 +ext3_fiemap_1936 ext3_fiemap 4 1936 NULL
103498 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
103499 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
103500 +read_swap_header_1957 read_swap_header 0 1957 NULL
103501 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
103502 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
103503 +gpio_power_write_1991 gpio_power_write 3 1991 NULL
103504 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
103505 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
103506 +sb_min_blocksize_2004 sb_min_blocksize 0-2 2004 NULL
103507 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
103508 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
103509 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
103510 +ksm_madvise_2012 ksm_madvise 0 2012 NULL
103511 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
103512 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
103513 +BcmCopySection_2035 BcmCopySection 5-0 2035 NULL
103514 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
103515 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
103516 +__generic_copy_from_user_intel_2073 __generic_copy_from_user_intel 0-3 2073 NULL
103517 +diva_set_driver_dbg_mask_2077 diva_set_driver_dbg_mask 0 2077 NULL nohasharray
103518 +alloc_retstack_tasklist_2077 alloc_retstack_tasklist 0 2077 &diva_set_driver_dbg_mask_2077
103519 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
103520 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
103521 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
103522 +audit_expand_2098 audit_expand 0 2098 NULL
103523 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
103524 +shrd128_2106 shrd128 0-1-3-2 2106 NULL
103525 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
103526 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
103527 +enable_read_2117 enable_read 3 2117 NULL
103528 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
103529 +snd_interval_refine_last_2127 snd_interval_refine_last 0 2127 NULL
103530 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
103531 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
103532 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
103533 +__copy_to_user_ll_2157 __copy_to_user_ll 0-3 2157 NULL
103534 +ocfs2_et_sanity_check_2164 ocfs2_et_sanity_check 0 2164 NULL
103535 +_ore_get_io_state_2166 _ore_get_io_state 5-3-4 2166 NULL
103536 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
103537 +picolcd_debug_reset_write_2195 picolcd_debug_reset_write 3 2195 NULL
103538 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
103539 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
103540 +vhci_write_2224 vhci_write 3 2224 NULL
103541 +__ocfs2_journal_access_2241 __ocfs2_journal_access 0 2241 NULL
103542 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
103543 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
103544 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
103545 +do_update_counters_2259 do_update_counters 4 2259 NULL
103546 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
103547 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
103548 +ocfs2_shift_tree_depth_2292 ocfs2_shift_tree_depth 0 2292 NULL
103549 +kvm_clear_guest_page_2308 kvm_clear_guest_page 2-4 2308 NULL
103550 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
103551 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL nohasharray
103552 +hfsplus_find_init_2318 hfsplus_find_init 0 2318 &picolcd_fb_write_2318
103553 +gart_map_page_2325 gart_map_page 4-3 2325 NULL
103554 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
103555 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
103556 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
103557 +SyS_mremap_2367 SyS_mremap 2-3-1-5 2367 NULL
103558 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL nohasharray
103559 +rose_recvmsg_2368 rose_recvmsg 4 2368 &xfs_buf_map_from_irec_2368
103560 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
103561 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
103562 +SYSC_mlock_2415 SYSC_mlock 1-2 2415 NULL
103563 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
103564 +raid1_size_2419 raid1_size 0-2 2419 NULL
103565 +timespec_to_jiffies_timeout_2428 timespec_to_jiffies_timeout 0 2428 NULL
103566 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
103567 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
103568 +wiphy_new_2482 wiphy_new 2 2482 NULL
103569 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
103570 +hfsplus_user_setxattr_2485 hfsplus_user_setxattr 4 2485 NULL
103571 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
103572 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
103573 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
103574 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
103575 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
103576 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
103577 +mdc_max_rpcs_in_flight_seq_write_2594 mdc_max_rpcs_in_flight_seq_write 3 2594 NULL
103578 +slot_bytes_2609 slot_bytes 0 2609 NULL
103579 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
103580 +switch_status_2629 switch_status 5 2629 NULL
103581 +tlv_put_string_2631 tlv_put_string 0 2631 NULL
103582 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
103583 +tcp_xmit_size_goal_2661 tcp_xmit_size_goal 2 2661 NULL
103584 +osc_build_ppga_2670 osc_build_ppga 2 2670 NULL
103585 +ffs_ep0_read_2672 ffs_ep0_read 3 2672 NULL
103586 +ocfs2_rotate_subtree_right_2674 ocfs2_rotate_subtree_right 0 2674 NULL
103587 +oti6858_write_2692 oti6858_write 4 2692 NULL
103588 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
103589 +memcpy_fromiovecend_2707 memcpy_fromiovecend 4-3 2707 NULL
103590 +SyS_pwrite64_2708 SyS_pwrite64 3 2708 NULL nohasharray
103591 +lprocfs_stats_counter_size_2708 lprocfs_stats_counter_size 0 2708 &SyS_pwrite64_2708
103592 +__xip_file_write_2733 __xip_file_write 3-4 2733 NULL
103593 +can_nocow_extent_2744 can_nocow_extent 3 2744 NULL
103594 +xfs_readdir_2767 xfs_readdir 3 2767 NULL
103595 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
103596 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
103597 +__next_cpu_2782 __next_cpu 1-0 2782 NULL
103598 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
103599 +device_add_attrs_2789 device_add_attrs 0 2789 NULL
103600 +iwl_dbgfs_clear_ucode_statistics_write_2804 iwl_dbgfs_clear_ucode_statistics_write 3 2804 NULL
103601 +vmemmap_pte_populate_2822 vmemmap_pte_populate 3 2822 NULL
103602 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
103603 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
103604 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
103605 +sock_create_2838 sock_create 0 2838 NULL
103606 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
103607 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
103608 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
103609 +irnet_ctrl_read_2863 irnet_ctrl_read 4 2863 NULL
103610 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
103611 +mq_map_2871 mq_map 2 2871 NULL
103612 +__swab64p_2875 __swab64p 0 2875 NULL
103613 +nla_padlen_2883 nla_padlen 1 2883 NULL
103614 +cmm_write_2896 cmm_write 3 2896 NULL
103615 +alloc_page_cgroup_2919 alloc_page_cgroup 1-2 2919 NULL
103616 +osc_import_seq_write_2923 osc_import_seq_write 3 2923 NULL
103617 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
103618 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
103619 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
103620 +i40e_dbg_prep_dump_buf_2951 i40e_dbg_prep_dump_buf 2 2951 NULL
103621 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
103622 +free_area_init_core_2962 free_area_init_core 2-3 2962 NULL
103623 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
103624 +ocfs2_find_branch_target_2989 ocfs2_find_branch_target 0 2989 NULL
103625 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
103626 +lov_stripetype_seq_write_3013 lov_stripetype_seq_write 3 3013 NULL
103627 +btrfs_add_block_group_cache_3016 btrfs_add_block_group_cache 0 3016 NULL
103628 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
103629 +depth_write_3021 depth_write 3 3021 NULL
103630 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
103631 +kvm_unmap_hva_3028 kvm_unmap_hva 2 3028 NULL
103632 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
103633 +lpfc_idiag_mbxacc_write_3038 lpfc_idiag_mbxacc_write 3 3038 NULL nohasharray
103634 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 &lpfc_idiag_mbxacc_write_3038
103635 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
103636 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
103637 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
103638 +__blk_end_bidi_request_3070 __blk_end_bidi_request 4-3 3070 NULL
103639 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
103640 +read_file_antenna_diversity_3077 read_file_antenna_diversity 3 3077 NULL
103641 +free_coherent_3082 free_coherent 4-2 3082 NULL
103642 +ocfs2_get_right_path_3097 ocfs2_get_right_path 0 3097 NULL
103643 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
103644 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
103645 +rb_alloc_3102 rb_alloc 1-3 3102 NULL
103646 +simple_write_to_buffer_3122 simple_write_to_buffer 2-5 3122 NULL
103647 +print_time_3132 print_time 0 3132 NULL
103648 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
103649 +find_free_extent_3153 find_free_extent 5 3153 NULL
103650 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
103651 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
103652 +i915_gem_obj_ggtt_offset_3162 i915_gem_obj_ggtt_offset 0 3162 NULL
103653 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
103654 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
103655 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
103656 +wait_table_bits_3187 wait_table_bits 1 3187 NULL
103657 +mempool_create_node_3191 mempool_create_node 1-6 3191 NULL
103658 +alloc_context_3194 alloc_context 1 3194 NULL
103659 +shmem_pread_slow_3198 shmem_pread_slow 3-2 3198 NULL
103660 +codec_reg_write_file_3204 codec_reg_write_file 3 3204 NULL
103661 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
103662 +btrfs_prealloc_file_range_3227 btrfs_prealloc_file_range 3 3227 NULL
103663 +btrfs_next_leaf_3232 btrfs_next_leaf 0 3232 NULL
103664 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
103665 +write_adapter_mem_3234 write_adapter_mem 3 3234 NULL
103666 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
103667 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
103668 +key_key_read_3241 key_key_read 3 3241 NULL
103669 +mmap_piobufs_3244 mmap_piobufs 4 3244 NULL
103670 +did_overwrite_first_ref_3259 did_overwrite_first_ref 0 3259 NULL
103671 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
103672 +__iovec_copy_from_user_inatomic_3314 __iovec_copy_from_user_inatomic 0-4-3 3314 NULL
103673 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
103674 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
103675 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
103676 +sysfs_create_group_3339 sysfs_create_group 0 3339 NULL
103677 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
103678 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
103679 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
103680 +scnprintf_3360 scnprintf 0-2 3360 NULL
103681 +ReadByteAmd7930_3365 ReadByteAmd7930 0 3365 NULL
103682 +sr_read_3366 sr_read 3 3366 NULL
103683 +count_inode_refs_3375 count_inode_refs 0 3375 NULL
103684 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
103685 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
103686 +send_stream_3397 send_stream 4 3397 NULL
103687 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
103688 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
103689 +zone_to_nid_3415 zone_to_nid 0 3415 NULL
103690 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
103691 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
103692 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
103693 +send_unlink_3438 send_unlink 0 3438 NULL
103694 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
103695 +map_single_3449 map_single 0 3449 NULL
103696 +softsynth_write_3455 softsynth_write 3 3455 NULL
103697 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
103698 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 5-4-2 3464 &jffs2_acl_setxattr_3464
103699 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
103700 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
103701 +run_one_delayed_ref_3503 run_one_delayed_ref 0 3503 NULL nohasharray
103702 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 &run_one_delayed_ref_3503
103703 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL
103704 +SyS_semtimedop_3532 SyS_semtimedop 3 3532 NULL
103705 +SyS_readv_3539 SyS_readv 3 3539 NULL
103706 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
103707 +iommu_map_3554 iommu_map 3-2 3554 NULL
103708 +btrfs_delayed_update_inode_3557 btrfs_delayed_update_inode 0 3557 NULL
103709 +i915_gem_execbuffer_reserve_3558 i915_gem_execbuffer_reserve 0 3558 NULL
103710 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
103711 +evtchn_read_3569 evtchn_read 3 3569 NULL
103712 +ll_track_ppid_seq_write_3582 ll_track_ppid_seq_write 3 3582 NULL
103713 +vc_resize_3585 vc_resize 3-2 3585 NULL
103714 +kvm_mmu_notifier_change_pte_3596 kvm_mmu_notifier_change_pte 3 3596 NULL
103715 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
103716 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
103717 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
103718 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
103719 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL
103720 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
103721 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
103722 +replace_pin_at_irq_node_3687 replace_pin_at_irq_node 2 3687 NULL
103723 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0-2 3694 NULL
103724 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
103725 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703
103726 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
103727 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
103728 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
103729 +uar_index2pfn_3741 uar_index2pfn 0-2 3741 NULL
103730 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
103731 +btrfs_alloc_chunk_3808 btrfs_alloc_chunk 0 3808 NULL
103732 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
103733 +llc_ui_recvmsg_3826 llc_ui_recvmsg 4 3826 NULL
103734 +btrfs_uuid_iter_rem_3831 btrfs_uuid_iter_rem 0 3831 NULL
103735 +hfsplus_direct_IO_3835 hfsplus_direct_IO 4 3835 NULL
103736 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
103737 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
103738 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
103739 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
103740 +get_fd_set_3866 get_fd_set 1 3866 NULL
103741 +apei_res_sub_3873 apei_res_sub 0 3873 NULL
103742 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
103743 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
103744 +nvram_write_3894 nvram_write 3 3894 NULL
103745 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
103746 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
103747 +vcs_write_3910 vcs_write 3 3910 NULL
103748 +SyS_move_pages_3920 SyS_move_pages 2 3920 NULL
103749 +hdlc_irq_one_3944 hdlc_irq_one 2 3944 NULL
103750 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
103751 +mite_bytes_written_to_memory_lb_3987 mite_bytes_written_to_memory_lb 0 3987 NULL
103752 +do_add_counters_3992 do_add_counters 3 3992 NULL
103753 +obd_alloc_memmd_4002 obd_alloc_memmd 0 4002 NULL
103754 +userspace_status_4004 userspace_status 4 4004 NULL
103755 +mei_write_4005 mei_write 3 4005 NULL nohasharray
103756 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
103757 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
103758 +mm_populate_4016 mm_populate 1-2 4016 NULL nohasharray
103759 +i915_gem_object_unbind_4016 i915_gem_object_unbind 0 4016 &mm_populate_4016
103760 +blk_end_request_4024 blk_end_request 3 4024 NULL
103761 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
103762 +mtip_hw_read_registers_4037 mtip_hw_read_registers 3 4037 NULL
103763 +i915_gpu_idle_4062 i915_gpu_idle 0 4062 NULL
103764 +vmemmap_pmd_populate_4071 vmemmap_pmd_populate 3 4071 NULL
103765 +read_file_queues_4078 read_file_queues 3 4078 NULL
103766 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
103767 +btrfs_inc_ref_4084 btrfs_inc_ref 0 4084 NULL
103768 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
103769 +tm6000_read_4151 tm6000_read 3 4151 NULL
103770 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
103771 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
103772 +get_alua_req_4166 get_alua_req 3 4166 NULL
103773 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
103774 +read_file_bool_4180 read_file_bool 3 4180 NULL
103775 +ocfs2_find_cpos_for_right_leaf_4194 ocfs2_find_cpos_for_right_leaf 0 4194 NULL
103776 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
103777 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
103778 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
103779 +ath6kl_force_roam_write_4282 ath6kl_force_roam_write 3 4282 NULL
103780 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
103781 +msb_do_write_request_4286 msb_do_write_request 2 4286 NULL
103782 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
103783 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
103784 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
103785 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
103786 +__pool_find_4308 __pool_find 3 4308 NULL
103787 +count_strings_4315 count_strings 0 4315 NULL
103788 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
103789 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
103790 +kvm_apic_get_reg_4354 kvm_apic_get_reg 0 4354 NULL
103791 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 0-3 4365 NULL nohasharray
103792 +lookup_string_4365 lookup_string 0 4365 &__copy_from_user_inatomic_4365
103793 +btrfs_set_disk_extent_flags_4374 btrfs_set_disk_extent_flags 0 4374 NULL
103794 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
103795 +access_process_vm_4412 access_process_vm 0-4-2 4412 NULL nohasharray
103796 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
103797 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
103798 +rtw_android_get_rssi_4421 rtw_android_get_rssi 0 4421 NULL
103799 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
103800 +memparse_4444 memparse 0 4444 NULL
103801 +tcp_dma_try_early_copy_4457 tcp_dma_try_early_copy 3 4457 NULL
103802 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
103803 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 5-0 4481 NULL
103804 +ocfs2_grow_tree_4492 ocfs2_grow_tree 0 4492 NULL
103805 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
103806 +set_link_security_4502 set_link_security 4 4502 NULL
103807 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
103808 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2-0 4530 NULL
103809 +ll_max_readahead_per_file_mb_seq_write_4531 ll_max_readahead_per_file_mb_seq_write 3 4531 NULL
103810 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
103811 +tty_register_device_4544 tty_register_device 2 4544 NULL
103812 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
103813 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
103814 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
103815 +iommu_map_page_4588 iommu_map_page 5 4588 NULL
103816 +bch_alloc_4593 bch_alloc 1 4593 NULL
103817 +ocfs2_refcount_lock_4595 ocfs2_refcount_lock 0 4595 NULL
103818 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
103819 +ll_rw_extents_stats_seq_write_4633 ll_rw_extents_stats_seq_write 3 4633 NULL
103820 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
103821 +ext3_orphan_add_4665 ext3_orphan_add 0 4665 NULL
103822 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
103823 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
103824 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
103825 +kone_receive_4690 kone_receive 4 4690 NULL
103826 +link_to_fixup_dir_4699 link_to_fixup_dir 0 4699 NULL
103827 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
103828 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
103829 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
103830 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
103831 +gfs2_bit_search_4728 gfs2_bit_search 0-2 4728 NULL
103832 +ll_rw_offset_stats_seq_write_4736 ll_rw_offset_stats_seq_write 3 4736 NULL nohasharray
103833 +bitmap_startwrite_4736 bitmap_startwrite 2 4736 &ll_rw_offset_stats_seq_write_4736
103834 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
103835 +lu_buf_alloc_4753 lu_buf_alloc 2 4753 NULL
103836 +find_next_best_node_4774 find_next_best_node 1-0 4774 NULL nohasharray
103837 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 &find_next_best_node_4774
103838 +btrfs_del_items_4791 btrfs_del_items 0 4791 NULL nohasharray
103839 +create_subvol_4791 create_subvol 4 4791 &btrfs_del_items_4791
103840 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
103841 +repair_io_failure_4815 repair_io_failure 4-3 4815 NULL
103842 +comedi_buf_write_free_4847 comedi_buf_write_free 2 4847 NULL
103843 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
103844 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
103845 +get_new_location_4866 get_new_location 0 4866 NULL
103846 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3-2 4873 NULL
103847 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
103848 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
103849 +ntfs_rl_insert_4931 ntfs_rl_insert 4-2 4931 NULL
103850 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
103851 +ocfs2_should_refresh_lock_res_4958 ocfs2_should_refresh_lock_res 0 4958 NULL
103852 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
103853 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
103854 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
103855 +do_sync_read_4977 do_sync_read 0 4977 NULL
103856 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
103857 +compat_SyS_ipc_5000 compat_SyS_ipc 3 5000 NULL
103858 +do_mincore_5018 do_mincore 0-2-1 5018 NULL
103859 +btrfs_punch_hole_5041 btrfs_punch_hole 2 5041 NULL
103860 +cfg80211_rx_mgmt_5056 cfg80211_rx_mgmt 5 5056 NULL
103861 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 3-2 5066 NULL
103862 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
103863 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
103864 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
103865 +kfifo_copy_from_user_5091 kfifo_copy_from_user 4-3-0 5091 &get_random_bytes_5091 nohasharray
103866 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
103867 +sound_write_5102 sound_write 3 5102 NULL
103868 +clear_dirty_5105 clear_dirty 3 5105 NULL
103869 +i40e_dbg_netdev_ops_write_5117 i40e_dbg_netdev_ops_write 3 5117 NULL
103870 +qib_7220_handle_hwerrors_5142 qib_7220_handle_hwerrors 3 5142 NULL
103871 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
103872 +ocfs2_inode_lock_full_nested_5148 ocfs2_inode_lock_full_nested 0 5148 NULL
103873 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
103874 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
103875 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
103876 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL nohasharray
103877 +r600_mip_minify_5214 r600_mip_minify 2-1-0 5214 &ppp_cp_parse_cr_5214
103878 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
103879 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
103880 +nouveau_fb_create__5244 nouveau_fb_create_ 5 5244 NULL
103881 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
103882 +btrfs_alloc_reserved_file_extent_5274 btrfs_alloc_reserved_file_extent 0 5274 NULL
103883 +iommu_domain_identity_map_5284 iommu_domain_identity_map 2-3 5284 NULL
103884 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
103885 +usb_descriptor_fillbuf_5302 usb_descriptor_fillbuf 0 5302 NULL
103886 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
103887 +r592_write_fifo_pio_5315 r592_write_fifo_pio 3 5315 NULL
103888 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
103889 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
103890 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
103891 +vm_insert_pfn_5341 vm_insert_pfn 3-0 5341 NULL
103892 +cq_free_res_5355 cq_free_res 5 5355 NULL
103893 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
103894 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 2-3 5368 NULL
103895 +kvm_pin_pages_5369 kvm_pin_pages 2-0 5369 NULL
103896 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
103897 +security_inode_init_security_5408 security_inode_init_security 0 5408 NULL
103898 +__resolve_indirect_refs_5409 __resolve_indirect_refs 0 5409 NULL
103899 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
103900 +check_item_in_log_5440 check_item_in_log 0 5440 NULL
103901 +__split_bvec_across_targets_5454 __split_bvec_across_targets 3 5454 NULL
103902 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
103903 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
103904 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
103905 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
103906 +tty_write_5494 tty_write 3 5494 NULL
103907 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
103908 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
103909 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
103910 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
103911 +iommu_prepare_identity_map_5540 iommu_prepare_identity_map 2-3 5540 NULL
103912 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
103913 +le_readq_5557 le_readq 0 5557 NULL
103914 +inw_5558 inw 0 5558 NULL
103915 +bioset_create_5580 bioset_create 1 5580 NULL
103916 +domain_sg_mapping_5586 domain_sg_mapping 4 5586 NULL
103917 +oz_ep_alloc_5587 oz_ep_alloc 1 5587 NULL
103918 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
103919 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
103920 +SYSC_init_module_5626 SYSC_init_module 2 5626 NULL
103921 +iterate_extent_inodes_5631 iterate_extent_inodes 0 5631 NULL
103922 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
103923 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
103924 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
103925 +kgdb_arch_pc_5673 kgdb_arch_pc 0 5673 NULL
103926 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
103927 +get_arg_5694 get_arg 3 5694 NULL
103928 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
103929 +ntfs_attr_record_resize_5720 ntfs_attr_record_resize 0 5720 NULL
103930 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
103931 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
103932 +ubi_calc_fm_size_5749 ubi_calc_fm_size 0 5749 NULL
103933 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
103934 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
103935 +nvme_trans_bdev_char_page_5797 nvme_trans_bdev_char_page 3 5797 NULL
103936 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
103937 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
103938 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
103939 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
103940 +setup_req_5848 setup_req 3 5848 NULL
103941 +ria_page_count_5849 ria_page_count 0 5849 NULL
103942 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
103943 +config_buf_5862 config_buf 0 5862 NULL
103944 +ext4_ext_correct_indexes_5865 ext4_ext_correct_indexes 0 5865 NULL
103945 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
103946 +scan_bitmap_5888 scan_bitmap 3 5888 NULL
103947 +lprocfs_fid_width_seq_write_5889 lprocfs_fid_width_seq_write 3 5889 NULL
103948 +port_show_regs_5904 port_show_regs 3 5904 NULL
103949 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
103950 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
103951 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
103952 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
103953 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
103954 +find_parent_nodes_5948 find_parent_nodes 0 5948 NULL
103955 +ll_statahead_one_5962 ll_statahead_one 3 5962 NULL
103956 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
103957 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
103958 +native_pte_val_5978 native_pte_val 0 5978 NULL
103959 +jbd2_journal_stop_5979 jbd2_journal_stop 0 5979 NULL
103960 +ntfs_rl_append_6037 ntfs_rl_append 4-2 6037 NULL
103961 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL nohasharray
103962 +device_add_attributes_6058 device_add_attributes 0 6058 &da9052_request_irq_6058
103963 +alloc_msg_6072 alloc_msg 1 6072 NULL
103964 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
103965 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
103966 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
103967 +finish_inode_if_needed_6098 finish_inode_if_needed 0 6098 NULL
103968 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
103969 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
103970 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
103971 +__btrfs_commit_inode_delayed_items_6150 __btrfs_commit_inode_delayed_items 0 6150 NULL
103972 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
103973 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
103974 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
103975 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
103976 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
103977 +SyS_setgroups_6182 SyS_setgroups 1 6182 NULL
103978 +__add_pin_to_irq_node_6188 __add_pin_to_irq_node 2 6188 NULL
103979 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
103980 +cl_sync_io_wait_6196 cl_sync_io_wait 0 6196 NULL
103981 +i915_gem_execbuffer_move_to_gpu_6197 i915_gem_execbuffer_move_to_gpu 0 6197 NULL
103982 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
103983 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
103984 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
103985 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
103986 +changed_ref_6242 changed_ref 0 6242 NULL
103987 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
103988 +ext4_ext_split_6249 ext4_ext_split 0 6249 NULL
103989 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
103990 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
103991 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3-0 6282 NULL nohasharray
103992 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
103993 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
103994 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
103995 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
103996 +exclude_super_stripes_6326 exclude_super_stripes 0 6326 NULL
103997 +SyS_mincore_6329 SyS_mincore 2-1 6329 NULL nohasharray
103998 +hfa384x_inw_6329 hfa384x_inw 0 6329 &SyS_mincore_6329
103999 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
104000 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
104001 +utc2ntfs_6347 utc2ntfs 0 6347 NULL
104002 +regcache_sync_block_raw_6350 regcache_sync_block_raw 5-4 6350 NULL
104003 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
104004 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
104005 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
104006 +msb_write_block_6379 msb_write_block 3 6379 NULL
104007 +BcmFlash2xBulkRead_6395 BcmFlash2xBulkRead 0 6395 NULL
104008 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
104009 +add_transaction_credits_6422 add_transaction_credits 2-3 6422 NULL
104010 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
104011 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
104012 +add_to_list_6433 add_to_list 0 6433 NULL
104013 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
104014 +i915_gem_object_wait_rendering_6446 i915_gem_object_wait_rendering 0 6446 NULL
104015 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL
104016 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
104017 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 5-4 6479 NULL
104018 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
104019 +ntfs_cluster_free_6497 ntfs_cluster_free 0 6497 NULL
104020 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
104021 +mei_read_6507 mei_read 3 6507 NULL
104022 +__start_delalloc_inodes_6528 __start_delalloc_inodes 0 6528 NULL
104023 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
104024 +wdm_read_6549 wdm_read 3 6549 NULL
104025 +dm_stats_create_6551 dm_stats_create 4-2-3 6551 NULL
104026 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
104027 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
104028 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
104029 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
104030 +btrfs_start_all_delalloc_inodes_6596 btrfs_start_all_delalloc_inodes 0 6596 NULL
104031 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
104032 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
104033 +xfs_do_div_6649 xfs_do_div 0-2 6649 NULL
104034 +journal_dirty_metadata_6658 journal_dirty_metadata 0 6658 NULL
104035 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
104036 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2-3-0 6696 NULL
104037 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
104038 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
104039 +mpeg_read_6708 mpeg_read 3 6708 NULL
104040 +ibmpex_query_sensor_count_6709 ibmpex_query_sensor_count 0 6709 NULL
104041 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
104042 +video_proc_write_6724 video_proc_write 3 6724 NULL
104043 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
104044 +ocfs2_insert_extent_6737 ocfs2_insert_extent 0 6737 NULL
104045 +btrfs_inode_delayed_dir_index_count_6759 btrfs_inode_delayed_dir_index_count 0 6759 NULL
104046 +kobject_add_varg_6781 kobject_add_varg 0 6781 NULL
104047 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
104048 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
104049 +zone_spanned_pages_in_node_6787 zone_spanned_pages_in_node 0-3-4 6787 NULL
104050 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
104051 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
104052 +ocfs2_calc_refcount_meta_credits_6802 ocfs2_calc_refcount_meta_credits 0 6802 NULL
104053 +lbs_rdrf_write_6826 lbs_rdrf_write 3 6826 NULL
104054 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
104055 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
104056 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
104057 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
104058 +ecryptfs_write_lower_6870 ecryptfs_write_lower 4 6870 NULL
104059 +dio_complete_6879 dio_complete 0-2-3 6879 NULL
104060 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
104061 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
104062 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
104063 +ext4_inode_bitmap_6902 ext4_inode_bitmap 0 6902 NULL
104064 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
104065 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
104066 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
104067 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
104068 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
104069 +__vxge_hw_mempool_create_6923 __vxge_hw_mempool_create 3-2-6 6923 NULL
104070 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
104071 +ipath_verbs_send_dma_6929 ipath_verbs_send_dma 6 6929 NULL
104072 +qsfp_cks_6945 qsfp_cks 2-0 6945 NULL
104073 +tg3_nvram_write_block_unbuffered_6955 tg3_nvram_write_block_unbuffered 3 6955 NULL
104074 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
104075 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
104076 +i40e_dbg_dump_write_6973 i40e_dbg_dump_write 3 6973 NULL nohasharray
104077 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 &i40e_dbg_dump_write_6973
104078 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
104079 +request_key_async_6990 request_key_async 4 6990 NULL
104080 +tpl_write_6998 tpl_write 3 6998 NULL
104081 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
104082 +log_wait_commit_7005 log_wait_commit 0 7005 NULL
104083 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
104084 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
104085 +ld_usb_write_7022 ld_usb_write 3 7022 NULL
104086 +wimax_msg_7030 wimax_msg 4 7030 NULL
104087 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
104088 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
104089 +hci_sock_recvmsg_7072 hci_sock_recvmsg 4 7072 NULL
104090 +event_enable_read_7074 event_enable_read 3 7074 NULL
104091 +ip_vs_sync_conn_7075 ip_vs_sync_conn 3 7075 NULL
104092 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
104093 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
104094 +check_header_7108 check_header 0 7108 NULL
104095 +osc_resend_count_seq_write_7120 osc_resend_count_seq_write 3 7120 NULL
104096 +qib_format_hwerrors_7133 qib_format_hwerrors 5 7133 NULL
104097 +kvm_mmu_notifier_test_young_7139 kvm_mmu_notifier_test_young 3 7139 NULL
104098 +ipv6_recv_rxpmtu_7142 ipv6_recv_rxpmtu 3 7142 NULL
104099 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
104100 +ocfs2_get_left_path_7159 ocfs2_get_left_path 0 7159 NULL
104101 +core_alua_write_tpg_metadata_7168 core_alua_write_tpg_metadata 3 7168 NULL
104102 +ext3_xattr_ibody_list_7201 ext3_xattr_ibody_list 3-0 7201 NULL
104103 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
104104 +get_param_h_7247 get_param_h 0 7247 NULL
104105 +af_alg_make_sg_7254 af_alg_make_sg 3-0 7254 NULL
104106 +hdlc_loop_7255 hdlc_loop 0 7255 NULL
104107 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
104108 +snd_mask_refine_7267 snd_mask_refine 0 7267 NULL
104109 +f_midi_start_ep_7270 f_midi_start_ep 0 7270 NULL
104110 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5-0 7272 NULL
104111 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
104112 +get_string_7302 get_string 0 7302 NULL
104113 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
104114 +wait_on_sync_kiocb_7327 wait_on_sync_kiocb 0 7327 NULL
104115 +mgmt_control_7349 mgmt_control 3 7349 NULL
104116 +max8998_irq_domain_map_7359 max8998_irq_domain_map 2 7359 NULL
104117 +i915_gem_do_execbuffer_7362 i915_gem_do_execbuffer 0 7362 NULL nohasharray
104118 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 &i915_gem_do_execbuffer_7362
104119 +at_est2timeout_7365 at_est2timeout 0-1 7365 NULL
104120 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
104121 +schedule_timeout_7371 schedule_timeout 0 7371 NULL
104122 +ath10k_read_fw_stats_7387 ath10k_read_fw_stats 3 7387 NULL
104123 +hweight_long_7388 hweight_long 1-0 7388 NULL
104124 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
104125 +_ore_add_stripe_unit_7399 _ore_add_stripe_unit 6-3 7399 NULL
104126 +readb_7401 readb 0 7401 NULL
104127 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
104128 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
104129 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
104130 +rt2x00debug_read_queue_stats_7455 rt2x00debug_read_queue_stats 3 7455 NULL
104131 +l2tp_ip6_sendmsg_7461 l2tp_ip6_sendmsg 4 7461 NULL
104132 +ReadHSCX_7471 ReadHSCX 0 7471 NULL nohasharray
104133 +garp_request_join_7471 garp_request_join 4 7471 &ReadHSCX_7471
104134 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
104135 +iwl_mvm_power_dbgfs_read_7502 iwl_mvm_power_dbgfs_read 0 7502 NULL
104136 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
104137 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
104138 +array_zalloc_7519 array_zalloc 2-1 7519 NULL
104139 +btrfs_insert_xattr_item_7545 btrfs_insert_xattr_item 0 7545 NULL
104140 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
104141 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
104142 +cfs_cpt_num_estimate_7571 cfs_cpt_num_estimate 0 7571 NULL
104143 +ext4_ext_insert_extent_7576 ext4_ext_insert_extent 0 7576 NULL
104144 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3-0 7579 NULL
104145 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3-0 7590 NULL
104146 +ocfs2_lock_create_7612 ocfs2_lock_create 0 7612 NULL
104147 +create_dir_7614 create_dir 0 7614 NULL nohasharray
104148 +groups_alloc_7614 groups_alloc 1 7614 &create_dir_7614
104149 +_rtw_zmalloc_7636 _rtw_zmalloc 1 7636 NULL
104150 +fault_inject_write_7662 fault_inject_write 3 7662 NULL
104151 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 1-2 7685 NULL
104152 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
104153 +dev_write_7708 dev_write 3 7708 NULL
104154 +unmap_region_7709 unmap_region 1 7709 NULL
104155 +dbg_check_cats_7713 dbg_check_cats 0 7713 NULL
104156 +pci_raw_set_power_state_7729 pci_raw_set_power_state 0 7729 NULL
104157 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
104158 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
104159 +paths_from_inode_7774 paths_from_inode 0 7774 NULL
104160 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
104161 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
104162 +bnx2_nvram_write_7790 bnx2_nvram_write 2-4 7790 NULL
104163 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL nohasharray
104164 +lustre_packed_msg_size_7792 lustre_packed_msg_size 0 7792 &diva_os_copy_from_user_7792
104165 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
104166 +cfs_trace_dump_debug_buffer_usrstr_7861 cfs_trace_dump_debug_buffer_usrstr 2 7861 NULL
104167 +tipc_alloc_entry_7875 tipc_alloc_entry 2 7875 NULL
104168 +btrfs_find_space_for_alloc_7876 btrfs_find_space_for_alloc 2 7876 NULL
104169 +config_desc_7878 config_desc 0 7878 NULL
104170 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
104171 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
104172 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
104173 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
104174 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
104175 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1-2 7934 NULL
104176 +compare_refs_7938 compare_refs 0 7938 NULL
104177 +fsnotify_7943 fsnotify 0 7943 NULL
104178 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
104179 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
104180 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
104181 +bch_btree_to_text_7960 bch_btree_to_text 2 7960 NULL
104182 +fixup_inode_link_count_8002 fixup_inode_link_count 0 8002 NULL
104183 +extend_or_restart_transaction_8008 extend_or_restart_transaction 0 8008 NULL
104184 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
104185 +vcs_read_8017 vcs_read 3 8017 NULL
104186 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
104187 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
104188 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
104189 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
104190 +spi_write_then_read_8073 spi_write_then_read 5-3 8073 NULL
104191 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
104192 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
104193 +ext4_ext_map_blocks_8078 ext4_ext_map_blocks 0 8078 NULL
104194 +venus_lookup_8121 venus_lookup 4 8121 NULL
104195 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
104196 +xfs_iomap_prealloc_size_8141 xfs_iomap_prealloc_size 3 8141 NULL
104197 +dma_map_area_8178 dma_map_area 3-2-5-0 8178 NULL
104198 +ore_truncate_8181 ore_truncate 3 8181 NULL
104199 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
104200 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
104201 +update_cowonly_root_8200 update_cowonly_root 0 8200 NULL
104202 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
104203 +__ocfs2_lock_refcount_tree_8207 __ocfs2_lock_refcount_tree 0 8207 NULL
104204 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
104205 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
104206 +play_iframe_8219 play_iframe 3 8219 NULL
104207 +create_log_8225 create_log 2 8225 NULL nohasharray
104208 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
104209 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
104210 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
104211 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
104212 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
104213 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
104214 +init_cdev_8274 init_cdev 1 8274 NULL
104215 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
104216 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
104217 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
104218 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
104219 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
104220 +cfs_cpt_spread_node_8338 cfs_cpt_spread_node 0 8338 NULL
104221 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
104222 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
104223 +generic_write_sync_8358 generic_write_sync 0 8358 NULL
104224 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
104225 +ath6kl_lrssi_roam_write_8362 ath6kl_lrssi_roam_write 3 8362 NULL
104226 +ocfs2_decrease_refcount_rec_8385 ocfs2_decrease_refcount_rec 0 8385 NULL
104227 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
104228 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
104229 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
104230 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
104231 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
104232 +irq_create_mapping_8437 irq_create_mapping 2-0 8437 NULL
104233 +generic_bin_search_8440 generic_bin_search 0 8440 NULL
104234 +ring_wait_for_space_8457 ring_wait_for_space 0 8457 NULL
104235 +dir_changed_8471 dir_changed 0 8471 NULL
104236 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
104237 +fore200e_chunk_alloc_8501 fore200e_chunk_alloc 4-3 8501 NULL
104238 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
104239 +dev_config_8506 dev_config 3 8506 NULL
104240 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
104241 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
104242 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
104243 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
104244 +user_on_off_8552 user_on_off 2 8552 NULL
104245 +profile_remove_8556 profile_remove 3 8556 NULL
104246 +remove_extent_backref_8559 remove_extent_backref 0 8559 NULL
104247 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
104248 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
104249 +tower_write_8580 tower_write 3 8580 NULL
104250 +ocfs2_reserve_local_alloc_bits_8581 ocfs2_reserve_local_alloc_bits 0 8581 NULL
104251 +cfs_cpt_number_8618 cfs_cpt_number 0 8618 NULL
104252 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
104253 +iommu_unmap_8624 iommu_unmap 2-0 8624 NULL
104254 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
104255 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
104256 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
104257 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
104258 +mlx5_vzalloc_8663 mlx5_vzalloc 1 8663 NULL
104259 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
104260 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
104261 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
104262 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
104263 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
104264 +arcfb_write_8702 arcfb_write 3 8702 NULL
104265 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
104266 +init_header_8703 init_header 0 8703 &i_size_read_8703
104267 +HDLC_irq_8709 HDLC_irq 2 8709 NULL
104268 +ctrl_out_8712 ctrl_out 5-3 8712 NULL
104269 +__create_free_space_inode_8724 __create_free_space_inode 0 8724 NULL
104270 +tracing_max_lat_write_8728 tracing_max_lat_write 3 8728 NULL
104271 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
104272 +f_dupfd_8730 f_dupfd 1 8730 NULL
104273 +__create_irqs_8733 __create_irqs 2-1-0-3 8733 NULL
104274 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
104275 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
104276 +compound_order_8750 compound_order 0 8750 NULL
104277 +ocfs2_find_path_8754 ocfs2_find_path 0 8754 NULL
104278 +yurex_write_8761 yurex_write 3 8761 NULL
104279 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
104280 +x32_arch_ptrace_8767 x32_arch_ptrace 3 8767 NULL
104281 +kstrtoint_from_user_8778 kstrtoint_from_user 2 8778 NULL
104282 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
104283 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
104284 +aligned_nrpages_8791 aligned_nrpages 0-1-2 8791 NULL
104285 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
104286 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
104287 +intel_ring_begin_8808 intel_ring_begin 0 8808 NULL
104288 +ntfs_commit_pages_after_write_8809 ntfs_commit_pages_after_write 4-3 8809 NULL
104289 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
104290 +SyS_llistxattr_8824 SyS_llistxattr 3 8824 NULL
104291 +get_queue_depth_8833 get_queue_depth 0 8833 NULL
104292 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
104293 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
104294 +clear_bitset_8840 clear_bitset 2 8840 NULL
104295 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
104296 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
104297 +sk_memory_allocated_8882 sk_memory_allocated 0 8882 NULL
104298 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
104299 +ab3100_get_set_reg_8890 ab3100_get_set_reg 3 8890 NULL nohasharray
104300 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 &ab3100_get_set_reg_8890
104301 +xfs_contig_bits_8904 xfs_contig_bits 3-0 8904 NULL
104302 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
104303 +sysfs_merge_group_8917 sysfs_merge_group 0 8917 NULL
104304 +write_file_ani_8918 write_file_ani 3 8918 NULL
104305 +layout_commit_8926 layout_commit 3 8926 NULL
104306 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
104307 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
104308 +lookup_zone_8956 lookup_zone 2 8956 NULL
104309 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
104310 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
104311 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
104312 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
104313 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
104314 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
104315 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
104316 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
104317 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3-8 8986 NULL
104318 +jbd2_journal_blocks_per_page_9004 jbd2_journal_blocks_per_page 0 9004 NULL
104319 +il_dbgfs_clear_ucode_stats_write_9016 il_dbgfs_clear_ucode_stats_write 3 9016 NULL
104320 +sparse_index_alloc_9021 sparse_index_alloc 1 9021 NULL
104321 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
104322 +fd_ioctl_9028 fd_ioctl 3 9028 NULL
104323 +nla_put_9042 nla_put 3 9042 NULL
104324 +offset_il_node_9059 offset_il_node 0 9059 NULL
104325 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 5-3 9061 NULL
104326 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
104327 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
104328 +create_queues_9088 create_queues 3-2 9088 NULL
104329 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
104330 +adxl34x_spi_read_block_9108 adxl34x_spi_read_block 3 9108 NULL
104331 +alloc_slabmgmt_9109 alloc_slabmgmt 5 9109 NULL
104332 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
104333 +gfn_to_rmap_9110 gfn_to_rmap 3-2 9110 &caif_stream_sendmsg_9110
104334 +udf_direct_IO_9111 udf_direct_IO 4 9111 NULL
104335 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
104336 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
104337 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
104338 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
104339 +apei_resources_merge_9149 apei_resources_merge 0 9149 NULL
104340 +vb2_dma_sg_alloc_9157 vb2_dma_sg_alloc 2 9157 NULL
104341 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
104342 +__btrfs_add_delayed_deletion_item_9177 __btrfs_add_delayed_deletion_item 0 9177 NULL
104343 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
104344 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
104345 +altera_swap_ir_9194 altera_swap_ir 2 9194 NULL
104346 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
104347 +get_pfn_9207 get_pfn 1 9207 NULL
104348 +virtqueue_add_9217 virtqueue_add 4-5 9217 NULL
104349 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
104350 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
104351 +ext4_mark_iloc_dirty_9239 ext4_mark_iloc_dirty 0 9239 NULL
104352 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4-0 9256 NULL
104353 +hfsplus_bnode_read_u16_9262 hfsplus_bnode_read_u16 0 9262 NULL
104354 +btrfs_search_slot_9264 btrfs_search_slot 0 9264 NULL
104355 +ocfs2_merge_rec_right_9267 ocfs2_merge_rec_right 0 9267 NULL
104356 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
104357 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
104358 +flakey_status_9274 flakey_status 5 9274 NULL
104359 +migrate_misplaced_transhuge_page_9298 migrate_misplaced_transhuge_page 7 9298 NULL
104360 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
104361 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
104362 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
104363 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
104364 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
104365 +__ksm_enter_9347 __ksm_enter 0 9347 NULL
104366 +ll_direct_rw_pages_9361 ll_direct_rw_pages 0 9361 NULL
104367 +of_node_to_nid_9367 of_node_to_nid 0 9367 NULL
104368 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
104369 +get_request_type_9393 get_request_type 0 9393 NULL nohasharray
104370 +mlx4_bitmap_init_9393 mlx4_bitmap_init 5-2 9393 &get_request_type_9393
104371 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
104372 +read_9397 read 3 9397 NULL
104373 +btrfs_drop_extents_9423 btrfs_drop_extents 4-0 9423 NULL
104374 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
104375 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
104376 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
104377 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
104378 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL nohasharray
104379 +get_registers_9470 get_registers 4 9470 &agp_generic_alloc_user_9470
104380 +btrfs_csum_file_blocks_9491 btrfs_csum_file_blocks 0 9491 NULL
104381 +crypt_status_9492 crypt_status 5 9492 NULL
104382 +lbs_threshold_write_9502 lbs_threshold_write 5 9502 NULL
104383 +btrfs_add_delayed_data_ref_9508 btrfs_add_delayed_data_ref 0 9508 NULL
104384 +lp_write_9511 lp_write 3 9511 NULL
104385 +mext_calc_swap_extents_9517 mext_calc_swap_extents 4 9517 NULL
104386 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
104387 +ll_max_read_ahead_whole_mb_seq_write_9528 ll_max_read_ahead_whole_mb_seq_write 3 9528 NULL
104388 +read_file_dma_9530 read_file_dma 3 9530 NULL
104389 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
104390 +iwl_dbgfs_bf_params_read_9542 iwl_dbgfs_bf_params_read 3 9542 NULL
104391 +unmerge_ksm_pages_9546 unmerge_ksm_pages 0 9546 NULL nohasharray
104392 +il_dbgfs_missed_beacon_write_9546 il_dbgfs_missed_beacon_write 3 9546 &unmerge_ksm_pages_9546
104393 +compat_SyS_pwritev64_9548 compat_SyS_pwritev64 3 9548 NULL
104394 +readl_9557 readl 0 9557 NULL
104395 +fw_node_create_9559 fw_node_create 2 9559 NULL
104396 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
104397 +kobj_map_9566 kobj_map 3-2 9566 NULL
104398 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
104399 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
104400 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
104401 +ocfs2_claim_suballoc_bits_9615 ocfs2_claim_suballoc_bits 0 9615 NULL
104402 +lov_ost_pool_add_9626 lov_ost_pool_add 3 9626 NULL
104403 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
104404 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 3-4 9635 NULL
104405 +acpi_ex_insert_into_field_9638 acpi_ex_insert_into_field 3 9638 NULL
104406 +compat_sys_keyctl_9639 compat_sys_keyctl 4 9639 NULL
104407 +ll_checksum_seq_write_9648 ll_checksum_seq_write 3 9648 NULL
104408 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
104409 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
104410 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
104411 +dns_query_9676 dns_query 3 9676 NULL
104412 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
104413 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
104414 +vx_transfer_end_9701 vx_transfer_end 0 9701 NULL
104415 +fnb_9703 fnb 2-3-0 9703 NULL
104416 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
104417 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
104418 +cfg80211_tx_mlme_mgmt_9715 cfg80211_tx_mlme_mgmt 3 9715 NULL
104419 +btrfs_stack_file_extent_num_bytes_9720 btrfs_stack_file_extent_num_bytes 0 9720 NULL
104420 +SYSC_ppoll_9721 SYSC_ppoll 2 9721 NULL
104421 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
104422 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
104423 +shmem_replace_page_9740 shmem_replace_page 0 9740 NULL
104424 +ddb_input_read_9743 ddb_input_read 3-0 9743 NULL
104425 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
104426 +ni_calculate_power_boost_limit_9757 ni_calculate_power_boost_limit 3 9757 NULL
104427 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
104428 +__alloc_percpu_9764 __alloc_percpu 2-1 9764 NULL
104429 +btrfs_write_and_wait_transaction_9768 btrfs_write_and_wait_transaction 0 9768 NULL
104430 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
104431 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
104432 +kvm_age_hva_9795 kvm_age_hva 2 9795 NULL
104433 +parse_uac2_sample_rate_range_9801 parse_uac2_sample_rate_range 0 9801 NULL
104434 +tpm_data_in_9802 tpm_data_in 0 9802 NULL
104435 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
104436 +udpv6_recvmsg_9813 udpv6_recvmsg 4 9813 NULL nohasharray
104437 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 &udpv6_recvmsg_9813
104438 +svc_pool_map_get_node_9817 svc_pool_map_get_node 0 9817 NULL
104439 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
104440 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
104441 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
104442 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
104443 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
104444 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
104445 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
104446 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
104447 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 5-3 9895 NULL
104448 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
104449 +ext4_map_blocks_9916 ext4_map_blocks 0 9916 NULL
104450 +root_nfs_parse_options_9937 root_nfs_parse_options 3 9937 NULL
104451 +tc3589x_reg_read_9940 tc3589x_reg_read 0 9940 NULL
104452 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
104453 +read_file_misc_9948 read_file_misc 3 9948 NULL
104454 +ext2_new_blocks_9954 ext2_new_blocks 2-0 9954 NULL
104455 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 4-3 9957 NULL
104456 +SyS_gethostname_9964 SyS_gethostname 2 9964 NULL
104457 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
104458 +btrfs_add_link_9973 btrfs_add_link 5-0 9973 NULL
104459 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
104460 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
104461 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
104462 +iterate_inodes_from_logical_10037 iterate_inodes_from_logical 0 10037 NULL
104463 +vm_iomap_memory_10038 vm_iomap_memory 2 10038 NULL
104464 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
104465 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
104466 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
104467 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
104468 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
104469 +SyS_migrate_pages_10134 SyS_migrate_pages 2 10134 NULL nohasharray
104470 +offset_to_bit_10134 offset_to_bit 0-2-1-3 10134 &SyS_migrate_pages_10134
104471 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
104472 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
104473 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
104474 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
104475 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
104476 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
104477 +kstrtol_from_user_10168 kstrtol_from_user 2 10168 NULL
104478 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
104479 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
104480 +register_ftrace_function_10218 register_ftrace_function 0 10218 NULL
104481 +hdlc_rpr_irq_10240 hdlc_rpr_irq 2 10240 NULL
104482 +mutex_lock_killable_10244 mutex_lock_killable 0 10244 NULL
104483 +insert_orphan_item_10249 insert_orphan_item 0 10249 NULL
104484 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
104485 +gpiochip_add_to_list_10262 gpiochip_add_to_list 0 10262 NULL
104486 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
104487 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
104488 +ubi_leb_change_10289 ubi_leb_change 0-4 10289 NULL
104489 +read_emulate_10310 read_emulate 2-4 10310 NULL
104490 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
104491 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
104492 +compat_SyS_writev_10327 compat_SyS_writev 3 10327 NULL
104493 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
104494 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
104495 +get_dump_page_10338 get_dump_page 1 10338 NULL
104496 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
104497 +whci_add_cap_10350 whci_add_cap 0 10350 NULL
104498 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
104499 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
104500 +__ntfs_cluster_free_10360 __ntfs_cluster_free 0 10360 NULL
104501 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
104502 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
104503 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
104504 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
104505 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
104506 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
104507 +ext4_itable_unused_count_10501 ext4_itable_unused_count 0 10501 NULL
104508 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
104509 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
104510 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
104511 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
104512 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
104513 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
104514 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
104515 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
104516 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL nohasharray
104517 +kstrtouint_from_user_10536 kstrtouint_from_user 2 10536 &snd_pcm_lib_read_10536
104518 +SYSC_read_10545 SYSC_read 3 10545 NULL
104519 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
104520 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
104521 +otp_read_10594 otp_read 5-4-2 10594 NULL
104522 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
104523 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
104524 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
104525 +ubi_io_write_vid_hdr_10660 ubi_io_write_vid_hdr 0 10660 NULL nohasharray
104526 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 &ubi_io_write_vid_hdr_10660
104527 +efx_max_tx_len_10662 efx_max_tx_len 0-2 10662 NULL
104528 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
104529 +parport_write_10669 parport_write 0 10669 NULL
104530 +alloc_vmap_area_10682 alloc_vmap_area 5 10682 NULL
104531 +edge_write_10692 edge_write 4 10692 NULL
104532 +ubi_wl_get_peb_10699 ubi_wl_get_peb 0 10699 NULL
104533 +inl_10708 inl 0 10708 NULL nohasharray
104534 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
104535 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
104536 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
104537 +spi_sync_10731 spi_sync 0 10731 NULL
104538 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
104539 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
104540 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
104541 +ttm_ref_object_add_10748 ttm_ref_object_add 0 10748 NULL
104542 +SyS_io_getevents_10756 SyS_io_getevents 3 10756 NULL
104543 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
104544 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 2-4 10765 NULL
104545 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
104546 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
104547 +i915_gem_wait_for_error_10791 i915_gem_wait_for_error 0 10791 NULL
104548 +snd_mask_value_10794 snd_mask_value 0 10794 NULL
104549 +diva_set_trace_filter_10820 diva_set_trace_filter 0-1 10820 NULL
104550 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
104551 +ida_get_new_above_10853 ida_get_new_above 2-0 10853 NULL
104552 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
104553 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
104554 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
104555 +drm_ht_insert_item_10877 drm_ht_insert_item 0 10877 NULL
104556 +wiidebug_drm_write_10879 wiidebug_drm_write 3 10879 NULL
104557 +get_scq_10897 get_scq 2 10897 NULL
104558 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
104559 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
104560 +lprocfs_wr_atomic_10912 lprocfs_wr_atomic 3 10912 NULL
104561 +__copy_from_user_10918 __copy_from_user 3-0 10918 NULL
104562 +kobject_add_10919 kobject_add 0 10919 NULL
104563 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
104564 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
104565 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
104566 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
104567 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
104568 +lz4_compress_10986 lz4_compress 2 10986 NULL
104569 +do_switch_10994 do_switch 0 10994 NULL
104570 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
104571 +btrfs_add_delayed_extent_op_11000 btrfs_add_delayed_extent_op 0 11000 NULL
104572 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
104573 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
104574 +btrfs_find_space_for_alloc_11028 btrfs_find_space_for_alloc 2 11028 NULL
104575 +mb_find_next_bit_11037 mb_find_next_bit 0-2-3 11037 NULL
104576 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
104577 +insert_inline_extent_backref_11063 insert_inline_extent_backref 8-0 11063 NULL
104578 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
104579 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
104580 +count_argc_11083 count_argc 0 11083 NULL
104581 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
104582 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
104583 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
104584 +page_offset_11120 page_offset 0 11120 NULL
104585 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
104586 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
104587 +alloc_alien_cache_11127 alloc_alien_cache 2-1 11127 NULL
104588 +eb_lookup_objects_11163 eb_lookup_objects 0 11163 NULL
104589 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 4-3 11172 NULL
104590 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
104591 +comedi_alloc_spriv_11234 comedi_alloc_spriv 2 11234 NULL
104592 +mmap_region_11247 mmap_region 0-2 11247 NULL
104593 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
104594 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
104595 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
104596 +ath6kl_power_params_write_11274 ath6kl_power_params_write 3 11274 NULL
104597 +__proc_daemon_file_11305 __proc_daemon_file 5 11305 NULL
104598 +split_vma_11312 split_vma 0 11312 NULL
104599 +btrfs_update_inode_fallback_11313 btrfs_update_inode_fallback 0 11313 NULL
104600 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
104601 +sk_filter_size_11316 sk_filter_size 0 11316 NULL nohasharray
104602 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 &sk_filter_size_11316
104603 +shmem_radix_tree_replace_11325 shmem_radix_tree_replace 0 11325 NULL
104604 +construct_key_11329 construct_key 3 11329 NULL nohasharray
104605 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
104606 +next_segment_11330 next_segment 0-2-1 11330 NULL
104607 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 2-1 11332 NULL
104608 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
104609 +nl80211_send_mgmt_11353 nl80211_send_mgmt 7 11353 NULL nohasharray
104610 +sel_write_create_11353 sel_write_create 3 11353 &nl80211_send_mgmt_11353
104611 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
104612 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
104613 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
104614 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
104615 +__btrfs_add_delayed_insertion_item_11400 __btrfs_add_delayed_insertion_item 0 11400 NULL
104616 +lprocfs_wr_evict_client_11402 lprocfs_wr_evict_client 3 11402 NULL
104617 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
104618 +str_to_user_11411 str_to_user 2 11411 NULL
104619 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
104620 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
104621 +relocate_entry_gtt_11416 relocate_entry_gtt 0 11416 NULL
104622 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
104623 +trace_options_read_11419 trace_options_read 3 11419 NULL
104624 +i40e_dbg_command_write_11421 i40e_dbg_command_write 3 11421 NULL
104625 +__irq_set_trigger_11422 __irq_set_trigger 0 11422 NULL nohasharray
104626 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 &__irq_set_trigger_11422
104627 +prepare_image_11424 prepare_image 0 11424 NULL
104628 +ext3_xattr_block_list_11428 ext3_xattr_block_list 3 11428 NULL
104629 +bttv_read_11432 bttv_read 3 11432 NULL
104630 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
104631 +do_blockdev_direct_IO_11455 do_blockdev_direct_IO 0-6 11455 NULL
104632 +swp_offset_11475 swp_offset 0 11475 NULL
104633 +st_sensors_write_data_with_mask_11476 st_sensors_write_data_with_mask 3 11476 NULL
104634 +pci_set_power_state_11479 pci_set_power_state 0 11479 NULL nohasharray
104635 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 &pci_set_power_state_11479
104636 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
104637 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
104638 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
104639 +ll_direct_IO_26_seg_11518 ll_direct_IO_26_seg 0 11518 NULL
104640 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
104641 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
104642 +radix_tree_extend_11555 radix_tree_extend 0 11555 NULL
104643 +skb_cow_data_11565 skb_cow_data 0 11565 NULL
104644 +posix_acl_create_masq_11567 posix_acl_create_masq 0 11567 NULL
104645 +qgroup_account_ref_step2_11575 qgroup_account_ref_step2 0 11575 NULL
104646 +lpfc_idiag_ctlacc_write_11576 lpfc_idiag_ctlacc_write 3 11576 NULL
104647 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
104648 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
104649 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
104650 +btrfs_uuid_tree_add_11598 btrfs_uuid_tree_add 0 11598 NULL
104651 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
104652 +i915_gem_object_pin_11630 i915_gem_object_pin 0 11630 NULL
104653 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
104654 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
104655 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
104656 +slab_ksize_11664 slab_ksize 0 11664 NULL
104657 +__btrfs_run_delayed_items_11671 __btrfs_run_delayed_items 0 11671 NULL
104658 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
104659 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 3 11675 NULL
104660 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
104661 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
104662 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
104663 +split_11691 split 2 11691 NULL
104664 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
104665 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
104666 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
104667 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
104668 +intel_map_page_11762 intel_map_page 4-3 11762 NULL
104669 +ocfs2_relink_block_group_11769 ocfs2_relink_block_group 0 11769 NULL
104670 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
104671 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
104672 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
104673 +rtw_alloc_etherdev_11792 rtw_alloc_etherdev 1 11792 NULL
104674 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
104675 +umc_device_register_11824 umc_device_register 0 11824 NULL
104676 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
104677 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
104678 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
104679 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
104680 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
104681 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
104682 +mdc_rename_11899 mdc_rename 4-6 11899 NULL
104683 +perf_mmap_alloc_page_11904 perf_mmap_alloc_page 1 11904 NULL
104684 +xstateregs_get_11906 xstateregs_get 4 11906 NULL
104685 +ti_write_11916 ti_write 4 11916 NULL
104686 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
104687 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
104688 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
104689 +r1_sync_page_io_11963 r1_sync_page_io 3 11963 NULL
104690 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
104691 +usc_InReg_11976 usc_InReg 0 11976 NULL nohasharray
104692 +split_node_11976 split_node 0 11976 &usc_InReg_11976
104693 +BeceemFlashBulkRead_11979 BeceemFlashBulkRead 0 11979 NULL
104694 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
104695 +i40e_pci_sriov_configure_12011 i40e_pci_sriov_configure 2 12011 NULL
104696 +intel_init_ring_buffer_12016 intel_init_ring_buffer 0 12016 NULL
104697 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
104698 +did_overwrite_ref_12046 did_overwrite_ref 0 12046 NULL
104699 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
104700 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
104701 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
104702 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
104703 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
104704 +rtw_malloc2d_12102 rtw_malloc2d 1-2-3 12102 NULL
104705 +twl6030_irq_map_12105 twl6030_irq_map 2 12105 NULL
104706 +i915_gem_evict_something_12118 i915_gem_evict_something 0 12118 NULL
104707 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
104708 +set_powered_12129 set_powered 4 12129 NULL
104709 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
104710 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
104711 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
104712 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
104713 +rawsock_recvmsg_12144 rawsock_recvmsg 4 12144 NULL
104714 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
104715 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
104716 +ocfs2_local_alloc_new_window_12153 ocfs2_local_alloc_new_window 0 12153 NULL
104717 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
104718 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
104719 +LNetEQAlloc_12178 LNetEQAlloc 1 12178 NULL
104720 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
104721 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
104722 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
104723 +scaled_div_12201 scaled_div 2-1-0 12201 NULL
104724 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
104725 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
104726 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
104727 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1 12235 NULL
104728 +kvirt_to_pa_12247 kvirt_to_pa 0 12247 NULL
104729 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
104730 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
104731 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
104732 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
104733 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
104734 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
104735 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
104736 +bt_sock_recvmsg_12316 bt_sock_recvmsg 4 12316 NULL
104737 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
104738 +btrfs_lookup_file_extent_12341 btrfs_lookup_file_extent 0 12341 NULL
104739 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
104740 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
104741 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
104742 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
104743 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL nohasharray
104744 +populate_dir_12391 populate_dir 0 12391 &btrfs_file_extent_ram_bytes_12391
104745 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL nohasharray
104746 +ext4_bg_num_gdb_nometa_12413 ext4_bg_num_gdb_nometa 0 12413 &ntfs_get_size_for_mapping_pairs_12413
104747 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
104748 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
104749 +cfs_array_alloc_12441 cfs_array_alloc 2 12441 NULL
104750 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
104751 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
104752 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
104753 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
104754 +xfs_get_extsz_hint_12531 xfs_get_extsz_hint 0 12531 NULL
104755 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
104756 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
104757 +ceph_osdc_wait_request_12572 ceph_osdc_wait_request 0 12572 NULL
104758 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
104759 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
104760 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
104761 +tlbflush_write_file_12598 tlbflush_write_file 3 12598 NULL
104762 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
104763 +ipath_mmap_mem_12625 ipath_mmap_mem 3 12625 NULL
104764 +sdhci_pltfm_init_12627 sdhci_pltfm_init 3 12627 NULL
104765 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
104766 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
104767 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
104768 +nr_recvmsg_12649 nr_recvmsg 4 12649 NULL
104769 +wb_create_12651 wb_create 1 12651 NULL
104770 +rtw_android_get_link_speed_12655 rtw_android_get_link_speed 0 12655 NULL
104771 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
104772 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
104773 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4-5 12669 &sel_read_class_12669
104774 +ext4_writepage_trans_blocks_12674 ext4_writepage_trans_blocks 0 12674 NULL
104775 +ext4_bg_num_gdb_meta_12702 ext4_bg_num_gdb_meta 0 12702 NULL
104776 +iwl_dbgfs_calib_disabled_write_12707 iwl_dbgfs_calib_disabled_write 3 12707 NULL
104777 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
104778 +ivtv_write_12721 ivtv_write 3 12721 NULL
104779 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
104780 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
104781 +run_delayed_data_ref_12749 run_delayed_data_ref 0 12749 NULL
104782 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
104783 +listxattr_12769 listxattr 3 12769 NULL
104784 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
104785 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2-0 12793 NULL
104786 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
104787 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
104788 +tlv_put_uuid_12824 tlv_put_uuid 0 12824 NULL
104789 +readq_12825 readq 0 12825 NULL
104790 +SyS_add_key_12834 SyS_add_key 4 12834 NULL
104791 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
104792 +spidev_sync_12842 spidev_sync 0 12842 NULL
104793 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
104794 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
104795 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
104796 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
104797 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
104798 +free_tind_blocks_12926 free_tind_blocks 0 12926 NULL
104799 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
104800 +SYSC_sendfile_12936 SYSC_sendfile 4 12936 NULL
104801 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
104802 +bm_status_write_12964 bm_status_write 3 12964 NULL
104803 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
104804 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
104805 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
104806 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
104807 +btrfs_write_dirty_block_groups_13030 btrfs_write_dirty_block_groups 0 13030 NULL
104808 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
104809 +SyS_sendfile64_13043 SyS_sendfile64 4 13043 NULL
104810 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
104811 +ptlrpc_lprocfs_threads_min_seq_write_13060 ptlrpc_lprocfs_threads_min_seq_write 3 13060 NULL nohasharray
104812 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 &ptlrpc_lprocfs_threads_min_seq_write_13060
104813 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
104814 +_ocfs2_free_suballoc_bits_13085 _ocfs2_free_suballoc_bits 0 13085 NULL
104815 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
104816 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
104817 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3-0 13100 NULL
104818 +ttm_dma_pool_alloc_new_pages_13105 ttm_dma_pool_alloc_new_pages 3 13105 NULL
104819 +SyS_msgrcv_13109 SyS_msgrcv 3 13109 NULL
104820 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
104821 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
104822 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
104823 +blk_update_request_13146 blk_update_request 3 13146 NULL
104824 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
104825 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
104826 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
104827 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
104828 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
104829 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
104830 +comedi_read_13199 comedi_read 3 13199 NULL
104831 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
104832 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
104833 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
104834 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
104835 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
104836 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
104837 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 NULL
104838 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
104839 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
104840 +simple_attr_write_13260 simple_attr_write 3 13260 NULL
104841 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
104842 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
104843 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
104844 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
104845 +sd_major_13294 sd_major 0-1 13294 NULL
104846 +kempld_read16_13297 kempld_read16 0 13297 NULL
104847 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
104848 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
104849 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
104850 +get_bits_13353 get_bits 0-2 13353 NULL
104851 +hscx_empty_fifo_13360 hscx_empty_fifo 2 13360 NULL
104852 +snd_ctl_elem_info_13363 snd_ctl_elem_info 0 13363 NULL
104853 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
104854 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
104855 +ext4_meta_trans_blocks_13380 ext4_meta_trans_blocks 0-3-2 13380 NULL
104856 +lov_mds_md_size_13388 lov_mds_md_size 0-1 13388 NULL nohasharray
104857 +dis_bypass_write_13388 dis_bypass_write 3 13388 &lov_mds_md_size_13388
104858 +BcmSetActiveSection_13389 BcmSetActiveSection 0 13389 NULL
104859 +ocfs2_inode_lock_update_13414 ocfs2_inode_lock_update 0 13414 NULL
104860 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
104861 +compat_SyS_sendfile64_13420 compat_SyS_sendfile64 4 13420 NULL
104862 +keyring_read_13438 keyring_read 3 13438 NULL
104863 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL
104864 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
104865 +sb_init_dio_done_wq_13482 sb_init_dio_done_wq 0 13482 NULL
104866 +data_read_13494 data_read 3 13494 NULL
104867 +i915_switch_context_13498 i915_switch_context 0 13498 NULL
104868 +ioat_chansts_32_13506 ioat_chansts_32 0 13506 NULL
104869 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2-0 13512 NULL
104870 +core_status_13515 core_status 4 13515 NULL
104871 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
104872 +bm_init_13529 bm_init 2 13529 NULL
104873 +kvm_get_cr8_13538 kvm_get_cr8 0 13538 NULL
104874 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1-2 13540 NULL nohasharray
104875 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 &SYSC_remap_file_pages_13540
104876 +__btrfs_alloc_chunk_13554 __btrfs_alloc_chunk 0 13554 NULL
104877 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
104878 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
104879 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
104880 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
104881 +cache_write_13589 cache_write 3 13589 NULL
104882 +Rd_Indx_13602 Rd_Indx 3-2 13602 NULL
104883 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
104884 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
104885 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
104886 +packet_snd_13634 packet_snd 3 13634 NULL
104887 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
104888 +cache_downcall_13666 cache_downcall 3 13666 NULL
104889 +ext3_xattr_list_entries_13682 ext3_xattr_list_entries 0-4 13682 NULL
104890 +nv94_aux_13689 nv94_aux 2-5 13689 NULL
104891 +usb_get_string_13693 usb_get_string 0 13693 NULL
104892 +atomic_cmpxchg_13700 atomic_cmpxchg 0 13700 NULL
104893 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
104894 +ocfs2_cache_block_dealloc_13731 ocfs2_cache_block_dealloc 0 13731 NULL
104895 +netdev_queue_numa_node_read_13732 netdev_queue_numa_node_read 0 13732 NULL
104896 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
104897 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
104898 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
104899 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
104900 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
104901 +random_read_13815 random_read 3 13815 NULL
104902 +mutex_lock_interruptible_nested_13817 mutex_lock_interruptible_nested 0 13817 NULL
104903 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
104904 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
104905 +enc_pools_insert_13849 enc_pools_insert 3 13849 NULL
104906 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2 13851 NULL
104907 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL
104908 +btrfs_insert_empty_item_13885 btrfs_insert_empty_item 0 13885 NULL
104909 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 5-2 13886 NULL nohasharray
104910 +__fsnotify_parent_13886 __fsnotify_parent 0 13886 &qp_memcpy_to_queue_13886
104911 +window_alignment_13895 window_alignment 0 13895 NULL
104912 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
104913 +is_inode_existent_13913 is_inode_existent 0 13913 NULL
104914 +cfg80211_inform_bss_width_13933 cfg80211_inform_bss_width 9 13933 NULL
104915 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
104916 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
104917 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
104918 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
104919 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
104920 +qib_mmap_mem_13947 qib_mmap_mem 3 13947 NULL
104921 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
104922 +osc_grant_shrink_interval_seq_write_13952 osc_grant_shrink_interval_seq_write 3 13952 NULL
104923 +ocfs2_refresh_slot_info_13957 ocfs2_refresh_slot_info 0 13957 NULL
104924 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
104925 +qcam_read_13977 qcam_read 3 13977 NULL
104926 +dsp_read_13980 dsp_read 2 13980 NULL
104927 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
104928 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
104929 +create_files_14003 create_files 0 14003 NULL
104930 +sddr09_write_data_14014 sddr09_write_data 3 14014 NULL
104931 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
104932 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
104933 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
104934 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
104935 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
104936 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
104937 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
104938 +ovs_flow_actions_alloc_14072 ovs_flow_actions_alloc 1 14072 NULL
104939 +lov_stripeoffset_seq_write_14078 lov_stripeoffset_seq_write 3 14078 NULL
104940 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
104941 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
104942 +intel_ring_wait_seqno_14107 intel_ring_wait_seqno 0 14107 NULL
104943 +ext4_journal_blocks_per_page_14127 ext4_journal_blocks_per_page 0 14127 NULL
104944 +ntfs_rl_replace_14136 ntfs_rl_replace 4-2 14136 NULL
104945 +qfq_ffs_14139 qfq_ffs 2 14139 NULL
104946 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
104947 +em_canid_change_14150 em_canid_change 3 14150 NULL
104948 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
104949 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
104950 +ocfs2_split_and_insert_14171 ocfs2_split_and_insert 0 14171 NULL
104951 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
104952 +datafab_read_data_14186 datafab_read_data 4 14186 NULL
104953 +do_splice_14196 do_splice 5 14196 NULL
104954 +hfsplus_brec_find_14200 hfsplus_brec_find 0 14200 NULL
104955 +alloc_async_14208 alloc_async 1 14208 NULL
104956 +ath6kl_regread_write_14220 ath6kl_regread_write 3 14220 NULL
104957 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
104958 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4 14244 NULL
104959 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
104960 +ext4_journal_restart_14251 ext4_journal_restart 0 14251 NULL
104961 +will_overwrite_ref_14252 will_overwrite_ref 0 14252 NULL
104962 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
104963 +numa_mem_id_14279 numa_mem_id 0 14279 NULL
104964 +rr_status_14293 rr_status 5 14293 NULL
104965 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
104966 +__readl_14308 __readl 0 14308 NULL
104967 +send_chown_14309 send_chown 0 14309 NULL
104968 +i915_gem_object_finish_gpu_14312 i915_gem_object_finish_gpu 0 14312 NULL
104969 +oo_objects_14319 oo_objects 0 14319 NULL
104970 +ww_mutex_deadlock_injection_14321 ww_mutex_deadlock_injection 0 14321 NULL
104971 +ll_get_user_pages_14328 ll_get_user_pages 2-3-0 14328 NULL
104972 +down_write_failed_14331 down_write_failed 2 14331 NULL
104973 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
104974 +alloc_tx_struct_14349 alloc_tx_struct 1 14349 NULL
104975 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
104976 +btrfs_set_inode_index_14379 btrfs_set_inode_index 0 14379 NULL
104977 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
104978 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
104979 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
104980 +first_logical_byte_14403 first_logical_byte 0 14403 NULL
104981 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
104982 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
104983 +qib_user_sdma_page_length_14432 qib_user_sdma_page_length 0-2-1 14432 NULL
104984 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
104985 +block_size_14443 block_size 0 14443 NULL
104986 +lmv_user_md_size_14456 lmv_user_md_size 0-1 14456 NULL
104987 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
104988 +lustre_msg_size_v2_14470 lustre_msg_size_v2 0 14470 NULL
104989 +dma_transfer_size_14473 dma_transfer_size 0 14473 NULL
104990 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
104991 +efx_mdio_check_mmds_14486 efx_mdio_check_mmds 2 14486 NULL nohasharray
104992 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 &efx_mdio_check_mmds_14486
104993 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
104994 +dataflash_read_user_otp_14536 dataflash_read_user_otp 3-2 14536 NULL nohasharray
104995 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
104996 +register_trace_sched_switch_14545 register_trace_sched_switch 0 14545 NULL
104997 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
104998 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
104999 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
105000 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
105001 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
105002 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
105003 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
105004 +ocfs2_steal_meta_14602 ocfs2_steal_meta 0 14602 NULL
105005 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
105006 +dbJoin_14644 dbJoin 0 14644 NULL
105007 +profile_replace_14652 profile_replace 3 14652 NULL
105008 +add_to_page_cache_locked_14668 add_to_page_cache_locked 0 14668 NULL
105009 +min_bytes_needed_14675 min_bytes_needed 0 14675 NULL
105010 +nvme_trans_log_info_exceptions_14677 nvme_trans_log_info_exceptions 3 14677 NULL
105011 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
105012 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
105013 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
105014 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
105015 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
105016 +rtw_cbuf_alloc_14710 rtw_cbuf_alloc 1 14710 NULL
105017 +cgroup_path_14713 cgroup_path 3 14713 NULL
105018 +get_bio_block_14714 get_bio_block 0 14714 NULL
105019 +vfd_write_14717 vfd_write 3 14717 NULL
105020 +SyS_sendfile_14718 SyS_sendfile 4 14718 NULL
105021 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
105022 +raid1_resize_14740 raid1_resize 2 14740 NULL
105023 +i915_error_state_buf_init_14742 i915_error_state_buf_init 2 14742 NULL
105024 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
105025 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
105026 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
105027 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
105028 +keys_proc_write_14792 keys_proc_write 3 14792 NULL
105029 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
105030 +__kfifo_in_14797 __kfifo_in 3-0 14797 NULL
105031 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 NULL nohasharray
105032 +hpet_readl_14801 hpet_readl 0 14801 &snd_als300_gcr_read_14801
105033 +changed_cb_14819 changed_cb 0 14819 NULL
105034 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
105035 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
105036 +lcd_write_14857 lcd_write 3 14857 NULL
105037 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
105038 +gmux_index_read8_14890 gmux_index_read8 0 14890 NULL
105039 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
105040 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
105041 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2-0 14910 NULL
105042 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
105043 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 5-2 14923 &__arch_hweight64_14923
105044 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
105045 +range_to_mtrr_14940 range_to_mtrr 2 14940 NULL
105046 +queue_cnt_14951 queue_cnt 0 14951 NULL
105047 +unix_dgram_recvmsg_14952 unix_dgram_recvmsg 4 14952 NULL
105048 +i915_vma_unbind_14954 i915_vma_unbind 0 14954 NULL
105049 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
105050 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
105051 +setkey_14987 setkey 3 14987 NULL nohasharray
105052 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
105053 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
105054 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
105055 +irq_get_next_irq_15053 irq_get_next_irq 1-0 15053 NULL
105056 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
105057 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
105058 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
105059 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5-0 15072 NULL
105060 +pppoe_recvmsg_15073 pppoe_recvmsg 4 15073 NULL
105061 +ceph_calc_ceph_pg_15075 ceph_calc_ceph_pg 0 15075 NULL
105062 +perf_trace_sched_stat_runtime_15115 perf_trace_sched_stat_runtime 3 15115 NULL
105063 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
105064 +start_port_15124 start_port 0 15124 NULL
105065 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
105066 +iwl_dbgfs_sta_drain_write_15167 iwl_dbgfs_sta_drain_write 3 15167 NULL
105067 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
105068 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
105069 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
105070 +reserve_resources_15194 reserve_resources 3 15194 NULL
105071 +mtt_alloc_res_15211 mtt_alloc_res 5 15211 NULL
105072 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
105073 +iwl_dbgfs_sram_write_15239 iwl_dbgfs_sram_write 3 15239 NULL
105074 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
105075 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
105076 +simple_strtol_15273 simple_strtol 0 15273 NULL
105077 +fw_realloc_buffer_15280 fw_realloc_buffer 2 15280 NULL
105078 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
105079 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
105080 +ocfs2_read_refcount_block_15305 ocfs2_read_refcount_block 0 15305 NULL
105081 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-3-5 15330 NULL
105082 +bfloat_mantissa_15334 bfloat_mantissa 0 15334 NULL
105083 +xlog_ticket_alloc_15335 xlog_ticket_alloc 2 15335 NULL
105084 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
105085 +ioread16_15342 ioread16 0 15342 NULL
105086 +ept_prefetch_gpte_15348 ept_prefetch_gpte 4 15348 NULL
105087 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
105088 +count_inode_extrefs_15366 count_inode_extrefs 0 15366 NULL
105089 +ext4_direct_IO_15369 ext4_direct_IO 4 15369 NULL
105090 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
105091 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
105092 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
105093 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
105094 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
105095 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
105096 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
105097 +get_modalias_15406 get_modalias 2 15406 NULL
105098 +blockdev_direct_IO_15408 blockdev_direct_IO 0-5 15408 NULL
105099 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
105100 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4-0 15423 NULL
105101 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2-0 15438 NULL
105102 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
105103 +memweight_15450 memweight 2 15450 NULL
105104 +vmalloc_15464 vmalloc 1 15464 NULL
105105 +__mutex_lock_killable_slowpath_15472 __mutex_lock_killable_slowpath 0 15472 NULL
105106 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
105107 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
105108 +ifx_spi_write_15531 ifx_spi_write 3 15531 NULL
105109 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
105110 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
105111 +xfrm_state_mtu_15548 xfrm_state_mtu 0-2 15548 NULL
105112 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
105113 +persistent_status_15574 persistent_status 4 15574 NULL
105114 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
105115 +cl_io_submit_sync_15579 cl_io_submit_sync 0 15579 NULL
105116 +vme_user_write_15587 vme_user_write 3 15587 NULL
105117 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7-0 15595 NULL
105118 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
105119 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
105120 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
105121 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
105122 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 4-2 15642 NULL nohasharray
105123 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
105124 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
105125 +joydev_handle_JSIOCSBTNMAP_15643 joydev_handle_JSIOCSBTNMAP 3 15643 NULL
105126 +fs_path_add_15648 fs_path_add 3-0 15648 NULL
105127 +xsd_read_15653 xsd_read 3 15653 NULL
105128 +unix_bind_15668 unix_bind 3 15668 NULL
105129 +SyS_connect_15674 SyS_connect 3 15674 NULL nohasharray
105130 +dm_read_15674 dm_read 3 15674 &SyS_connect_15674
105131 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
105132 +i915_gem_object_set_to_cpu_domain_15705 i915_gem_object_set_to_cpu_domain 0 15705 NULL nohasharray
105133 +uncore_alloc_box_15705 uncore_alloc_box 2 15705 &i915_gem_object_set_to_cpu_domain_15705
105134 +ocfs2_split_tree_15716 ocfs2_split_tree 5-0 15716 NULL
105135 +tracing_snapshot_write_15719 tracing_snapshot_write 3 15719 NULL
105136 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
105137 +ftrace_profile_init_cpu_15761 ftrace_profile_init_cpu 0 15761 NULL
105138 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1-0 15762 NULL
105139 +i915_gem_init_seqno_15793 i915_gem_init_seqno 0 15793 NULL
105140 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
105141 +nameseq_list_15817 nameseq_list 3-0 15817 NULL nohasharray
105142 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
105143 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
105144 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
105145 +table_size_15851 table_size 0-1-2 15851 NULL
105146 +ubi_io_write_15870 ubi_io_write 0-5-4 15870 NULL nohasharray
105147 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
105148 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
105149 +profile_pc_15887 profile_pc 0 15887 NULL
105150 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
105151 +native_read_msr_15905 native_read_msr 0 15905 NULL
105152 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
105153 +power_read_15939 power_read 3 15939 NULL
105154 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
105155 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 5-2-4 15952 NULL
105156 +tfrc_calc_x_15975 tfrc_calc_x 2-1 15975 NULL
105157 +frame_alloc_15981 frame_alloc 4 15981 NULL
105158 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
105159 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
105160 +i915_gem_object_pin_16032 i915_gem_object_pin 0 16032 NULL
105161 +dccp_recvmsg_16056 dccp_recvmsg 4 16056 NULL
105162 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
105163 +si5351_msynth_params_address_16062 si5351_msynth_params_address 0-1 16062 NULL
105164 +ocfs2_sync_local_to_main_16076 ocfs2_sync_local_to_main 0 16076 NULL
105165 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
105166 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
105167 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
105168 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
105169 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
105170 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
105171 +fsm_init_16134 fsm_init 2 16134 NULL
105172 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
105173 +update_block_group_16155 update_block_group 0 16155 NULL
105174 +optimal_reclaimed_pages_16172 optimal_reclaimed_pages 0 16172 NULL
105175 +mapping_level_16188 mapping_level 2-0 16188 NULL
105176 +i40e_allocate_virt_mem_d_16191 i40e_allocate_virt_mem_d 3 16191 NULL
105177 +tcp_syn_options_16197 tcp_syn_options 0 16197 NULL
105178 +ath10k_htt_rx_ring_size_16201 ath10k_htt_rx_ring_size 0 16201 NULL
105179 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
105180 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
105181 +create_table_16213 create_table 2 16213 NULL
105182 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
105183 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
105184 +lov_prep_brw_set_16246 lov_prep_brw_set 3 16246 NULL
105185 +i40e_dbg_dump_read_16247 i40e_dbg_dump_read 3 16247 NULL nohasharray
105186 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &i40e_dbg_dump_read_16247
105187 +il_dbgfs_disable_ht40_write_16249 il_dbgfs_disable_ht40_write 3 16249 NULL
105188 +SyS_fgetxattr_16254 SyS_fgetxattr 4 16254 NULL
105189 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
105190 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
105191 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
105192 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
105193 +nand_bch_init_16280 nand_bch_init 2-3 16280 &drbd_setsockopt_16280
105194 +account_16283 account 0-4-2 16283 NULL nohasharray
105195 +mirror_status_16283 mirror_status 5 16283 &account_16283
105196 +retry_instruction_16285 retry_instruction 2 16285 NULL
105197 +jumpshot_read_data_16287 jumpshot_read_data 4 16287 NULL
105198 +mo_xattr_get_16288 mo_xattr_get 0 16288 NULL
105199 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
105200 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
105201 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
105202 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
105203 +wb_map_16301 wb_map 2 16301 NULL
105204 +kvm_handle_hva_range_16312 kvm_handle_hva_range 3-2 16312 NULL
105205 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
105206 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
105207 +btrfs_insert_item_16357 btrfs_insert_item 0 16357 NULL
105208 +sysfs_create_groups_16360 sysfs_create_groups 0 16360 NULL
105209 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
105210 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
105211 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
105212 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
105213 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
105214 +__bio_add_page_16435 __bio_add_page 0-4 16435 NULL
105215 +btrfs_truncate_inode_items_16452 btrfs_truncate_inode_items 0-4 16452 NULL
105216 +ocfs2_expand_refcount_tree_16455 ocfs2_expand_refcount_tree 0 16455 NULL
105217 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
105218 +alloc_disk_node_16458 alloc_disk_node 2 16458 NULL
105219 +req_capsule_get_size_16467 req_capsule_get_size 0 16467 NULL
105220 +ocfs2_block_group_set_bits_16488 ocfs2_block_group_set_bits 0 16488 NULL
105221 +add_qgroup_item_16492 add_qgroup_item 0 16492 NULL
105222 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
105223 +filemap_write_and_wait_16506 filemap_write_and_wait 0 16506 NULL
105224 +start_this_handle_16519 start_this_handle 0 16519 NULL
105225 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
105226 +raid10_resize_16537 raid10_resize 2 16537 NULL
105227 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
105228 +perf_event_set_period_16574 perf_event_set_period 2-3 16574 NULL
105229 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
105230 +lustre_msg_hdr_size_v2_16589 lustre_msg_hdr_size_v2 0 16589 NULL
105231 +btrfs_insert_orphan_item_16602 btrfs_insert_orphan_item 0 16602 NULL
105232 +gmux_index_read32_16604 gmux_index_read32 0 16604 NULL
105233 +btrfs_end_transaction_16610 btrfs_end_transaction 0 16610 NULL
105234 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
105235 +btrfs_wait_marked_extents_16615 btrfs_wait_marked_extents 0 16615 NULL
105236 +rtw_set_wpa_ie_16633 rtw_set_wpa_ie 3 16633 NULL
105237 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
105238 +packet_recv_error_16669 packet_recv_error 3 16669 NULL
105239 +__proc_lnet_buffers_16717 __proc_lnet_buffers 5 16717 NULL
105240 +__copy_to_user_swizzled_16748 __copy_to_user_swizzled 3-4 16748 NULL
105241 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
105242 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
105243 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
105244 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
105245 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
105246 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
105247 +cache_grow_16818 cache_grow 3 16818 NULL
105248 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
105249 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
105250 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
105251 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
105252 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
105253 +st_write_16874 st_write 3 16874 NULL
105254 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
105255 +transport_init_session_tags_16878 transport_init_session_tags 1-2 16878 NULL
105256 +ext4_ext_zeroout_16895 ext4_ext_zeroout 0 16895 NULL
105257 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
105258 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
105259 +_sp2d_alloc_16944 _sp2d_alloc 3-2-1 16944 NULL
105260 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
105261 +wrm_16966 wrm 0 16966 NULL
105262 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
105263 +ocfs2_read_quota_phys_block_16990 ocfs2_read_quota_phys_block 0 16990 NULL
105264 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
105265 +snd_mask_refine_first_17026 snd_mask_refine_first 0 17026 NULL
105266 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
105267 +btrfs_unlink_inode_17043 btrfs_unlink_inode 0 17043 NULL
105268 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
105269 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
105270 +__copy_user_nocache_17065 __copy_user_nocache 0 17065 NULL
105271 +sddr55_read_data_17072 sddr55_read_data 4 17072 NULL
105272 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
105273 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
105274 +__kmalloc_reserve_17080 __kmalloc_reserve 3 17080 NULL
105275 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
105276 +entry_length_17093 entry_length 0 17093 NULL
105277 +ocfs2_get_refcount_cpos_end_17113 ocfs2_get_refcount_cpos_end 0 17113 NULL
105278 +write_mem_17114 write_mem 3 17114 NULL
105279 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
105280 +wrmaltWithLock_17139 wrmaltWithLock 0 17139 NULL
105281 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
105282 +jumpshot_write_data_17151 jumpshot_write_data 4 17151 NULL
105283 +sep_read_17161 sep_read 3 17161 NULL
105284 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
105285 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
105286 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
105287 +ocfs2_flock_handle_signal_17189 ocfs2_flock_handle_signal 0 17189 NULL nohasharray
105288 +access_remote_vm_17189 access_remote_vm 0-4-2 17189 &ocfs2_flock_handle_signal_17189 nohasharray
105289 +iwl_dbgfs_txfifo_flush_write_17189 iwl_dbgfs_txfifo_flush_write 3 17189 &access_remote_vm_17189
105290 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
105291 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
105292 +sync_request_17208 sync_request 2 17208 NULL
105293 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
105294 +send_write_or_clone_17241 send_write_or_clone 0 17241 NULL
105295 +to_oblock_17254 to_oblock 0-1 17254 NULL
105296 +unpack_value_17259 unpack_value 1 17259 NULL
105297 +lprocfs_read_frac_helper_17261 lprocfs_read_frac_helper 0 17261 NULL
105298 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
105299 +alloc_reserved_file_extent_17267 alloc_reserved_file_extent 0 17267 NULL
105300 +alloc_ep_17269 alloc_ep 1 17269 NULL
105301 +hw_test_and_write_17271 hw_test_and_write 3 17271 NULL
105302 +pg_read_17276 pg_read 3 17276 NULL
105303 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
105304 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
105305 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
105306 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
105307 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
105308 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
105309 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
105310 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
105311 +SYSC_pread64_17337 SYSC_pread64 3 17337 NULL
105312 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
105313 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
105314 +mdc_import_seq_write_17409 mdc_import_seq_write 3 17409 NULL
105315 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
105316 +compat_sys_ppoll_17430 compat_sys_ppoll 2 17430 NULL
105317 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
105318 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
105319 +libcfs_ipif_enumerate_17445 libcfs_ipif_enumerate 0 17445 NULL
105320 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
105321 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
105322 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
105323 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
105324 +lookup_tree_block_ref_17494 lookup_tree_block_ref 0 17494 NULL
105325 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
105326 +lbs_highrssi_write_17515 lbs_highrssi_write 3 17515 NULL
105327 +qp_free_res_17541 qp_free_res 5 17541 NULL
105328 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
105329 +__copy_to_user_17551 __copy_to_user 3-0 17551 NULL
105330 +copy_from_user_17559 copy_from_user 3-0 17559 NULL
105331 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
105332 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
105333 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
105334 +__inode_info_17603 __inode_info 0 17603 NULL
105335 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
105336 +osst_execute_17607 osst_execute 7-6 17607 NULL
105337 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
105338 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
105339 +dma_map_page_17628 dma_map_page 0 17628 NULL
105340 +ocfs2_rotate_subtree_left_17634 ocfs2_rotate_subtree_left 0 17634 NULL
105341 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
105342 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
105343 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
105344 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
105345 +kernel_write_17665 kernel_write 3 17665 NULL
105346 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
105347 +filemap_fdatawait_17688 filemap_fdatawait 0 17688 NULL
105348 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2-0 17693 NULL
105349 +__einj_error_trigger_17707 __einj_error_trigger 0 17707 NULL nohasharray
105350 +venus_rename_17707 venus_rename 4-5 17707 &__einj_error_trigger_17707
105351 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
105352 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
105353 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
105354 +dgap_do_fep_load_17765 dgap_do_fep_load 3 17765 NULL
105355 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
105356 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
105357 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
105358 +perf_clock_17787 perf_clock 0 17787 NULL
105359 +ubifs_leb_change_17789 ubifs_leb_change 0-4 17789 NULL
105360 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL nohasharray
105361 +shrink_slab_node_17794 shrink_slab_node 3-4 17794 &get_unaligned_be64_17794
105362 +bkey_to_cacheline_17811 bkey_to_cacheline 0 17811 NULL
105363 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
105364 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
105365 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
105366 +dm_stats_message_17863 dm_stats_message 5 17863 NULL
105367 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
105368 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
105369 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
105370 +orinoco_set_key_17878 orinoco_set_key 7-5 17878 NULL nohasharray
105371 +i40e_align_l2obj_base_17878 i40e_align_l2obj_base 0-1 17878 &orinoco_set_key_17878
105372 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
105373 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
105374 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
105375 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
105376 +recover_head_17904 recover_head 3 17904 NULL
105377 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
105378 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
105379 +__mutex_lock_check_stamp_17947 __mutex_lock_check_stamp 0 17947 NULL
105380 +beacon_interval_write_17952 beacon_interval_write 3 17952 NULL
105381 +ufs_free_blocks_17963 ufs_free_blocks 3-2 17963 NULL nohasharray
105382 +tlv_put_u64_17963 tlv_put_u64 0 17963 &ufs_free_blocks_17963
105383 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
105384 +ext4_ext_calc_credits_for_single_extent_17983 ext4_ext_calc_credits_for_single_extent 0-2 17983 NULL
105385 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
105386 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
105387 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
105388 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
105389 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
105390 +fill_read_18019 fill_read 0 18019 NULL
105391 +o2hb_highest_node_18034 o2hb_highest_node 2-0 18034 NULL
105392 +__posix_lock_file_18035 __posix_lock_file 0 18035 NULL
105393 +ocfs2_cache_cluster_dealloc_18043 ocfs2_cache_cluster_dealloc 0 18043 NULL
105394 +cryptd_alloc_instance_18048 cryptd_alloc_instance 3-2 18048 NULL
105395 +find_next_inuse_18051 find_next_inuse 2-3-0 18051 NULL
105396 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
105397 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
105398 +fpregs_get_18066 fpregs_get 4 18066 NULL
105399 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
105400 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
105401 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
105402 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
105403 +hfs_direct_IO_18104 hfs_direct_IO 4 18104 NULL
105404 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
105405 +svc_getnl_18120 svc_getnl 0 18120 NULL
105406 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-2-1 18131 NULL
105407 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
105408 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
105409 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
105410 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
105411 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
105412 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
105413 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
105414 +ocfs2_divide_leaf_refcount_block_18214 ocfs2_divide_leaf_refcount_block 0 18214 NULL
105415 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
105416 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
105417 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
105418 +rfcomm_sock_setsockopt_18254 rfcomm_sock_setsockopt 5 18254 NULL
105419 +__sysfs_add_one_18258 __sysfs_add_one 0 18258 NULL
105420 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
105421 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
105422 +alloc_ring_18278 alloc_ring 4-2-8 18278 NULL
105423 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
105424 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
105425 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
105426 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
105427 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
105428 +um_idi_write_18293 um_idi_write 3 18293 NULL
105429 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
105430 +vga_r_18310 vga_r 0 18310 NULL
105431 +class_add_profile_18315 class_add_profile 1-3-5 18315 NULL
105432 +csio_mem_read_18319 csio_mem_read 3 18319 NULL
105433 +alloc_and_copy_string_18321 alloc_and_copy_string 2 18321 NULL
105434 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
105435 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
105436 +__inorder_to_tree_18329 __inorder_to_tree 0-3-1 18329 NULL
105437 +lcd_proc_write_18351 lcd_proc_write 3 18351 NULL
105438 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
105439 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
105440 +SyS_process_vm_readv_18366 SyS_process_vm_readv 5-3 18366 NULL
105441 +ep_io_18367 ep_io 0 18367 NULL
105442 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
105443 +ci_role_write_18388 ci_role_write 3 18388 NULL nohasharray
105444 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 &ci_role_write_18388
105445 +btrfs_update_inode_18394 btrfs_update_inode 0 18394 NULL
105446 +hdlc_empty_fifo_18397 hdlc_empty_fifo 2 18397 NULL
105447 +__video_register_device_18399 __video_register_device 3 18399 NULL
105448 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
105449 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
105450 +btrfs_rmap_block_18403 btrfs_rmap_block 0 18403 NULL
105451 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
105452 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
105453 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
105454 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
105455 +btrfs_uuid_tree_lookup_18451 btrfs_uuid_tree_lookup 0 18451 NULL
105456 +flash_dev_cache_miss_18454 flash_dev_cache_miss 4 18454 NULL
105457 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
105458 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
105459 +pcibios_window_alignment_18460 pcibios_window_alignment 0 18460 NULL
105460 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
105461 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL nohasharray
105462 +mite_bytes_in_transit_18479 mite_bytes_in_transit 0 18479 &pci_vpd_lrdt_size_18479
105463 +r600_texture_size_18487 r600_texture_size 4-5-6 18487 NULL nohasharray
105464 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 &r600_texture_size_18487
105465 +btrfs_fiemap_18501 btrfs_fiemap 3 18501 NULL nohasharray
105466 +remap_pmd_range_18501 remap_pmd_range 3-4-5 18501 &btrfs_fiemap_18501
105467 +i915_gem_object_wait_fence_18508 i915_gem_object_wait_fence 0 18508 NULL
105468 +__copy_user_zeroing_intel_18510 __copy_user_zeroing_intel 0-3 18510 NULL
105469 +snd_vx_inb_18514 snd_vx_inb 0 18514 NULL
105470 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
105471 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 9 18530 NULL
105472 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
105473 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
105474 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
105475 +vb2_streamon_18562 vb2_streamon 0 18562 NULL
105476 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
105477 +debug_output_18575 debug_output 3 18575 NULL
105478 +is_extent_unchanged_18576 is_extent_unchanged 0 18576 NULL
105479 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
105480 +numa_node_id_18596 numa_node_id 0 18596 NULL
105481 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
105482 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
105483 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
105484 +audio_get_endpoint_req_18624 audio_get_endpoint_req 0 18624 NULL
105485 +from_buffer_18625 from_buffer 3 18625 NULL
105486 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
105487 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
105488 +unmap_page_18665 unmap_page 2-3 18665 NULL
105489 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
105490 +__alloc_skb_head_18683 __alloc_skb_head 2 18683 NULL
105491 +echo_client_prep_commit_18693 echo_client_prep_commit 8 18693 NULL
105492 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
105493 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
105494 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
105495 +ocfs2_trim_extent_18711 ocfs2_trim_extent 3-4 18711 NULL
105496 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
105497 +byt_gpio_to_irq_18721 byt_gpio_to_irq 2 18721 NULL
105498 +ext4_es_insert_extent_18729 ext4_es_insert_extent 0 18729 NULL
105499 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
105500 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
105501 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
105502 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
105503 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
105504 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
105505 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
105506 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
105507 +prealloc_18800 prealloc 0 18800 NULL
105508 +alloc_pages_node_18809 alloc_pages_node 1 18809 NULL
105509 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
105510 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
105511 +dm_stats_print_18815 dm_stats_print 7 18815 NULL
105512 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
105513 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
105514 +iterate_inode_refs_18846 iterate_inode_refs 0 18846 NULL
105515 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
105516 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
105517 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL nohasharray
105518 +heads_to_leaves_18869 heads_to_leaves 2-0 18869 &ieee80211_if_read_element_ttl_18869
105519 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
105520 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
105521 +overwrite_item_18896 overwrite_item 0 18896 NULL
105522 +kmem_cache_alloc_node_18899 kmem_cache_alloc_node 3 18899 NULL
105523 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
105524 +ext4_block_in_group_18922 ext4_block_in_group 2 18922 NULL
105525 +ieee80211_rx_mgmt_disassoc_18927 ieee80211_rx_mgmt_disassoc 3 18927 NULL
105526 +create_pending_snapshot_18936 create_pending_snapshot 0 18936 NULL
105527 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
105528 +regcache_sync_block_18963 regcache_sync_block 4-3 18963 NULL
105529 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
105530 +__blockdev_direct_IO_18977 __blockdev_direct_IO 0-6 18977 NULL
105531 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
105532 +get_inode_path_18988 get_inode_path 0 18988 NULL
105533 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL nohasharray
105534 +test_check_exists_19001 test_check_exists 2 19001 &find_dirtiest_idx_leb_19001
105535 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
105536 +huge_page_size_19008 huge_page_size 0 19008 NULL
105537 +push_leaf_right_19017 push_leaf_right 0 19017 NULL
105538 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
105539 +ocfs2_steal_resource_19036 ocfs2_steal_resource 0 19036 NULL
105540 +revalidate_19043 revalidate 2 19043 NULL
105541 +afs_vnode_store_data_19048 afs_vnode_store_data 2-3-4-5 19048 NULL
105542 +osc_pinger_recov_seq_write_19056 osc_pinger_recov_seq_write 3 19056 NULL
105543 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
105544 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
105545 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
105546 +kvm_lapic_set_vapic_addr_19083 kvm_lapic_set_vapic_addr 2 19083 NULL
105547 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
105548 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
105549 +ATOMIC_SUB_RETURN_19115 ATOMIC_SUB_RETURN 2 19115 NULL
105550 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
105551 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
105552 +btrfs_run_delayed_refs_19137 btrfs_run_delayed_refs 0 19137 NULL
105553 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
105554 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
105555 +ext3_reserve_inode_write_19163 ext3_reserve_inode_write 0 19163 NULL
105556 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
105557 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
105558 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
105559 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3-0 19214 NULL
105560 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
105561 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
105562 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
105563 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
105564 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
105565 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
105566 +ucma_query_19260 ucma_query 4 19260 NULL
105567 +write_one_cache_group_19261 write_one_cache_group 0 19261 NULL
105568 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
105569 +cfg80211_rx_unprot_mlme_mgmt_19288 cfg80211_rx_unprot_mlme_mgmt 3 19288 NULL
105570 +____cache_alloc_node_19297 ____cache_alloc_node 3 19297 NULL
105571 +qc_capture_19298 qc_capture 3 19298 NULL
105572 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 4-3 19303 NULL
105573 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
105574 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
105575 +debug_read_19322 debug_read 3 19322 NULL
105576 +SYSC_sendfile64_19327 SYSC_sendfile64 4 19327 NULL
105577 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL nohasharray
105578 +lbs_host_sleep_write_19332 lbs_host_sleep_write 3 19332 &cfg80211_inform_bss_19332
105579 +closure_sub_19359 closure_sub 2 19359 NULL
105580 +firmware_data_write_19360 firmware_data_write 6-5 19360 NULL
105581 +read_zero_19366 read_zero 3 19366 NULL
105582 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
105583 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
105584 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
105585 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
105586 +pep_recvmsg_19402 pep_recvmsg 4 19402 NULL
105587 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
105588 +__phys_addr_19434 __phys_addr 0 19434 NULL
105589 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
105590 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
105591 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
105592 +sky2_read16_19475 sky2_read16 0 19475 NULL
105593 +__read_status_pciv2_19492 __read_status_pciv2 0 19492 NULL
105594 +kstrtoll_from_user_19500 kstrtoll_from_user 2 19500 NULL
105595 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
105596 +cfc_write_array_to_buffer_19529 cfc_write_array_to_buffer 3 19529 NULL nohasharray
105597 +apei_exec_pre_map_gars_19529 apei_exec_pre_map_gars 0 19529 &cfc_write_array_to_buffer_19529
105598 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
105599 +howmany_64_19548 howmany_64 2 19548 NULL
105600 +btrfs_xattr_security_init_19553 btrfs_xattr_security_init 0 19553 NULL
105601 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
105602 +kernel_read_19559 kernel_read 4-0 19559 NULL
105603 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
105604 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL
105605 +nfsd_read_19568 nfsd_read 5 19568 NULL
105606 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
105607 +bm_status_read_19583 bm_status_read 3 19583 NULL
105608 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
105609 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
105610 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
105611 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
105612 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
105613 +i915_gem_object_bind_to_gtt_19682 i915_gem_object_bind_to_gtt 0 19682 NULL
105614 +bio_detain_19690 bio_detain 2 19690 NULL
105615 +btrfs_del_inode_extref_19692 btrfs_del_inode_extref 0 19692 NULL
105616 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
105617 +btrfs_write_marked_extents_19720 btrfs_write_marked_extents 0 19720 NULL
105618 +read_reg_19723 read_reg 0 19723 NULL
105619 +wm8350_block_write_19727 wm8350_block_write 2-3 19727 NULL
105620 +memcpy_toiovecend_19736 memcpy_toiovecend 3-4-0 19736 NULL
105621 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
105622 +p9_client_read_19750 p9_client_read 0-5 19750 NULL
105623 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
105624 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
105625 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
105626 +readhscx_19769 readhscx 0 19769 NULL
105627 +ocfs2_read_group_descriptor_19771 ocfs2_read_group_descriptor 0 19771 NULL
105628 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
105629 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
105630 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
105631 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
105632 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
105633 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
105634 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
105635 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
105636 +__nla_put_19857 __nla_put 3 19857 NULL
105637 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
105638 +blk_alloc_queue_node_19887 blk_alloc_queue_node 2 19887 NULL
105639 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
105640 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
105641 +mangle_name_19923 mangle_name 0 19923 NULL
105642 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
105643 +guest_read_tsc_19931 guest_read_tsc 0 19931 NULL
105644 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
105645 +cfg80211_rx_assoc_resp_19944 cfg80211_rx_assoc_resp 4 19944 NULL
105646 +alloc_elfnotes_buf_19974 alloc_elfnotes_buf 1 19974 NULL
105647 +get_jack_mode_name_19976 get_jack_mode_name 4 19976 NULL
105648 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
105649 +rtw_set_wps_probe_resp_19989 rtw_set_wps_probe_resp 3 19989 NULL
105650 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
105651 +lov_stripe_md_size_20009 lov_stripe_md_size 0-1 20009 NULL
105652 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
105653 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
105654 +mlx5_ib_db_map_user_20037 mlx5_ib_db_map_user 2 20037 NULL
105655 +btrfs_block_rsv_migrate_20050 btrfs_block_rsv_migrate 0 20050 NULL
105656 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
105657 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
105658 +iwl_mvm_power_mac_dbgfs_read_20067 iwl_mvm_power_mac_dbgfs_read 4 20067 NULL
105659 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
105660 +target_message_20072 target_message 2 20072 NULL
105661 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
105662 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
105663 +aat2870_reg_write_file_20086 aat2870_reg_write_file 3 20086 NULL
105664 +team_options_register_20091 team_options_register 3 20091 NULL
105665 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
105666 +read_int_20098 read_int 0 20098 NULL
105667 +root_nfs_copy_20111 root_nfs_copy 3 20111 NULL
105668 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
105669 +self_check_vid_hdr_20131 self_check_vid_hdr 0 20131 NULL
105670 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
105671 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
105672 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
105673 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
105674 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
105675 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
105676 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
105677 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
105678 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
105679 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
105680 +resource_size_20256 resource_size 0 20256 NULL
105681 +uv_blade_to_memory_nid_20259 uv_blade_to_memory_nid 0 20259 NULL
105682 +r10_sync_page_io_20307 r10_sync_page_io 3 20307 NULL
105683 +dm_get_reserved_bio_based_ios_20315 dm_get_reserved_bio_based_ios 0 20315 NULL
105684 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
105685 +vx_send_msg_nolock_20322 vx_send_msg_nolock 0 20322 NULL
105686 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
105687 +ocfs2_et_insert_check_20341 ocfs2_et_insert_check 0 20341 NULL
105688 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
105689 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
105690 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
105691 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
105692 +block_read_full_page_20380 block_read_full_page 0 20380 NULL
105693 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL nohasharray
105694 +read_7220_creg32_20394 read_7220_creg32 0 20394 &snd_nm256_readl_20394
105695 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL nohasharray
105696 +SyS_get_mempolicy_20399 SyS_get_mempolicy 3-4 20399 &__kfifo_from_user_20399
105697 +btrfs_set_acl_20440 btrfs_set_acl 0 20440 NULL
105698 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
105699 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
105700 +read_buf_20469 read_buf 2 20469 NULL
105701 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
105702 +fast_user_write_20494 fast_user_write 5 20494 NULL
105703 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL
105704 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
105705 +link_free_space_20512 link_free_space 0 20512 NULL
105706 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 3-2 20517 NULL
105707 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
105708 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
105709 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
105710 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
105711 +venus_create_20555 venus_create 4 20555 NULL
105712 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
105713 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
105714 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL nohasharray
105715 +ocfs2_cluster_lock_20588 ocfs2_cluster_lock 0 20588 &batadv_tt_append_diff_20588
105716 +kvm_test_age_hva_20593 kvm_test_age_hva 2 20593 NULL
105717 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
105718 +lirc_write_20604 lirc_write 3 20604 NULL
105719 +qib_qsfp_write_20614 qib_qsfp_write 0-2-4 20614 NULL
105720 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
105721 +get_extent_skip_holes_20642 get_extent_skip_holes 2 20642 NULL
105722 +kfifo_copy_to_user_20646 kfifo_copy_to_user 4-3 20646 NULL
105723 +cpulist_scnprintf_20648 cpulist_scnprintf 2-0 20648 NULL
105724 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
105725 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
105726 +btrfs_qgroup_reserve_20676 btrfs_qgroup_reserve 0 20676 NULL nohasharray
105727 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 &btrfs_qgroup_reserve_20676
105728 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
105729 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
105730 +cpumask_size_20683 cpumask_size 0 20683 NULL
105731 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
105732 +gru_vtop_20689 gru_vtop 2 20689 NULL
105733 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
105734 +i915_gem_obj_ggtt_pin_20698 i915_gem_obj_ggtt_pin 0 20698 NULL
105735 +__maestro_read_20700 __maestro_read 0 20700 NULL
105736 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
105737 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
105738 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
105739 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
105740 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
105741 +fb_prepare_logo_20743 fb_prepare_logo 0 20743 NULL
105742 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
105743 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
105744 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
105745 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
105746 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
105747 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
105748 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
105749 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
105750 +ext4_convert_unwritten_extents_endio_20812 ext4_convert_unwritten_extents_endio 0 20812 NULL
105751 +strndup_user_20819 strndup_user 2 20819 NULL
105752 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
105753 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
105754 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
105755 +btrfs_orphan_add_20840 btrfs_orphan_add 0 20840 NULL
105756 +p9_tag_alloc_20845 p9_tag_alloc 3 20845 NULL
105757 +nvme_trans_supported_vpd_pages_20847 nvme_trans_supported_vpd_pages 4 20847 NULL
105758 +get_name_20855 get_name 4 20855 NULL
105759 +iwl_dbgfs_pm_params_read_20866 iwl_dbgfs_pm_params_read 3 20866 NULL
105760 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
105761 +srq_free_res_20868 srq_free_res 5 20868 NULL
105762 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
105763 +cfs_cpt_table_create_20884 cfs_cpt_table_create 1 20884 NULL
105764 +rb_simple_write_20890 rb_simple_write 3 20890 NULL
105765 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
105766 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
105767 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
105768 +lbs_rdbbp_write_20918 lbs_rdbbp_write 3 20918 NULL
105769 +htable_bits_20933 htable_bits 0 20933 NULL
105770 +check_eofblocks_fl_20942 check_eofblocks_fl 0 20942 NULL
105771 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
105772 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
105773 +rsxx_cram_read_20957 rsxx_cram_read 3 20957 NULL
105774 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
105775 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
105776 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
105777 +qib_verbs_send_20999 qib_verbs_send 5-3 20999 NULL
105778 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4-0 21001 NULL
105779 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
105780 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
105781 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
105782 +reiserfs_direct_IO_21051 reiserfs_direct_IO 4 21051 NULL
105783 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
105784 +btrfs_insert_root_21061 btrfs_insert_root 0 21061 NULL
105785 +qdisc_get_default_21072 qdisc_get_default 2 21072 NULL
105786 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
105787 +bl_add_page_to_bio_21094 bl_add_page_to_bio 2 21094 NULL nohasharray
105788 +multipath_status_21094 multipath_status 5 21094 &bl_add_page_to_bio_21094
105789 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
105790 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
105791 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
105792 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
105793 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
105794 +chunk_size_21146 chunk_size 0 21146 NULL
105795 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
105796 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
105797 +btrfs_add_root_ref_21186 btrfs_add_root_ref 0 21186 NULL
105798 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
105799 +get_current_ntfs_time_21198 get_current_ntfs_time 0 21198 NULL
105800 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
105801 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
105802 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4-0 21220 NULL
105803 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
105804 +SyS_mlock_21238 SyS_mlock 1-2 21238 NULL
105805 +input_ff_create_21240 input_ff_create 2 21240 NULL
105806 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
105807 +fru_length_21257 fru_length 0 21257 NULL
105808 +rtw_set_wps_beacon_21262 rtw_set_wps_beacon 3 21262 NULL
105809 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
105810 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
105811 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
105812 +add_res_range_21310 add_res_range 4 21310 NULL
105813 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
105814 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
105815 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
105816 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
105817 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
105818 +split_leaf_21378 split_leaf 0 21378 NULL
105819 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
105820 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
105821 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
105822 +sle64_to_cpu_21400 sle64_to_cpu 0-1 21400 NULL
105823 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
105824 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
105825 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
105826 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
105827 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
105828 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
105829 +ReadISAR_21453 ReadISAR 0 21453 NULL
105830 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
105831 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
105832 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
105833 +dma_skb_copy_datagram_iovec_21516 dma_skb_copy_datagram_iovec 3-5 21516 NULL
105834 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
105835 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
105836 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
105837 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
105838 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
105839 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
105840 +snd_es18xx_mixer_read_21586 snd_es18xx_mixer_read 0 21586 NULL
105841 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
105842 +filemap_get_page_21606 filemap_get_page 2 21606 NULL
105843 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
105844 +pci_cardbus_resource_alignment_21625 pci_cardbus_resource_alignment 0 21625 NULL
105845 +add_pin_to_irq_node_21628 add_pin_to_irq_node 2 21628 NULL
105846 +ocfs2_refcount_cow_hunk_21630 ocfs2_refcount_cow_hunk 3-4 21630 NULL
105847 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
105848 +validate_nnode_21638 validate_nnode 0 21638 NULL
105849 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-0-3-4 21639 NULL
105850 +ocfs2_lock_refcount_allocators_21646 ocfs2_lock_refcount_allocators 0 21646 NULL
105851 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
105852 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
105853 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1 21687 NULL
105854 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
105855 +btrfs_find_all_leafs_21712 btrfs_find_all_leafs 0 21712 NULL
105856 +unix_skb_len_21722 unix_skb_len 0 21722 NULL
105857 +lprocfs_wr_import_21728 lprocfs_wr_import 3 21728 NULL
105858 +ocfs2_remove_rightmost_path_21729 ocfs2_remove_rightmost_path 0 21729 NULL
105859 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL nohasharray
105860 +ext4_split_extent_at_21732 ext4_split_extent_at 0 21732 &reiserfs_allocate_list_bitmaps_21732
105861 +vm_brk_21739 vm_brk 1-2 21739 NULL
105862 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
105863 +usbat_flash_read_data_21762 usbat_flash_read_data 4 21762 NULL
105864 +gen_pool_add_21776 gen_pool_add 3-4 21776 NULL
105865 +SyS_sendfile_21777 SyS_sendfile 4 21777 NULL
105866 +atomic64_cmpxchg_21782 atomic64_cmpxchg 0 21782 NULL
105867 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
105868 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
105869 +__ocfs2_cluster_lock_21812 __ocfs2_cluster_lock 0 21812 NULL
105870 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
105871 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
105872 +gen_unique_name_21852 gen_unique_name 0 21852 NULL
105873 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
105874 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
105875 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL
105876 +ldlm_lock_create_21888 ldlm_lock_create 7 21888 NULL
105877 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 2-1 21895 NULL
105878 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
105879 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
105880 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
105881 +ast_ttm_tt_create_21917 ast_ttm_tt_create 2 21917 NULL
105882 +__ocfs2_claim_clusters_21936 __ocfs2_claim_clusters 0 21936 NULL
105883 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
105884 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
105885 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
105886 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 3-0 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
105887 +ocfs2_reserve_cluster_bitmap_bits_22016 ocfs2_reserve_cluster_bitmap_bits 0 22016 NULL
105888 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
105889 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
105890 +i915_gem_evict_something_22028 i915_gem_evict_something 0 22028 NULL
105891 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
105892 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
105893 +atalk_recvmsg_22053 atalk_recvmsg 4 22053 NULL
105894 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
105895 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2-3 22077 NULL
105896 +write_opcode_22082 write_opcode 2 22082 NULL
105897 +mem_rw_22085 mem_rw 3 22085 NULL
105898 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
105899 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
105900 +rt2x00debug_read_crypto_stats_22109 rt2x00debug_read_crypto_stats 3 22109 NULL
105901 +shmem_add_to_page_cache_22121 shmem_add_to_page_cache 0 22121 NULL
105902 +snd_hda_codec_read_22130 snd_hda_codec_read 0 22130 NULL
105903 +SyS_sched_setaffinity_22148 SyS_sched_setaffinity 2 22148 NULL
105904 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
105905 +remap_pud_range_22164 remap_pud_range 3-4-5 22164 NULL
105906 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL nohasharray
105907 +vmci_qp_broker_map_22173 vmci_qp_broker_map 3 22173 &__kfifo_alloc_22173
105908 +fls_22210 fls 0 22210 NULL
105909 +rfcomm_sock_recvmsg_22227 rfcomm_sock_recvmsg 4 22227 NULL nohasharray
105910 +bitmap_clear_bits_22227 bitmap_clear_bits 3 22227 &rfcomm_sock_recvmsg_22227
105911 +mem_write_22232 mem_write 3 22232 NULL
105912 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
105913 +fsnotify_parent_22243 fsnotify_parent 0 22243 NULL
105914 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
105915 +ping_common_sendmsg_22261 ping_common_sendmsg 5 22261 NULL
105916 +add_res_tree_22263 add_res_tree 7 22263 NULL
105917 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
105918 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
105919 +i915_gem_execbuffer_relocate_22294 i915_gem_execbuffer_relocate 0 22294 NULL
105920 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
105921 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
105922 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
105923 +lov_setstripe_22307 lov_setstripe 2 22307 NULL
105924 +udpv6_sendmsg_22316 udpv6_sendmsg 4 22316 NULL
105925 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 3 22320 NULL
105926 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 3-2-0 22334 NULL
105927 +atomic_read_22342 atomic_read 0 22342 NULL
105928 +ll_lazystatfs_seq_write_22353 ll_lazystatfs_seq_write 3 22353 NULL
105929 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
105930 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
105931 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
105932 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
105933 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
105934 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
105935 +alloc_large_system_hash_22391 alloc_large_system_hash 2-8-9 22391 NULL
105936 +ocfs2_assign_bh_22392 ocfs2_assign_bh 0 22392 NULL
105937 +zoran_write_22404 zoran_write 3 22404 NULL
105938 +ATOMIC_ADD_RETURN_22413 ATOMIC_ADD_RETURN 2 22413 NULL
105939 +queue_reply_22416 queue_reply 3 22416 NULL
105940 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
105941 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
105942 +_rtw_vmalloc_22444 _rtw_vmalloc 1 22444 NULL
105943 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
105944 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
105945 +btrfs_write_out_cache_22471 btrfs_write_out_cache 0 22471 NULL nohasharray
105946 +dtf_write_device_22471 dtf_write_device 3 22471 &btrfs_write_out_cache_22471
105947 +source_sink_start_ep_22472 source_sink_start_ep 0 22472 NULL
105948 +alloc_desc_22487 alloc_desc 2 22487 NULL
105949 +ecryptfs_write_22488 ecryptfs_write 4-3 22488 NULL
105950 +qib_user_sdma_alloc_header_22490 qib_user_sdma_alloc_header 2 22490 NULL
105951 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
105952 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
105953 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
105954 +__btrfs_add_delayed_item_22511 __btrfs_add_delayed_item 0 22511 NULL
105955 +trim_no_bitmap_22524 trim_no_bitmap 4-3 22524 NULL
105956 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
105957 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
105958 +snd_pcm_hw_params_choose_22560 snd_pcm_hw_params_choose 0 22560 NULL
105959 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
105960 +snapshot_read_22601 snapshot_read 3 22601 NULL
105961 +ocfs2_get_refcount_block_22610 ocfs2_get_refcount_block 0 22610 NULL
105962 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
105963 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
105964 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
105965 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
105966 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
105967 +sysfs_attr_ns_22645 sysfs_attr_ns 0 22645 NULL
105968 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
105969 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 3 22661 NULL
105970 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL nohasharray
105971 +ext4_ext_direct_IO_22679 ext4_ext_direct_IO 4 22679 &ubifs_leb_write_22679
105972 +fill_gap_22681 fill_gap 0 22681 NULL nohasharray
105973 +l2tp_ip_recvmsg_22681 l2tp_ip_recvmsg 4 22681 &fill_gap_22681
105974 +bch_dump_read_22685 bch_dump_read 3 22685 NULL
105975 +reg_umr_22686 reg_umr 5 22686 NULL
105976 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
105977 +map_22700 map 2 22700 NULL nohasharray
105978 +btrfs_del_inode_ref_in_log_22700 btrfs_del_inode_ref_in_log 0 22700 &map_22700
105979 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
105980 +ecryptfs_write_metadata_to_contents_22721 ecryptfs_write_metadata_to_contents 3 22721 NULL
105981 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4-0 22735 NULL
105982 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
105983 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
105984 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
105985 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
105986 +print_frame_22769 print_frame 0 22769 NULL
105987 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
105988 +ocfs2_block_group_alloc_22774 ocfs2_block_group_alloc 0 22774 NULL
105989 +pla_ocp_write_22802 pla_ocp_write 4 22802 NULL
105990 +__generic_copy_to_user_intel_22806 __generic_copy_to_user_intel 0-3 22806 NULL
105991 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
105992 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
105993 +create_attr_set_22861 create_attr_set 1 22861 NULL
105994 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
105995 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
105996 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
105997 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
105998 +__btrfs_add_free_space_22917 __btrfs_add_free_space 0 22917 NULL
105999 +xstateregs_set_22932 xstateregs_set 4 22932 NULL
106000 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
106001 +alloc_sglist_22960 alloc_sglist 3-2 22960 NULL
106002 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
106003 +vme_get_size_22964 vme_get_size 0 22964 NULL
106004 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
106005 +cached_dev_cache_miss_22979 cached_dev_cache_miss 4 22979 NULL
106006 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
106007 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
106008 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
106009 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
106010 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
106011 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
106012 +ocfs2_refcount_cow_xattr_23029 ocfs2_refcount_cow_xattr 0-6-7 23029 NULL
106013 +st_status_23032 st_status 5 23032 NULL
106014 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
106015 +comedi_buf_write_n_available_23057 comedi_buf_write_n_available 0 23057 NULL
106016 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL nohasharray
106017 +unix_seqpacket_recvmsg_23062 unix_seqpacket_recvmsg 4 23062 &reiserfs_add_entry_23062
106018 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
106019 +filp_close_23071 filp_close 0 23071 NULL
106020 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
106021 +vm_map_ram_23078 vm_map_ram 3 23078 NULL nohasharray
106022 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
106023 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
106024 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
106025 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
106026 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
106027 +__add_prelim_ref_23095 __add_prelim_ref 0 23095 NULL
106028 +fls_long_23096 fls_long 0 23096 NULL
106029 +ntfs_ucstonls_23097 ntfs_ucstonls 5-3 23097 NULL
106030 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
106031 +dgram_recvmsg_23104 dgram_recvmsg 4 23104 NULL
106032 +ip_recv_error_23109 ip_recv_error 3 23109 NULL
106033 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
106034 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
106035 +__clear_user_23118 __clear_user 0-2 23118 NULL
106036 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
106037 +ata_scsi_change_queue_depth_23126 ata_scsi_change_queue_depth 2 23126 NULL
106038 +ext3_listxattr_23137 ext3_listxattr 3 23137 NULL
106039 +read_file_ani_23161 read_file_ani 3 23161 NULL
106040 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
106041 +usblp_write_23178 usblp_write 3 23178 NULL
106042 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
106043 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
106044 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
106045 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
106046 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
106047 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL
106048 +tty_buffer_request_room_23228 tty_buffer_request_room 2-0 23228 NULL
106049 +__read_status_pci_23229 __read_status_pci 0 23229 NULL nohasharray
106050 +xlog_get_bp_23229 xlog_get_bp 2 23229 &__read_status_pci_23229
106051 +ft1000_read_dpram_mag_32_23232 ft1000_read_dpram_mag_32 0 23232 NULL
106052 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
106053 +__gfn_to_rmap_23240 __gfn_to_rmap 2-1 23240 NULL
106054 +sctp_recvmsg_23265 sctp_recvmsg 4 23265 NULL
106055 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
106056 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
106057 +gru_preload_tlb_23305 gru_preload_tlb 7-4 23305 NULL
106058 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
106059 +__aa_kvmalloc_23320 __aa_kvmalloc 1 23320 NULL
106060 +__es_remove_extent_23323 __es_remove_extent 0 23323 NULL
106061 +page_readlink_23346 page_readlink 3 23346 NULL
106062 +kmem_zalloc_large_23351 kmem_zalloc_large 1 23351 NULL
106063 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
106064 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
106065 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
106066 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
106067 +vzalloc_node_23424 vzalloc_node 1-2 23424 NULL
106068 +vmemmap_populate_basepages_23435 vmemmap_populate_basepages 3 23435 NULL
106069 +__ctzsi2_23444 __ctzsi2 1 23444 NULL
106070 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
106071 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
106072 +__ata_change_queue_depth_23484 __ata_change_queue_depth 3-0 23484 NULL
106073 +linear_conf_23485 linear_conf 2 23485 NULL
106074 +copy_module_from_user_23492 copy_module_from_user 2 23492 NULL
106075 +event_filter_read_23494 event_filter_read 3 23494 NULL
106076 +ext4_remove_blocks_23497 ext4_remove_blocks 0 23497 NULL
106077 +lustre_acl_xattr_merge2ext_23502 lustre_acl_xattr_merge2ext 2 23502 NULL
106078 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
106079 +devm_iio_device_alloc_23511 devm_iio_device_alloc 2 23511 NULL
106080 +__proc_cpt_table_23516 __proc_cpt_table 5 23516 NULL
106081 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
106082 +__es_insert_extent_23543 __es_insert_extent 0 23543 NULL
106083 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
106084 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
106085 +dbg_leb_change_23555 dbg_leb_change 0-4 23555 NULL
106086 +btrfs_super_bytenr_23561 btrfs_super_bytenr 0 23561 NULL
106087 +venus_symlink_23570 venus_symlink 6-4 23570 NULL
106088 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
106089 +xfpregs_get_23586 xfpregs_get 4 23586 NULL
106090 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
106091 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
106092 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
106093 +ocfs2_journal_access_23616 ocfs2_journal_access 0 23616 NULL
106094 +alloc_pte_23642 alloc_pte 3 23642 NULL
106095 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
106096 +sInW_23663 sInW 0 23663 NULL
106097 +SyS_connect_23669 SyS_connect 3 23669 NULL
106098 +cx18_read_23699 cx18_read 3 23699 NULL
106099 +btrfs_insert_delayed_item_23705 btrfs_insert_delayed_item 0 23705 NULL
106100 +at_get_23708 at_get 0 23708 NULL
106101 +snd_pcm_hw_refine_23721 snd_pcm_hw_refine 0 23721 NULL
106102 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
106103 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
106104 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
106105 +svc_prepare_thread_23772 svc_prepare_thread 3 23772 NULL
106106 +__build_packet_message_23778 __build_packet_message 4-10 23778 NULL
106107 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
106108 +cfg80211_inform_bss_width_frame_23782 cfg80211_inform_bss_width_frame 5 23782 NULL
106109 +mpt_free_res_23793 mpt_free_res 5 23793 NULL
106110 +map_write_23795 map_write 3 23795 NULL
106111 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
106112 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
106113 +ocfs2_replace_cow_23803 ocfs2_replace_cow 0 23803 NULL
106114 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
106115 +lustre_msg_buflen_23827 lustre_msg_buflen 0 23827 NULL
106116 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 0-4-3 23829 NULL
106117 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
106118 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
106119 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
106120 +p54_init_common_23850 p54_init_common 1 23850 NULL
106121 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
106122 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
106123 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
106124 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
106125 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
106126 +_rtw_zvmalloc_23892 _rtw_zvmalloc 1 23892 NULL
106127 +tipc_snprintf_23893 tipc_snprintf 2-0 23893 NULL
106128 +usbg_prepare_w_request_23895 usbg_prepare_w_request 0 23895 NULL
106129 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
106130 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
106131 +device_create_bin_file_23914 device_create_bin_file 0 23914 NULL
106132 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
106133 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
106134 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
106135 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL nohasharray
106136 +intel_ring_alloc_seqno_23928 intel_ring_alloc_seqno 0 23928 &kvm_read_guest_23928
106137 +__alloc_skb_23940 __alloc_skb 4 23940 NULL
106138 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
106139 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
106140 +size_roundup_power2_23958 size_roundup_power2 0-1 23958 NULL
106141 +vfs_write_23971 vfs_write 0-3 23971 NULL
106142 +sddr55_write_data_23983 sddr55_write_data 4 23983 NULL
106143 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
106144 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
106145 +intel_ring_idle_24014 intel_ring_idle 0 24014 NULL
106146 +give_pages_24021 give_pages 3 24021 NULL
106147 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
106148 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
106149 +hmac_setkey_24043 hmac_setkey 3 24043 NULL
106150 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
106151 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
106152 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
106153 +ocfs2_cannibalize_resv_24090 ocfs2_cannibalize_resv 3 24090 NULL
106154 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
106155 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
106156 +lov_brw_24122 lov_brw 4 24122 NULL
106157 +mpu401_read_24126 mpu401_read 3-0 24126 NULL
106158 +_picolcd_flash_write_24134 _picolcd_flash_write 4 24134 NULL
106159 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
106160 +SyS_sethostname_24150 SyS_sethostname 2 24150 NULL
106161 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
106162 +set_discard_24162 set_discard 2 24162 NULL
106163 +__copy_user_zeroing_intel_nocache_24163 __copy_user_zeroing_intel_nocache 0-3 24163 NULL
106164 +adu_read_24177 adu_read 3 24177 NULL
106165 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
106166 +shrink_tnc_24190 shrink_tnc 0 24190 NULL
106167 +irq_remapping_setup_msi_irqs_24194 irq_remapping_setup_msi_irqs 2 24194 NULL
106168 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
106169 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
106170 +SyS_sendfile64_24220 SyS_sendfile64 4 24220 NULL
106171 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
106172 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 3-2-1 24224 NULL nohasharray
106173 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
106174 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
106175 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
106176 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
106177 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
106178 +calculate_sizes_24273 calculate_sizes 2 24273 NULL
106179 +thin_status_24278 thin_status 5 24278 NULL
106180 +msg_size_24288 msg_size 0 24288 NULL
106181 +ext2_free_blocks_24292 ext2_free_blocks 3-2 24292 NULL
106182 +i2c_smbus_check_pec_24297 i2c_smbus_check_pec 0 24297 NULL
106183 +map_page_24298 map_page 3-4 24298 NULL
106184 +gserial_connect_24302 gserial_connect 0 24302 NULL
106185 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
106186 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3-0 24313 NULL
106187 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
106188 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
106189 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
106190 +kzalloc_node_24352 kzalloc_node 1-3 24352 NULL
106191 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
106192 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
106193 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
106194 +igetword_24373 igetword 0 24373 NULL
106195 +max_io_len_24384 max_io_len 0-1 24384 NULL
106196 +mpt_alloc_res_24387 mpt_alloc_res 5 24387 NULL
106197 +osc_cur_grant_bytes_seq_write_24396 osc_cur_grant_bytes_seq_write 3 24396 NULL
106198 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
106199 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398 nohasharray
106200 +__btrfs_write_out_cache_24398 __btrfs_write_out_cache 0 24398 &getxattr_24398
106201 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
106202 +nvme_trans_log_supp_pages_24418 nvme_trans_log_supp_pages 3 24418 NULL
106203 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
106204 +xenbus_file_read_24427 xenbus_file_read 3 24427 NULL
106205 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
106206 +copy_and_ioctl_24434 copy_and_ioctl 4 24434 NULL
106207 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 6-4 24439 NULL
106208 +smk_user_access_24440 smk_user_access 3 24440 NULL nohasharray
106209 +rtw_set_wps_assoc_resp_24440 rtw_set_wps_assoc_resp 3 24440 &smk_user_access_24440
106210 +__push_leaf_left_24456 __push_leaf_left 0 24456 NULL
106211 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
106212 +lbs_highsnr_write_24460 lbs_highsnr_write 3 24460 NULL
106213 +skb_copy_and_csum_datagram_iovec_24466 skb_copy_and_csum_datagram_iovec 2 24466 NULL nohasharray
106214 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 6-5 24466 &skb_copy_and_csum_datagram_iovec_24466
106215 +snd_pcm_hw_param_first_24487 snd_pcm_hw_param_first 0 24487 NULL
106216 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
106217 +i915_gem_obj_offset_24494 i915_gem_obj_offset 0 24494 NULL
106218 +push_nodes_for_insert_24496 push_nodes_for_insert 0 24496 NULL
106219 +pd_video_read_24510 pd_video_read 3 24510 NULL
106220 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
106221 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
106222 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
106223 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
106224 +SyS_pselect6_24582 SyS_pselect6 1 24582 NULL
106225 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
106226 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL nohasharray
106227 +lov_alloc_memmd_24605 lov_alloc_memmd 2 24605 &sensor_hub_get_physical_device_count_24605
106228 +SyS_poll_24620 SyS_poll 2 24620 NULL
106229 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
106230 +context_alloc_24645 context_alloc 3 24645 NULL
106231 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
106232 +btrfs_check_data_free_space_24692 btrfs_check_data_free_space 0 24692 NULL
106233 +datafab_write_data_24696 datafab_write_data 4 24696 NULL
106234 +intelfbhw_get_p1p2_24703 intelfbhw_get_p1p2 2 24703 NULL
106235 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
106236 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
106237 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
106238 +ocfs2_cow_file_pos_24751 ocfs2_cow_file_pos 3 24751 NULL
106239 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
106240 +kempld_read8_24756 kempld_read8 0 24756 NULL
106241 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
106242 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
106243 +cache_read_24790 cache_read 3 24790 NULL
106244 +__xfs_get_blocks_24791 __xfs_get_blocks 2 24791 NULL
106245 +i915_gem_check_wedge_24793 i915_gem_check_wedge 0 24793 NULL
106246 +user_regset_copyout_24796 user_regset_copyout 7 24796 NULL
106247 +kvm_read_guest_virt_helper_24804 kvm_read_guest_virt_helper 3-1 24804 NULL
106248 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
106249 +sb_set_blocksize_24807 sb_set_blocksize 0-2 24807 NULL
106250 +ath6kl_fwlog_mask_write_24810 ath6kl_fwlog_mask_write 3 24810 NULL
106251 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
106252 +net2272_read_24825 net2272_read 0 24825 NULL
106253 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
106254 +btrfs_next_old_item_24843 btrfs_next_old_item 0 24843 NULL
106255 +xfs_free_file_space_24853 xfs_free_file_space 2-3 24853 NULL
106256 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
106257 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
106258 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
106259 +setup_buffering_24872 setup_buffering 3 24872 NULL
106260 +queues_read_24877 queues_read 3 24877 NULL
106261 +__vxge_hw_vp_initialize_24885 __vxge_hw_vp_initialize 2 24885 NULL
106262 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
106263 +__btrfs_free_extent_24927 __btrfs_free_extent 7-0 24927 NULL nohasharray
106264 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 &__btrfs_free_extent_24927
106265 +ocfs2_fiemap_24949 ocfs2_fiemap 4-3 24949 NULL
106266 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
106267 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
106268 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
106269 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
106270 +btrfs_update_delayed_inode_24988 btrfs_update_delayed_inode 0 24988 NULL
106271 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
106272 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
106273 +twl6030_irq_unmap_25014 twl6030_irq_unmap 2 25014 NULL
106274 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
106275 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
106276 +load_unaligned_zeropad_25050 load_unaligned_zeropad 0 25050 NULL
106277 +btrfs_stack_key_blockptr_25058 btrfs_stack_key_blockptr 0 25058 NULL
106278 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
106279 +ll_track_pid_seq_write_25068 ll_track_pid_seq_write 3 25068 NULL
106280 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
106281 +iwl_dbgfs_tx_flush_write_25091 iwl_dbgfs_tx_flush_write 3 25091 NULL
106282 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL nohasharray
106283 +blkg_path_25099 blkg_path 3 25099 &gfs2_iter_unstuffed_25099
106284 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
106285 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
106286 +record_new_ref_25154 record_new_ref 0 25154 NULL
106287 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL nohasharray
106288 +btrfs_delete_delayed_items_25167 btrfs_delete_delayed_items 0 25167 &ipath_init_qp_table_25167
106289 +kvm_mmu_notifier_change_pte_25169 kvm_mmu_notifier_change_pte 3 25169 NULL
106290 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
106291 +res_counter_read_u64_25180 res_counter_read_u64 0 25180 NULL
106292 +send_create_inode_if_needed_25211 send_create_inode_if_needed 0 25211 NULL
106293 +security_socket_post_create_25221 security_socket_post_create 0 25221 NULL
106294 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
106295 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
106296 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
106297 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 5-3 25245 NULL
106298 +stripe_status_25259 stripe_status 5 25259 NULL
106299 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
106300 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
106301 +vfs_writev_25278 vfs_writev 3 25278 NULL
106302 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
106303 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 NULL
106304 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
106305 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
106306 +rio_destid_next_25368 rio_destid_next 2-0 25368 NULL nohasharray
106307 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
106308 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
106309 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
106310 +orphanize_inode_25382 orphanize_inode 0 25382 NULL
106311 +SyS_splice_25390 SyS_splice 5 25390 NULL
106312 +btrfs_update_reserved_bytes_25393 btrfs_update_reserved_bytes 0 25393 NULL
106313 +vsp1_entity_init_25407 vsp1_entity_init 3 25407 NULL
106314 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
106315 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
106316 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
106317 +ipath_decode_err_25468 ipath_decode_err 3 25468 NULL
106318 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
106319 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
106320 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4-0 25502 NULL
106321 +evm_init_hmac_25504 evm_init_hmac 0 25504 NULL
106322 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
106323 +sb_permission_25523 sb_permission 0 25523 NULL
106324 +down_read_failed_25532 down_read_failed 2 25532 NULL
106325 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
106326 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
106327 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
106328 +mgag200_ttm_tt_create_25550 mgag200_ttm_tt_create 2 25550 NULL
106329 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
106330 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
106331 +ping_recvmsg_25597 ping_recvmsg 4 25597 NULL nohasharray
106332 +find_extend_vma_25597 find_extend_vma 2 25597 &ping_recvmsg_25597
106333 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
106334 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
106335 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
106336 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
106337 +__direct_map_25647 __direct_map 6-5 25647 NULL
106338 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2-0 25667 NULL
106339 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
106340 +lpfc_idiag_cmd_get_25672 lpfc_idiag_cmd_get 2 25672 NULL
106341 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
106342 +sparse_mem_map_populate_25693 sparse_mem_map_populate 2 25693 NULL
106343 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
106344 +wl1271_tx_enabled_rates_get_25712 wl1271_tx_enabled_rates_get 0 25712 NULL nohasharray
106345 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 &wl1271_tx_enabled_rates_get_25712
106346 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
106347 +ttm_tt_init_25717 ttm_tt_init 3 25717 NULL
106348 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
106349 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
106350 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
106351 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
106352 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
106353 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
106354 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
106355 +sg_read_25799 sg_read 3 25799 NULL
106356 +system_enable_read_25815 system_enable_read 3 25815 NULL
106357 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
106358 +ftrace_profile_init_25821 ftrace_profile_init 0 25821 NULL
106359 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
106360 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
106361 +parport_read_25855 parport_read 0 25855 NULL
106362 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
106363 +key_attr_size_25865 key_attr_size 0 25865 NULL
106364 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
106365 +run_delalloc_nocow_25896 run_delalloc_nocow 3-4 25896 NULL
106366 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
106367 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
106368 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7-4 25908 NULL
106369 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
106370 +rcname_read_25919 rcname_read 3 25919 NULL
106371 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
106372 +key_flags_read_25931 key_flags_read 3 25931 NULL
106373 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
106374 +flush_25957 flush 2 25957 NULL
106375 +video_register_device_25971 video_register_device 3 25971 NULL
106376 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
106377 +lustre_msg_buflen_v2_25997 lustre_msg_buflen_v2 0 25997 NULL
106378 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
106379 +blk_init_queue_node_26015 blk_init_queue_node 3 26015 NULL
106380 +SyS_process_vm_readv_26019 SyS_process_vm_readv 3-5 26019 NULL
106381 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
106382 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
106383 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
106384 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
106385 +tun_do_read_26047 tun_do_read 5 26047 NULL
106386 +make_bfloat_26056 make_bfloat 2 26056 NULL
106387 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
106388 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
106389 +__add_inline_refs_26096 __add_inline_refs 0 26096 NULL
106390 +dup_ref_26100 dup_ref 0 26100 NULL
106391 +intel_wrap_ring_buffer_26117 intel_wrap_ring_buffer 0 26117 NULL
106392 +read_sb_page_26119 read_sb_page 5 26119 NULL
106393 +__fswab64_26155 __fswab64 0 26155 NULL
106394 +copy_oldmem_page_26164 copy_oldmem_page 3 26164 NULL
106395 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 NULL nohasharray
106396 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 &ath6kl_roam_table_read_26166
106397 +disk_devt_26180 disk_devt 0 26180 NULL
106398 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
106399 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
106400 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
106401 +mce_write_26201 mce_write 3 26201 NULL
106402 +SyS_splice_26206 SyS_splice 5 26206 NULL
106403 +mwifiex_regrdwr_write_26225 mwifiex_regrdwr_write 3 26225 NULL
106404 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
106405 +rxrpc_recvmsg_26233 rxrpc_recvmsg 4 26233 NULL
106406 +bio_split_26235 bio_split 2 26235 NULL
106407 +btrfs_delayed_inode_reserve_metadata_26236 btrfs_delayed_inode_reserve_metadata 0 26236 NULL
106408 +ecryptfs_read_lower_page_segment_26244 ecryptfs_read_lower_page_segment 4 26244 NULL
106409 +do_setxattr_26264 do_setxattr 0 26264 NULL
106410 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
106411 +apei_resources_request_26279 apei_resources_request 0 26279 NULL
106412 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
106413 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
106414 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
106415 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
106416 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
106417 +check_can_nocow_26336 check_can_nocow 2 26336 NULL
106418 +snd_vx_check_reg_bit_26344 snd_vx_check_reg_bit 0 26344 NULL
106419 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5-0-6-3 26357 NULL
106420 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
106421 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
106422 +ntty_write_26404 ntty_write 3 26404 NULL
106423 +pagemap_read_26441 pagemap_read 3 26441 NULL
106424 +tower_read_26461 tower_read 3 26461 NULL nohasharray
106425 +enc_pools_add_pages_26461 enc_pools_add_pages 1 26461 &tower_read_26461 nohasharray
106426 +numa_cpu_node_26461 numa_cpu_node 0 26461 &enc_pools_add_pages_26461
106427 +memory_present_26470 memory_present 1 26470 NULL
106428 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
106429 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
106430 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
106431 +vfio_pin_pages_26494 vfio_pin_pages 1 26494 NULL
106432 +read_vmcore_26501 read_vmcore 3 26501 NULL
106433 +uhid_char_write_26502 uhid_char_write 3 26502 NULL
106434 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 4-3 26507 NULL
106435 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
106436 +SyS_rt_sigpending_26538 SyS_rt_sigpending 2 26538 NULL
106437 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
106438 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
106439 +qgroup_account_ref_step3_26558 qgroup_account_ref_step3 0 26558 NULL
106440 +dio_new_bio_26562 dio_new_bio 0 26562 NULL
106441 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
106442 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL
106443 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
106444 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
106445 +dev_to_node_26617 dev_to_node 0 26617 NULL
106446 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
106447 +pack_value_26625 pack_value 1 26625 NULL
106448 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
106449 +drm_ht_find_item_26637 drm_ht_find_item 0 26637 NULL
106450 +process_extent_26646 process_extent 0 26646 NULL nohasharray
106451 +btrfs_lookup_inode_26646 btrfs_lookup_inode 0 26646 &process_extent_26646
106452 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
106453 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
106454 +usb_reset_device_26661 usb_reset_device 0 26661 NULL
106455 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
106456 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
106457 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
106458 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
106459 +bos_desc_26752 bos_desc 0 26752 NULL
106460 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
106461 +dma_map_single_attrs_26779 dma_map_single_attrs 0 26779 NULL
106462 +cache_save_setup_26783 cache_save_setup 0 26783 NULL
106463 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
106464 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
106465 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
106466 +smk_write_load_26829 smk_write_load 3 26829 NULL
106467 +ept_get_level1_sp_gpa_26831 ept_get_level1_sp_gpa 0 26831 NULL
106468 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
106469 +scnprint_id_26842 scnprint_id 3-0 26842 NULL
106470 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
106471 +tipc_conn_sendmsg_26867 tipc_conn_sendmsg 5 26867 NULL
106472 +ath6kl_create_qos_write_26879 ath6kl_create_qos_write 3 26879 NULL
106473 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
106474 +cfg80211_process_auth_26916 cfg80211_process_auth 3 26916 NULL
106475 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
106476 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
106477 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
106478 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
106479 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
106480 +remove_from_bitmap_26939 remove_from_bitmap 0 26939 NULL
106481 +create_bm_block_list_26940 create_bm_block_list 0 26940 NULL
106482 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
106483 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
106484 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
106485 +xlog_grant_push_ail_26972 xlog_grant_push_ail 2 26972 NULL
106486 +do_direct_IO_26979 do_direct_IO 0 26979 NULL
106487 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
106488 +i2c_smbus_xfer_27006 i2c_smbus_xfer 0 27006 NULL
106489 +omfs_allocate_range_27034 omfs_allocate_range 3 27034 NULL
106490 +fill_read_buf_27036 fill_read_buf 0 27036 NULL
106491 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
106492 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
106493 +ext4_convert_unwritten_extents_27064 ext4_convert_unwritten_extents 4-3-0 27064 NULL
106494 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
106495 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
106496 +snd_mixer_oss_set_recsrc_27080 snd_mixer_oss_set_recsrc 2 27080 NULL
106497 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
106498 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
106499 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
106500 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
106501 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
106502 +i915_gem_execbuffer_relocate_slow_27116 i915_gem_execbuffer_relocate_slow 0 27116 NULL
106503 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
106504 +__ext4_handle_dirty_metadata_27137 __ext4_handle_dirty_metadata 0 27137 NULL
106505 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
106506 +pms_capture_27142 pms_capture 4 27142 NULL
106507 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
106508 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
106509 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
106510 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
106511 +__intel_ring_begin_27197 __intel_ring_begin 0 27197 NULL
106512 +__sg_alloc_table_27198 __sg_alloc_table 0 27198 NULL
106513 +ocfs2_read_blocks_sync_27210 ocfs2_read_blocks_sync 0 27210 NULL
106514 +write_kmem_27225 write_kmem 3 27225 NULL
106515 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
106516 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
106517 +ocfs2_journal_access_path_27243 ocfs2_journal_access_path 0 27243 NULL
106518 +ll_track_gid_seq_write_27267 ll_track_gid_seq_write 3 27267 NULL
106519 +qfq_unblock_groups_27269 qfq_unblock_groups 2 27269 NULL
106520 +comedi_alloc_devpriv_27272 comedi_alloc_devpriv 2 27272 NULL
106521 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
106522 +copy_from_buf_27308 copy_from_buf 2-4 27308 NULL
106523 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL
106524 +write_buf_27316 write_buf 0-3 27316 NULL
106525 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
106526 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
106527 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
106528 +iwl_dbgfs_csr_write_27363 iwl_dbgfs_csr_write 3 27363 NULL
106529 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
106530 +lz4_compress_crypto_27387 lz4_compress_crypto 3 27387 NULL
106531 +seq_read_27411 seq_read 3 27411 NULL
106532 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL nohasharray
106533 +zalloc_cpumask_var_node_27413 zalloc_cpumask_var_node 3 27413 &ib_dma_map_sg_27413
106534 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 NULL
106535 +ocfs2_refcount_cal_cow_clusters_27422 ocfs2_refcount_cal_cow_clusters 0-3-4 27422 NULL nohasharray
106536 +evm_inode_init_security_27422 evm_inode_init_security 0 27422 &ocfs2_refcount_cal_cow_clusters_27422
106537 +cypress_write_27423 cypress_write 4 27423 NULL
106538 +vmemmap_populate_27442 vmemmap_populate 3 27442 NULL
106539 +sddr09_read_data_27447 sddr09_read_data 3 27447 NULL
106540 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
106541 +sk_extract_addr_27474 sk_extract_addr 0 27474 NULL
106542 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
106543 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
106544 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
106545 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
106546 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
106547 +ept_walk_addr_generic_27501 ept_walk_addr_generic 4 27501 NULL
106548 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
106549 +oti_alloc_cookies_27510 oti_alloc_cookies 2 27510 NULL
106550 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
106551 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
106552 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
106553 +sco_sock_recvmsg_27572 sco_sock_recvmsg 4 27572 NULL
106554 +libipw_alloc_txb_27579 libipw_alloc_txb 1 27579 NULL
106555 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
106556 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
106557 +ocfs2_direct_IO_27642 ocfs2_direct_IO 4 27642 &nl80211_send_connect_result_27642 nohasharray
106558 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &ocfs2_direct_IO_27642
106559 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
106560 +btrfs_fallocate_27647 btrfs_fallocate 3-4 27647 NULL
106561 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
106562 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
106563 +record_changed_ref_27665 record_changed_ref 0 27665 NULL
106564 +iommu_pgsize_27677 iommu_pgsize 2-0 27677 NULL
106565 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
106566 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4-0 27702 NULL
106567 +evm_write_key_27715 evm_write_key 3 27715 NULL
106568 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
106569 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
106570 +macvtap_skb_to_vnet_hdr_27747 macvtap_skb_to_vnet_hdr 0 27747 NULL
106571 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
106572 +gpiochip_export_27776 gpiochip_export 0 27776 NULL
106573 +__lov_setstripe_27782 __lov_setstripe 2 27782 NULL
106574 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
106575 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
106576 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL nohasharray
106577 +SyS_readv_27804 SyS_readv 3 27804 &ttm_object_file_init_27804
106578 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
106579 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
106580 +hpt374_read_freq_27828 hpt374_read_freq 0 27828 NULL
106581 +init_header_complete_27833 init_header_complete 0 27833 NULL
106582 +read_profile_27859 read_profile 3 27859 NULL
106583 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
106584 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
106585 +process_all_extents_27879 process_all_extents 0 27879 NULL
106586 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
106587 +gluebi_write_27905 gluebi_write 3-2 27905 NULL
106588 +SyS_ptrace_27924 SyS_ptrace 3 27924 NULL
106589 +bm_find_next_27929 bm_find_next 2 27929 NULL
106590 +check_mapped_name_27943 check_mapped_name 3 27943 NULL
106591 +i915_gem_execbuffer_reserve_object_27956 i915_gem_execbuffer_reserve_object 0 27956 NULL
106592 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
106593 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
106594 +device_register_27972 device_register 0 27972 NULL nohasharray
106595 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 &device_register_27972
106596 +pci_enable_device_flags_27977 pci_enable_device_flags 0 27977 NULL
106597 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
106598 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
106599 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
106600 +remove_extent_data_ref_28023 remove_extent_data_ref 0 28023 NULL
106601 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
106602 +record_deleted_ref_28039 record_deleted_ref 0 28039 NULL
106603 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
106604 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
106605 +p9_fd_write_28050 p9_fd_write 3 28050 NULL
106606 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2-4 28053 NULL
106607 +pool_status_28055 pool_status 5 28055 NULL
106608 +init_rs_non_canonical_28059 init_rs_non_canonical 1 28059 NULL
106609 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
106610 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
106611 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
106612 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
106613 +SyS_brk_28096 SyS_brk 1 28096 NULL
106614 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 2-3 28102 NULL
106615 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
106616 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
106617 +tipc_msg_init_28128 tipc_msg_init 4-2 28128 NULL
106618 +video_read_28148 video_read 3 28148 NULL
106619 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
106620 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
106621 +__add_reloc_root_28155 __add_reloc_root 0 28155 NULL
106622 +vread_28173 vread 0-3 28173 NULL
106623 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
106624 +counter_free_res_28187 counter_free_res 5 28187 NULL
106625 +read_disk_sb_28188 read_disk_sb 2 28188 NULL
106626 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
106627 +__exclude_logged_extent_28212 __exclude_logged_extent 2-0 28212 NULL
106628 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
106629 +ocfs2_cow_sync_writeback_28221 ocfs2_cow_sync_writeback 0 28221 NULL
106630 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL
106631 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
106632 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
106633 +fuse_direct_IO_28275 fuse_direct_IO 4 28275 NULL
106634 +usemap_size_28281 usemap_size 0 28281 NULL
106635 +inline_xattr_size_28285 inline_xattr_size 0 28285 NULL
106636 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
106637 +SyS_ppoll_28290 SyS_ppoll 2 28290 NULL
106638 +kstrtos16_from_user_28300 kstrtos16_from_user 2 28300 NULL
106639 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
106640 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
106641 +create_io_context_28306 create_io_context 2 28306 NULL
106642 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3-0 28315 NULL
106643 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
106644 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
106645 +tcp_copy_to_iovec_28344 tcp_copy_to_iovec 3 28344 NULL
106646 +cpuset_spread_node_28351 cpuset_spread_node 0 28351 NULL nohasharray
106647 +snapshot_write_28351 snapshot_write 3 28351 &cpuset_spread_node_28351
106648 +xfs_iomap_write_unwritten_28365 xfs_iomap_write_unwritten 3-2 28365 NULL
106649 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
106650 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
106651 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
106652 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
106653 +get_extent_allocation_hint_28423 get_extent_allocation_hint 0 28423 NULL
106654 +ksocknal_alloc_tx_28426 ksocknal_alloc_tx 2 28426 NULL
106655 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
106656 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
106657 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
106658 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
106659 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
106660 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
106661 +__filemap_fdatawrite_28485 __filemap_fdatawrite 0 28485 NULL
106662 +clear_discard_28494 clear_discard 2 28494 NULL
106663 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
106664 +__next_node_28521 __next_node 1-0 28521 NULL
106665 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
106666 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
106667 +run_delalloc_range_28545 run_delalloc_range 3-4 28545 NULL nohasharray
106668 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545 nohasharray
106669 +aio_read_events_28545 aio_read_events 3 28545 &mptctl_getiocinfo_28545
106670 +sysfs_create_bin_file_28551 sysfs_create_bin_file 0 28551 NULL
106671 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
106672 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
106673 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
106674 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
106675 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
106676 +extract_entropy_28604 extract_entropy 5-3 28604 NULL
106677 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
106678 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
106679 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
106680 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
106681 +qib_handle_6120_hwerrors_28642 qib_handle_6120_hwerrors 3 28642 NULL
106682 +p9_fcall_alloc_28652 p9_fcall_alloc 1 28652 NULL
106683 +read_nic_io_byte_28654 read_nic_io_byte 0 28654 NULL
106684 +btrfs_previous_item_28667 btrfs_previous_item 0 28667 NULL
106685 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
106686 +__perf_sw_event_28684 __perf_sw_event 2 28684 NULL
106687 +SyS_setgroups16_28686 SyS_setgroups16 1 28686 NULL
106688 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 NULL
106689 +balance_level_28707 balance_level 0 28707 NULL
106690 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
106691 +alloc_irq_cfg_28734 alloc_irq_cfg 2 28734 NULL
106692 +spi_execute_28736 spi_execute 5 28736 NULL
106693 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL
106694 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
106695 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
106696 +rpc_pipe_generic_upcall_28766 rpc_pipe_generic_upcall 4 28766 NULL
106697 +atomic_inc_return_unchecked_28778 atomic_inc_return_unchecked 0 28778 NULL
106698 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
106699 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
106700 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
106701 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
106702 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
106703 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
106704 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
106705 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
106706 +max_io_len_target_boundary_28879 max_io_len_target_boundary 0-1 28879 NULL
106707 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
106708 +to_cblock_28899 to_cblock 0-1 28899 NULL
106709 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
106710 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
106711 +iwl_dbgfs_sleep_level_override_write_28925 iwl_dbgfs_sleep_level_override_write 3 28925 NULL
106712 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
106713 +push_rx_28939 push_rx 3 28939 NULL
106714 +btrfs_trim_block_group_28963 btrfs_trim_block_group 4-3 28963 NULL
106715 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
106716 +remap_pfn_range_28976 remap_pfn_range 3-4-2 28976 NULL
106717 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
106718 +hci_sock_setsockopt_28993 hci_sock_setsockopt 5 28993 NULL
106719 +bin_uuid_28999 bin_uuid 3 28999 NULL
106720 +fd_execute_rw_29004 fd_execute_rw 3 29004 NULL nohasharray
106721 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 &fd_execute_rw_29004
106722 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
106723 +i915_gem_object_bind_to_vm_29035 i915_gem_object_bind_to_vm 0 29035 NULL
106724 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
106725 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL nohasharray
106726 +ProcessGetHostMibs_29049 ProcessGetHostMibs 0 29049 &rxrpc_sendmsg_29049
106727 +btrfs_root_bytenr_29058 btrfs_root_bytenr 0 29058 NULL
106728 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
106729 +roundup_64_29066 roundup_64 2-0-1 29066 NULL
106730 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
106731 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
106732 +iwl_dbgfs_log_event_write_29088 iwl_dbgfs_log_event_write 3 29088 NULL
106733 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
106734 +init_cache_node_node_29092 init_cache_node_node 1 29092 NULL
106735 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
106736 +snprintf_29125 snprintf 0 29125 NULL
106737 +iov_shorten_29130 iov_shorten 0 29130 NULL
106738 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
106739 +alloc_irqs_from_29152 alloc_irqs_from 1-2-0-3 29152 NULL
106740 +kvm_mmu_notifier_clear_flush_young_29154 kvm_mmu_notifier_clear_flush_young 3 29154 NULL
106741 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
106742 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL
106743 +__mm_populate_29204 __mm_populate 1-2 29204 NULL
106744 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
106745 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
106746 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
106747 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
106748 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
106749 +recover_peb_29238 recover_peb 0-7-6 29238 NULL
106750 +evdev_handle_get_val_29242 evdev_handle_get_val 5-6 29242 NULL
106751 +rw_verify_area_29243 rw_verify_area 0-4 29243 NULL
106752 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
106753 +block_div_29268 block_div 0-1-2 29268 NULL
106754 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
106755 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
106756 +ext4_fiemap_29296 ext4_fiemap 4 29296 NULL
106757 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
106758 +replace_file_extents_29312 replace_file_extents 0 29312 NULL
106759 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
106760 +lprocfs_write_helper_29323 lprocfs_write_helper 2 29323 NULL
106761 +kvm_handle_hva_29326 kvm_handle_hva 2 29326 NULL
106762 +tun_put_user_29337 tun_put_user 5 29337 NULL
106763 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
106764 +ide_read_altstatus_29343 ide_read_altstatus 0 29343 NULL
106765 +l2cap_sock_setsockopt_old_29346 l2cap_sock_setsockopt_old 4 29346 NULL
106766 +gpiochip_find_base_29366 gpiochip_find_base 0-1 29366 NULL
106767 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
106768 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
106769 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
106770 +btrfs_run_delayed_items_29428 btrfs_run_delayed_items 0 29428 NULL
106771 +mempool_create_29437 mempool_create 1 29437 NULL
106772 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
106773 +p9_client_prepare_req_29448 p9_client_prepare_req 3 29448 NULL
106774 +ept_page_fault_29450 ept_page_fault 2 29450 NULL
106775 +__kmalloc_node_29455 __kmalloc_node 3 29455 NULL
106776 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
106777 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
106778 +do_register_entry_29478 do_register_entry 4 29478 NULL
106779 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
106780 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
106781 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
106782 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
106783 +write_file_regidx_29517 write_file_regidx 3 29517 NULL
106784 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
106785 +_regmap_raw_write_29541 _regmap_raw_write 2-4 29541 NULL
106786 +vfs_read_29543 vfs_read 0-3 29543 NULL
106787 +set_brk_29551 set_brk 1-2 29551 NULL nohasharray
106788 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
106789 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
106790 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL
106791 +kvm_read_guest_virt_system_29569 kvm_read_guest_virt_system 4-2 29569 NULL
106792 +p9_fd_read_29570 p9_fd_read 3 29570 NULL
106793 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
106794 +iwl_dbgfs_missed_beacon_write_29586 iwl_dbgfs_missed_beacon_write 3 29586 NULL
106795 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4-0 29589 NULL
106796 +dio_set_defer_completion_29599 dio_set_defer_completion 0 29599 NULL
106797 +slots_per_page_29601 slots_per_page 0 29601 NULL
106798 +osc_cached_mb_seq_write_29610 osc_cached_mb_seq_write 3 29610 NULL
106799 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
106800 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
106801 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
106802 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
106803 +tracepoint_probe_register_29688 tracepoint_probe_register 0 29688 NULL
106804 +__btrfs_setxattr_29689 __btrfs_setxattr 0 29689 NULL
106805 +jbd2_journal_restart_29692 jbd2_journal_restart 0 29692 NULL
106806 +lustre_posix_acl_xattr_2ext_29693 lustre_posix_acl_xattr_2ext 2 29693 NULL
106807 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 NULL
106808 +probes_write_29711 probes_write 3 29711 NULL
106809 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
106810 +xfs_new_eof_29737 xfs_new_eof 2 29737 NULL
106811 +std_nic_write_29752 std_nic_write 3 29752 NULL
106812 +dbAlloc_29794 dbAlloc 0 29794 NULL
106813 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
106814 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
106815 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
106816 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
106817 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
106818 +count_partial_29850 count_partial 0 29850 NULL
106819 +radeon_ttm_tt_create_29859 radeon_ttm_tt_create 2 29859 NULL
106820 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
106821 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
106822 +tlv_put_29872 tlv_put 0 29872 NULL
106823 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
106824 +changed_extent_29881 changed_extent 0 29881 NULL
106825 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
106826 +lov_ost_pool_extend_29914 lov_ost_pool_extend 2 29914 NULL
106827 +write_file_queue_29922 write_file_queue 3 29922 NULL
106828 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
106829 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL nohasharray
106830 +ipv6_recv_error_29947 ipv6_recv_error 3 29947 &__btrfs_getxattr_29947
106831 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 NULL
106832 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
106833 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
106834 +dev_mem_write_30028 dev_mem_write 3 30028 NULL
106835 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
106836 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
106837 +drp_wmove_30043 drp_wmove 4 30043 NULL nohasharray
106838 +wrmalt_30043 wrmalt 0 30043 &drp_wmove_30043
106839 +mem_cgroup_charge_common_30047 mem_cgroup_charge_common 0 30047 NULL
106840 +SyS_write_30059 SyS_write 3 30059 NULL
106841 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
106842 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
106843 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
106844 +defragment_dma_buffer_30113 defragment_dma_buffer 0 30113 NULL
106845 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
106846 +calgary_unmap_page_30130 calgary_unmap_page 3-2 30130 NULL
106847 +recv_stream_30138 recv_stream 4 30138 NULL
106848 +u_memcpya_30139 u_memcpya 3-2 30139 NULL
106849 +elfcorehdr_read_30159 elfcorehdr_read 2 30159 NULL
106850 +alloc_switch_ctx_30165 alloc_switch_ctx 2 30165 NULL
106851 +expand_inode_data_30169 expand_inode_data 2-3 30169 NULL
106852 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
106853 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
106854 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
106855 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
106856 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
106857 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
106858 +bitmap_file_set_bit_30228 bitmap_file_set_bit 2 30228 NULL
106859 +shmem_unuse_inode_30263 shmem_unuse_inode 0 30263 NULL
106860 +rawv6_recvmsg_30265 rawv6_recvmsg 4 30265 NULL
106861 +hfsplus_trusted_setxattr_30270 hfsplus_trusted_setxattr 4 30270 NULL
106862 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
106863 +compat_readv_30273 compat_readv 3 30273 NULL
106864 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
106865 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
106866 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
106867 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
106868 +osc_contention_seconds_seq_write_30305 osc_contention_seconds_seq_write 3 30305 NULL
106869 +drm_core_get_reg_ofs_30309 drm_core_get_reg_ofs 0 30309 NULL
106870 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
106871 +i8254_read_30330 i8254_read 0 30330 NULL
106872 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
106873 +resource_from_user_30341 resource_from_user 3 30341 NULL
106874 +o2nm_this_node_30342 o2nm_this_node 0 30342 NULL
106875 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1-2 30352 NULL
106876 +kstrtou32_from_user_30361 kstrtou32_from_user 2 30361 NULL
106877 +inet_getid_30365 inet_getid 2 30365 NULL
106878 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
106879 +blkdev_issue_zeroout_30392 blkdev_issue_zeroout 3-0 30392 NULL
106880 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
106881 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
106882 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
106883 +ext3_xattr_list_30419 ext3_xattr_list 3 30419 NULL
106884 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
106885 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
106886 +mq_create_30425 mq_create 1 30425 NULL nohasharray
106887 +lstcon_session_info_30425 lstcon_session_info 6 30425 &mq_create_30425
106888 +ext4_ext_create_new_leaf_30428 ext4_ext_create_new_leaf 0 30428 NULL
106889 +enable_write_30456 enable_write 3 30456 NULL
106890 +pci_resource_alignment_30457 pci_resource_alignment 0 30457 NULL
106891 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
106892 +urandom_read_30462 urandom_read 3 30462 NULL
106893 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
106894 +i2c_ctrl_read_30467 i2c_ctrl_read 0 30467 NULL
106895 +send_rmdir_30470 send_rmdir 0 30470 NULL
106896 +i915_mutex_lock_interruptible_30474 i915_mutex_lock_interruptible 0 30474 NULL nohasharray
106897 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 &i915_mutex_lock_interruptible_30474
106898 +write_head_30481 write_head 4 30481 NULL
106899 +adu_write_30487 adu_write 3 30487 NULL
106900 +dtim_interval_write_30489 dtim_interval_write 3 30489 NULL
106901 +btrfs_free_extent_30515 btrfs_free_extent 0 30515 NULL
106902 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
106903 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL nohasharray
106904 +set_config_30526 set_config 0 30526 &debug_debug2_read_30526
106905 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
106906 +set_le_30581 set_le 4 30581 NULL
106907 +from_cblock_30582 from_cblock 0-1 30582 NULL
106908 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
106909 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
106910 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
106911 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
106912 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
106913 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
106914 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
106915 +mlx5_ib_alloc_fast_reg_page_list_30638 mlx5_ib_alloc_fast_reg_page_list 2 30638 NULL
106916 +SyS_listxattr_30647 SyS_listxattr 3 30647 NULL
106917 +agp_remap_30665 agp_remap 2 30665 NULL
106918 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
106919 +ni_ai_fifo_read_30681 ni_ai_fifo_read 3 30681 NULL
106920 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
106921 +lbs_wrbbp_write_30712 lbs_wrbbp_write 3 30712 NULL
106922 +ocfs2_find_cpos_for_left_leaf_30713 ocfs2_find_cpos_for_left_leaf 0 30713 NULL
106923 +__mutex_lock_common_30717 __mutex_lock_common 0 30717 NULL
106924 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
106925 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
106926 +snapshot_status_30744 snapshot_status 5 30744 NULL
106927 +fuse_conn_limit_write_30777 fuse_conn_limit_write 3 30777 NULL
106928 +SyS_pread64_30778 SyS_pread64 3 30778 NULL
106929 +btrfs_run_ordered_operations_30793 btrfs_run_ordered_operations 0 30793 NULL
106930 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
106931 +SYSC_splice_30820 SYSC_splice 5 30820 NULL
106932 +xlog_grant_head_wait_30829 xlog_grant_head_wait 4 30829 NULL
106933 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
106934 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
106935 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
106936 +wd_autoreset_write_30862 wd_autoreset_write 3 30862 NULL
106937 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
106938 +pn_recvmsg_30887 pn_recvmsg 4 30887 NULL
106939 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
106940 +find_free_dev_extent_30963 find_free_dev_extent 0 30963 NULL
106941 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
106942 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
106943 +read_file_bt_ant_diversity_30983 read_file_bt_ant_diversity 3 30983 NULL
106944 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
106945 +do_setup_msi_irqs_31043 do_setup_msi_irqs 2 31043 NULL
106946 +stride_pg_count_31053 stride_pg_count 0-2-1-4-3-5 31053 NULL
106947 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
106948 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
106949 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
106950 +proc_gid_map_write_31093 proc_gid_map_write 3 31093 NULL
106951 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
106952 +si_calculate_power_efficiency_ratio_31111 si_calculate_power_efficiency_ratio 3-2 31111 NULL
106953 +depth_read_31112 depth_read 3 31112 NULL
106954 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
106955 +size_inside_page_31141 size_inside_page 0-1-2 31141 NULL
106956 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
106957 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
106958 +crypto_rng_seedsize_31196 crypto_rng_seedsize 0 31196 NULL
106959 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
106960 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
106961 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
106962 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
106963 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
106964 +__read_reg_31216 __read_reg 0 31216 NULL
106965 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
106966 +ulist_rbtree_insert_31235 ulist_rbtree_insert 0 31235 NULL
106967 +tcp_recvmsg_31238 tcp_recvmsg 4 31238 NULL
106968 +cyy_readb_31240 cyy_readb 0 31240 NULL
106969 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
106970 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
106971 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
106972 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
106973 +push_leaf_left_31306 push_leaf_left 0 31306 NULL
106974 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
106975 +command_file_write_31318 command_file_write 3 31318 NULL
106976 +ext4_xattr_block_list_31325 ext4_xattr_block_list 3 31325 NULL
106977 +hwerr_crcbits_31334 hwerr_crcbits 4 31334 NULL
106978 +radix_tree_insert_31336 radix_tree_insert 0 31336 NULL
106979 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
106980 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
106981 +outlen_write_31358 outlen_write 3 31358 NULL
106982 +ieee80211_rx_mgmt_auth_31366 ieee80211_rx_mgmt_auth 3 31366 NULL
106983 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
106984 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 2-3 31374 NULL
106985 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
106986 +inb_31388 inb 0 31388 NULL
106987 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
106988 +i915_gem_object_put_fence_31413 i915_gem_object_put_fence 0 31413 NULL
106989 +_sp2d_max_pg_31422 _sp2d_max_pg 0 31422 NULL
106990 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
106991 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
106992 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
106993 +transport_alloc_session_tags_31449 transport_alloc_session_tags 2-3 31449 NULL
106994 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
106995 +register_ftrace_graph_31456 register_ftrace_graph 0 31456 NULL
106996 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
106997 +do_fcntl_31468 do_fcntl 3 31468 NULL
106998 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
106999 +__ext4_journal_get_write_access_31482 __ext4_journal_get_write_access 0 31482 NULL
107000 +alg_setkey_31485 alg_setkey 3 31485 NULL
107001 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
107002 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
107003 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
107004 +nouveau_mc_create__31513 nouveau_mc_create_ 5 31513 NULL
107005 +hidraw_write_31536 hidraw_write 3 31536 NULL
107006 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
107007 +usbvision_read_31555 usbvision_read 3 31555 NULL
107008 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
107009 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
107010 +osst_write_31581 osst_write 3 31581 NULL
107011 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
107012 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
107013 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
107014 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
107015 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
107016 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
107017 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
107018 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
107019 +__lgread_31668 __lgread 4 31668 NULL
107020 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
107021 +fst_recover_rx_error_31687 fst_recover_rx_error 3 31687 NULL
107022 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
107023 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 NULL
107024 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL nohasharray
107025 +lu_buf_check_and_grow_31735 lu_buf_check_and_grow 2 31735 &utf16s_to_utf8s_31735
107026 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3-2 31741 NULL
107027 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
107028 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
107029 +muldiv64_31743 muldiv64 3-2-0 31743 NULL
107030 +stmpe_set_altfunc_31750 stmpe_set_altfunc 2 31750 NULL nohasharray
107031 +bcm_char_read_31750 bcm_char_read 3 31750 &stmpe_set_altfunc_31750
107032 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
107033 +SyS_lsetxattr_31766 SyS_lsetxattr 4 31766 NULL
107034 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
107035 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
107036 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
107037 +data_write_31805 data_write 3 31805 NULL
107038 +SyS_msgsnd_31814 SyS_msgsnd 3 31814 NULL
107039 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
107040 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
107041 +fsnotify_perm_31843 fsnotify_perm 0 31843 NULL
107042 +SyS_ppoll_31855 SyS_ppoll 2 31855 NULL
107043 +iwl_dbgfs_disable_ht40_write_31876 iwl_dbgfs_disable_ht40_write 3 31876 NULL
107044 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
107045 +ddb_output_write_31902 ddb_output_write 3-0 31902 NULL
107046 +xattr_permission_31907 xattr_permission 0 31907 NULL
107047 +lu_buf_realloc_31915 lu_buf_realloc 2 31915 NULL
107048 +new_dir_31919 new_dir 3 31919 NULL
107049 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
107050 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
107051 +process_recorded_refs_if_needed_31938 process_recorded_refs_if_needed 0 31938 NULL
107052 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
107053 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4-0 31942 NULL nohasharray
107054 +read_mem_31942 read_mem 3 31942 &iov_iter_copy_from_user_31942
107055 +vb2_write_31948 vb2_write 3 31948 NULL
107056 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
107057 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
107058 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
107059 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
107060 +btrfs_insert_empty_inode_31975 btrfs_insert_empty_inode 0 31975 NULL
107061 +vx_read_status_31982 vx_read_status 0 31982 NULL nohasharray
107062 +iblock_execute_rw_31982 iblock_execute_rw 3 31982 &vx_read_status_31982
107063 +find_next_zero_bit_31990 find_next_zero_bit 3-2-0 31990 NULL
107064 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
107065 +lustre_acl_xattr_merge2posix_31992 lustre_acl_xattr_merge2posix 2 31992 NULL
107066 +sysfs_create_file_31996 sysfs_create_file 0 31996 NULL
107067 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
107068 +calc_hmac_32010 calc_hmac 3 32010 NULL
107069 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
107070 +resource_alignment_32020 resource_alignment 0 32020 NULL
107071 +aead_len_32021 aead_len 0 32021 NULL
107072 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3-0 32032 NULL
107073 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
107074 +stk_read_32038 stk_read 3 32038 NULL
107075 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
107076 +ocfs2_update_edge_lengths_32046 ocfs2_update_edge_lengths 0 32046 NULL
107077 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
107078 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
107079 +cow_file_range_inline_32091 cow_file_range_inline 3 32091 NULL
107080 +bio_alloc_32095 bio_alloc 2 32095 NULL
107081 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
107082 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
107083 +disk_status_32120 disk_status 4 32120 NULL
107084 +kobject_add_internal_32133 kobject_add_internal 0 32133 NULL
107085 +btrfs_split_item_32164 btrfs_split_item 0 32164 NULL
107086 +venus_link_32165 venus_link 5 32165 NULL
107087 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
107088 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
107089 +load_header_32183 load_header 0 32183 NULL
107090 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
107091 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
107092 +__mem_cgroup_try_charge_swapin_32204 __mem_cgroup_try_charge_swapin 0 32204 NULL
107093 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
107094 +caif_seqpkt_recvmsg_32241 caif_seqpkt_recvmsg 4 32241 NULL
107095 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
107096 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
107097 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
107098 +kvm_set_spte_hva_32312 kvm_set_spte_hva 2 32312 NULL
107099 +cas_calc_tabort_32316 cas_calc_tabort 0 32316 NULL
107100 +SyS_select_32319 SyS_select 1 32319 NULL
107101 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
107102 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
107103 +apic_get_tmcct_32338 apic_get_tmcct 0 32338 NULL
107104 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
107105 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL nohasharray
107106 +rx_streaming_always_write_32357 rx_streaming_always_write 3 32357 &dispatch_ioctl_32357
107107 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL nohasharray
107108 +ReadHDLCPCI_32362 ReadHDLCPCI 0 32362 &sel_read_initcon_32362
107109 +__wait_seqno_32370 __wait_seqno 0 32370 NULL
107110 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
107111 +cpuset_slab_spread_node_32376 cpuset_slab_spread_node 0 32376 NULL
107112 +intel_iommu_map_32384 intel_iommu_map 4-3 32384 NULL
107113 +local_clock_32385 local_clock 0 32385 NULL
107114 +ocfs2_cancel_convert_32392 ocfs2_cancel_convert 0 32392 NULL
107115 +ll_setxattr_common_32398 ll_setxattr_common 4 32398 NULL
107116 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
107117 +__add_missing_keys_32402 __add_missing_keys 0 32402 NULL
107118 +vmci_qp_alloc_32405 vmci_qp_alloc 5-3 32405 NULL
107119 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
107120 +break_ksm_32439 break_ksm 0 32439 NULL
107121 +__ext4_handle_dirty_super_32458 __ext4_handle_dirty_super 0 32458 NULL
107122 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
107123 +cache_status_32462 cache_status 5 32462 NULL
107124 +fill_readbuf_32464 fill_readbuf 3 32464 NULL
107125 +dgap_usertoboard_32490 dgap_usertoboard 4 32490 NULL
107126 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
107127 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
107128 +mdc_pinger_recov_seq_write_32510 mdc_pinger_recov_seq_write 3 32510 NULL
107129 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
107130 +ocfs2_local_alloc_reserve_for_window_32518 ocfs2_local_alloc_reserve_for_window 0 32518 NULL
107131 +disconnect_32521 disconnect 4 32521 NULL
107132 +qsfp_read_32522 qsfp_read 0-2-4 32522 NULL
107133 +audio_get_intf_req_32524 audio_get_intf_req 0 32524 NULL nohasharray
107134 +ocfs2_refresh_qinfo_32524 ocfs2_refresh_qinfo 0 32524 &audio_get_intf_req_32524
107135 +ilo_read_32531 ilo_read 3 32531 NULL
107136 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
107137 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
107138 +__first_node_32558 __first_node 0 32558 NULL
107139 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
107140 +osc_iocontrol_32565 osc_iocontrol 3 32565 NULL
107141 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
107142 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
107143 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
107144 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
107145 +irda_recvmsg_dgram_32631 irda_recvmsg_dgram 4 32631 NULL
107146 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
107147 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
107148 +kvmalloc_32646 kvmalloc 1 32646 NULL
107149 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
107150 +generic_readlink_32654 generic_readlink 3 32654 NULL nohasharray
107151 +ftrace_startup_32654 ftrace_startup 0 32654 &generic_readlink_32654
107152 +get_unaligned_be24_32667 get_unaligned_be24 0 32667 NULL
107153 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
107154 +apei_res_add_32674 apei_res_add 0 32674 NULL
107155 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
107156 +rt2x00debug_read_queue_dump_32712 rt2x00debug_read_queue_dump 3 32712 NULL
107157 +i40e_pci_sriov_enable_32742 i40e_pci_sriov_enable 2 32742 NULL
107158 +get_arg_page_32746 get_arg_page 2 32746 NULL
107159 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
107160 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
107161 +begin_cmd_32766 begin_cmd 0 32766 NULL
107162 +vmci_transport_dgram_dequeue_32775 vmci_transport_dgram_dequeue 4 32775 NULL
107163 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
107164 +ocfs2_read_inode_block_full_32790 ocfs2_read_inode_block_full 0 32790 NULL
107165 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
107166 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
107167 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1-2 32868 NULL
107168 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
107169 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
107170 +vp702x_usb_inout_cmd_32884 vp702x_usb_inout_cmd 6-4 32884 NULL
107171 +ext4_get_group_number_32899 ext4_get_group_number 0-2 32899 NULL
107172 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
107173 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
107174 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
107175 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
107176 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
107177 +xfs_log_reserve_32959 xfs_log_reserve 2 32959 NULL
107178 +ext4_group_overhead_blocks_32971 ext4_group_overhead_blocks 0 32971 NULL
107179 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
107180 +compat_filldir_32999 compat_filldir 3 32999 NULL
107181 +btrfs_lookup_extent_info_33000 btrfs_lookup_extent_info 0 33000 NULL
107182 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3-0 33007 NULL nohasharray
107183 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
107184 +br_multicast_set_hash_max_33012 br_multicast_set_hash_max 2 33012 NULL
107185 +write_file_bt_ant_diversity_33019 write_file_bt_ant_diversity 3 33019 NULL
107186 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
107187 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
107188 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
107189 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
107190 +bitmap_resize_33054 bitmap_resize 2-3 33054 NULL
107191 +intel_ring_flush_all_caches_33059 intel_ring_flush_all_caches 0 33059 NULL
107192 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
107193 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
107194 +alloc_tio_33077 alloc_tio 3 33077 NULL
107195 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
107196 +write_node_33121 write_node 4 33121 NULL
107197 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
107198 +__len_within_target_33132 __len_within_target 0 33132 NULL
107199 +SyS_poll_33152 SyS_poll 2 33152 NULL
107200 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
107201 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 3-2 33204 NULL
107202 +pp_read_33210 pp_read 3 33210 NULL
107203 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL nohasharray
107204 +i915_gem_object_wait_rendering__tail_33234 i915_gem_object_wait_rendering__tail 0 33234 &xfs_file_aio_write_33234
107205 +__vb2_wait_for_done_vb_33246 __vb2_wait_for_done_vb 0 33246 NULL
107206 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
107207 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
107208 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
107209 +btrfs_delete_one_dir_name_33303 btrfs_delete_one_dir_name 0 33303 NULL
107210 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
107211 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
107212 +vx_send_irq_dsp_33329 vx_send_irq_dsp 0 33329 NULL
107213 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
107214 +lov_stripesize_seq_write_33353 lov_stripesize_seq_write 3 33353 NULL
107215 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
107216 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
107217 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
107218 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
107219 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
107220 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
107221 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
107222 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 3-2 33394 NULL
107223 +cfs_trace_copyin_string_33396 cfs_trace_copyin_string 4 33396 NULL
107224 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
107225 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
107226 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
107227 +filemap_fdatawrite_33415 filemap_fdatawrite 0 33415 NULL
107228 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
107229 +ubh_scanc_33436 ubh_scanc 0-3-4 33436 NULL
107230 +message_stats_list_33440 message_stats_list 5 33440 NULL
107231 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
107232 +create_entry_33479 create_entry 2 33479 NULL
107233 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
107234 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
107235 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
107236 +res_counter_read_33499 res_counter_read 4 33499 NULL
107237 +fb_read_33506 fb_read 3 33506 NULL
107238 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
107239 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
107240 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
107241 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
107242 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
107243 +osc_max_rpcs_in_flight_seq_write_33539 osc_max_rpcs_in_flight_seq_write 3 33539 NULL nohasharray
107244 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 &osc_max_rpcs_in_flight_seq_write_33539
107245 +read_symlink_33572 read_symlink 0 33572 NULL
107246 +count_subheaders_33591 count_subheaders 0 33591 NULL
107247 +scsi_execute_33596 scsi_execute 5 33596 NULL
107248 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
107249 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL
107250 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
107251 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
107252 +do_sync_write_33624 do_sync_write 0 33624 NULL
107253 +stride_page_count_33641 stride_page_count 2 33641 NULL
107254 +slab_alloc_node_33663 slab_alloc_node 3 33663 NULL
107255 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
107256 +inw_p_33668 inw_p 0 33668 NULL
107257 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
107258 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
107259 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
107260 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 NULL
107261 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
107262 +ext4_wb_update_i_disksize_33717 ext4_wb_update_i_disksize 2 33717 NULL
107263 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
107264 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
107265 +write_file_spectral_count_33723 write_file_spectral_count 3 33723 NULL nohasharray
107266 +ocfs2_lock_allocators_move_extents_33723 ocfs2_lock_allocators_move_extents 0 33723 &write_file_spectral_count_33723
107267 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
107268 +do_munmap_33752 do_munmap 0 33752 NULL
107269 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
107270 +hashtab_create_33769 hashtab_create 3 33769 NULL
107271 +btrfs_delayed_refs_qgroup_accounting_33775 btrfs_delayed_refs_qgroup_accounting 0 33775 NULL
107272 +irq_map_generic_chip_33793 irq_map_generic_chip 2 33793 NULL
107273 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
107274 +find_next_offset_33804 find_next_offset 3-0 33804 NULL
107275 +filter_write_33819 filter_write 3 33819 NULL
107276 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
107277 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
107278 +ext4_journal_extend_33835 ext4_journal_extend 2-0 33835 NULL
107279 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
107280 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
107281 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
107282 +bin_string_33884 bin_string 3-5 33884 NULL
107283 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
107284 +ath6kl_roam_mode_write_33912 ath6kl_roam_mode_write 3 33912 NULL
107285 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
107286 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
107287 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
107288 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL nohasharray
107289 +btrfs_uuid_tree_rem_33944 btrfs_uuid_tree_rem 0 33944 &read_file_tgt_rx_stats_33944
107290 +hfsplus_osx_setxattr_33952 hfsplus_osx_setxattr 4 33952 NULL
107291 +__proc_dump_kernel_33954 __proc_dump_kernel 5 33954 NULL
107292 +ocfs2_create_new_meta_bhs_33955 ocfs2_create_new_meta_bhs 0 33955 NULL
107293 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
107294 +snd_interval_refine_33987 snd_interval_refine 0 33987 NULL
107295 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
107296 +lbs_lowrssi_write_34025 lbs_lowrssi_write 3 34025 NULL
107297 +ppp_write_34034 ppp_write 3 34034 NULL
107298 +tty_insert_flip_string_34042 tty_insert_flip_string 3-0 34042 NULL
107299 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
107300 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
107301 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
107302 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
107303 +__irq_domain_add_34101 __irq_domain_add 2 34101 NULL
107304 +i915_gem_object_set_cache_level_34107 i915_gem_object_set_cache_level 0 34107 NULL nohasharray
107305 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 &i915_gem_object_set_cache_level_34107
107306 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
107307 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
107308 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2-0 34135 NULL
107309 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
107310 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
107311 +ext4_xattr_list_34162 ext4_xattr_list 3 34162 NULL
107312 +ocfs2_xattr_list_entry_34165 ocfs2_xattr_list_entry 0 34165 NULL
107313 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
107314 +dtf_write_run_34196 dtf_write_run 3 34196 NULL
107315 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
107316 +i915_gem_execbuffer_reserve_object_34224 i915_gem_execbuffer_reserve_object 0 34224 NULL
107317 +setup_nodes_for_search_34248 setup_nodes_for_search 0 34248 NULL
107318 +numa_migrate_prep_34256 numa_migrate_prep 0 34256 NULL
107319 +btrfs_bitmap_cluster_34257 btrfs_bitmap_cluster 4 34257 NULL
107320 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
107321 +ocfs2_dlm_lock_34265 ocfs2_dlm_lock 0 34265 NULL
107322 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
107323 +device_private_init_34279 device_private_init 0 34279 NULL
107324 +get_task_io_context_34316 get_task_io_context 3 34316 NULL
107325 +ext4_get_groups_count_34324 ext4_get_groups_count 0 34324 NULL
107326 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
107327 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
107328 +SYSC_brk_34331 SYSC_brk 1 34331 NULL
107329 +__insert_34349 __insert 2-3 34349 NULL
107330 +sync_page_io_34363 sync_page_io 3 34363 NULL nohasharray
107331 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 &sync_page_io_34363
107332 +rngapi_reset_34366 rngapi_reset 3 34366 NULL
107333 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
107334 +ea_read_34378 ea_read 0 34378 NULL
107335 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
107336 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
107337 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
107338 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
107339 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 NULL nohasharray
107340 +iwl_calib_set_34400 iwl_calib_set 3 34400 &ivtv_read_pos_34400
107341 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
107342 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
107343 +security_socket_create_34439 security_socket_create 0 34439 NULL
107344 +usbtest_alloc_urb_34446 usbtest_alloc_urb 5-3 34446 NULL
107345 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
107346 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
107347 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
107348 +ocfs2_block_group_clear_bits_34484 ocfs2_block_group_clear_bits 0 34484 NULL
107349 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
107350 +__ffs64_34494 __ffs64 1-0 34494 NULL nohasharray
107351 +SyS_pwritev_34494 SyS_pwritev 3 34494 &__ffs64_34494
107352 +qp_alloc_res_34496 qp_alloc_res 5 34496 NULL
107353 +lu_buf_check_and_alloc_34505 lu_buf_check_and_alloc 2 34505 NULL
107354 +snd_pcm_hw_param_value_34525 snd_pcm_hw_param_value 0 34525 NULL
107355 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL nohasharray
107356 +ext4_fallocate_34537 ext4_fallocate 4-3 34537 &tracing_stats_read_34537
107357 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 4-5-2-0 34547 NULL
107358 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
107359 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL nohasharray
107360 +self_check_peb_ec_hdr_34564 self_check_peb_ec_hdr 0 34564 &alloc_ieee80211_rsl_34564
107361 +i915_gem_execbuffer_relocate_object_34575 i915_gem_execbuffer_relocate_object 0 34575 NULL
107362 +lov_stripecount_seq_write_34582 lov_stripecount_seq_write 3 34582 NULL
107363 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
107364 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
107365 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL nohasharray
107366 +cw1200_queue_init_34599 cw1200_queue_init 4 34599 &ceph_msgpool_init_34599
107367 +__add_prelim_ref_34600 __add_prelim_ref 0 34600 NULL
107368 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
107369 +mtd_write_34609 mtd_write 0 34609 NULL nohasharray
107370 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 &mtd_write_34609
107371 +apei_get_nvs_resources_34616 apei_get_nvs_resources 0 34616 NULL
107372 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
107373 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
107374 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
107375 +kvm_set_spte_hva_34671 kvm_set_spte_hva 2 34671 NULL
107376 +sleep_auth_write_34676 sleep_auth_write 3 34676 NULL
107377 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
107378 +port_print_34704 port_print 3 34704 NULL
107379 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1-2 34706 NULL
107380 +ext4_listxattr_34712 ext4_listxattr 3 34712 NULL
107381 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
107382 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
107383 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
107384 +lsm_alloc_plain_34755 lsm_alloc_plain 1 34755 NULL
107385 +device_add_34766 device_add 0 34766 NULL
107386 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
107387 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
107388 +can_nocow_extent_34801 can_nocow_extent 2 34801 NULL
107389 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
107390 +ll_setxattr_34806 ll_setxattr 4 34806 NULL
107391 +file_page_index_34820 file_page_index 0-2 34820 NULL
107392 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
107393 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
107394 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
107395 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
107396 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
107397 +msg_print_text_34889 msg_print_text 0 34889 NULL
107398 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
107399 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
107400 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
107401 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
107402 +ODM_AllocateMemory_34929 ODM_AllocateMemory 3 34929 NULL
107403 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
107404 +sec_flags2str_34933 sec_flags2str 3 34933 NULL
107405 +snd_info_entry_read_34938 snd_info_entry_read 3 34938 NULL
107406 +i2c_transfer_34958 i2c_transfer 0 34958 NULL
107407 +do_add_page_to_bio_34974 do_add_page_to_bio 2-10 34974 NULL
107408 +mq_lookup_34990 mq_lookup 2 34990 NULL
107409 +i915_gem_gtt_prepare_object_34991 i915_gem_gtt_prepare_object 0 34991 NULL
107410 +schedule_erase_34996 schedule_erase 0 34996 NULL
107411 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
107412 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
107413 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
107414 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
107415 +snd_pcm_hw_params_35020 snd_pcm_hw_params 0 35020 NULL
107416 +process_changed_xattr_35025 process_changed_xattr 0 35025 NULL
107417 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
107418 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
107419 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
107420 +ext4_split_unwritten_extents_35063 ext4_split_unwritten_extents 0 35063 NULL
107421 +ntfs_attr_extend_initialized_35084 ntfs_attr_extend_initialized 2 35084 NULL
107422 +store_ifalias_35088 store_ifalias 4 35088 NULL
107423 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
107424 +alloc_thread_info_node_35101 alloc_thread_info_node 2 35101 NULL
107425 +capi_write_35104 capi_write 3 35104 NULL nohasharray
107426 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
107427 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
107428 +ceph_osdc_start_request_35122 ceph_osdc_start_request 0 35122 NULL
107429 +message_stats_print_35158 message_stats_print 6 35158 NULL
107430 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
107431 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
107432 +relocate_entry_cpu_35176 relocate_entry_cpu 0 35176 NULL
107433 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
107434 +SyS_init_module_35180 SyS_init_module 2 35180 NULL
107435 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
107436 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
107437 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
107438 +striped_read_35218 striped_read 0-3-2 35218 NULL nohasharray
107439 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
107440 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
107441 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
107442 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL nohasharray
107443 +may_commit_transaction_35234 may_commit_transaction 0 35234 &gfn_to_page_many_atomic_35234
107444 +SYSC_madvise_35241 SYSC_madvise 1-2 35241 NULL
107445 +set_fd_set_35249 set_fd_set 1 35249 NULL
107446 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
107447 +alloc_thread_groups_35256 alloc_thread_groups 2 35256 NULL
107448 +jbd2_journal_get_write_access_35263 jbd2_journal_get_write_access 0 35263 NULL
107449 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
107450 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
107451 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
107452 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
107453 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
107454 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
107455 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
107456 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
107457 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
107458 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
107459 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
107460 +ieee80211_rx_mgmt_deauth_35351 ieee80211_rx_mgmt_deauth 3 35351 NULL
107461 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
107462 +amd_iommu_map_35355 amd_iommu_map 4 35355 NULL
107463 +read_kmem_35372 read_kmem 3 35372 NULL
107464 +ocfs2_journal_access_di_35393 ocfs2_journal_access_di 0 35393 NULL
107465 +create_pending_snapshots_35402 create_pending_snapshots 0 35402 NULL
107466 +btrfs_search_old_slot_35406 btrfs_search_old_slot 0 35406 NULL
107467 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
107468 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
107469 +C_SYSC_sendfile_35432 C_SYSC_sendfile 4 35432 NULL
107470 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
107471 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
107472 +memcg_memory_allocated_read_35469 memcg_memory_allocated_read 0 35469 NULL
107473 +fiemap_prepare_and_copy_exts_35494 fiemap_prepare_and_copy_exts 5 35494 NULL
107474 +btrfs_prealloc_file_range_trans_35500 btrfs_prealloc_file_range_trans 4-0 35500 NULL
107475 +async_setkey_35521 async_setkey 3 35521 NULL
107476 +inet_mask_len_35527 inet_mask_len 1 35527 NULL
107477 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
107478 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
107479 +pstore_mkfile_35536 pstore_mkfile 7 35536 NULL
107480 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
107481 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
107482 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
107483 +send_update_extent_35556 send_update_extent 0 35556 NULL
107484 +vb2_dqbuf_35559 vb2_dqbuf 0 35559 NULL
107485 +sysfs_create_subdir_35567 sysfs_create_subdir 0 35567 NULL
107486 +ext4_blocks_for_truncate_35579 ext4_blocks_for_truncate 0 35579 NULL
107487 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
107488 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
107489 +kernel_readv_35617 kernel_readv 3 35617 NULL
107490 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
107491 +ptlrpcd_steal_rqset_35637 ptlrpcd_steal_rqset 0 35637 NULL
107492 +nv50_vm_create_35643 nv50_vm_create 2-3 35643 NULL
107493 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
107494 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
107495 +cpu_to_sle64_35677 cpu_to_sle64 0-1 35677 NULL
107496 +ext3_mark_iloc_dirty_35686 ext3_mark_iloc_dirty 0 35686 NULL
107497 +dm_table_create_35687 dm_table_create 3 35687 NULL
107498 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
107499 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
107500 +md_super_write_35703 md_super_write 4 35703 NULL
107501 +btrfs_commit_transaction_35725 btrfs_commit_transaction 0 35725 NULL
107502 +rtw_IOL_cmd_tx_pkt_buf_dump_35732 rtw_IOL_cmd_tx_pkt_buf_dump 2 35732 NULL
107503 +ext4_truncate_restart_trans_35750 ext4_truncate_restart_trans 0 35750 NULL
107504 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
107505 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
107506 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
107507 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
107508 +vx_query_hbuffer_size_35859 vx_query_hbuffer_size 0 35859 NULL
107509 +changed_xattr_35860 changed_xattr 0 35860 NULL
107510 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
107511 +fls64_35862 fls64 0 35862 NULL
107512 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
107513 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
107514 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
107515 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
107516 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
107517 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
107518 +balance_node_right_35920 balance_node_right 0 35920 NULL
107519 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
107520 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
107521 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
107522 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
107523 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL nohasharray
107524 +generic_ocp_read_35974 generic_ocp_read 3 35974 &ceph_buffer_new_35974
107525 +acl_alloc_35979 acl_alloc 1 35979 NULL
107526 +device_add_class_symlinks_35985 device_add_class_symlinks 0 35985 NULL
107527 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
107528 +write_file_antenna_35998 write_file_antenna 3 35998 NULL nohasharray
107529 +kuc_alloc_35998 kuc_alloc 1 35998 &write_file_antenna_35998
107530 +locks_mandatory_area_35999 locks_mandatory_area 0 35999 NULL
107531 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
107532 +ubi_eba_write_leb_36029 ubi_eba_write_leb 0-6-5 36029 NULL
107533 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
107534 +account_shadowed_36048 account_shadowed 2 36048 NULL
107535 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
107536 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
107537 +did_create_dir_36062 did_create_dir 0 36062 NULL
107538 +write_emulate_36065 write_emulate 2-4 36065 NULL
107539 +stack_max_size_write_36068 stack_max_size_write 3 36068 NULL
107540 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
107541 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
107542 +ext3_new_blocks_36073 ext3_new_blocks 3-0 36073 NULL
107543 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
107544 +vmemmap_pud_populate_36080 vmemmap_pud_populate 3 36080 NULL nohasharray
107545 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 &vmemmap_pud_populate_36080
107546 +mtip_hw_read_device_status_36082 mtip_hw_read_device_status 3 36082 NULL
107547 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
107548 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
107549 +compat_ptrace_request_36131 compat_ptrace_request 3 36131 NULL
107550 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
107551 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
107552 +set_flexbg_block_bitmap_36136 set_flexbg_block_bitmap 0-4-5 36136 NULL
107553 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
107554 +twl_set_36154 twl_set 2 36154 NULL
107555 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
107556 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
107557 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
107558 +wm8994_edge_irq_map_36170 wm8994_edge_irq_map 2 36170 NULL
107559 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
107560 +ramoops_init_przs_36199 ramoops_init_przs 4 36199 NULL
107561 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
107562 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 5-3 36216 NULL
107563 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
107564 +is_dirty_36223 is_dirty 2 36223 NULL
107565 +ept_walk_addr_36226 ept_walk_addr 3 36226 NULL
107566 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
107567 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
107568 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
107569 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
107570 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
107571 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
107572 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL nohasharray
107573 +cfs_hash_buckets_realloc_36276 cfs_hash_buckets_realloc 4 36276 &usb_buffer_alloc_36276
107574 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
107575 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
107576 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
107577 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
107578 +cfg80211_rx_mlme_mgmt_36306 cfg80211_rx_mlme_mgmt 3 36306 NULL
107579 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
107580 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
107581 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
107582 +lc_create_36332 lc_create 4 36332 NULL
107583 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
107584 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
107585 +ath6kl_regwrite_write_36351 ath6kl_regwrite_write 3 36351 NULL
107586 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
107587 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
107588 +to_sector_36361 to_sector 0-1 36361 NULL
107589 +irq_domain_disassociate_36367 irq_domain_disassociate 2 36367 NULL
107590 +posix_acl_create_36383 posix_acl_create 0 36383 NULL
107591 +tunables_read_36385 tunables_read 3 36385 NULL
107592 +afs_alloc_flat_call_36399 afs_alloc_flat_call 3-2 36399 NULL
107593 +sierra_write_36402 sierra_write 4 36402 NULL
107594 +msb_update_block_36412 msb_update_block 2 36412 NULL
107595 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
107596 +ReadW6692B_36445 ReadW6692B 0 36445 NULL
107597 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
107598 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
107599 +check_extent_in_eb_36467 check_extent_in_eb 0 36467 NULL
107600 +SyS_process_vm_writev_36476 SyS_process_vm_writev 5-3 36476 NULL
107601 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
107602 +set_var_mtrr_range_36483 set_var_mtrr_range 2 36483 NULL
107603 +ip6_append_data_36490 ip6_append_data 4 36490 NULL nohasharray
107604 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 &ip6_append_data_36490
107605 +cmd_loop_36491 cmd_loop 0 36491 NULL
107606 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
107607 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
107608 +get_param_l_36518 get_param_l 0 36518 NULL
107609 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
107610 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
107611 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
107612 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
107613 +__kfifo_to_user_36555 __kfifo_to_user 3-0 36555 NULL nohasharray
107614 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
107615 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
107616 +__erst_read_36579 __erst_read 0 36579 NULL
107617 +put_cmsg_36589 put_cmsg 4 36589 NULL
107618 +do_sendfile_36610 do_sendfile 4-5 36610 NULL
107619 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
107620 +i915_gem_execbuffer_relocate_slow_36634 i915_gem_execbuffer_relocate_slow 0 36634 NULL
107621 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
107622 +convert_extent_item_v0_36645 convert_extent_item_v0 4-0 36645 NULL
107623 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
107624 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
107625 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
107626 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
107627 +xillybus_read_36678 xillybus_read 3 36678 NULL
107628 +tlv_put_btrfs_timespec_36685 tlv_put_btrfs_timespec 0 36685 NULL nohasharray
107629 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 &tlv_put_btrfs_timespec_36685
107630 +gsmtty_write_36702 gsmtty_write 3 36702 NULL
107631 +sched_clock_36717 sched_clock 0 36717 NULL
107632 +ocfs2_rotate_tree_right_36723 ocfs2_rotate_tree_right 0 36723 NULL
107633 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4-0 36740 NULL
107634 +cxgbi_device_register_36746 cxgbi_device_register 2-1 36746 NULL
107635 +fc_exch_mgr_alloc_36751 fc_exch_mgr_alloc 3-4 36751 NULL
107636 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
107637 +ext4_ext_convert_to_initialized_36765 ext4_ext_convert_to_initialized 0 36765 NULL
107638 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
107639 +i40e_init_lan_hmc_36796 i40e_init_lan_hmc 2-3-4-5 36796 NULL
107640 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
107641 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
107642 +ocfs2_journal_access_rb_36823 ocfs2_journal_access_rb 0 36823 NULL
107643 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
107644 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
107645 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
107646 +cm_write_36858 cm_write 3 36858 NULL
107647 +range_to_mtrr_with_hole_36861 range_to_mtrr_with_hole 2 36861 NULL
107648 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
107649 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
107650 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
107651 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
107652 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
107653 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
107654 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
107655 +audio_set_endpoint_req_36918 audio_set_endpoint_req 0 36918 NULL
107656 +build_key_36931 build_key 1 36931 NULL
107657 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
107658 +div_u64_36951 div_u64 0 36951 NULL
107659 +write_leb_36957 write_leb 0-5 36957 NULL
107660 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
107661 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
107662 +il4965_rs_sta_dbgfs_scale_table_write_36979 il4965_rs_sta_dbgfs_scale_table_write 3 36979 NULL
107663 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
107664 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
107665 +setxattr_37006 setxattr 4 37006 NULL
107666 +btrfs_update_root_37035 btrfs_update_root 0 37035 NULL
107667 +ocfs2_dlm_unlock_37037 ocfs2_dlm_unlock 0 37037 NULL
107668 +command_file_read_37038 command_file_read 3 37038 NULL
107669 +__hfsplus_brec_find_37048 __hfsplus_brec_find 0 37048 NULL
107670 +figure_loop_size_37051 figure_loop_size 2-3 37051 NULL
107671 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
107672 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
107673 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
107674 +parse_command_37079 parse_command 2 37079 NULL
107675 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
107676 +tun_get_user_37094 tun_get_user 5 37094 NULL
107677 +has_wrprotected_page_37123 has_wrprotected_page 3-2 37123 NULL
107678 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
107679 +mtt_free_res_37144 mtt_free_res 5 37144 NULL
107680 +msg_word_37164 msg_word 0 37164 NULL
107681 +BeceemNVMRead_37166 BeceemNVMRead 0 37166 NULL
107682 +f2fs_direct_IO_37167 f2fs_direct_IO 4 37167 NULL
107683 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
107684 +btrfs_insert_delayed_items_37191 btrfs_insert_delayed_items 0 37191 NULL
107685 +vcc_recvmsg_37198 vcc_recvmsg 4 37198 NULL
107686 +sysfs_add_file_37200 sysfs_add_file 0 37200 NULL
107687 +mpol_misplaced_37205 mpol_misplaced 0 37205 NULL
107688 +forced_ps_write_37209 forced_ps_write 3 37209 NULL
107689 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL nohasharray
107690 +ext4_ind_direct_IO_37212 ext4_ind_direct_IO 0-4 37212 &crypto_shash_descsize_37212
107691 +bchannel_get_rxbuf_37213 bchannel_get_rxbuf 2-0 37213 NULL
107692 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
107693 +__do_replace_37227 __do_replace 5 37227 NULL
107694 +produce_free_peb_37232 produce_free_peb 0 37232 NULL
107695 +iwl_dbgfs_d3_sram_read_37237 iwl_dbgfs_d3_sram_read 3 37237 NULL
107696 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
107697 +BeceemFlashBulkWrite_37255 BeceemFlashBulkWrite 0 37255 NULL
107698 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
107699 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
107700 +__add_keyed_refs_37264 __add_keyed_refs 0 37264 NULL
107701 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
107702 +create_cq_user_37278 create_cq_user 5 37278 NULL
107703 +request_threaded_irq_37303 request_threaded_irq 0 37303 NULL
107704 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
107705 +ext3_direct_IO_37308 ext3_direct_IO 4 37308 NULL
107706 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
107707 +send_msg_37323 send_msg 4 37323 NULL
107708 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL nohasharray
107709 +bnx2x_vf_fill_fw_str_37327 bnx2x_vf_fill_fw_str 3 37327 &l2cap_create_connless_pdu_37327
107710 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
107711 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
107712 +lz4_compressbound_37337 lz4_compressbound 0-1 37337 NULL
107713 +move_vma_37341 move_vma 0-5 37341 NULL
107714 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
107715 +cl_io_submit_rw_37374 cl_io_submit_rw 0 37374 NULL
107716 +iterate_leaf_refs_37385 iterate_leaf_refs 0 37385 NULL
107717 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
107718 +btrfs_find_free_objectid_37412 btrfs_find_free_objectid 0 37412 NULL
107719 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
107720 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
107721 +find_next_bit_37422 find_next_bit 0-3-2 37422 &acpi_os_allocate_zeroed_37422
107722 +ocfs2_insert_path_37425 ocfs2_insert_path 0 37425 NULL
107723 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4-0 37428 NULL
107724 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
107725 +fru_alloc_37442 fru_alloc 1 37442 NULL
107726 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
107727 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
107728 +__remove_37457 __remove 2 37457 NULL
107729 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
107730 +get_est_timing_37484 get_est_timing 0 37484 NULL
107731 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
107732 +__hfsplus_setxattr_37499 __hfsplus_setxattr 4 37499 NULL
107733 +bitmap_dirty_bits_37503 bitmap_dirty_bits 2 37503 NULL
107734 +osc_active_seq_write_37514 osc_active_seq_write 3 37514 NULL
107735 +bdev_writeseg_37519 bdev_writeseg 2-3 37519 NULL nohasharray
107736 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 &bdev_writeseg_37519
107737 +xz_dec_test_write_37527 xz_dec_test_write 3 37527 NULL
107738 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
107739 +hdr_size_37536 hdr_size 0 37536 NULL
107740 +extent_map_end_37550 extent_map_end 0 37550 NULL
107741 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL
107742 +ioat_chansts_37558 ioat_chansts 0 37558 NULL
107743 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
107744 +ocfs2_add_branch_37588 ocfs2_add_branch 0 37588 NULL
107745 +alloc_descs_37593 alloc_descs 0-1-3 37593 NULL
107746 +qla2x00_debounce_register_37597 qla2x00_debounce_register 0 37597 NULL
107747 +find_extent_clone_37603 find_extent_clone 0 37603 NULL
107748 +btrfs_write_and_wait_marked_extents_37604 btrfs_write_and_wait_marked_extents 0 37604 NULL
107749 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
107750 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL nohasharray
107751 +ocfs2_split_refcount_rec_37622 ocfs2_split_refcount_rec 0 37622 &SYSC_mbind_37622
107752 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
107753 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
107754 +alloc_fd_37637 alloc_fd 1 37637 NULL
107755 +SyS_mbind_37638 SyS_mbind 5 37638 NULL
107756 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
107757 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
107758 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
107759 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
107760 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
107761 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
107762 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
107763 +page_chain_free_37697 page_chain_free 0 37697 NULL
107764 +nametbl_header_37698 nametbl_header 2-0 37698 NULL
107765 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
107766 +dynamic_ps_timeout_write_37713 dynamic_ps_timeout_write 3 37713 NULL
107767 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
107768 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
107769 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
107770 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 5-4-6 37749 NULL
107771 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
107772 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
107773 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
107774 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
107775 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
107776 +deny_write_access_37813 deny_write_access 0 37813 NULL
107777 +ocrdma_alloc_frmr_page_list_37815 ocrdma_alloc_frmr_page_list 2 37815 NULL
107778 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
107779 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-0-5-4 37827 NULL
107780 +android_get_p2p_addr_37832 android_get_p2p_addr 0 37832 NULL
107781 +jbd2_journal_get_undo_access_37837 jbd2_journal_get_undo_access 0 37837 NULL
107782 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
107783 +SYSC_pwrite64_37862 SYSC_pwrite64 3 37862 NULL
107784 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
107785 +set_registers_37883 set_registers 4 37883 NULL
107786 +btrfs_stack_file_extent_disk_bytenr_37888 btrfs_stack_file_extent_disk_bytenr 0 37888 NULL
107787 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
107788 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
107789 +_rtw_malloc_37928 _rtw_malloc 1 37928 NULL nohasharray
107790 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 &_rtw_malloc_37928
107791 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
107792 +write_file_bool_37957 write_file_bool 3 37957 NULL
107793 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
107794 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 4-3 37967 NULL
107795 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
107796 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
107797 +vfs_readv_38011 vfs_readv 3 38011 NULL
107798 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
107799 +SyS_pwrite64_38041 SyS_pwrite64 3 38041 NULL
107800 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
107801 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
107802 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
107803 +sysfs_do_create_link_38051 sysfs_do_create_link 0 38051 NULL
107804 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
107805 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
107806 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
107807 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
107808 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
107809 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
107810 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
107811 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
107812 +ep0_read_38095 ep0_read 3 38095 NULL
107813 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL nohasharray
107814 +osc_checksum_seq_write_38096 osc_checksum_seq_write 3 38096 &sk_wmem_schedule_38096
107815 +o2hb_read_slots_38105 o2hb_read_slots 2 38105 NULL
107816 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
107817 +_get_val_38115 _get_val 2 38115 NULL
107818 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
107819 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 0-4-3 38153 NULL
107820 +btrfs_extent_same_38163 btrfs_extent_same 3-2 38163 NULL
107821 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
107822 +cirrus_ttm_tt_create_38167 cirrus_ttm_tt_create 2 38167 NULL
107823 +send_rename_38170 send_rename 0 38170 NULL
107824 +cdev_add_38176 cdev_add 2-3 38176 NULL
107825 +create_srq_user_38191 create_srq_user 5 38191 NULL
107826 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
107827 +do_chunk_alloc_38200 do_chunk_alloc 0 38200 NULL
107828 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
107829 +ext3_new_block_38208 ext3_new_block 3-0 38208 NULL
107830 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
107831 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
107832 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
107833 +ceph_decode_16_38239 ceph_decode_16 0 38239 NULL
107834 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
107835 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
107836 +from_dblock_38256 from_dblock 0-1 38256 NULL
107837 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 3-2 38260 NULL
107838 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
107839 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
107840 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
107841 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
107842 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
107843 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL
107844 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
107845 +ucma_query_path_38305 ucma_query_path 3 38305 NULL
107846 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
107847 +ida_simple_get_38326 ida_simple_get 2-0 38326 NULL
107848 +ocfs2_rotate_rightmost_leaf_left_38330 ocfs2_rotate_rightmost_leaf_left 0 38330 NULL
107849 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
107850 +ocfs2_replace_extent_rec_38357 ocfs2_replace_extent_rec 0 38357 NULL
107851 +btrfs_file_extent_disk_num_bytes_38363 btrfs_file_extent_disk_num_bytes 0 38363 NULL
107852 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
107853 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
107854 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 0-2 38413 NULL
107855 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
107856 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
107857 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
107858 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
107859 +btrfs_next_old_leaf_38465 btrfs_next_old_leaf 0 38465 NULL
107860 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
107861 +blk_end_bidi_request_38482 blk_end_bidi_request 4-3 38482 NULL
107862 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
107863 +dev_names_read_38509 dev_names_read 3 38509 NULL
107864 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
107865 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
107866 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
107867 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
107868 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
107869 +kuc_len_38557 kuc_len 0-1 38557 NULL
107870 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
107871 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
107872 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
107873 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
107874 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
107875 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
107876 +compat_sys_ptrace_38595 compat_sys_ptrace 3 38595 NULL
107877 +blkg_stat_read_38612 blkg_stat_read 0 38612 NULL
107878 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
107879 +write_enabled_file_bool_38630 write_enabled_file_bool 3 38630 NULL
107880 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
107881 +cma_create_area_38642 cma_create_area 2 38642 NULL
107882 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
107883 +qp_broker_alloc_38646 qp_broker_alloc 6-5 38646 NULL
107884 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
107885 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
107886 +snd_es1371_wait_src_ready_38673 snd_es1371_wait_src_ready 0 38673 NULL
107887 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
107888 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
107889 +validate_vid_hdr_38699 validate_vid_hdr 0 38699 NULL
107890 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
107891 +find_next_usable_block_38716 find_next_usable_block 3-1-0 38716 NULL
107892 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
107893 +w83977af_sir_interrupt_38738 w83977af_sir_interrupt 0 38738 NULL
107894 +udf_readpages_38761 udf_readpages 4 38761 NULL
107895 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
107896 +bcache_device_init_38781 bcache_device_init 3 38781 NULL
107897 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
107898 +slab_order_38794 slab_order 0 38794 NULL
107899 +do_pci_enable_device_38802 do_pci_enable_device 0 38802 NULL
107900 +err_decode_38804 err_decode 2 38804 NULL
107901 +btrfs_find_space_cluster_38812 btrfs_find_space_cluster 4-0 38812 NULL
107902 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
107903 +direct_entry_38836 direct_entry 3 38836 NULL
107904 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
107905 +read_nic_io_word_38853 read_nic_io_word 0 38853 NULL
107906 +interfaces_38859 interfaces 2 38859 NULL
107907 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
107908 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
107909 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
107910 +traverse_38897 traverse 0 38897 NULL
107911 +__fswab16_38898 __fswab16 0 38898 NULL
107912 +ext3_trim_all_free_38929 ext3_trim_all_free 4-3-2 38929 NULL
107913 +il_dbgfs_sram_write_38942 il_dbgfs_sram_write 3 38942 NULL
107914 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
107915 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL nohasharray
107916 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 &usb_maxpacket_38977
107917 +OSDSetBlock_38986 OSDSetBlock 2-4 38986 NULL
107918 +lpfc_idiag_extacc_write_38998 lpfc_idiag_extacc_write 3 38998 NULL
107919 +udf_new_block_38999 udf_new_block 4 38999 NULL
107920 +get_nodes_39012 get_nodes 3 39012 NULL
107921 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
107922 +__blkdev_issue_zeroout_39020 __blkdev_issue_zeroout 3-0 39020 NULL
107923 +qgroup_account_ref_step1_39024 qgroup_account_ref_step1 0 39024 NULL
107924 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
107925 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
107926 +do_write_kmem_39051 do_write_kmem 1-3-0 39051 NULL
107927 +gen_pool_create_39064 gen_pool_create 2 39064 NULL
107928 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
107929 +ReadHFC_39104 ReadHFC 0 39104 NULL
107930 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
107931 +leb_write_lock_39111 leb_write_lock 0 39111 NULL
107932 +__kfifo_to_user_r_39123 __kfifo_to_user_r 5-3 39123 NULL
107933 +ttm_mem_global_alloc_zone_39125 ttm_mem_global_alloc_zone 0 39125 NULL
107934 +ea_foreach_39133 ea_foreach 0 39133 NULL
107935 +generic_permission_39150 generic_permission 0 39150 NULL
107936 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
107937 +echo_client_kbrw_39170 echo_client_kbrw 6 39170 NULL
107938 +btrfs_start_delalloc_flush_39173 btrfs_start_delalloc_flush 0 39173 NULL
107939 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
107940 +ubi_more_update_data_39189 ubi_more_update_data 4-0 39189 NULL
107941 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
107942 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
107943 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
107944 +drm_order_39244 drm_order 0 39244 NULL
107945 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
107946 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
107947 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
107948 +i915_error_state_read_39254 i915_error_state_read 3 39254 NULL
107949 +bitmap_set_bits_39272 bitmap_set_bits 3 39272 NULL
107950 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
107951 +__vmalloc_node_39308 __vmalloc_node 1-5 39308 NULL
107952 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
107953 +insert_reserved_file_extent_39327 insert_reserved_file_extent 3-0 39327 NULL
107954 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
107955 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3-0 39351 NULL
107956 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
107957 +do_write_log_from_user_39362 do_write_log_from_user 3-0 39362 NULL
107958 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
107959 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
107960 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
107961 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
107962 +__send_to_port_39386 __send_to_port 3 39386 NULL
107963 +perf_trace_buf_submit_39413 perf_trace_buf_submit 5 39413 NULL
107964 +user_power_read_39414 user_power_read 3 39414 NULL
107965 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
107966 +__vb2_get_done_vb_39448 __vb2_get_done_vb 0 39448 NULL
107967 +apei_resources_add_39470 apei_resources_add 0 39470 NULL
107968 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
107969 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
107970 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
107971 +cl_req_alloc_39523 cl_req_alloc 4 39523 NULL
107972 +int_proc_write_39542 int_proc_write 3 39542 NULL
107973 +pp_write_39554 pp_write 3 39554 NULL
107974 +ol_dqblk_block_39558 ol_dqblk_block 2-0-3 39558 NULL
107975 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
107976 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
107977 +ext_depth_39607 ext_depth 0 39607 NULL
107978 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
107979 +sdio_readb_39618 sdio_readb 0 39618 NULL
107980 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 NULL nohasharray
107981 +set_dev_class_39645 set_dev_class 4 39645 &dm_exception_table_init_39645
107982 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
107983 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL
107984 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
107985 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
107986 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
107987 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
107988 +vmx_set_cr3_39688 vmx_set_cr3 2 39688 NULL
107989 +sd_completed_bytes_39705 sd_completed_bytes 0 39705 NULL
107990 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
107991 +test_add_free_space_entry_39754 test_add_free_space_entry 2-3 39754 NULL
107992 +adt7316_spi_multi_read_39765 adt7316_spi_multi_read 3 39765 NULL
107993 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
107994 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
107995 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
107996 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
107997 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
107998 +can_rmdir_39890 can_rmdir 0 39890 NULL
107999 +pkt_add_39897 pkt_add 3 39897 NULL
108000 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
108001 +gen_pool_add_virt_39913 gen_pool_add_virt 4-5 39913 NULL
108002 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
108003 +dma_to_mm_pfn_39916 dma_to_mm_pfn 0-1 39916 NULL
108004 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
108005 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
108006 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
108007 +__spi_async_39932 __spi_async 0 39932 NULL
108008 +__get_order_39935 __get_order 0 39935 NULL
108009 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL
108010 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3-0 39955 NULL
108011 +lstcon_group_list_39958 lstcon_group_list 2 39958 NULL
108012 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
108013 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
108014 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
108015 +fw_device_op_read_39990 fw_device_op_read 3 39990 NULL
108016 +server_name2svname_39998 server_name2svname 4 39998 NULL
108017 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
108018 +ivtvfb_write_40023 ivtvfb_write 3 40023 NULL
108019 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
108020 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
108021 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
108022 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
108023 +ocfs2_claim_clusters_40050 ocfs2_claim_clusters 0 40050 NULL
108024 +add_tty_40055 add_tty 1 40055 NULL nohasharray
108025 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
108026 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
108027 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
108028 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
108029 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
108030 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
108031 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
108032 +ath10k_write_simulate_fw_crash_40143 ath10k_write_simulate_fw_crash 3 40143 NULL
108033 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
108034 +clone_backref_node_40154 clone_backref_node 0 40154 NULL
108035 +pt_write_40159 pt_write 3 40159 NULL
108036 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
108037 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
108038 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
108039 +allocate_probes_40204 allocate_probes 1 40204 NULL
108040 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
108041 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
108042 +compress_file_range_40225 compress_file_range 3-4 40225 NULL
108043 +osst_read_40237 osst_read 3 40237 NULL
108044 +lpage_info_slot_40243 lpage_info_slot 3-1 40243 NULL
108045 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4-3 40248 NULL
108046 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
108047 +ext2_fiemap_40271 ext2_fiemap 4 40271 NULL
108048 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
108049 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
108050 +vfio_unmap_unpin_40284 vfio_unmap_unpin 3 40284 NULL
108051 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
108052 +SyS_bind_40303 SyS_bind 3 40303 NULL
108053 +ubi_io_write_data_40305 ubi_io_write_data 0-5-4 40305 NULL
108054 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
108055 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
108056 +mmio_read_40348 mmio_read 4 40348 NULL
108057 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4-0 40355 NULL
108058 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
108059 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 3-2 40365 NULL
108060 +get_chars_40373 get_chars 3 40373 NULL
108061 +submit_page_section_40408 submit_page_section 0 40408 NULL
108062 +ecryptfs_read_lower_40419 ecryptfs_read_lower 3 40419 NULL
108063 +slab_node_40421 slab_node 0 40421 NULL
108064 +fb_prepare_extra_logos_40429 fb_prepare_extra_logos 0-2 40429 NULL
108065 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
108066 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
108067 +SyS_writev_40467 SyS_writev 3 40467 NULL
108068 +__i915_add_request_40469 __i915_add_request 0 40469 NULL
108069 +SyS_select_40473 SyS_select 1 40473 NULL
108070 +afs_fs_store_data_40484 afs_fs_store_data 3-4-5-6 40484 NULL
108071 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
108072 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
108073 +drm_vma_node_start_40500 drm_vma_node_start 0 40500 NULL
108074 +sg_phys_40507 sg_phys 0 40507 NULL
108075 +__ethtool_get_sset_count_40511 __ethtool_get_sset_count 0 40511 NULL
108076 +TSS_checkhmac2_40520 TSS_checkhmac2 7-5 40520 NULL
108077 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
108078 +i915_gem_execbuffer_relocate_object_slow_40546 i915_gem_execbuffer_relocate_object_slow 0 40546 NULL
108079 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
108080 +btrfs_flush_all_pending_stuffs_40553 btrfs_flush_all_pending_stuffs 0 40553 NULL
108081 +esp_alloc_tmp_40558 esp_alloc_tmp 2-3 40558 NULL
108082 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
108083 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
108084 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
108085 +b1_get_byte_40597 b1_get_byte 0 40597 NULL
108086 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
108087 +qla8044_rd_reg_40652 qla8044_rd_reg 0 40652 NULL
108088 +pid_nr_ns_40654 pid_nr_ns 0 40654 NULL
108089 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
108090 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
108091 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
108092 +fops_read_40672 fops_read 3 40672 NULL
108093 +ext4_mark_inode_dirty_40673 ext4_mark_inode_dirty 0 40673 NULL
108094 +idr_get_empty_slot_40674 idr_get_empty_slot 0 40674 NULL
108095 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
108096 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3-4 40678 NULL
108097 +pci_enable_resources_40680 pci_enable_resources 0 40680 NULL
108098 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
108099 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
108100 +btrfs_find_one_extref_40724 btrfs_find_one_extref 0 40724 NULL
108101 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
108102 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
108103 +find_next_zero_bit_le_40744 find_next_zero_bit_le 2-3-0 40744 &xfs_iext_remove_direct_40744
108104 +i915_gem_execbuffer_relocate_entry_40750 i915_gem_execbuffer_relocate_entry 0 40750 NULL
108105 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
108106 +card_send_command_40757 card_send_command 3 40757 NULL
108107 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
108108 +pg_write_40766 pg_write 3 40766 NULL
108109 +show_list_40775 show_list 3-0 40775 NULL
108110 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
108111 +kfifo_out_copy_r_40784 kfifo_out_copy_r 3-0 40784 NULL
108112 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
108113 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
108114 +add_action_40811 add_action 4 40811 NULL
108115 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
108116 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
108117 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
108118 +nilfs_mdt_init_40849 nilfs_mdt_init 3 40849 NULL
108119 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
108120 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
108121 +read_file_queue_40895 read_file_queue 3 40895 NULL
108122 +btrfs_set_inode_index_count_40901 btrfs_set_inode_index_count 0 40901 NULL
108123 +waiters_read_40902 waiters_read 3 40902 NULL
108124 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
108125 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
108126 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
108127 +snd_vx_create_40948 snd_vx_create 4 40948 NULL nohasharray
108128 +sg_alloc_table_40948 sg_alloc_table 0 40948 &snd_vx_create_40948
108129 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
108130 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
108131 +btrfs_find_orphan_item_40977 btrfs_find_orphan_item 0 40977 NULL
108132 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
108133 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
108134 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
108135 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
108136 +__proc_dobitmasks_41029 __proc_dobitmasks 5 41029 NULL
108137 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
108138 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
108139 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
108140 +lprocfs_write_frac_helper_41050 lprocfs_write_frac_helper 2 41050 NULL
108141 +BcmFlash2xBulkWrite_41054 BcmFlash2xBulkWrite 0 41054 NULL
108142 +calculate_order_41061 calculate_order 0 41061 NULL
108143 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL nohasharray
108144 +beacon_filtering_write_41062 beacon_filtering_write 3 41062 &vfs_listxattr_41062
108145 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
108146 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
108147 +nvme_map_user_pages_41093 nvme_map_user_pages 4-3 41093 &roccat_read_41093
108148 +dma_attach_41094 dma_attach 6-5 41094 NULL
108149 +provide_user_output_41105 provide_user_output 3 41105 NULL
108150 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
108151 +ath10k_read_wmi_services_41112 ath10k_read_wmi_services 3 41112 NULL
108152 +ocfs2_extend_trans_41116 ocfs2_extend_trans 0 41116 NULL
108153 +btrfs_subvolume_reserve_metadata_41130 btrfs_subvolume_reserve_metadata 3 41130 NULL
108154 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
108155 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
108156 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
108157 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
108158 +dgap_driver_kzmalloc_41189 dgap_driver_kzmalloc 1 41189 NULL
108159 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
108160 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
108161 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
108162 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
108163 +cfg80211_process_disassoc_41231 cfg80211_process_disassoc 3 41231 NULL
108164 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2 41255 NULL
108165 +create_dir_41256 create_dir 0 41256 NULL
108166 +erst_read_41260 erst_read 0 41260 NULL
108167 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4-0 41270 NULL
108168 +alloc_context_41283 alloc_context 1 41283 NULL
108169 +objio_alloc_io_state_41316 objio_alloc_io_state 7-6 41316 NULL
108170 +o2hb_setup_one_bio_41341 o2hb_setup_one_bio 4 41341 NULL
108171 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
108172 +rtw_android_set_block_41347 rtw_android_set_block 0 41347 NULL
108173 +irq_expand_nr_irqs_41351 irq_expand_nr_irqs 0 41351 NULL
108174 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
108175 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
108176 +kmp_init_41373 kmp_init 2 41373 NULL
108177 +netlink_alloc_large_skb_41375 netlink_alloc_large_skb 1 41375 NULL
108178 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
108179 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
108180 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
108181 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
108182 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
108183 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
108184 +vmemmap_populate_hugepages_41434 vmemmap_populate_hugepages 3 41434 NULL
108185 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
108186 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 6-4 41442 NULL
108187 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
108188 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
108189 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
108190 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
108191 +bl_alloc_init_bio_41478 bl_alloc_init_bio 1 41478 NULL
108192 +split_item_41483 split_item 0 41483 NULL
108193 +kvm_unmap_hva_range_41484 kvm_unmap_hva_range 3-2 41484 NULL
108194 +ipath_user_sdma_page_length_41490 ipath_user_sdma_page_length 0-2-1 41490 NULL
108195 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
108196 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
108197 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
108198 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
108199 +perf_sw_event_41517 perf_sw_event 2 41517 NULL
108200 +SyS_preadv_41523 SyS_preadv 3 41523 NULL
108201 +dm_get_reserved_rq_based_ios_41529 dm_get_reserved_rq_based_ios 0 41529 NULL
108202 +add_excluded_extent_41547 add_excluded_extent 0 41547 NULL
108203 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
108204 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
108205 +si476x_radio_fops_read_41559 si476x_radio_fops_read 3 41559 NULL nohasharray
108206 +nr_status_frames_41559 nr_status_frames 0-1 41559 &si476x_radio_fops_read_41559
108207 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
108208 +vga_io_r_41609 vga_io_r 0 41609 NULL
108209 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
108210 +lbs_bcnmiss_write_41613 lbs_bcnmiss_write 3 41613 NULL nohasharray
108211 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 &lbs_bcnmiss_write_41613
108212 +a2mp_send_41615 a2mp_send 4 41615 NULL
108213 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
108214 +lstcon_batch_list_41627 lstcon_batch_list 2 41627 NULL
108215 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
108216 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
108217 +get_std_timing_41654 get_std_timing 0 41654 NULL
108218 +start_graph_tracing_41656 start_graph_tracing 0 41656 NULL
108219 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
108220 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
108221 +fill_pcm_stream_name_41685 fill_pcm_stream_name 2 41685 NULL
108222 +lov_unpackmd_41701 lov_unpackmd 4 41701 NULL
108223 +__ext3_journal_get_write_access_41705 __ext3_journal_get_write_access 0 41705 NULL
108224 +apei_exec_for_each_entry_41717 apei_exec_for_each_entry 0 41717 NULL
108225 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
108226 +ocfs2_block_group_fill_41744 ocfs2_block_group_fill 0 41744 NULL
108227 +fillonedir_41746 fillonedir 3 41746 NULL
108228 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
108229 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
108230 +remap_pte_range_41800 remap_pte_range 5 41800 NULL
108231 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
108232 +regcache_sync_block_raw_41803 regcache_sync_block_raw 4-3 41803 NULL
108233 +rtw_android_get_macaddr_41812 rtw_android_get_macaddr 0 41812 NULL
108234 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
108235 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
108236 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
108237 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
108238 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
108239 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
108240 +pci_map_single_41869 pci_map_single 0 41869 NULL
108241 +usb_gadget_get_string_41871 usb_gadget_get_string 0 41871 NULL
108242 +v_APCI3120_InterruptDmaMoveBlock16bit_41914 v_APCI3120_InterruptDmaMoveBlock16bit 4 41914 NULL
108243 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
108244 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
108245 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
108246 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
108247 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
108248 +read_gssp_41947 read_gssp 3 41947 NULL
108249 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
108250 +portnames_read_41958 portnames_read 3 41958 NULL
108251 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 0-4 41959 NULL
108252 +dst_mtu_41969 dst_mtu 0 41969 NULL
108253 +btrfs_check_trunc_cache_free_space_41973 btrfs_check_trunc_cache_free_space 0 41973 NULL
108254 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
108255 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
108256 +pool_allocate_42012 pool_allocate 3 42012 NULL
108257 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
108258 +rs_sta_dbgfs_scale_table_write_42017 rs_sta_dbgfs_scale_table_write 3 42017 NULL
108259 +nouveau_ttm_tt_create_42026 nouveau_ttm_tt_create 2 42026 NULL
108260 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
108261 +__btrfs_drop_extents_42032 __btrfs_drop_extents 5-0 42032 NULL
108262 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
108263 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
108264 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
108265 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
108266 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
108267 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
108268 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
108269 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
108270 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
108271 +send_truncate_42107 send_truncate 0 42107 NULL
108272 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
108273 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
108274 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
108275 +__btrfs_unlink_inode_42114 __btrfs_unlink_inode 0 42114 NULL
108276 +ext4_do_update_inode_42127 ext4_do_update_inode 0 42127 NULL
108277 +blk_ioctl_zeroout_42160 blk_ioctl_zeroout 3 42160 NULL
108278 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
108279 +kvm_lapic_get_cr8_42166 kvm_lapic_get_cr8 0 42166 NULL
108280 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
108281 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
108282 +write_file_beacon_42185 write_file_beacon 3 42185 NULL
108283 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
108284 +ocfs2_resv_window_bits_42207 ocfs2_resv_window_bits 0 42207 NULL
108285 +pla_ocp_read_42235 pla_ocp_read 3 42235 NULL
108286 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
108287 +vfio_remove_dma_overlap_42255 vfio_remove_dma_overlap 2 42255 NULL
108288 +__pcpu_size_to_slot_42271 __pcpu_size_to_slot 0 42271 NULL
108289 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
108290 +__cpus_weight_42299 __cpus_weight 2-0 42299 NULL
108291 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
108292 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
108293 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
108294 +gfn_to_hva_42305 gfn_to_hva 2-0 42305 NULL
108295 +close_cur_inode_file_42308 close_cur_inode_file 0 42308 NULL nohasharray
108296 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 &close_cur_inode_file_42308
108297 +free_cblock_42318 free_cblock 2 42318 NULL
108298 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
108299 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
108300 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
108301 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
108302 +drbd_md_last_sector_42378 drbd_md_last_sector 0 42378 NULL
108303 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
108304 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
108305 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
108306 +krng_get_random_42420 krng_get_random 3 42420 NULL
108307 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
108308 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
108309 +alloc_request_42448 alloc_request 0 42448 NULL
108310 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
108311 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
108312 +kuc_free_42455 kuc_free 2 42455 NULL
108313 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
108314 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
108315 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
108316 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
108317 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
108318 +bypass_write_42498 bypass_write 3 42498 NULL
108319 +SyS_mincore_42511 SyS_mincore 1-2 42511 NULL
108320 +jbd2_log_wait_commit_42519 jbd2_log_wait_commit 0 42519 NULL
108321 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
108322 +dio_bio_complete_42524 dio_bio_complete 0 42524 NULL
108323 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
108324 +self_check_ec_hdr_42528 self_check_ec_hdr 0 42528 NULL
108325 +__register_ftrace_function_42543 __register_ftrace_function 0 42543 NULL
108326 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
108327 +inorder_next_42548 inorder_next 1-0 42548 NULL
108328 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 NULL
108329 +udp_recvmsg_42558 udp_recvmsg 4 42558 NULL
108330 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
108331 +ocfs2_reserve_suballoc_bits_42569 ocfs2_reserve_suballoc_bits 0 42569 NULL
108332 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
108333 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
108334 +map_state_42602 map_state 1 42602 NULL
108335 +resp_write_42628 resp_write 2 42628 NULL
108336 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
108337 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
108338 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
108339 +parport_pc_compat_write_block_pio_42644 parport_pc_compat_write_block_pio 3 42644 NULL
108340 +ocfs2_search_chain_42655 ocfs2_search_chain 0 42655 NULL
108341 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
108342 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
108343 +vb2_read_42703 vb2_read 3 42703 NULL
108344 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 5-4-0 42717 NULL
108345 +read_status_42722 read_status 0 42722 NULL
108346 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
108347 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
108348 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
108349 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
108350 +dpm_sysfs_add_42756 dpm_sysfs_add 0 42756 NULL
108351 +x25_recvmsg_42777 x25_recvmsg 4 42777 NULL
108352 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
108353 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
108354 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
108355 +elfcorehdr_read_notes_42786 elfcorehdr_read_notes 2 42786 NULL
108356 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
108357 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2-3 42796 NULL
108358 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2 42804 NULL
108359 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
108360 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
108361 +xfs_iomap_eof_prealloc_initial_size_42822 xfs_iomap_eof_prealloc_initial_size 0-3 42822 NULL
108362 +set_arg_42824 set_arg 3 42824 NULL
108363 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
108364 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
108365 +prandom_u32_42853 prandom_u32 0 42853 NULL
108366 +ntfs_mapping_pairs_build_42859 ntfs_mapping_pairs_build 0 42859 NULL
108367 +nouveau_vm_create_42869 nouveau_vm_create 3-2 42869 NULL
108368 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
108369 +nvme_trans_unit_serial_page_42879 nvme_trans_unit_serial_page 4 42879 NULL
108370 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
108371 +hd_end_request_42904 hd_end_request 2 42904 NULL
108372 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
108373 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
108374 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
108375 +vx_reset_chk_42946 vx_reset_chk 0 42946 NULL
108376 +send_link_42948 send_link 0 42948 NULL
108377 +blkdev_direct_IO_42962 blkdev_direct_IO 4 42962 NULL
108378 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
108379 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
108380 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 2-4 42990 NULL nohasharray
108381 +rtw_os_xmit_resource_alloc_42990 rtw_os_xmit_resource_alloc 3 42990 &nfs_idmap_get_desc_42990
108382 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
108383 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
108384 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0-3-4 43026 NULL
108385 +init_phys_status_page_43028 init_phys_status_page 0 43028 NULL
108386 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
108387 +send_to_group_43051 send_to_group 0 43051 NULL
108388 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
108389 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
108390 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
108391 +calculate_node_totalpages_43118 calculate_node_totalpages 2-3 43118 NULL
108392 +cow_file_range_inline_43132 cow_file_range_inline 4 43132 NULL
108393 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
108394 +cfs_cpt_table_alloc_43159 cfs_cpt_table_alloc 1 43159 NULL
108395 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
108396 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
108397 +send_cmd_43168 send_cmd 0 43168 NULL
108398 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
108399 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
108400 +uio_write_43202 uio_write 3 43202 NULL
108401 +iso_callback_43208 iso_callback 3 43208 NULL
108402 +ath10k_p2p_calc_noa_ie_len_43209 ath10k_p2p_calc_noa_ie_len 0 43209 NULL
108403 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
108404 +atomic_long_add_return_43217 atomic_long_add_return 1-0 43217 NULL
108405 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1-2 43245 NULL
108406 +fixup_leb_43256 fixup_leb 3 43256 NULL
108407 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
108408 +nilfs_direct_IO_43271 nilfs_direct_IO 4 43271 NULL
108409 +mlx5_ib_reg_user_mr_43275 mlx5_ib_reg_user_mr 2-3 43275 NULL
108410 +parport_pc_ecp_write_block_pio_43278 parport_pc_ecp_write_block_pio 3 43278 NULL nohasharray
108411 +evtchn_write_43278 evtchn_write 3 43278 &parport_pc_ecp_write_block_pio_43278
108412 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
108413 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
108414 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
108415 +mmu_set_spte_43327 mmu_set_spte 7-6 43327 NULL
108416 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
108417 +kvm_host_page_size_43348 kvm_host_page_size 2-0 43348 NULL
108418 +activation_descriptor_init_43358 activation_descriptor_init 1 43358 NULL
108419 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
108420 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
108421 +xenfb_write_43412 xenfb_write 3 43412 NULL
108422 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 NULL
108423 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
108424 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
108425 +ocfs2_rotate_tree_left_43442 ocfs2_rotate_tree_left 0 43442 NULL
108426 +usb_string_43443 usb_string 0 43443 NULL nohasharray
108427 +usemap_size_43443 usemap_size 0-2-1 43443 &usb_string_43443
108428 +get_vm_area_size_43444 get_vm_area_size 0 43444 NULL
108429 +nvme_trans_device_id_page_43466 nvme_trans_device_id_page 4 43466 NULL
108430 +calculate_discard_block_size_43480 calculate_discard_block_size 0 43480 NULL nohasharray
108431 +alloc_new_reservation_43480 alloc_new_reservation 4-0-2 43480 &calculate_discard_block_size_43480
108432 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
108433 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
108434 +do_readlink_43518 do_readlink 2 43518 NULL
108435 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
108436 +read_events_43534 read_events 3 43534 NULL
108437 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
108438 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
108439 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
108440 +request_resource_43548 request_resource 0 43548 NULL
108441 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
108442 +handle_frequent_errors_43599 handle_frequent_errors 4 43599 NULL
108443 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
108444 +proc_read_43614 proc_read 3 43614 NULL
108445 +i915_gem_execbuffer_relocate_object_slow_43618 i915_gem_execbuffer_relocate_object_slow 0 43618 NULL nohasharray
108446 +disable_dma_on_even_43618 disable_dma_on_even 0 43618 &i915_gem_execbuffer_relocate_object_slow_43618
108447 +alloc_thread_groups_43625 alloc_thread_groups 2 43625 NULL
108448 +random_write_43656 random_write 3 43656 NULL
108449 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
108450 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
108451 +fs_path_copy_43673 fs_path_copy 0 43673 NULL
108452 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4 43679 NULL
108453 +calgary_map_page_43686 calgary_map_page 4 43686 NULL
108454 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
108455 +wait_for_completion_interruptible_43723 wait_for_completion_interruptible 0 43723 NULL
108456 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
108457 +reset_card_proc_43731 reset_card_proc 0 43731 NULL
108458 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
108459 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5-0 43733 NULL
108460 +fuse_conn_congestion_threshold_write_43736 fuse_conn_congestion_threshold_write 3 43736 NULL
108461 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
108462 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
108463 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
108464 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
108465 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
108466 +btrfs_copy_from_user_43806 btrfs_copy_from_user 0-3-1 43806 NULL
108467 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
108468 +div64_u64_safe_43815 div64_u64_safe 2-1 43815 NULL
108469 +ext4_split_extent_43818 ext4_split_extent 0 43818 NULL
108470 +i915_gem_execbuffer_relocate_entry_43822 i915_gem_execbuffer_relocate_entry 0 43822 NULL
108471 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
108472 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
108473 +read_flush_43851 read_flush 3 43851 NULL
108474 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
108475 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
108476 +SendString_43928 SendString 3 43928 NULL
108477 +xen_register_gsi_43946 xen_register_gsi 2-1 43946 NULL
108478 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
108479 +perf_tp_event_43971 perf_tp_event 2 43971 NULL
108480 +__get_required_blob_size_43980 __get_required_blob_size 0-3-2 43980 NULL
108481 +nla_reserve_43984 nla_reserve 3 43984 NULL
108482 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
108483 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
108484 +kvm_read_guest_virt_43992 kvm_read_guest_virt 4-2 43992 &scsi_command_size_43992 nohasharray
108485 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &kvm_read_guest_virt_43992
108486 +ulist_add_43994 ulist_add 0 43994 NULL
108487 +emit_flags_44006 emit_flags 4-3 44006 NULL
108488 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
108489 +fru_strlen_44046 fru_strlen 0 44046 NULL
108490 +tree_insert_offset_44069 tree_insert_offset 0 44069 NULL
108491 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
108492 +btrfs_prev_leaf_44083 btrfs_prev_leaf 0 44083 NULL nohasharray
108493 +load_discard_44083 load_discard 3 44083 &btrfs_prev_leaf_44083
108494 +__vxge_hw_vpath_tim_configure_44093 __vxge_hw_vpath_tim_configure 2 44093 NULL
108495 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
108496 +skb_frag_dma_map_44112 skb_frag_dma_map 0 44112 NULL
108497 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
108498 +hwif_to_node_44127 hwif_to_node 0 44127 NULL
108499 +SyS_process_vm_writev_44129 SyS_process_vm_writev 3-5 44129 NULL
108500 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
108501 +lookup_extent_data_ref_44136 lookup_extent_data_ref 0 44136 NULL
108502 +ttm_get_pages_44142 ttm_get_pages 2 44142 NULL
108503 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
108504 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
108505 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
108506 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
108507 +readreg_ipac_44186 readreg_ipac 0 44186 NULL
108508 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
108509 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
108510 +__set_free_44211 __set_free 2 44211 NULL
108511 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
108512 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
108513 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
108514 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
108515 +sigma_action_write_regmap_44240 sigma_action_write_regmap 3 44240 NULL
108516 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
108517 +apei_resources_sub_44252 apei_resources_sub 0 44252 NULL
108518 +byt_gpio_irq_map_44275 byt_gpio_irq_map 2 44275 NULL
108519 +device_create_file_44285 device_create_file 0 44285 NULL
108520 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
108521 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
108522 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
108523 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
108524 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
108525 +rs_init_44327 rs_init 1 44327 NULL
108526 +create_free_space_inode_44332 create_free_space_inode 0 44332 NULL
108527 +insert_into_bitmap_44340 insert_into_bitmap 0 44340 NULL
108528 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 0-5 44343 NULL
108529 +radix_tree_maybe_preload_44346 radix_tree_maybe_preload 0 44346 NULL
108530 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
108531 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
108532 +__is_discarded_44359 __is_discarded 2 44359 NULL
108533 +ipx_recvmsg_44366 ipx_recvmsg 4 44366 NULL
108534 +alloc_requests_44372 alloc_requests 0 44372 NULL
108535 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
108536 +iterate_dir_item_44386 iterate_dir_item 0 44386 NULL
108537 +mtip_hw_read_flags_44396 mtip_hw_read_flags 3 44396 NULL
108538 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
108539 +strlcpy_44400 strlcpy 3 44400 NULL
108540 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
108541 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
108542 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
108543 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
108544 +iwl_dbgfs_bf_params_write_44450 iwl_dbgfs_bf_params_write 3 44450 NULL
108545 +write_file_debug_44476 write_file_debug 3 44476 NULL
108546 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
108547 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
108548 +bio_advance_44496 bio_advance 2 44496 NULL
108549 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
108550 +ac_register_board_44504 ac_register_board 3 44504 NULL
108551 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
108552 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
108553 +spidev_write_44510 spidev_write 3 44510 NULL
108554 +SyS_io_getevents_44519 SyS_io_getevents 3 44519 NULL
108555 +ieee80211_rx_mgmt_assoc_resp_44525 ieee80211_rx_mgmt_assoc_resp 3 44525 NULL
108556 +comm_write_44537 comm_write 3 44537 NULL
108557 +xfs_log_calc_unit_res_44540 xfs_log_calc_unit_res 0-2 44540 NULL
108558 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
108559 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
108560 +shmem_getpage_gfp_44556 shmem_getpage_gfp 0 44556 NULL
108561 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
108562 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
108563 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
108564 +btrfs_qgroup_account_ref_44604 btrfs_qgroup_account_ref 0 44604 NULL
108565 +huge_page_shift_44618 huge_page_shift 0 44618 NULL
108566 +sysfs_add_one_44629 sysfs_add_one 0 44629 NULL
108567 +msb_get_free_block_44633 msb_get_free_block 2 44633 NULL
108568 +ext2_new_block_44645 ext2_new_block 2-0 44645 NULL
108569 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
108570 +mpi_resize_44674 mpi_resize 2 44674 NULL
108571 +sysfs_create_link_44685 sysfs_create_link 0 44685 NULL nohasharray
108572 +__copy_user_intel_nocache_44685 __copy_user_intel_nocache 0-3 44685 &sysfs_create_link_44685
108573 +ts_read_44687 ts_read 3 44687 NULL
108574 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
108575 +lov_emerg_alloc_44698 lov_emerg_alloc 1 44698 NULL
108576 +__ocfs2_rotate_tree_left_44705 __ocfs2_rotate_tree_left 0 44705 NULL
108577 +xfer_to_user_44713 xfer_to_user 3 44713 NULL nohasharray
108578 +__generic_block_fiemap_44713 __generic_block_fiemap 4 44713 &xfer_to_user_44713
108579 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
108580 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
108581 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
108582 +SyS_read_44732 SyS_read 3 44732 NULL
108583 +vm_insert_mixed_44738 vm_insert_mixed 3 44738 NULL
108584 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
108585 +set_brk_44749 set_brk 1-2 44749 NULL
108586 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
108587 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
108588 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4-0 44769 NULL
108589 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
108590 +irq_domain_add_legacy_44781 irq_domain_add_legacy 4-2 44781 NULL
108591 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
108592 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
108593 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
108594 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
108595 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
108596 +sisusb_write_44834 sisusb_write 3 44834 NULL
108597 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
108598 +cubic_root_44848 cubic_root 1 44848 NULL
108599 +qib_verbs_send_dma_44850 qib_verbs_send_dma 6 44850 NULL
108600 +copydesc_user_44855 copydesc_user 3 44855 NULL
108601 +i915_gem_execbuffer_relocate_44868 i915_gem_execbuffer_relocate 0 44868 NULL
108602 +init_rs_44873 init_rs 1 44873 NULL
108603 +skb_availroom_44883 skb_availroom 0 44883 NULL
108604 +ocfs2_wait_for_mask_44893 ocfs2_wait_for_mask 0 44893 NULL
108605 +do_tty_write_44896 do_tty_write 5 44896 NULL
108606 +regmap_spi_read_44921 regmap_spi_read 3-5 44921 NULL
108607 +_snd_pcm_hw_param_last_44947 _snd_pcm_hw_param_last 0 44947 NULL
108608 +__add_delayed_refs_44977 __add_delayed_refs 0 44977 NULL
108609 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
108610 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
108611 +send_chmod_45011 send_chmod 0 45011 NULL
108612 +i915_gem_do_execbuffer_45012 i915_gem_do_execbuffer 0 45012 NULL
108613 +bytepos_delta_45017 bytepos_delta 0-2 45017 NULL
108614 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
108615 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
108616 +dm_kvzalloc_45025 dm_kvzalloc 1-2 45025 NULL
108617 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
108618 +sysfs_do_create_link_sd_45057 sysfs_do_create_link_sd 0 45057 NULL
108619 +remap_oldmem_pfn_range_45060 remap_oldmem_pfn_range 2-3-4 45060 NULL nohasharray
108620 +sel_write_user_45060 sel_write_user 3 45060 &remap_oldmem_pfn_range_45060
108621 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
108622 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL
108623 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
108624 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
108625 +usbdev_read_45114 usbdev_read 3 45114 NULL
108626 +send_to_tty_45141 send_to_tty 3 45141 NULL
108627 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
108628 +cfs_trace_daemon_command_usrstr_45147 cfs_trace_daemon_command_usrstr 2 45147 NULL
108629 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
108630 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
108631 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
108632 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
108633 +SYSC_write_45160 SYSC_write 3 45160 NULL
108634 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
108635 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
108636 +sctp_pack_cookie_45190 sctp_pack_cookie 6 45190 NULL nohasharray
108637 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 &sctp_pack_cookie_45190
108638 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
108639 +__radix_tree_preload_45197 __radix_tree_preload 0 45197 NULL
108640 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
108641 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
108642 +__dirty_45228 __dirty 2 45228 NULL
108643 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
108644 +event_enable_write_45238 event_enable_write 3 45238 NULL
108645 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
108646 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
108647 +gfs2_fiemap_45282 gfs2_fiemap 4 45282 NULL
108648 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
108649 +e1000_tx_map_45309 e1000_tx_map 5 45309 NULL
108650 +pte_val_45313 pte_val 0 45313 NULL
108651 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
108652 +null_alloc_repbuf_45375 null_alloc_repbuf 3 45375 NULL
108653 +sock_recv_errqueue_45412 sock_recv_errqueue 3 45412 NULL
108654 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
108655 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
108656 +alloc_task_struct_node_45426 alloc_task_struct_node 1 45426 NULL
108657 +ll_iocontrol_register_45430 ll_iocontrol_register 2 45430 NULL
108658 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
108659 +SYSC_mremap_45446 SYSC_mremap 5-1-2-3 45446 NULL
108660 +__node_remap_45458 __node_remap 4 45458 NULL
108661 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
108662 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
108663 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
108664 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
108665 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
108666 +i40e_alloc_vfs_45511 i40e_alloc_vfs 2 45511 NULL
108667 +__split_vma_45522 __split_vma 0 45522 NULL
108668 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
108669 +copy_macs_45534 copy_macs 4 45534 NULL
108670 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
108671 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
108672 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
108673 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
108674 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
108675 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
108676 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
108677 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
108678 +btrfs_find_free_ino_45585 btrfs_find_free_ino 0 45585 NULL
108679 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
108680 +ath6kl_keepalive_write_45600 ath6kl_keepalive_write 3 45600 NULL
108681 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
108682 +commit_cowonly_roots_45640 commit_cowonly_roots 0 45640 NULL
108683 +ebitmap_next_positive_45651 ebitmap_next_positive 3-0 45651 NULL
108684 +ext4_reserve_inode_write_45654 ext4_reserve_inode_write 0 45654 NULL
108685 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
108686 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
108687 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
108688 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
108689 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
108690 +bscnl_emit_45699 bscnl_emit 0-2-5 45699 &unix_dgram_sendmsg_45699
108691 +sg_proc_write_adio_45704 sg_proc_write_adio 3 45704 NULL
108692 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL nohasharray
108693 +task_cgroup_path_45734 task_cgroup_path 3 45734 &snd_cs46xx_io_read_45734
108694 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3-0 45748 NULL nohasharray
108695 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
108696 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
108697 +btrfs_delete_delayed_dir_index_45757 btrfs_delete_delayed_dir_index 0 45757 NULL
108698 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
108699 +osc_checksum_type_seq_write_45785 osc_checksum_type_seq_write 3 45785 NULL
108700 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
108701 +rds_tcp_inc_copy_to_user_45804 rds_tcp_inc_copy_to_user 3 45804 NULL
108702 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
108703 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
108704 +ll_max_readahead_mb_seq_write_45815 ll_max_readahead_mb_seq_write 3 45815 NULL
108705 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
108706 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
108707 +ipv6_recv_rxpmtu_45830 ipv6_recv_rxpmtu 3 45830 NULL
108708 +task_state_char_45839 task_state_char 1 45839 NULL
108709 +__ip_select_ident_45851 __ip_select_ident 3 45851 NULL
108710 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
108711 +efx_tx_queue_insert_45859 efx_tx_queue_insert 2 45859 NULL
108712 +isdn_write_45863 isdn_write 3 45863 NULL
108713 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
108714 +tpm_config_in_45880 tpm_config_in 0 45880 NULL
108715 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
108716 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
108717 +online_page_cgroup_45894 online_page_cgroup 3 45894 NULL
108718 +cfs_cpt_weight_45903 cfs_cpt_weight 0 45903 NULL
108719 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
108720 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
108721 +alloc_mr_45935 alloc_mr 1 45935 NULL
108722 +kmem_cache_alloc_node_trace_45968 kmem_cache_alloc_node_trace 3 45968 NULL
108723 +copy_to_45969 copy_to 3 45969 NULL
108724 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
108725 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
108726 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
108727 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
108728 +get_free_entries_46030 get_free_entries 1 46030 NULL
108729 +__access_remote_vm_46031 __access_remote_vm 0-3-5 46031 NULL
108730 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
108731 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
108732 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6-4-0-3 46060 NULL nohasharray
108733 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
108734 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
108735 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
108736 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 NULL nohasharray
108737 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 &il3945_ucode_general_stats_read_46111
108738 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
108739 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
108740 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
108741 +replay_dir_deletes_46136 replay_dir_deletes 0 46136 NULL
108742 +rtw_buf_update_46138 rtw_buf_update 4 46138 NULL
108743 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2-3 46146 NULL
108744 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
108745 +alloc_iova_46160 alloc_iova 2 46160 NULL
108746 +kmalloc_section_memmap_46168 kmalloc_section_memmap 2 46168 NULL
108747 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
108748 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
108749 +fq_resize_46195 fq_resize 2 46195 NULL
108750 +add_conn_list_46197 add_conn_list 3-0 46197 NULL
108751 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
108752 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
108753 +dsp_write_46218 dsp_write 2 46218 NULL
108754 +xen_setup_msi_irqs_46245 xen_setup_msi_irqs 2 46245 NULL
108755 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
108756 +ReadReg_46277 ReadReg 0 46277 NULL
108757 +sg_proc_write_dressz_46316 sg_proc_write_dressz 3 46316 NULL
108758 +compat_SyS_readv_46328 compat_SyS_readv 3 46328 NULL nohasharray
108759 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 &compat_SyS_readv_46328
108760 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
108761 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
108762 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
108763 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
108764 +mmap_ureg_46388 mmap_ureg 3 46388 NULL
108765 +vma_adjust_46390 vma_adjust 0 46390 NULL
108766 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
108767 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
108768 +ttm_page_pool_get_pages_46431 ttm_page_pool_get_pages 0-5 46431 NULL
108769 +cfs_power2_roundup_46433 cfs_power2_roundup 0-1 46433 NULL
108770 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
108771 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
108772 +parport_pc_fifo_write_block_46455 parport_pc_fifo_write_block 3 46455 NULL
108773 +il_dbgfs_clear_traffic_stats_write_46458 il_dbgfs_clear_traffic_stats_write 3 46458 NULL
108774 +filldir64_46469 filldir64 3 46469 NULL
108775 +ocfs2_reserve_clusters_with_limit_46479 ocfs2_reserve_clusters_with_limit 0 46479 NULL
108776 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
108777 +p9pdu_vreadf_46500 p9pdu_vreadf 0 46500 NULL
108778 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
108779 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
108780 +nouveau_drm_ioctl_46514 nouveau_drm_ioctl 2 46514 NULL nohasharray
108781 +kmsg_read_46514 kmsg_read 3 46514 &nouveau_drm_ioctl_46514
108782 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
108783 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
108784 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
108785 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
108786 +dn_current_mss_46574 dn_current_mss 0 46574 NULL nohasharray
108787 +blk_flush_complete_seq_46574 blk_flush_complete_seq 2 46574 &dn_current_mss_46574
108788 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
108789 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
108790 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
108791 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
108792 +__kfifo_out_r_46623 __kfifo_out_r 3-0 46623 NULL
108793 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
108794 +pci_enable_device_46642 pci_enable_device 0 46642 NULL
108795 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
108796 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
108797 +e1000_tx_map_46672 e1000_tx_map 4 46672 NULL
108798 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
108799 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
108800 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
108801 +ide_read_status_46719 ide_read_status 0 46719 NULL
108802 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
108803 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
108804 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
108805 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
108806 +ntfs2utc_46762 ntfs2utc 1 46762 NULL
108807 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
108808 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
108809 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
108810 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
108811 +btrfs_insert_empty_items_46822 btrfs_insert_empty_items 0 46822 NULL
108812 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
108813 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
108814 +readreg_46845 readreg 0 46845 NULL
108815 +spi_async_46857 spi_async 0 46857 NULL
108816 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
108817 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
108818 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
108819 +rvmalloc_46873 rvmalloc 1 46873 NULL
108820 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 5-4 46874 NULL
108821 +lov_iocontrol_46876 lov_iocontrol 3 46876 NULL
108822 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
108823 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
108824 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
108825 +ol_dqblk_off_46904 ol_dqblk_off 2-3 46904 NULL
108826 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
108827 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1-3 46917 NULL
108828 +fb_write_46924 fb_write 3 46924 NULL
108829 +i915_gem_check_olr_46925 i915_gem_check_olr 0 46925 NULL
108830 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
108831 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
108832 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
108833 +SYSC_poll_46965 SYSC_poll 2 46965 NULL
108834 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
108835 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
108836 +strlcat_46985 strlcat 3 46985 NULL
108837 +bitmap_file_clear_bit_46990 bitmap_file_clear_bit 2 46990 NULL
108838 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
108839 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
108840 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
108841 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
108842 +__map_single_47020 __map_single 3-4-7-0 47020 NULL
108843 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2-4 47024 NULL
108844 +fs_path_len_47060 fs_path_len 0 47060 NULL
108845 +ufs_new_fragments_47070 ufs_new_fragments 4-3-5 47070 NULL nohasharray
108846 +ext4_xattr_list_entries_47070 ext4_xattr_list_entries 0-4 47070 &ufs_new_fragments_47070
108847 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
108848 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
108849 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
108850 +ptlrpc_lprocfs_threads_max_seq_write_47104 ptlrpc_lprocfs_threads_max_seq_write 3 47104 NULL
108851 +tboot_log_read_47110 tboot_log_read 3 47110 NULL
108852 +mousedev_read_47123 mousedev_read 3 47123 NULL
108853 +ubi_compare_lebs_47141 ubi_compare_lebs 0 47141 NULL
108854 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
108855 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
108856 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
108857 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
108858 +alloc_cpumask_var_node_47167 alloc_cpumask_var_node 3 47167 NULL
108859 +bpf_alloc_binary_47170 bpf_alloc_binary 1 47170 NULL
108860 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
108861 +btrfs_del_inode_ref_47181 btrfs_del_inode_ref 0 47181 NULL
108862 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
108863 +options_write_47243 options_write 3 47243 NULL
108864 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
108865 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
108866 +p9pdu_readf_47269 p9pdu_readf 0 47269 NULL
108867 +ablkcipher_next_slow_47274 ablkcipher_next_slow 3-4 47274 NULL
108868 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
108869 +vsnprintf_47291 vsnprintf 0 47291 NULL
108870 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
108871 +iterate_inode_ref_47322 iterate_inode_ref 0 47322 NULL
108872 +SyS_madvise_47354 SyS_madvise 1-2 47354 NULL
108873 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
108874 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
108875 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
108876 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
108877 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
108878 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
108879 +nametbl_list_47391 nametbl_list 2 47391 NULL
108880 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
108881 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
108882 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
108883 +lbs_wrmac_write_47400 lbs_wrmac_write 3 47400 NULL
108884 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
108885 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
108886 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
108887 +lbs_wrrf_write_47418 lbs_wrrf_write 3 47418 NULL
108888 +vzalloc_47421 vzalloc 1 47421 NULL
108889 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
108890 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
108891 +numaq_apicid_to_cpu_present_47449 numaq_apicid_to_cpu_present 1 47449 NULL
108892 +environ_read_47451 environ_read 3 47451 NULL
108893 +__load_mapping_47460 __load_mapping 2 47460 NULL
108894 +try_lock_extent_47465 try_lock_extent 0 47465 NULL
108895 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
108896 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
108897 +newpart_47485 newpart 6-4 47485 &wb_force_mapping_47485
108898 +mcp23s17_read_regs_47491 mcp23s17_read_regs 4 47491 NULL
108899 +core_sys_select_47494 core_sys_select 1 47494 NULL
108900 +read_block_for_search_47502 read_block_for_search 0 47502 NULL
108901 +alloc_arraycache_47505 alloc_arraycache 2-1 47505 NULL nohasharray
108902 +btrfs_init_inode_security_47505 btrfs_init_inode_security 0 47505 &alloc_arraycache_47505
108903 +unlink_simple_47506 unlink_simple 3 47506 NULL
108904 +pstore_decompress_47510 pstore_decompress 0 47510 NULL
108905 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
108906 +__proc_lnet_portal_rotor_47529 __proc_lnet_portal_rotor 5 47529 NULL
108907 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
108908 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
108909 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
108910 +einj_check_trigger_header_47534 einj_check_trigger_header 0 47534 NULL
108911 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
108912 +ocfs2_resv_find_window_47557 ocfs2_resv_find_window 3 47557 NULL
108913 +read_ldt_47570 read_ldt 2 47570 NULL
108914 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 NULL
108915 +rpipe_get_idx_47579 rpipe_get_idx 2-0 47579 NULL
108916 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
108917 +vendorextnReadSection_47583 vendorextnReadSection 0 47583 NULL
108918 +btrfs_stack_header_bytenr_47589 btrfs_stack_header_bytenr 0 47589 NULL
108919 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
108920 +sctp_ssnmap_new_47608 sctp_ssnmap_new 2-1 47608 NULL
108921 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
108922 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
108923 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
108924 +get_size_47644 get_size 1-2 47644 NULL
108925 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
108926 +packet_recvmsg_47700 packet_recvmsg 4 47700 NULL nohasharray
108927 +ipath_format_hwmsg_47700 ipath_format_hwmsg 2 47700 &packet_recvmsg_47700
108928 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
108929 +save_microcode_47717 save_microcode 3 47717 NULL
108930 +bits_to_user_47733 bits_to_user 3-2 47733 NULL
108931 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
108932 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
108933 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
108934 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
108935 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
108936 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
108937 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
108938 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
108939 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
108940 +W6692_empty_Bfifo_47804 W6692_empty_Bfifo 2 47804 NULL
108941 +lov_packmd_47810 lov_packmd 0 47810 NULL
108942 +pinconf_dbg_config_write_47835 pinconf_dbg_config_write 3 47835 NULL
108943 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
108944 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
108945 +vhci_read_47878 vhci_read 3 47878 NULL
108946 +ubi_wl_put_peb_47886 ubi_wl_put_peb 0 47886 NULL
108947 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
108948 +load_mapping_47904 load_mapping 3 47904 NULL
108949 +btrfs_duplicate_item_47910 btrfs_duplicate_item 0 47910 NULL
108950 +cfs_percpt_alloc_47918 cfs_percpt_alloc 2 47918 NULL
108951 +comedi_write_47926 comedi_write 3 47926 NULL
108952 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
108953 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
108954 +gether_get_ifname_47972 gether_get_ifname 3 47972 NULL
108955 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
108956 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
108957 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
108958 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
108959 +ocfs2_find_refcount_split_pos_48001 ocfs2_find_refcount_split_pos 0 48001 NULL
108960 +lustre_cfg_len_48002 lustre_cfg_len 0 48002 NULL
108961 +gdm_tty_recv_complete_48011 gdm_tty_recv_complete 2 48011 NULL
108962 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
108963 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
108964 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
108965 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
108966 +btrfs_reserve_extent_48044 btrfs_reserve_extent 6 48044 NULL
108967 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
108968 +ocfs2_change_refcount_rec_48059 ocfs2_change_refcount_rec 0 48059 NULL
108969 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
108970 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
108971 +disc_write_48070 disc_write 3 48070 NULL
108972 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
108973 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5-0 48102 NULL
108974 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
108975 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
108976 +set_discoverable_48141 set_discoverable 4 48141 NULL
108977 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
108978 +get_cur_inode_state_48149 get_cur_inode_state 0 48149 NULL
108979 +bitmap_onto_48152 bitmap_onto 4 48152 NULL nohasharray
108980 +_add_to_r4w_48152 _add_to_r4w 4 48152 &bitmap_onto_48152
108981 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
108982 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
108983 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
108984 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
108985 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
108986 +init_ipath_48187 init_ipath 1 48187 NULL
108987 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
108988 +cfg80211_process_deauth_48200 cfg80211_process_deauth 3 48200 NULL
108989 +ext4_index_trans_blocks_48205 ext4_index_trans_blocks 0-2 48205 NULL
108990 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
108991 +ll_direct_IO_26_48216 ll_direct_IO_26 4 48216 NULL
108992 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
108993 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
108994 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
108995 +read_file_recv_48232 read_file_recv 3 48232 NULL
108996 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
108997 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
108998 +nouveau_i2c_port_create__48240 nouveau_i2c_port_create_ 7 48240 NULL
108999 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
109000 +batadv_socket_read_48257 batadv_socket_read 3 48257 NULL
109001 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
109002 +trace_options_write_48275 trace_options_write 3 48275 NULL
109003 +send_set_info_48288 send_set_info 7 48288 NULL
109004 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
109005 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
109006 +hash_setkey_48310 hash_setkey 3 48310 NULL
109007 +audio_set_intf_req_48319 audio_set_intf_req 0 48319 NULL
109008 +kvm_mmu_pte_write_48340 kvm_mmu_pte_write 2 48340 NULL
109009 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
109010 +skb_add_data_48363 skb_add_data 3 48363 NULL
109011 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
109012 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
109013 +uhid_event_from_user_48417 uhid_event_from_user 2 48417 NULL
109014 +div64_u64_rem_48418 div64_u64_rem 0-1-2 48418 NULL
109015 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
109016 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
109017 +hugepage_madvise_48435 hugepage_madvise 0 48435 NULL
109018 +print_filtered_48442 print_filtered 2-0 48442 NULL
109019 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
109020 +compat_SyS_preadv64_48469 compat_SyS_preadv64 3 48469 NULL
109021 +ipath_format_hwerrors_48487 ipath_format_hwerrors 5 48487 NULL
109022 +init_section_page_cgroup_48489 init_section_page_cgroup 2 48489 NULL nohasharray
109023 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 &init_section_page_cgroup_48489
109024 +ocfs2_refcount_cow_48495 ocfs2_refcount_cow 3 48495 NULL
109025 +send_control_msg_48498 send_control_msg 6 48498 NULL
109026 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
109027 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
109028 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
109029 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
109030 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
109031 +drbd_bm_capacity_48530 drbd_bm_capacity 0 48530 NULL
109032 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
109033 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
109034 +llog_data_len_48607 llog_data_len 1 48607 NULL
109035 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
109036 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
109037 +ll_rw_extents_stats_pp_seq_write_48651 ll_rw_extents_stats_pp_seq_write 3 48651 NULL
109038 +mtd_read_48655 mtd_read 0 48655 NULL
109039 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
109040 +ore_get_rw_state_48667 ore_get_rw_state 5-4 48667 NULL
109041 +sm501_create_subdev_48668 sm501_create_subdev 4-3 48668 NULL
109042 +ubi_eba_unmap_leb_48671 ubi_eba_unmap_leb 0 48671 NULL
109043 +hysdn_log_write_48694 hysdn_log_write 3 48694 NULL
109044 +altera_drscan_48698 altera_drscan 2 48698 NULL
109045 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
109046 +recv_msg_48709 recv_msg 4 48709 NULL
109047 +lpfc_idiag_drbacc_write_48712 lpfc_idiag_drbacc_write 3 48712 NULL
109048 +SyS_lgetxattr_48719 SyS_lgetxattr 4 48719 NULL
109049 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
109050 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
109051 +event_buffer_read_48772 event_buffer_read 3 48772 NULL nohasharray
109052 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 &event_buffer_read_48772
109053 +gfs2_direct_IO_48774 gfs2_direct_IO 4 48774 NULL
109054 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
109055 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
109056 +register_ftrace_profiler_48816 register_ftrace_profiler 0 48816 NULL
109057 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
109058 +azx_get_position_48841 azx_get_position 0 48841 NULL
109059 +vc_do_resize_48842 vc_do_resize 4-3 48842 NULL
109060 +comedi_buf_write_alloc_48846 comedi_buf_write_alloc 0-2 48846 NULL
109061 +suspend_dtim_interval_write_48854 suspend_dtim_interval_write 3 48854 NULL
109062 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL nohasharray
109063 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 &viafb_dvp1_proc_write_48864
109064 +ide_port_alloc_devices_48866 ide_port_alloc_devices 2 48866 NULL
109065 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
109066 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
109067 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
109068 +joydev_handle_JSIOCSAXMAP_48898 joydev_handle_JSIOCSAXMAP 3 48898 NULL
109069 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
109070 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
109071 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 NULL
109072 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
109073 +si5351_write_parameters_48940 si5351_write_parameters 2 48940 NULL
109074 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
109075 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
109076 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
109077 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
109078 +btrfs_delete_delayed_insertion_item_48981 btrfs_delete_delayed_insertion_item 0 48981 NULL
109079 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
109080 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
109081 +null_alloc_rs_49019 null_alloc_rs 2 49019 NULL
109082 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
109083 +aic_inb_49023 aic_inb 0 49023 NULL
109084 +transient_status_49027 transient_status 4 49027 NULL
109085 +iwl_mvm_power_legacy_dbgfs_read_49038 iwl_mvm_power_legacy_dbgfs_read 4 49038 NULL nohasharray
109086 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 &iwl_mvm_power_legacy_dbgfs_read_49038
109087 +aic7xxx_rem_scb_from_disc_list_49041 aic7xxx_rem_scb_from_disc_list 0 49041 NULL
109088 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
109089 +ubi_read_49061 ubi_read 0 49061 NULL
109090 +sparse_early_nid_49094 sparse_early_nid 0 49094 NULL nohasharray
109091 +scsi_register_49094 scsi_register 2 49094 &sparse_early_nid_49094
109092 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
109093 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
109094 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
109095 +ll_max_cached_mb_seq_write_49122 ll_max_cached_mb_seq_write 3 49122 NULL
109096 +qib_user_sdma_pin_pages_49136 qib_user_sdma_pin_pages 4-5-6 49136 NULL nohasharray
109097 +pt_read_49136 pt_read 3 49136 &qib_user_sdma_pin_pages_49136
109098 +read_file_49137 read_file 4 49137 NULL
109099 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
109100 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
109101 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
109102 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
109103 +__jfs_setxattr_49175 __jfs_setxattr 5 49175 NULL
109104 +ath6kl_bgscan_int_write_49178 ath6kl_bgscan_int_write 3 49178 NULL
109105 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
109106 +print_queue_49191 print_queue 0 49191 NULL
109107 +root_nfs_cat_49192 root_nfs_cat 3 49192 NULL
109108 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
109109 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
109110 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
109111 +resp_write_same_49217 resp_write_same 2 49217 NULL
109112 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
109113 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
109114 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
109115 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
109116 +ptlrpc_check_set_49277 ptlrpc_check_set 0 49277 NULL
109117 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
109118 +__ext4_ext_dirty_49284 __ext4_ext_dirty 0 49284 NULL
109119 +ext4_xattr_ibody_list_49287 ext4_xattr_ibody_list 3-0 49287 NULL
109120 +viafb_dfph_proc_write_49288 viafb_dfph_proc_write 3 49288 NULL
109121 +uio_read_49300 uio_read 3 49300 NULL
109122 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
109123 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
109124 +update_ref_for_cow_49313 update_ref_for_cow 0 49313 NULL
109125 +SYSC_mincore_49319 SYSC_mincore 2-1 49319 NULL
109126 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
109127 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-4-3 49330 NULL
109128 +__intel_map_single_49338 __intel_map_single 3-2 49338 NULL
109129 +intel_ring_invalidate_all_caches_49346 intel_ring_invalidate_all_caches 0 49346 NULL
109130 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
109131 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-3-5 49370 NULL
109132 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
109133 +ext4_ext_index_trans_blocks_49396 ext4_ext_index_trans_blocks 0 49396 NULL
109134 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
109135 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
109136 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
109137 +ubi_add_to_av_49432 ubi_add_to_av 0 49432 NULL nohasharray
109138 +md_domain_init_49432 md_domain_init 2 49432 &ubi_add_to_av_49432
109139 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
109140 +get_lru_size_49441 get_lru_size 0 49441 NULL
109141 +i915_gem_object_set_to_gtt_domain_49450 i915_gem_object_set_to_gtt_domain 0 49450 NULL
109142 +ocfs2_merge_rec_left_49455 ocfs2_merge_rec_left 0 49455 NULL
109143 +__hfsplus_getxattr_49460 __hfsplus_getxattr 0 49460 NULL
109144 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
109145 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
109146 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
109147 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
109148 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
109149 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
109150 +btrfs_add_free_space_49524 btrfs_add_free_space 0 49524 NULL
109151 +smk_write_access_49561 smk_write_access 3 49561 NULL
109152 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
109153 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
109154 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
109155 +readfifo_49583 readfifo 1 49583 NULL
109156 +tap_write_49595 tap_write 3 49595 NULL
109157 +create_task_io_context_49601 create_task_io_context 3 49601 NULL
109158 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
109159 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
109160 +heap_init_49617 heap_init 2 49617 NULL
109161 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
109162 +port_fops_read_49626 port_fops_read 3 49626 NULL
109163 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
109164 +__swab32p_49657 __swab32p 0 49657 NULL
109165 +ubi_wl_flush_49682 ubi_wl_flush 0 49682 NULL
109166 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
109167 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
109168 +__setup_irq_49696 __setup_irq 0 49696 NULL
109169 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
109170 +do_splice_to_49714 do_splice_to 4 49714 NULL
109171 +write_pool_49718 write_pool 3 49718 NULL
109172 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
109173 +kvm_mmu_notifier_invalidate_page_49723 kvm_mmu_notifier_invalidate_page 3 49723 NULL
109174 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
109175 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
109176 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
109177 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
109178 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
109179 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
109180 +w83977af_fir_interrupt_49775 w83977af_fir_interrupt 0 49775 NULL
109181 +ceph_osdc_readpages_49789 ceph_osdc_readpages 0 49789 NULL
109182 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
109183 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
109184 +add_uuid_49831 add_uuid 4 49831 NULL
109185 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
109186 +iraw_loop_49842 iraw_loop 0-1 49842 NULL
109187 +twl4030_write_49846 twl4030_write 2 49846 NULL
109188 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
109189 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
109190 +ubifs_destroy_tnc_subtree_49853 ubifs_destroy_tnc_subtree 0 49853 NULL
109191 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
109192 +fiemap_count_to_size_49869 fiemap_count_to_size 0-1 49869 NULL
109193 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
109194 +snd_mask_eq_49889 snd_mask_eq 0 49889 NULL
109195 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
109196 +osc_brw_49896 osc_brw 4 49896 NULL
109197 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
109198 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
109199 +config_ep_by_speed_49939 config_ep_by_speed 0 49939 NULL
109200 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
109201 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
109202 +drm_buffer_copy_from_user_49990 drm_buffer_copy_from_user 3 49990 NULL
109203 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
109204 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
109205 +__module_alloc_50004 __module_alloc 1 50004 NULL
109206 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
109207 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
109208 +isdn_read_50021 isdn_read 3 50021 NULL
109209 +mdc_rename_pack_50023 mdc_rename_pack 4-6 50023 NULL
109210 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
109211 +ioread8_50049 ioread8 0 50049 NULL
109212 +fuse_conn_max_background_write_50061 fuse_conn_max_background_write 3 50061 NULL
109213 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
109214 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
109215 +__kfifo_dma_in_prepare_50081 __kfifo_dma_in_prepare 4 50081 NULL
109216 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
109217 +libcfs_ioctl_popdata_50087 libcfs_ioctl_popdata 3 50087 NULL
109218 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
109219 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
109220 +android_set_cntry_50100 android_set_cntry 0 50100 NULL
109221 +process_recorded_refs_50110 process_recorded_refs 0 50110 NULL
109222 +read_file_slot_50111 read_file_slot 3 50111 NULL
109223 +xfs_dir3_sf_entsize_50112 xfs_dir3_sf_entsize 0-3 50112 NULL
109224 +rx_streaming_interval_write_50120 rx_streaming_interval_write 3 50120 NULL
109225 +ocfs2_search_one_group_50125 ocfs2_search_one_group 0 50125 NULL nohasharray
109226 +jfs_direct_IO_50125 jfs_direct_IO 4 50125 &ocfs2_search_one_group_50125
109227 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
109228 +copy_items_50140 copy_items 6 50140 NULL
109229 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
109230 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
109231 +kmalloc_node_50163 kmalloc_node 1-3 50163 NULL
109232 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
109233 +ahd_probe_stack_size_50168 ahd_probe_stack_size 0 50168 NULL
109234 +odev_update_50169 odev_update 2 50169 NULL
109235 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
109236 +xfs_get_blocks_direct_50172 xfs_get_blocks_direct 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 nohasharray
109237 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &xfs_get_blocks_direct_50172
109238 +ext3_do_update_inode_50178 ext3_do_update_inode 0 50178 NULL
109239 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 6-4 50198 NULL
109240 +cyttsp4_probe_50201 cyttsp4_probe 4 50201 NULL
109241 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
109242 +compat_SyS_sendfile_50206 compat_SyS_sendfile 4 50206 NULL nohasharray
109243 +mthca_buddy_init_50206 mthca_buddy_init 2 50206 &compat_SyS_sendfile_50206
109244 +l2cap_sock_setsockopt_50207 l2cap_sock_setsockopt 5 50207 NULL
109245 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
109246 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
109247 +vma_dup_policy_50269 vma_dup_policy 0 50269 NULL
109248 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
109249 +soc_codec_reg_show_50302 soc_codec_reg_show 0-3 50302 NULL
109250 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
109251 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
109252 +iterate_irefs_50313 iterate_irefs 0 50313 NULL
109253 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
109254 +do_launder_page_50329 do_launder_page 0 50329 NULL
109255 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
109256 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
109257 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
109258 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
109259 +tpm_read_50344 tpm_read 3 50344 NULL
109260 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
109261 +efx_nic_update_stats_50352 efx_nic_update_stats 2 50352 NULL
109262 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
109263 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
109264 +ocfs2_figure_insert_type_50362 ocfs2_figure_insert_type 0 50362 NULL nohasharray
109265 +iwl_dbgfs_echo_test_write_50362 iwl_dbgfs_echo_test_write 3 50362 &ocfs2_figure_insert_type_50362
109266 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
109267 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
109268 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
109269 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
109270 +snd_mask_refine_last_50406 snd_mask_refine_last 0 50406 NULL
109271 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
109272 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
109273 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
109274 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL nohasharray
109275 +ecryptfs_write_lower_page_segment_50444 ecryptfs_write_lower_page_segment 4 50444 &btrfs_error_discard_extent_50444
109276 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
109277 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
109278 +device_create_sys_dev_entry_50458 device_create_sys_dev_entry 0 50458 NULL
109279 +force_mapping_50464 force_mapping 2 50464 NULL
109280 +cfs_size_round_50472 cfs_size_round 0-1 50472 NULL
109281 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
109282 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
109283 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
109284 +__ctzdi2_50536 __ctzdi2 1 50536 NULL
109285 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
109286 +usbat_flash_write_data_50553 usbat_flash_write_data 4 50553 NULL
109287 +self_check_peb_vid_hdr_50563 self_check_peb_vid_hdr 0 50563 NULL nohasharray
109288 +ttm_agp_tt_create_50563 ttm_agp_tt_create 3 50563 &self_check_peb_vid_hdr_50563
109289 +fat_readpages_50582 fat_readpages 4 50582 NULL
109290 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
109291 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
109292 +xillybus_write_50605 xillybus_write 3 50605 NULL
109293 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
109294 +ocfs2_split_extent_50618 ocfs2_split_extent 0 50618 NULL
109295 +sparse_early_usemaps_alloc_node_50623 sparse_early_usemaps_alloc_node 4 50623 NULL
109296 +__ffs_50625 __ffs 0-1 50625 NULL
109297 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
109298 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
109299 +ocfs2_do_insert_extent_50658 ocfs2_do_insert_extent 0 50658 NULL
109300 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL
109301 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
109302 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2-0 50669 NULL
109303 +prism2_read_fid_reg_50689 prism2_read_fid_reg 0 50689 NULL nohasharray
109304 +i2c_smbus_read_byte_data_50689 i2c_smbus_read_byte_data 0 50689 &prism2_read_fid_reg_50689
109305 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
109306 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
109307 +dev_mem_read_50706 dev_mem_read 3 50706 NULL
109308 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
109309 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
109310 +btrfs_truncate_free_space_cache_50769 btrfs_truncate_free_space_cache 0 50769 NULL
109311 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
109312 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
109313 +bio_alloc_map_data_50782 bio_alloc_map_data 2-1 50782 NULL
109314 +tpm_write_50798 tpm_write 3 50798 NULL
109315 +write_flush_50803 write_flush 3 50803 NULL
109316 +dvb_play_50814 dvb_play 3 50814 NULL
109317 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
109318 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
109319 +SetArea_50835 SetArea 4 50835 NULL nohasharray
109320 +mask_from_50835 mask_from 0-1-2 50835 &SetArea_50835 nohasharray
109321 +create_mem_extents_50835 create_mem_extents 0 50835 &mask_from_50835
109322 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3-4 50839 NULL
109323 +btrfs_search_slot_for_read_50843 btrfs_search_slot_for_read 0 50843 NULL
109324 +self_check_write_50856 self_check_write 0-5 50856 NULL
109325 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
109326 +alloc_masks_50861 alloc_masks 3 50861 NULL
109327 +__percpu_counter_init_50878 __percpu_counter_init 0 50878 NULL
109328 +btrfs_insert_inode_ref_50884 btrfs_insert_inode_ref 0 50884 NULL
109329 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
109330 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
109331 +__bdev_writeseg_50903 __bdev_writeseg 4 50903 NULL
109332 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
109333 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
109334 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
109335 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
109336 +show_device_status_50947 show_device_status 0 50947 NULL
109337 +irq_timeout_write_50950 irq_timeout_write 3 50950 NULL
109338 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
109339 +sdio_uart_write_50954 sdio_uart_write 3 50954 NULL
109340 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
109341 +btrfs_del_csums_50969 btrfs_del_csums 0 50969 NULL
109342 +__btrfs_mod_ref_50973 __btrfs_mod_ref 0 50973 NULL
109343 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
109344 +timeout_write_50991 timeout_write 3 50991 NULL
109345 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
109346 +proc_write_51003 proc_write 3 51003 NULL
109347 +jbd2_journal_extend_51012 jbd2_journal_extend 2-0 51012 NULL
109348 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
109349 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
109350 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
109351 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
109352 +dump_midi_51040 dump_midi 3 51040 NULL
109353 +usb_get_descriptor_51041 usb_get_descriptor 0 51041 NULL
109354 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
109355 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
109356 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
109357 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
109358 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
109359 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
109360 +btrfs_del_item_51110 btrfs_del_item 0 51110 NULL nohasharray
109361 +ti_recv_51110 ti_recv 3 51110 &btrfs_del_item_51110
109362 +uasp_prepare_r_request_51124 uasp_prepare_r_request 0 51124 NULL
109363 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
109364 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
109365 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
109366 +set_dirty_51144 set_dirty 3 51144 NULL
109367 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
109368 +walk_page_buffers_51170 walk_page_buffers 0 51170 NULL
109369 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
109370 +uhci_frame_skel_link_51213 uhci_frame_skel_link 2 51213 NULL
109371 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
109372 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
109373 +tipc_send_51238 tipc_send 4 51238 NULL
109374 +drm_property_create_51239 drm_property_create 4 51239 NULL
109375 +__mxt_read_reg_51249 __mxt_read_reg 0 51249 NULL
109376 +st_read_51251 st_read 3 51251 NULL
109377 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
109378 +target_alloc_sgl_51264 target_alloc_sgl 3 51264 NULL
109379 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
109380 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
109381 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL nohasharray
109382 +__get_cur_name_and_parent_51283 __get_cur_name_and_parent 0 51283 &zone_reclaimable_pages_51283
109383 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
109384 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
109385 +get_cell_51316 get_cell 2 51316 NULL
109386 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
109387 +ocfs2_read_inode_block_51319 ocfs2_read_inode_block 0 51319 NULL
109388 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
109389 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
109390 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
109391 +compat_arch_ptrace_51337 compat_arch_ptrace 3 51337 &alloc_smp_req_51337
109392 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
109393 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
109394 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
109395 +pci_sriov_resource_alignment_51406 pci_sriov_resource_alignment 0 51406 NULL
109396 +ceph_sync_read_51410 ceph_sync_read 3-0 51410 NULL
109397 +get_first_ref_51413 get_first_ref 0 51413 NULL
109398 +__btrfs_end_transaction_51420 __btrfs_end_transaction 0 51420 NULL
109399 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
109400 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
109401 +hfsplus_brec_read_51436 hfsplus_brec_read 0 51436 NULL
109402 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
109403 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
109404 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
109405 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
109406 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 NULL
109407 +kvm_fetch_guest_virt_51493 kvm_fetch_guest_virt 4-2 51493 NULL
109408 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
109409 +key_search_51533 key_search 0 51533 NULL
109410 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
109411 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
109412 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
109413 +snd_interval_refine_first_51589 snd_interval_refine_first 0 51589 NULL nohasharray
109414 +get_cur_path_51589 get_cur_path 0 51589 &snd_interval_refine_first_51589
109415 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
109416 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
109417 +extent_fiemap_51621 extent_fiemap 3 51621 NULL
109418 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
109419 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
109420 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
109421 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
109422 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
109423 +host_mapping_level_51696 host_mapping_level 2-0 51696 NULL
109424 +sel_write_access_51704 sel_write_access 3 51704 NULL
109425 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
109426 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
109427 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
109428 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
109429 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
109430 +cm4040_read_51732 cm4040_read 3 51732 NULL
109431 +get_user_pages_fast_51751 get_user_pages_fast 1-2-0 51751 NULL
109432 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
109433 +if_write_51756 if_write 3 51756 NULL
109434 +ext4_ext_create_new_leaf_51763 ext4_ext_create_new_leaf 0 51763 NULL
109435 +__fswab32_51781 __fswab32 0 51781 NULL
109436 +to_ratio_51809 to_ratio 1-2 51809 NULL
109437 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
109438 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
109439 +max732x_irq_pending_51840 max732x_irq_pending 0 51840 NULL
109440 +ioread32_51847 ioread32 0 51847 NULL nohasharray
109441 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
109442 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
109443 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
109444 +bm_page_io_async_51858 bm_page_io_async 2 51858 NULL
109445 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
109446 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
109447 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
109448 +user_read_51881 user_read 3 51881 NULL
109449 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
109450 +virt_to_phys_51896 virt_to_phys 0 51896 NULL nohasharray
109451 +SyS_mq_timedsend_51896 SyS_mq_timedsend 3 51896 &virt_to_phys_51896
109452 +commit_fs_roots_51898 commit_fs_roots 0 51898 NULL
109453 +uvhub_to_first_node_51916 uvhub_to_first_node 0 51916 NULL
109454 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
109455 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
109456 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
109457 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
109458 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
109459 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
109460 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
109461 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
109462 +__blkdev_get_51972 __blkdev_get 0 51972 NULL nohasharray
109463 +read_page_51972 read_page 2 51972 &__blkdev_get_51972
109464 +get_zone_51981 get_zone 0-1 51981 NULL
109465 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
109466 +_c4iw_write_mem_dma_51991 _c4iw_write_mem_dma 3 51991 NULL
109467 +ntfs_attr_size_51994 ntfs_attr_size 0 51994 NULL
109468 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
109469 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
109470 +rdmalt_52022 rdmalt 0 52022 NULL
109471 +override_release_52032 override_release 2 52032 NULL
109472 +end_port_52042 end_port 0 52042 NULL
109473 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
109474 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
109475 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
109476 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
109477 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
109478 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
109479 +ulist_add_merge_52096 ulist_add_merge 0 52096 NULL
109480 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
109481 +split_scan_timeout_write_52128 split_scan_timeout_write 3 52128 NULL
109482 +retry_count_read_52129 retry_count_read 3 52129 NULL
109483 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
109484 +gdm_usb_hci_send_52138 gdm_usb_hci_send 3 52138 NULL
109485 +sub_alloc_52140 sub_alloc 0 52140 NULL nohasharray
109486 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 &sub_alloc_52140
109487 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
109488 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2-0 52145 &hysdn_conf_write_52145
109489 +htable_size_52148 htable_size 0-1 52148 NULL
109490 +smk_write_load2_52155 smk_write_load2 3 52155 NULL
109491 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
109492 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
109493 +print_prefix_52176 print_prefix 0 52176 NULL
109494 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
109495 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 6-5 52216 NULL
109496 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
109497 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL nohasharray
109498 +xfs_iomap_eof_align_last_fsb_52243 xfs_iomap_eof_align_last_fsb 3 52243 &fuse_request_alloc_52243
109499 +ocfs2_try_to_merge_extent_52244 ocfs2_try_to_merge_extent 0 52244 NULL
109500 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
109501 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
109502 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
109503 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
109504 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
109505 +handle_supp_msgs_52284 handle_supp_msgs 4 52284 NULL
109506 +kobject_set_name_vargs_52309 kobject_set_name_vargs 0 52309 NULL
109507 +read_file_reset_52310 read_file_reset 3 52310 NULL
109508 +request_asymmetric_key_52317 request_asymmetric_key 4-2 52317 NULL
109509 +hwflags_read_52318 hwflags_read 3 52318 NULL
109510 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
109511 +ntfs_rl_split_52328 ntfs_rl_split 4-2 52328 NULL
109512 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
109513 +hur_len_52339 hur_len 0 52339 NULL
109514 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
109515 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
109516 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
109517 +hfsplus_find_attr_52374 hfsplus_find_attr 0 52374 NULL
109518 +ocfs2_journal_access_eb_52377 ocfs2_journal_access_eb 0 52377 NULL
109519 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
109520 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
109521 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
109522 +aer_inject_write_52399 aer_inject_write 3 52399 NULL nohasharray
109523 +cl_page_own_52399 cl_page_own 0 52399 &aer_inject_write_52399
109524 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
109525 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
109526 +hso_serial_common_create_52428 hso_serial_common_create 4 52428 NULL
109527 +delay_status_52431 delay_status 5 52431 NULL
109528 +ath6kl_delete_qos_write_52435 ath6kl_delete_qos_write 3 52435 NULL
109529 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
109530 +acpi_nvs_for_each_region_52448 acpi_nvs_for_each_region 0 52448 NULL
109531 +alauda_read_data_52452 alauda_read_data 3 52452 NULL
109532 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1 52477 NULL
109533 +usb_tranzport_write_52479 usb_tranzport_write 3 52479 NULL
109534 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
109535 +fd_do_rw_52495 fd_do_rw 3 52495 NULL
109536 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5-4 52498 NULL
109537 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
109538 +lmv_get_easize_52504 lmv_get_easize 0 52504 NULL
109539 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
109540 +bt_sock_stream_recvmsg_52518 bt_sock_stream_recvmsg 4 52518 NULL
109541 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
109542 +raw_recvmsg_52529 raw_recvmsg 4 52529 NULL
109543 +from_oblock_52546 from_oblock 0-1 52546 NULL
109544 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
109545 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
109546 +debug_level_proc_write_52572 debug_level_proc_write 3 52572 NULL
109547 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
109548 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
109549 +SyS_setsockopt_52610 SyS_setsockopt 5 52610 NULL
109550 +ll_sa_entry_alloc_52611 ll_sa_entry_alloc 4 52611 NULL
109551 +affs_set_blocksize_52625 affs_set_blocksize 2 52625 NULL
109552 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
109553 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
109554 +perf_trace_sched_stat_template_52656 perf_trace_sched_stat_template 3 52656 NULL
109555 +nvme_queue_extra_52661 nvme_queue_extra 0-1 52661 NULL
109556 +htb_add_class_to_row_52663 htb_add_class_to_row 3 52663 NULL
109557 +posix_acl_equiv_mode_52666 posix_acl_equiv_mode 0 52666 NULL
109558 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
109559 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
109560 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
109561 +vendorextnWriteSection_52698 vendorextnWriteSection 0 52698 NULL
109562 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
109563 +__dm_stat_bio_52722 __dm_stat_bio 3 52722 NULL
109564 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
109565 +blkcipher_next_slow_52733 blkcipher_next_slow 4-3 52733 NULL
109566 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
109567 +hfcsusb_rx_frame_52745 hfcsusb_rx_frame 3 52745 NULL
109568 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
109569 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
109570 +radeon_get_ib_value_52757 radeon_get_ib_value 0 52757 NULL
109571 +nvme_trans_ext_inq_page_52776 nvme_trans_ext_inq_page 3 52776 NULL
109572 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
109573 +map_try_harder_52846 map_try_harder 2-3 52846 NULL
109574 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
109575 +process_deleted_xattr_52861 process_deleted_xattr 0 52861 NULL
109576 +mon_bin_get_event_52863 mon_bin_get_event 6-4 52863 NULL
109577 +twl6030_gpadc_write_52867 twl6030_gpadc_write 1 52867 NULL
109578 +qib_decode_6120_err_52876 qib_decode_6120_err 3 52876 NULL
109579 +twlreg_write_52880 twlreg_write 3 52880 NULL
109580 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
109581 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
109582 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
109583 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
109584 +create_vtbl_52909 create_vtbl 0 52909 NULL
109585 +dio_bio_reap_52913 dio_bio_reap 0 52913 NULL
109586 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
109587 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL
109588 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
109589 +send_packet_52960 send_packet 4 52960 NULL
109590 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
109591 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
109592 +num_node_state_52989 num_node_state 0 52989 NULL
109593 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
109594 +uasp_alloc_stream_res_53015 uasp_alloc_stream_res 0 53015 NULL
109595 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
109596 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
109597 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
109598 +ocfs2_new_leaf_refcount_block_53036 ocfs2_new_leaf_refcount_block 0 53036 NULL
109599 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
109600 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
109601 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
109602 +iwl_dbgfs_interrupt_write_53069 iwl_dbgfs_interrupt_write 3 53069 NULL
109603 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
109604 +page_to_nid_53085 page_to_nid 0 53085 NULL
109605 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
109606 +insert_new_root_53097 insert_new_root 0 53097 NULL
109607 +verity_status_53120 verity_status 5 53120 NULL
109608 +__copy_from_user_ll_nocache_nozero_53123 __copy_from_user_ll_nocache_nozero 0-3 53123 NULL
109609 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
109610 +btrfs_search_forward_53137 btrfs_search_forward 0 53137 NULL
109611 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
109612 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
109613 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
109614 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
109615 +SyS_init_module_53202 SyS_init_module 2 53202 NULL
109616 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
109617 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
109618 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
109619 +ptlrpc_lprocfs_req_history_max_seq_write_53243 ptlrpc_lprocfs_req_history_max_seq_write 3 53243 NULL
109620 +hfsplus_xattr_set_posix_acl_53249 hfsplus_xattr_set_posix_acl 4 53249 NULL
109621 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
109622 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
109623 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
109624 +tsk_fork_get_node_53271 tsk_fork_get_node 0 53271 NULL
109625 +btrfs_find_highest_objectid_53284 btrfs_find_highest_objectid 0 53284 NULL
109626 +setup_leaf_for_split_53312 setup_leaf_for_split 0 53312 NULL
109627 +ftrace_profile_write_53327 ftrace_profile_write 3 53327 NULL
109628 +setup_cluster_no_bitmap_53328 setup_cluster_no_bitmap 0 53328 NULL
109629 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
109630 +vm_mmap_53339 vm_mmap 0 53339 NULL
109631 +vendorextnIoctl_53350 vendorextnIoctl 0 53350 NULL nohasharray
109632 +btrfs_find_all_roots_53350 btrfs_find_all_roots 0 53350 &vendorextnIoctl_53350
109633 +read_6120_creg32_53363 read_6120_creg32 0 53363 NULL
109634 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
109635 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
109636 +isolate_lru_page_53417 isolate_lru_page 0 53417 NULL
109637 +i915_gem_execbuffer_relocate_object_53435 i915_gem_execbuffer_relocate_object 0 53435 NULL
109638 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
109639 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
109640 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
109641 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
109642 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
109643 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
109644 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
109645 +ext4_ext_grow_indepth_53503 ext4_ext_grow_indepth 0 53503 NULL
109646 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
109647 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
109648 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
109649 +check_acl_53512 check_acl 0 53512 NULL
109650 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 1 53515 NULL
109651 +send_utimes_53516 send_utimes 0 53516 NULL
109652 +SYSC_bind_53582 SYSC_bind 3 53582 NULL
109653 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
109654 +proc_uid_map_write_53596 proc_uid_map_write 3 53596 NULL
109655 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
109656 +pfkey_recvmsg_53604 pfkey_recvmsg 4 53604 NULL
109657 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
109658 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
109659 +stmpe_gpio_request_53634 stmpe_gpio_request 2 53634 NULL nohasharray
109660 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 &stmpe_gpio_request_53634
109661 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
109662 +fuse_fill_write_pages_53682 fuse_fill_write_pages 0-4 53682 NULL
109663 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
109664 +igb_alloc_q_vector_53690 igb_alloc_q_vector 6-4 53690 NULL nohasharray
109665 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 &igb_alloc_q_vector_53690
109666 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
109667 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
109668 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
109669 +__proc_debug_mb_53732 __proc_debug_mb 5 53732 NULL
109670 +wdm_write_53735 wdm_write 3 53735 NULL
109671 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3-0 53737 NULL
109672 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
109673 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
109674 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
109675 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
109676 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
109677 +qp_alloc_host_work_53798 qp_alloc_host_work 5-3 53798 NULL
109678 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
109679 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
109680 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
109681 +insert_pfn_53816 insert_pfn 3-0 53816 NULL
109682 +setup_data_read_53822 setup_data_read 3 53822 NULL
109683 +pms_read_53873 pms_read 3 53873 NULL
109684 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
109685 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 4-5-3 53900 NULL nohasharray
109686 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
109687 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
109688 +usb_serial_generic_write_53927 usb_serial_generic_write 4 53927 NULL
109689 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 5-4-0 53938 NULL
109690 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
109691 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
109692 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
109693 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
109694 +send_clone_54011 send_clone 0 54011 NULL
109695 +hfsplus_attr_build_key_54013 hfsplus_attr_build_key 0 54013 NULL
109696 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 5-2-4 54018 NULL
109697 +mdc_kuc_write_54019 mdc_kuc_write 3 54019 NULL
109698 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
109699 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
109700 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
109701 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
109702 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
109703 +_malloc_54077 _malloc 1 54077 NULL
109704 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
109705 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL nohasharray
109706 +lustre_posix_acl_xattr_filter_54103 lustre_posix_acl_xattr_filter 2 54103 &altera_set_ir_pre_54103
109707 +__comedi_buf_write_alloc_54112 __comedi_buf_write_alloc 0-2 54112 NULL
109708 +strn_len_54122 strn_len 0 54122 NULL
109709 +isku_receive_54130 isku_receive 4 54130 NULL
109710 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
109711 +irq_blk_threshold_write_54138 irq_blk_threshold_write 3 54138 NULL
109712 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 NULL
109713 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
109714 +p9_client_prepare_req_54175 p9_client_prepare_req 3 54175 NULL
109715 +devm_request_threaded_irq_54215 devm_request_threaded_irq 0 54215 NULL
109716 +do_sys_poll_54221 do_sys_poll 2 54221 NULL
109717 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
109718 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
109719 +mcp23s08_read_regs_54246 mcp23s08_read_regs 4 54246 NULL
109720 +reada_add_block_54247 reada_add_block 2 54247 NULL
109721 +write_file_spec_scan_ctl_54248 write_file_spec_scan_ctl 3 54248 NULL
109722 +jbd2__journal_restart_54249 jbd2__journal_restart 0 54249 NULL
109723 +barrier_all_devices_54254 barrier_all_devices 0 54254 NULL nohasharray
109724 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 &barrier_all_devices_54254
109725 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
109726 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
109727 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
109728 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
109729 +kstrtou16_from_user_54274 kstrtou16_from_user 2 54274 NULL
109730 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
109731 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
109732 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
109733 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
109734 +ttm_mem_global_alloc_54299 ttm_mem_global_alloc 0 54299 NULL
109735 +reclaim_pages_54301 reclaim_pages 3 54301 NULL
109736 +sprintf_54306 sprintf 0 54306 NULL
109737 +bio_add_pc_page_54319 bio_add_pc_page 4 54319 NULL
109738 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
109739 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
109740 +__get_free_pages_54352 __get_free_pages 0 54352 NULL
109741 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
109742 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
109743 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
109744 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
109745 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
109746 +ah_alloc_tmp_54378 ah_alloc_tmp 2-3 54378 NULL
109747 +gart_unmap_page_54379 gart_unmap_page 3-2 54379 NULL
109748 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 3-0 54387 NULL
109749 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
109750 +efx_nic_describe_stats_54407 efx_nic_describe_stats 2 54407 NULL
109751 +ll_ra_count_get_54410 ll_ra_count_get 3 54410 NULL
109752 +copy_gadget_strings_54417 copy_gadget_strings 3-2 54417 NULL
109753 +btrfs_inc_extent_ref_54442 btrfs_inc_extent_ref 0 54442 NULL
109754 +sparse_early_mem_maps_alloc_node_54485 sparse_early_mem_maps_alloc_node 4-5 54485 NULL
109755 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
109756 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 0 54495 NULL
109757 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
109758 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
109759 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
109760 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
109761 +viacam_read_54526 viacam_read 3 54526 NULL
109762 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
109763 +setsockopt_54539 setsockopt 5 54539 NULL
109764 +i915_reset_gen7_sol_offsets_54547 i915_reset_gen7_sol_offsets 0 54547 NULL
109765 +lbs_lowsnr_write_54549 lbs_lowsnr_write 3 54549 NULL
109766 +ntfs_commit_pages_after_non_resident_write_54555 ntfs_commit_pages_after_non_resident_write 4-3 54555 NULL nohasharray
109767 +i915_gem_get_seqno_54555 i915_gem_get_seqno 0 54555 &ntfs_commit_pages_after_non_resident_write_54555
109768 +btrfs_update_inode_item_54561 btrfs_update_inode_item 0 54561 NULL nohasharray
109769 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 &btrfs_update_inode_item_54561
109770 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
109771 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
109772 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
109773 +irq_pkt_threshold_write_54605 irq_pkt_threshold_write 3 54605 NULL
109774 +devm_gen_pool_create_54607 devm_gen_pool_create 3 54607 NULL
109775 +port_fops_write_54627 port_fops_write 3 54627 NULL
109776 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
109777 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
109778 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
109779 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
109780 +tdp_page_fault_54663 tdp_page_fault 2 54663 NULL
109781 +bus_add_device_54665 bus_add_device 0 54665 NULL
109782 +cw1200_queue_stats_init_54670 cw1200_queue_stats_init 2 54670 NULL
109783 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
109784 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
109785 +evm_read_key_54674 evm_read_key 3 54674 NULL
109786 +fs_path_add_path_54680 fs_path_add_path 0 54680 NULL
109787 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
109788 +__btrfs_inc_extent_ref_54706 __btrfs_inc_extent_ref 7-0 54706 NULL
109789 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
109790 +clk_divider_set_rate_54726 clk_divider_set_rate 3-2 54726 NULL
109791 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
109792 +kzalloc_54740 kzalloc 1 54740 NULL
109793 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
109794 +lpfc_idiag_pcicfg_write_54749 lpfc_idiag_pcicfg_write 3 54749 NULL
109795 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
109796 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
109797 +ldsem_atomic_update_54774 ldsem_atomic_update 1-0 54774 NULL
109798 +gpiochip_add_54781 gpiochip_add 0 54781 NULL
109799 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
109800 +domain_init_54797 domain_init 2 54797 NULL
109801 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
109802 +get_dev_size_54807 get_dev_size 0 54807 NULL
109803 +nfsd_write_54809 nfsd_write 6 54809 NULL
109804 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
109805 +kvzalloc_54815 kvzalloc 1 54815 &aes_decrypt_fail_read_54815 nohasharray
109806 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &kvzalloc_54815
109807 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
109808 +write_rio_54837 write_rio 3 54837 NULL
109809 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
109810 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
109811 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
109812 +printer_read_54851 printer_read 3 54851 NULL
109813 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
109814 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
109815 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
109816 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
109817 +iscsi_pool_init_54913 iscsi_pool_init 4-2 54913 NULL nohasharray
109818 +kobject_set_name_vargs_54913 kobject_set_name_vargs 0 54913 &iscsi_pool_init_54913
109819 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
109820 +bio_add_page_54933 bio_add_page 0-3 54933 NULL
109821 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
109822 +add_port_54941 add_port 2 54941 NULL
109823 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
109824 +alauda_write_data_54967 alauda_write_data 3 54967 NULL
109825 +c4_add_card_54968 c4_add_card 3 54968 NULL
109826 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
109827 +ubi_change_vtbl_record_54979 ubi_change_vtbl_record 0 54979 NULL
109828 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
109829 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
109830 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
109831 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
109832 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
109833 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
109834 +dgap_do_bios_load_55025 dgap_do_bios_load 3 55025 NULL
109835 +btrfs_init_acl_55028 btrfs_init_acl 0 55028 NULL
109836 +write_ctree_super_55039 write_ctree_super 0 55039 NULL
109837 +ext4_ext_handle_uninitialized_extents_55059 ext4_ext_handle_uninitialized_extents 0-6 55059 NULL
109838 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
109839 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
109840 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL nohasharray
109841 +read_dma_55086 read_dma 3 55086 &snd_pcm_capture_hw_avail_55086
109842 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
109843 +corrupt_data_55120 corrupt_data 0-3 55120 NULL
109844 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
109845 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3-0 55137 NULL nohasharray
109846 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
109847 +validate_vid_hdr_55145 validate_vid_hdr 0 55145 NULL
109848 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
109849 +npages_to_npools_55149 npages_to_npools 0-1 55149 NULL
109850 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
109851 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
109852 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
109853 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
109854 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
109855 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
109856 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
109857 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
109858 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
109859 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
109860 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
109861 +lbs_failcount_write_55276 lbs_failcount_write 3 55276 NULL
109862 +persistent_ram_new_55286 persistent_ram_new 2-1 55286 NULL
109863 +ptrace_request_55288 ptrace_request 3 55288 NULL
109864 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
109865 +lov_get_stripecnt_55297 lov_get_stripecnt 0-3 55297 NULL
109866 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
109867 +wimax_msg_len_55304 wimax_msg_len 0 55304 NULL
109868 +qp_alloc_guest_work_55305 qp_alloc_guest_work 5-3 55305 NULL nohasharray
109869 +__get_vm_area_node_55305 __get_vm_area_node 6 55305 &qp_alloc_guest_work_55305
109870 +__vxge_hw_vpath_initialize_55328 __vxge_hw_vpath_initialize 2 55328 NULL
109871 +do_shmat_55336 do_shmat 5 55336 NULL
109872 +vme_user_read_55338 vme_user_read 3 55338 NULL
109873 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
109874 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
109875 +iterate_inode_extrefs_55362 iterate_inode_extrefs 0 55362 NULL nohasharray
109876 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 &iterate_inode_extrefs_55362
109877 +cw1200_sdio_align_size_55391 cw1200_sdio_align_size 2 55391 NULL
109878 +__domain_mapping_55393 __domain_mapping 5 55393 NULL
109879 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
109880 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
109881 +SyS_read_55449 SyS_read 3 55449 NULL
109882 +add_relation_rb_55451 add_relation_rb 0 55451 NULL
109883 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
109884 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
109885 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
109886 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
109887 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL nohasharray
109888 +ras_stride_increase_window_55501 ras_stride_increase_window 3 55501 &ocfs2_rec_clusters_55501
109889 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
109890 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 NULL
109891 +ea_get_55522 ea_get 3-0 55522 NULL
109892 +buffer_size_55534 buffer_size 0 55534 NULL
109893 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
109894 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
109895 +dgap_do_config_load_55548 dgap_do_config_load 2 55548 NULL
109896 +dm_stats_list_55551 dm_stats_list 4 55551 NULL
109897 +gfs2_bitfit_55566 gfs2_bitfit 2-3-0 55566 NULL
109898 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
109899 +add_partition_55588 add_partition 2 55588 NULL
109900 +kstrtou8_from_user_55599 kstrtou8_from_user 2 55599 NULL
109901 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
109902 +allocate_without_wrapping_disk_55607 allocate_without_wrapping_disk 4 55607 NULL
109903 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
109904 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
109905 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
109906 +snd_pcm_hw_param_last_55624 snd_pcm_hw_param_last 0 55624 NULL
109907 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
109908 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
109909 +osc_obd_max_pages_per_rpc_seq_write_55636 osc_obd_max_pages_per_rpc_seq_write 3 55636 NULL
109910 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
109911 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
109912 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
109913 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
109914 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
109915 +btrfs_reloc_cow_block_55672 btrfs_reloc_cow_block 0 55672 NULL
109916 +get_info_55681 get_info 3 55681 NULL
109917 +iwl_dbgfs_plcp_delta_write_55682 iwl_dbgfs_plcp_delta_write 3 55682 NULL
109918 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
109919 +ocfs2_lock_refcount_tree_55719 ocfs2_lock_refcount_tree 0 55719 NULL nohasharray
109920 +mtdswap_init_55719 mtdswap_init 2 55719 &ocfs2_lock_refcount_tree_55719
109921 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
109922 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
109923 +set_local_name_55757 set_local_name 4 55757 NULL
109924 +strlen_55778 strlen 0 55778 NULL nohasharray
109925 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
109926 +set_spte_55783 set_spte 4-5 55783 NULL
109927 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
109928 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
109929 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
109930 +sb16_copy_from_user_55836 sb16_copy_from_user 7-6-10 55836 NULL
109931 +ept_gva_to_gpa_55848 ept_gva_to_gpa 2 55848 NULL
109932 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
109933 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
109934 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
109935 +__check_block_validity_55869 __check_block_validity 0 55869 NULL
109936 +hsc_write_55875 hsc_write 3 55875 NULL
109937 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
109938 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
109939 +ext2_direct_IO_55932 ext2_direct_IO 4 55932 NULL
109940 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
109941 +kvm_write_guest_virt_system_55944 kvm_write_guest_virt_system 4-2 55944 NULL
109942 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
109943 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
109944 +simple_read_from_buffer_55957 simple_read_from_buffer 5-2 55957 NULL
109945 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
109946 +btrfs_clone_55977 btrfs_clone 5-3 55977 NULL
109947 +wa_xfer_create_subset_sg_55992 wa_xfer_create_subset_sg 2-3 55992 NULL
109948 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
109949 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
109950 +__set_discard_56081 __set_discard 2 56081 NULL
109951 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
109952 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
109953 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
109954 +write_file_frameerrors_56145 write_file_frameerrors 3 56145 NULL
109955 +add_extent_mapping_56157 add_extent_mapping 0 56157 NULL
109956 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
109957 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
109958 +create_irq_nr_56180 create_irq_nr 1-0-2 56180 NULL
109959 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
109960 +ocfs2_journal_access_gd_56209 ocfs2_journal_access_gd 0 56209 NULL
109961 +update_space_info_56213 update_space_info 0 56213 NULL
109962 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
109963 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
109964 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
109965 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
109966 +fd_copyin_56247 fd_copyin 3 56247 NULL
109967 +svc_init_buffer_56249 svc_init_buffer 3 56249 NULL
109968 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
109969 +p9pdu_vreadf_56271 p9pdu_vreadf 0 56271 NULL
109970 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
109971 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
109972 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
109973 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
109974 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
109975 +speakup_file_write_56310 speakup_file_write 3 56310 NULL
109976 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
109977 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
109978 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
109979 +ipv6_recv_error_56347 ipv6_recv_error 3 56347 NULL
109980 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
109981 +mite_device_bytes_transferred_56355 mite_device_bytes_transferred 0 56355 NULL
109982 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 0-4 56368 NULL
109983 +dev_read_56369 dev_read 3 56369 NULL
109984 +ath10k_read_simulate_fw_crash_56371 ath10k_read_simulate_fw_crash 3 56371 NULL
109985 +ata_qc_complete_multiple_56376 ata_qc_complete_multiple 2 56376 NULL
109986 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
109987 +write_gssp_56404 write_gssp 3 56404 NULL
109988 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
109989 +do_get_write_access_56410 do_get_write_access 0 56410 NULL
109990 +i915_gem_object_sync_56417 i915_gem_object_sync 0 56417 NULL nohasharray
109991 +store_msg_56417 store_msg 3 56417 &i915_gem_object_sync_56417
109992 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
109993 +fl_create_56435 fl_create 5 56435 NULL
109994 +gnttab_map_56439 gnttab_map 2 56439 NULL
109995 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2-4 56453 NULL
109996 +set_connectable_56458 set_connectable 4 56458 NULL
109997 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
109998 +putused_user_56467 putused_user 3 56467 NULL
109999 +lbs_rdmac_write_56471 lbs_rdmac_write 3 56471 NULL
110000 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
110001 +global_rt_period_56476 global_rt_period 0 56476 NULL
110002 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
110003 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
110004 +cfs_access_process_vm_56503 cfs_access_process_vm 2-4-0 56503 NULL
110005 +init_map_ip_56508 init_map_ip 5 56508 NULL
110006 +lustre_posix_acl_xattr_reduce_space_56512 lustre_posix_acl_xattr_reduce_space 3 56512 NULL
110007 +ext4_zeroout_es_56514 ext4_zeroout_es 0 56514 NULL
110008 +cfg80211_connect_result_56515 cfg80211_connect_result 6-4 56515 NULL
110009 +ip_options_get_56538 ip_options_get 4 56538 NULL
110010 +ll_wr_track_id_56544 ll_wr_track_id 2 56544 NULL
110011 +vb2_queue_or_prepare_buf_56547 vb2_queue_or_prepare_buf 0 56547 NULL
110012 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
110013 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
110014 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
110015 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
110016 +event_filter_write_56609 event_filter_write 3 56609 NULL
110017 +nvme_trans_log_temperature_56613 nvme_trans_log_temperature 3 56613 NULL
110018 +gather_array_56641 gather_array 3 56641 NULL
110019 +lookup_extent_backref_56644 lookup_extent_backref 9-0 56644 NULL
110020 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
110021 +tg3_nvram_write_block_56666 tg3_nvram_write_block 3 56666 NULL
110022 +btrfs_cow_block_56678 btrfs_cow_block 0 56678 NULL
110023 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
110024 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
110025 +build_map_info_56696 build_map_info 2 56696 NULL
110026 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3-0 56702 NULL
110027 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
110028 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
110029 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
110030 +__copy_from_user_ll_56738 __copy_from_user_ll 0-3 56738 NULL
110031 +pcpu_populate_chunk_56741 pcpu_populate_chunk 3-2 56741 NULL
110032 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
110033 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
110034 +alloc_iommu_56778 alloc_iommu 2-3-0 56778 NULL
110035 +hash_lookup_56792 hash_lookup 2 56792 NULL nohasharray
110036 +ttm_alloc_new_pages_56792 ttm_alloc_new_pages 5 56792 &hash_lookup_56792
110037 +do_syslog_56807 do_syslog 3 56807 NULL
110038 +ext4_ext_rm_idx_56827 ext4_ext_rm_idx 0 56827 NULL
110039 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
110040 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
110041 +sysctl_sync_threshold_56835 sysctl_sync_threshold 0 56835 NULL
110042 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4-0 56847 NULL
110043 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
110044 +wb_lookup_56858 wb_lookup 2 56858 NULL
110045 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
110046 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
110047 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
110048 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
110049 +hfsplus_find_cat_56899 hfsplus_find_cat 0 56899 NULL
110050 +hfsplus_setxattr_56902 hfsplus_setxattr 4 56902 NULL
110051 +__bitmap_clear_bits_56912 __bitmap_clear_bits 3 56912 NULL
110052 +strcspn_56913 strcspn 0 56913 NULL
110053 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
110054 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL nohasharray
110055 +CopyBufferToControlPacket_56933 CopyBufferToControlPacket 0 56933 &journal_init_revoke_56933
110056 +nouveau_xtensa_create__56952 nouveau_xtensa_create_ 8 56952 NULL
110057 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
110058 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
110059 +sptlrpc_secflags2str_56995 sptlrpc_secflags2str 3 56995 NULL
110060 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
110061 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
110062 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
110063 +i915_gem_evict_everything_57038 i915_gem_evict_everything 0 57038 NULL
110064 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
110065 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
110066 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
110067 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
110068 +__wl_get_peb_57058 __wl_get_peb 0 57058 NULL
110069 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
110070 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
110071 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
110072 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
110073 +altera_get_note_57099 altera_get_note 6 57099 NULL
110074 +hpfs_readpages_57106 hpfs_readpages 4 57106 NULL
110075 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
110076 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
110077 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
110078 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
110079 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
110080 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
110081 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
110082 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
110083 +changed_inode_57156 changed_inode 0 57156 NULL
110084 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
110085 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
110086 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
110087 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
110088 +ocfs2_claim_metadata_57192 ocfs2_claim_metadata 0 57192 NULL
110089 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
110090 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
110091 +flush_space_57241 flush_space 3-0 57241 NULL
110092 +rsxx_cram_write_57244 rsxx_cram_write 3 57244 NULL
110093 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
110094 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
110095 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
110096 +lbs_sleepparams_write_57283 lbs_sleepparams_write 3 57283 NULL
110097 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
110098 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
110099 +fw_file_size_57307 fw_file_size 0 57307 NULL
110100 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
110101 +write_file_regval_57313 write_file_regval 3 57313 NULL
110102 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
110103 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
110104 +usblp_read_57342 usblp_read 3 57342 NULL
110105 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
110106 +dio_send_cur_page_57348 dio_send_cur_page 0 57348 NULL
110107 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
110108 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
110109 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
110110 +read_file_blob_57406 read_file_blob 3 57406 NULL
110111 +enclosure_register_57412 enclosure_register 3 57412 NULL
110112 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL
110113 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
110114 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
110115 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL
110116 +sisusb_clear_vram_57466 sisusb_clear_vram 2-3 57466 NULL
110117 +blk_flush_cur_seq_57467 blk_flush_cur_seq 0 57467 NULL
110118 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
110119 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
110120 +ocfs2_write_cluster_57483 ocfs2_write_cluster 9-8-2 57483 NULL
110121 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
110122 +skb_headlen_57501 skb_headlen 0 57501 NULL
110123 +copy_in_user_57502 copy_in_user 3 57502 NULL
110124 +ckhdid_printf_57505 ckhdid_printf 2 57505 NULL
110125 +init_tag_map_57515 init_tag_map 3 57515 NULL
110126 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
110127 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517 nohasharray
110128 +btrfs_insert_inode_extref_57517 btrfs_insert_inode_extref 0 57517 &il_dbgfs_force_reset_read_57517
110129 +cmm_read_57520 cmm_read 3 57520 NULL
110130 +inode_permission_57531 inode_permission 0 57531 NULL
110131 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL
110132 +ptlrpc_lprocfs_hp_ratio_seq_write_57537 ptlrpc_lprocfs_hp_ratio_seq_write 3 57537 NULL
110133 +ReadHDLCPnP_57559 ReadHDLCPnP 0 57559 NULL nohasharray
110134 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 &ReadHDLCPnP_57559
110135 +obd_unpackmd_57563 obd_unpackmd 0 57563 NULL
110136 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
110137 +get_bridge_ifindices_57579 get_bridge_ifindices 0 57579 NULL
110138 +ldlm_cli_enqueue_local_57582 ldlm_cli_enqueue_local 11 57582 NULL
110139 +il_dbgfs_interrupt_write_57591 il_dbgfs_interrupt_write 3 57591 NULL
110140 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
110141 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
110142 +vma_kernel_pagesize_57616 vma_kernel_pagesize 0 57616 NULL
110143 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
110144 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 NULL
110145 +mem_read_57631 mem_read 3 57631 NULL
110146 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
110147 +r3964_write_57662 r3964_write 4 57662 NULL
110148 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
110149 +__lgwrite_57669 __lgwrite 4 57669 NULL
110150 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
110151 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
110152 +snd_interval_value_57713 snd_interval_value 0 57713 NULL
110153 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
110154 +i915_gem_object_get_pages_57734 i915_gem_object_get_pages 0 57734 NULL
110155 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
110156 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL nohasharray
110157 +pppol2tp_recvmsg_57742 pppol2tp_recvmsg 4 57742 &compat_sys_set_mempolicy_57742
110158 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
110159 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 5-3 57776 NULL
110160 +apei_exec_collect_resources_57788 apei_exec_collect_resources 0 57788 NULL
110161 +ld2_57794 ld2 0 57794 NULL
110162 +ivtv_read_57796 ivtv_read 3 57796 NULL
110163 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
110164 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
110165 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
110166 +copy_to_user_57835 copy_to_user 3-0 57835 NULL
110167 +flash_read_57843 flash_read 3 57843 NULL
110168 +kiblnd_create_tx_pool_57846 kiblnd_create_tx_pool 2 57846 NULL
110169 +process_all_new_xattrs_57881 process_all_new_xattrs 0 57881 NULL
110170 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
110171 +atomic_add_return_unchecked_57910 atomic_add_return_unchecked 0-1 57910 NULL nohasharray
110172 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 &atomic_add_return_unchecked_57910
110173 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
110174 +twl_i2c_write_57923 twl_i2c_write 3-4 57923 NULL
110175 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
110176 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
110177 +nvc0_vm_create_57942 nvc0_vm_create 2-3 57942 NULL
110178 +xfs_mru_cache_create_57943 xfs_mru_cache_create 3 57943 NULL
110179 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
110180 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
110181 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
110182 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
110183 +interleave_nodes_57992 interleave_nodes 0 57992 NULL
110184 +do_rx_dma_57996 do_rx_dma 5 57996 NULL
110185 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
110186 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
110187 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
110188 +ext4_block_bitmap_58033 ext4_block_bitmap 0 58033 NULL
110189 +mce_async_out_58056 mce_async_out 3 58056 NULL
110190 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
110191 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
110192 +cm4040_write_58079 cm4040_write 3 58079 NULL
110193 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
110194 +slhc_init_58135 slhc_init 2-1 58135 &ipv6_flowlabel_opt_58135
110195 +ocfs2_reserve_clusters_58164 ocfs2_reserve_clusters 0 58164 NULL
110196 +ext4_bg_num_gdb_58171 ext4_bg_num_gdb 0 58171 NULL
110197 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
110198 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
110199 +sysfs_add_file_mode_58222 sysfs_add_file_mode 0 58222 NULL
110200 +hva_to_pfn_58241 hva_to_pfn 1-0 58241 NULL
110201 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
110202 +read_file_debug_58256 read_file_debug 3 58256 NULL
110203 +osc_max_dirty_mb_seq_write_58263 osc_max_dirty_mb_seq_write 3 58263 NULL
110204 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
110205 +profile_load_58267 profile_load 3 58267 NULL
110206 +kstrtos8_from_user_58268 kstrtos8_from_user 2 58268 NULL
110207 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
110208 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
110209 +intel_alloc_coherent_58302 intel_alloc_coherent 2 58302 NULL
110210 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
110211 +i915_wait_seqno_58309 i915_wait_seqno 0 58309 NULL
110212 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
110213 +ext4_ext_truncate_extend_restart_58331 ext4_ext_truncate_extend_restart 3-0 58331 NULL
110214 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
110215 +__copy_from_user_swizzled_58337 __copy_from_user_swizzled 2-4 58337 NULL
110216 +next_pidmap_58347 next_pidmap 2-0 58347 NULL
110217 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
110218 +save_hint_58359 save_hint 2 58359 NULL
110219 +vmw_ttm_tt_create_58369 vmw_ttm_tt_create 2 58369 NULL nohasharray
110220 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 &vmw_ttm_tt_create_58369
110221 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
110222 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
110223 +_drbd_md_sync_page_io_58403 _drbd_md_sync_page_io 6 58403 NULL
110224 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3-4 58406 NULL nohasharray
110225 +idetape_pad_zeros_58406 idetape_pad_zeros 2 58406 &kvm_mmu_write_protect_pt_masked_58406
110226 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
110227 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
110228 +capabilities_read_58457 capabilities_read 3 58457 NULL
110229 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
110230 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
110231 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
110232 +nv_rd08_58472 nv_rd08 0 58472 NULL
110233 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
110234 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
110235 +btrfs_cont_expand_58498 btrfs_cont_expand 2-3 58498 NULL
110236 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
110237 +__clear_discard_58546 __clear_discard 2 58546 NULL
110238 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
110239 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
110240 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
110241 +get_rhf_errstring_58582 get_rhf_errstring 3 58582 NULL
110242 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
110243 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
110244 +xip_file_read_58592 xip_file_read 3 58592 NULL
110245 +ecryptfs_write_end_58594 ecryptfs_write_end 5-3 58594 NULL
110246 +radeon_bo_size_58606 radeon_bo_size 0 58606 NULL
110247 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
110248 +xfs_iomap_write_delay_58616 xfs_iomap_write_delay 2 58616 NULL
110249 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
110250 +filemap_fdatawrite_range_58630 filemap_fdatawrite_range 0 58630 NULL
110251 +vb2_qbuf_58631 vb2_qbuf 0 58631 NULL
110252 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL
110253 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
110254 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
110255 +iwl_dbgfs_rx_handlers_write_58655 iwl_dbgfs_rx_handlers_write 3 58655 NULL
110256 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
110257 +find_zero_58685 find_zero 0-1 58685 NULL
110258 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
110259 +tps6586x_writes_58689 tps6586x_writes 2-3 58689 NULL
110260 +vmalloc_node_58700 vmalloc_node 1-2 58700 NULL
110261 +vx_send_msg_58711 vx_send_msg 0 58711 NULL
110262 +i915_gem_execbuffer_reserve_58722 i915_gem_execbuffer_reserve 0 58722 NULL
110263 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
110264 +csum_exist_in_range_58730 csum_exist_in_range 2-3 58730 NULL
110265 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
110266 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
110267 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
110268 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
110269 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
110270 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
110271 +isku_sysfs_read_58806 isku_sysfs_read 5 58806 NULL
110272 +write_file_58812 write_file 4 58812 NULL
110273 +ep_read_58813 ep_read 3 58813 NULL
110274 +command_write_58841 command_write 3 58841 NULL
110275 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3-0 58850 NULL
110276 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
110277 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
110278 +esas2r_change_queue_depth_58886 esas2r_change_queue_depth 2 58886 NULL
110279 +lprocfs_wr_pinger_recov_58914 lprocfs_wr_pinger_recov 3 58914 NULL
110280 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
110281 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
110282 +SyS_pread64_58935 SyS_pread64 3 58935 NULL
110283 +wait_table_hash_nr_entries_58962 wait_table_hash_nr_entries 0 58962 NULL
110284 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
110285 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
110286 +__mem_cgroup_try_charge_58976 __mem_cgroup_try_charge 0 58976 NULL
110287 +init_list_58990 init_list 3 58990 NULL
110288 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
110289 +ep_write_59008 ep_write 3 59008 NULL
110290 +lpfc_idiag_baracc_write_59014 lpfc_idiag_baracc_write 3 59014 NULL
110291 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
110292 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
110293 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
110294 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
110295 +regmap_bulk_write_59049 regmap_bulk_write 2-4 59049 NULL
110296 +sysfs_link_sibling_59078 sysfs_link_sibling 0 59078 NULL
110297 +do_perf_sw_event_59099 do_perf_sw_event 3 59099 NULL
110298 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
110299 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
110300 +init_status_page_59124 init_status_page 0 59124 NULL
110301 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
110302 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
110303 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
110304 +ocfs2_claim_local_alloc_bits_59147 ocfs2_claim_local_alloc_bits 0 59147 NULL
110305 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
110306 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
110307 +ksize_59176 ksize 0 59176 NULL
110308 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
110309 +ocfs2_move_extent_59187 ocfs2_move_extent 3-5-2 59187 NULL
110310 +validate_exec_list_59204 validate_exec_list 0 59204 NULL
110311 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
110312 +check_mapped_selector_name_59216 check_mapped_selector_name 5 59216 NULL
110313 +dt3155_read_59226 dt3155_read 3 59226 NULL
110314 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
110315 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
110316 +nla_len_59258 nla_len 0 59258 NULL
110317 +drbd_bm_write_page_59290 drbd_bm_write_page 2 59290 NULL
110318 +__push_leaf_right_59302 __push_leaf_right 0 59302 NULL
110319 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4-0 59304 NULL
110320 +fd_copyout_59323 fd_copyout 3 59323 NULL
110321 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
110322 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
110323 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
110324 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
110325 +__map_request_59350 __map_request 0 59350 NULL
110326 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
110327 +blk_flush_policy_59368 blk_flush_policy 0 59368 NULL
110328 +f2fs_fallocate_59377 f2fs_fallocate 3-4 59377 NULL
110329 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
110330 +ocfs2_replay_truncate_records_59382 ocfs2_replay_truncate_records 0 59382 NULL
110331 +journal_init_dev_59384 journal_init_dev 5 59384 NULL
110332 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
110333 +pci_ctrl_read_59424 pci_ctrl_read 0 59424 NULL
110334 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
110335 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
110336 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
110337 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2-0 59445 NULL
110338 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
110339 +block_rsv_use_bytes_59464 block_rsv_use_bytes 0 59464 NULL
110340 +shrink_tnc_trees_59481 shrink_tnc_trees 0 59481 NULL
110341 +btrfs_del_dir_entries_in_log_59490 btrfs_del_dir_entries_in_log 0 59490 NULL
110342 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
110343 +rds_pin_pages_59507 rds_pin_pages 1-2 59507 NULL
110344 +kmalloc_large_node_59542 kmalloc_large_node 3 59542 NULL
110345 +ext4_resize_fs_59543 ext4_resize_fs 2 59543 NULL
110346 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
110347 +tunables_write_59563 tunables_write 3 59563 NULL
110348 +__copy_from_user_ll_nozero_59571 __copy_from_user_ll_nozero 0-3 59571 NULL
110349 +write_pbl_59583 write_pbl 4 59583 NULL
110350 +memdup_user_59590 memdup_user 2 59590 NULL
110351 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
110352 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL nohasharray
110353 +xrcdn_free_res_59616 xrcdn_free_res 5 59616 &mem_fwlog_free_mem_blks_read_59616
110354 +ath6kl_endpoint_stats_write_59621 ath6kl_endpoint_stats_write 3 59621 NULL
110355 +mtrr_write_59622 mtrr_write 3 59622 NULL
110356 +ocfs2_adjust_rightmost_branch_59623 ocfs2_adjust_rightmost_branch 0 59623 NULL
110357 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
110358 +SyS_setdomainname_59646 SyS_setdomainname 2 59646 NULL
110359 +hidraw_read_59650 hidraw_read 3 59650 NULL
110360 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
110361 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
110362 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
110363 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
110364 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
110365 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
110366 +ioperm_get_59701 ioperm_get 4-3 59701 NULL
110367 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
110368 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
110369 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
110370 +fat_direct_IO_59741 fat_direct_IO 4 59741 NULL
110371 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
110372 +strnlen_59746 strnlen 0 59746 NULL
110373 +process_all_refs_59754 process_all_refs 0 59754 NULL nohasharray
110374 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 &process_all_refs_59754
110375 +process_new_xattr_59755 process_new_xattr 0 59755 NULL
110376 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
110377 +venus_remove_59781 venus_remove 4 59781 NULL
110378 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
110379 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
110380 +msb_get_zone_from_lba_59800 msb_get_zone_from_lba 0-1 59800 NULL
110381 +ipw_write_59807 ipw_write 3 59807 NULL
110382 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
110383 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
110384 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
110385 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
110386 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
110387 +intel_ring_wait_request_59865 intel_ring_wait_request 0 59865 NULL
110388 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
110389 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
110390 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
110391 +l2cap_sock_recvmsg_59886 l2cap_sock_recvmsg 4 59886 NULL
110392 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
110393 +ocfs2_extend_rotate_transaction_59894 ocfs2_extend_rotate_transaction 0 59894 NULL
110394 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
110395 +aic7xxx_abort_waiting_scb_59932 aic7xxx_abort_waiting_scb 0 59932 NULL
110396 +kvm_mmu_notifier_invalidate_range_start_59944 kvm_mmu_notifier_invalidate_range_start 3-4 59944 NULL
110397 +ocfs2_expand_inline_ref_root_59945 ocfs2_expand_inline_ref_root 0 59945 NULL
110398 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
110399 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
110400 +lookup_node_59953 lookup_node 2 59953 NULL
110401 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL
110402 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
110403 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
110404 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
110405 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
110406 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
110407 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
110408 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
110409 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
110410 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
110411 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
110412 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
110413 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
110414 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
110415 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
110416 +open_cur_inode_file_60057 open_cur_inode_file 0 60057 NULL
110417 +compat_writev_60063 compat_writev 3 60063 NULL
110418 +ath6kl_listen_int_write_60066 ath6kl_listen_int_write 3 60066 NULL
110419 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
110420 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
110421 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
110422 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
110423 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
110424 +nfs_idmap_request_key_60124 nfs_idmap_request_key 2 60124 NULL
110425 +__mutex_lock_common_60134 __mutex_lock_common 0 60134 NULL
110426 +ld_usb_read_60156 ld_usb_read 3 60156 NULL
110427 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
110428 +init_state_60165 init_state 2 60165 NULL
110429 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
110430 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
110431 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
110432 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
110433 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 NULL
110434 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
110435 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
110436 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0 60230 &arizona_map_irq_60230
110437 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
110438 +irq_alloc_domain_generic_chips_60264 irq_alloc_domain_generic_chips 3-2 60264 NULL
110439 +printer_write_60276 printer_write 3 60276 NULL
110440 +alloc_irq_pin_list_60277 alloc_irq_pin_list 1 60277 NULL
110441 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
110442 +getDataLength_60301 getDataLength 0 60301 NULL
110443 +xfs_next_bit_60322 xfs_next_bit 0-3 60322 NULL
110444 +inorder_to_tree_60331 inorder_to_tree 1-0 60331 NULL
110445 +usb_alphatrack_write_60341 usb_alphatrack_write 3 60341 NULL
110446 +__kfifo_from_user_r_60345 __kfifo_from_user_r 5-3 60345 NULL
110447 +max_unfragmented_pages_60362 max_unfragmented_pages 0 60362 NULL
110448 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
110449 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 0-5 60379 NULL
110450 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
110451 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
110452 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
110453 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
110454 +driver_names_read_60399 driver_names_read 3 60399 NULL
110455 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
110456 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
110457 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
110458 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
110459 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
110460 +scaled_div32_60442 scaled_div32 2-1-0 60442 NULL
110461 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
110462 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
110463 +lustre_msg_early_size_60496 lustre_msg_early_size 0 60496 NULL
110464 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
110465 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
110466 +osc_lockless_truncate_seq_write_60553 osc_lockless_truncate_seq_write 3 60553 NULL
110467 +tracing_entries_write_60563 tracing_entries_write 3 60563 NULL
110468 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
110469 +btrfs_add_delayed_tree_ref_60602 btrfs_add_delayed_tree_ref 0 60602 NULL
110470 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
110471 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
110472 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
110473 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
110474 +free_dind_blocks_60635 free_dind_blocks 0 60635 NULL
110475 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
110476 +__proc_lnet_stats_60647 __proc_lnet_stats 5 60647 NULL
110477 +mv_ffc64_60648 mv_ffc64 1 60648 NULL
110478 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
110479 +run_clustered_refs_60668 run_clustered_refs 0 60668 NULL
110480 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
110481 +btrfs_reserve_extent_60674 btrfs_reserve_extent 5-0 60674 NULL
110482 +init_data_container_60709 init_data_container 1 60709 NULL
110483 +vga_rcrt_60731 vga_rcrt 0 60731 NULL
110484 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
110485 +raid_status_60755 raid_status 5 60755 NULL
110486 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
110487 +opticon_write_60775 opticon_write 4 60775 NULL
110488 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
110489 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
110490 +block_rsv_migrate_bytes_60843 block_rsv_migrate_bytes 0 60843 NULL
110491 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
110492 +alloc_buf_60864 alloc_buf 2-3 60864 NULL
110493 +generic_writepages_60871 generic_writepages 0 60871 NULL
110494 +tipc_createport_60875 tipc_createport 4 60875 NULL
110495 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
110496 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
110497 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
110498 +libcfs_sock_ioctl_60915 libcfs_sock_ioctl 0 60915 NULL
110499 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
110500 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
110501 +submit_extent_page_60928 submit_extent_page 5 60928 NULL
110502 +pti_char_write_60960 pti_char_write 3 60960 NULL
110503 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 3-2 60961 NULL
110504 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
110505 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
110506 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
110507 +graph_depth_write_61024 graph_depth_write 3 61024 NULL
110508 +sdhci_pltfm_register_61031 sdhci_pltfm_register 3 61031 NULL
110509 +lpfc_idiag_queacc_write_61043 lpfc_idiag_queacc_write 3 61043 NULL
110510 +symtab_init_61050 symtab_init 2 61050 NULL
110511 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
110512 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
110513 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
110514 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
110515 +journal_stop_61080 journal_stop 0 61080 NULL
110516 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
110517 +get_derived_key_61100 get_derived_key 4 61100 NULL
110518 +mem_cgroup_cache_charge_61101 mem_cgroup_cache_charge 0 61101 NULL
110519 +i40e_calculate_l2fpm_size_61104 i40e_calculate_l2fpm_size 0-1-2-3-4 61104 NULL
110520 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
110521 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 NULL
110522 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1-2 61126 NULL
110523 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
110524 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
110525 +__vmalloc_61168 __vmalloc 1 61168 NULL
110526 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
110527 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
110528 +dio_bio_add_page_61178 dio_bio_add_page 0 61178 NULL
110529 +btrfs_reloc_post_snapshot_61189 btrfs_reloc_post_snapshot 0 61189 NULL
110530 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
110531 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
110532 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
110533 +__verify_planes_array_61249 __verify_planes_array 0 61249 NULL
110534 +find_get_pages_tag_61270 find_get_pages_tag 0 61270 NULL nohasharray
110535 +ifalias_store_61270 ifalias_store 4 61270 &find_get_pages_tag_61270 nohasharray
110536 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 &ifalias_store_61270
110537 +kick_a_thread_61273 kick_a_thread 0 61273 NULL
110538 +hfsplus_getxattr_finder_info_61283 hfsplus_getxattr_finder_info 0 61283 NULL nohasharray
110539 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 &hfsplus_getxattr_finder_info_61283
110540 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 NULL
110541 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
110542 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
110543 +ocfs2_get_sector_61309 ocfs2_get_sector 4 61309 NULL
110544 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
110545 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
110546 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 3 61330 NULL
110547 +write_file_spectral_short_repeat_61335 write_file_spectral_short_repeat 3 61335 NULL
110548 +__fls_61340 __fls 0 61340 NULL nohasharray
110549 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 &__fls_61340
110550 +do_splice_direct_61341 do_splice_direct 5 61341 NULL nohasharray
110551 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 &do_splice_direct_61341
110552 +__dm_get_reserved_ios_61342 __dm_get_reserved_ios 0-2-3 61342 NULL
110553 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
110554 +kvm_apic_id_61363 kvm_apic_id 0 61363 NULL
110555 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
110556 +get_inode_info_61387 get_inode_info 0 61387 NULL
110557 +system_enable_write_61396 system_enable_write 3 61396 NULL
110558 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
110559 +xfs_zero_remaining_bytes_61423 xfs_zero_remaining_bytes 3 61423 NULL
110560 +i915_emit_box_61436 i915_emit_box 0 61436 NULL
110561 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5-0 61440 NULL
110562 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
110563 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
110564 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 5-4-2 61483 NULL
110565 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
110566 +ocfs2_get_refcount_rec_61514 ocfs2_get_refcount_rec 0 61514 NULL
110567 +__vmalloc_area_node_61525 __vmalloc_area_node 4 61525 NULL
110568 +erst_errno_61526 erst_errno 0 61526 NULL
110569 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
110570 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
110571 +trace_options_core_write_61551 trace_options_core_write 3 61551 NULL
110572 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
110573 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
110574 +alloc_pgtable_page_61562 alloc_pgtable_page 1 61562 NULL
110575 +parport_pc_fifo_write_block_dma_61568 parport_pc_fifo_write_block_dma 3 61568 NULL
110576 +fan_proc_write_61569 fan_proc_write 3 61569 NULL
110577 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
110578 +ldlm_pool_rw_atomic_seq_write_61572 ldlm_pool_rw_atomic_seq_write 3 61572 NULL
110579 +seq_open_private_61589 seq_open_private 3 61589 NULL
110580 +ept_gpte_to_gfn_lvl_61591 ept_gpte_to_gfn_lvl 0-2-1 61591 NULL
110581 +netlink_recvmsg_61600 netlink_recvmsg 4 61600 NULL
110582 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
110583 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
110584 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
110585 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
110586 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
110587 +resize_stripes_61650 resize_stripes 2 61650 NULL
110588 +ttm_page_pool_free_61661 ttm_page_pool_free 2-0 61661 NULL
110589 +insert_one_name_61668 insert_one_name 7 61668 NULL
110590 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
110591 +qib_format_hwmsg_61679 qib_format_hwmsg 2 61679 NULL
110592 +lock_loop_61681 lock_loop 1 61681 NULL
110593 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
110594 +filter_read_61692 filter_read 3 61692 NULL
110595 +prog_page_61711 prog_page 2 61711 NULL
110596 +iov_length_61716 iov_length 0 61716 NULL
110597 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
110598 +null_alloc_reqbuf_61719 null_alloc_reqbuf 3 61719 NULL
110599 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
110600 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
110601 +SyS_sendto_61763 SyS_sendto 6 61763 NULL
110602 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
110603 +num_counter_active_61789 num_counter_active 0 61789 NULL
110604 +mls_compute_context_len_61812 mls_compute_context_len 0 61812 NULL
110605 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
110606 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
110607 +regcache_sync_block_61846 regcache_sync_block 4-5 61846 NULL
110608 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2-0 61854 NULL
110609 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
110610 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
110611 +get_fw_name_61874 get_fw_name 3 61874 NULL
110612 +twl4030_sih_setup_61878 twl4030_sih_setup 3-0 61878 NULL
110613 +btrfs_ioctl_clone_61886 btrfs_ioctl_clone 4-3-5 61886 NULL
110614 +lprocfs_write_frac_u64_helper_61897 lprocfs_write_frac_u64_helper 2 61897 NULL
110615 +lov_mds_md_stripecnt_61899 lov_mds_md_stripecnt 0-1 61899 NULL
110616 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
110617 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
110618 +au0828_init_isoc_61917 au0828_init_isoc 3-2-4 61917 NULL
110619 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
110620 +ocfs2_reserve_new_metadata_blocks_61926 ocfs2_reserve_new_metadata_blocks 0 61926 NULL
110621 +SyS_kexec_load_61946 SyS_kexec_load 2 61946 NULL
110622 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
110623 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
110624 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
110625 +fix_read_error_61965 fix_read_error 4 61965 NULL
110626 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
110627 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
110628 +fd_locked_ioctl_61978 fd_locked_ioctl 3 61978 NULL
110629 +cow_file_range_61979 cow_file_range 3 61979 NULL
110630 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
110631 +dequeue_event_62000 dequeue_event 3 62000 NULL
110632 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
110633 +SyS_setxattr_62019 SyS_setxattr 4 62019 NULL
110634 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
110635 +SYSC_select_62024 SYSC_select 1 62024 NULL
110636 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
110637 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
110638 +do_pselect_62061 do_pselect 1 62061 NULL
110639 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
110640 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
110641 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5-4 62100 NULL
110642 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
110643 +btrfs_direct_IO_62114 btrfs_direct_IO 4 62114 NULL
110644 +ip_recv_error_62117 ip_recv_error 3 62117 NULL
110645 +generic_block_fiemap_62122 generic_block_fiemap 4 62122 NULL
110646 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
110647 +qib_diag_write_62133 qib_diag_write 3 62133 NULL nohasharray
110648 +kobject_add_varg_62133 kobject_add_varg 0 62133 &qib_diag_write_62133
110649 +ql_status_62135 ql_status 5 62135 NULL nohasharray
110650 +device_add_attrs_62135 device_add_attrs 0 62135 &ql_status_62135
110651 +video_usercopy_62151 video_usercopy 2 62151 NULL
110652 +wrmWithLock_62164 wrmWithLock 0 62164 NULL
110653 +SyS_getxattr_62166 SyS_getxattr 4 62166 NULL
110654 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
110655 +write_file_dfs_62180 write_file_dfs 3 62180 NULL
110656 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
110657 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
110658 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
110659 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
110660 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
110661 +allocate_partition_62245 allocate_partition 4 62245 NULL
110662 +security_file_permission_62278 security_file_permission 0 62278 NULL
110663 +get_random_int_62279 get_random_int 0 62279 NULL
110664 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
110665 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
110666 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
110667 +ocfs2_find_victim_alloc_group_62306 ocfs2_find_victim_alloc_group 0 62306 NULL
110668 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
110669 +vmemmap_pgd_populate_62315 vmemmap_pgd_populate 2 62315 NULL
110670 +timespec_to_jiffies_62321 timespec_to_jiffies 0 62321 NULL
110671 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
110672 +subseq_list_62332 subseq_list 3-0 62332 NULL
110673 +ll_statahead_max_seq_write_62333 ll_statahead_max_seq_write 3 62333 NULL
110674 +flash_write_62354 flash_write 3 62354 NULL
110675 +xfpregs_set_62363 xfpregs_set 4 62363 NULL
110676 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
110677 +altera_irscan_62396 altera_irscan 2 62396 NULL
110678 +set_ssp_62411 set_ssp 4 62411 NULL
110679 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
110680 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
110681 +mtip_get_next_rr_node_62502 mtip_get_next_rr_node 0 62502 NULL
110682 +ocfs2_path_bh_journal_access_62504 ocfs2_path_bh_journal_access 0 62504 NULL
110683 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
110684 +test_iso_queue_62534 test_iso_queue 5 62534 NULL nohasharray
110685 +__kmalloc_node_track_caller_62534 __kmalloc_node_track_caller 3 62534 &test_iso_queue_62534
110686 +debugfs_read_62535 debugfs_read 3 62535 NULL
110687 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
110688 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
110689 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
110690 +get_subdir_62581 get_subdir 3 62581 NULL
110691 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 NULL
110692 +get_desc_base_62617 get_desc_base 0 62617 NULL
110693 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7-0 62619 NULL
110694 +vfs_fsync_range_62635 vfs_fsync_range 0 62635 NULL
110695 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
110696 +write_62671 write 3 62671 NULL
110697 +ocfs2_wait_for_mask_interruptible_62675 ocfs2_wait_for_mask_interruptible 0 62675 NULL
110698 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
110699 +ext4_ind_map_blocks_62690 ext4_ind_map_blocks 0 62690 NULL
110700 +htb_remove_class_from_row_62692 htb_remove_class_from_row 3 62692 NULL
110701 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
110702 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
110703 +gfs2_log_write_62717 gfs2_log_write 3 62717 NULL
110704 +rdm_62719 rdm 0 62719 NULL
110705 +obd_ioctl_popdata_62741 obd_ioctl_popdata 3 62741 NULL
110706 +key_replays_read_62746 key_replays_read 3 62746 NULL
110707 +lov_verify_lmm_62747 lov_verify_lmm 2 62747 NULL
110708 +mwifiex_rdeeprom_write_62754 mwifiex_rdeeprom_write 3 62754 NULL
110709 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
110710 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
110711 +C_SYSC_ipc_62776 C_SYSC_ipc 3 62776 NULL
110712 +SyS_sched_getaffinity_62786 SyS_sched_getaffinity 2 62786 NULL
110713 +dm_stats_account_io_62787 dm_stats_account_io 3 62787 NULL
110714 +posix_acl_valid_62788 posix_acl_valid 0 62788 NULL
110715 +is_first_ref_62805 is_first_ref 0 62805 NULL
110716 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
110717 +name_cache_insert_62822 name_cache_insert 0 62822 NULL
110718 +BeceemEEPROMBulkRead_62835 BeceemEEPROMBulkRead 0 62835 NULL
110719 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
110720 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
110721 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
110722 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
110723 +set_swbp_62853 set_swbp 3 62853 NULL
110724 +read_nic_io_dword_62859 read_nic_io_dword 0 62859 NULL
110725 +l2tp_ip6_recvmsg_62874 l2tp_ip6_recvmsg 4 62874 NULL
110726 +aoechr_write_62883 aoechr_write 3 62883 NULL
110727 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
110728 +ocfs2_validate_gd_parent_62905 ocfs2_validate_gd_parent 0 62905 NULL
110729 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
110730 +getdqbuf_62908 getdqbuf 1 62908 NULL
110731 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
110732 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1-2 62914 &try_async_pf_62914
110733 +ll_statahead_agl_seq_write_62928 ll_statahead_agl_seq_write 3 62928 NULL
110734 +atomic64_sub_return_62941 atomic64_sub_return 1 62941 NULL
110735 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
110736 +send_write_62969 send_write 0-3 62969 NULL
110737 +__ext3_journal_stop_63017 __ext3_journal_stop 0 63017 NULL
110738 +alloc_mem_cgroup_per_zone_info_63024 alloc_mem_cgroup_per_zone_info 2 63024 NULL
110739 +kstrtoull_from_user_63026 kstrtoull_from_user 2 63026 NULL
110740 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
110741 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
110742 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
110743 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
110744 +run_delayed_tree_ref_63042 run_delayed_tree_ref 0 63042 NULL
110745 +unlink1_63059 unlink1 3 63059 NULL
110746 +__do_munmap_63063 __do_munmap 0 63063 NULL
110747 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
110748 +iwl_dbgfs_fw_rx_stats_read_63070 iwl_dbgfs_fw_rx_stats_read 3 63070 NULL
110749 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 4-3-0 63078 NULL
110750 +find_extent_in_eb_63082 find_extent_in_eb 0 63082 NULL
110751 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-3-2 63087 NULL
110752 +__ocfs2_flush_truncate_log_63097 __ocfs2_flush_truncate_log 0 63097 NULL
110753 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
110754 +ext4_chunk_trans_blocks_63123 ext4_chunk_trans_blocks 0-2 63123 NULL
110755 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
110756 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
110757 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
110758 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
110759 +SyS_syslog_63178 SyS_syslog 3 63178 NULL
110760 +security_policydb_len_63198 security_policydb_len 0 63198 NULL
110761 +vme_master_read_63221 vme_master_read 0 63221 NULL
110762 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
110763 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
110764 +ptp_read_63251 ptp_read 4 63251 NULL
110765 +xfs_dir2_leaf_getdents_63262 xfs_dir2_leaf_getdents 3 63262 NULL
110766 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
110767 +raid5_resize_63306 raid5_resize 2 63306 NULL
110768 +proc_info_read_63344 proc_info_read 3 63344 NULL
110769 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
110770 +idmouse_read_63374 idmouse_read 3 63374 NULL
110771 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
110772 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
110773 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
110774 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
110775 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
110776 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 3-4-2 63429 NULL
110777 +gfn_to_hva_many_63437 gfn_to_hva_many 2-0 63437 NULL
110778 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
110779 +lookup_dir_item_inode_63447 lookup_dir_item_inode 0 63447 NULL
110780 +i915_gem_object_get_fence_63455 i915_gem_object_get_fence 0 63455 NULL
110781 +__do_kmalloc_node_63461 __do_kmalloc_node 3 63461 NULL
110782 +si5351_bulk_write_63468 si5351_bulk_write 2-3 63468 NULL
110783 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
110784 +do_work_63483 do_work 0 63483 NULL
110785 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
110786 +__copy_from_user_ll_nocache_63487 __copy_from_user_ll_nocache 0-3 63487 NULL
110787 +read_kcore_63488 read_kcore 3 63488 NULL nohasharray
110788 +alloc_reserved_tree_block_63488 alloc_reserved_tree_block 0 63488 &read_kcore_63488
110789 +save_hint_63497 save_hint 2 63497 NULL
110790 +wl1271_tx_min_rate_get_63498 wl1271_tx_min_rate_get 2 63498 NULL
110791 +sis_voice_irq_63501 sis_voice_irq 1 63501 NULL
110792 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
110793 +efx_mcdi_rpc_async_63529 efx_mcdi_rpc_async 5-4 63529 NULL
110794 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4-0 63534 NULL
110795 +write_file_spectral_period_63536 write_file_spectral_period 3 63536 NULL
110796 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
110797 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
110798 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
110799 +kvm_write_guest_page_63555 kvm_write_guest_page 2-5 63555 &dbg_leb_write_63555
110800 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
110801 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
110802 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
110803 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
110804 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
110805 +write_debug_level_63613 write_debug_level 3 63613 NULL
110806 +module_alloc_63630 module_alloc 1 63630 NULL
110807 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
110808 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
110809 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 3-5-4 63640 NULL
110810 +ext4_ext_get_access_63642 ext4_ext_get_access 0 63642 NULL
110811 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
110812 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
110813 +ldlm_cli_enqueue_63657 ldlm_cli_enqueue 8 63657 NULL
110814 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
110815 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
110816 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
110817 +write_file_spectral_fft_period_63696 write_file_spectral_fft_period 3 63696 NULL
110818 +bin_search_63697 bin_search 0 63697 NULL
110819 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
110820 +ocfs2_et_root_journal_access_63713 ocfs2_et_root_journal_access 0 63713 NULL
110821 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
110822 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4-0 63720 NULL
110823 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
110824 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
110825 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
110826 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
110827 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2 63778 NULL
110828 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
110829 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
110830 +prepare_copy_63826 prepare_copy 2 63826 NULL
110831 +sel_write_load_63830 sel_write_load 3 63830 NULL
110832 +ll_readlink_63836 ll_readlink 3 63836 NULL
110833 +IsSectionWritable_63842 IsSectionWritable 0 63842 NULL
110834 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
110835 +divas_write_63901 divas_write 3 63901 NULL
110836 +IsOffsetWritable_63902 IsOffsetWritable 0 63902 NULL nohasharray
110837 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 &IsOffsetWritable_63902
110838 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-2-3 63922 NULL
110839 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
110840 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
110841 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
110842 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
110843 +__team_options_register_63941 __team_options_register 3 63941 NULL
110844 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
110845 +generic_acl_init_63955 generic_acl_init 0 63955 NULL
110846 +domain_pfn_mapping_63957 domain_pfn_mapping 4 63957 NULL
110847 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
110848 +rs_extent_to_bm_page_63996 rs_extent_to_bm_page 0-1 63996 NULL
110849 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
110850 +hfsplus_security_setxattr_64009 hfsplus_security_setxattr 4 64009 NULL
110851 +C_SYSC_sendfile64_64017 C_SYSC_sendfile64 4 64017 NULL
110852 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
110853 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL
110854 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
110855 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
110856 +SyS_fsetxattr_64039 SyS_fsetxattr 4 64039 NULL
110857 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
110858 +__sock_create_64069 __sock_create 0 64069 NULL
110859 +get_u8_64076 get_u8 0 64076 NULL
110860 +xilly_malloc_64077 xilly_malloc 2 64077 NULL
110861 +btrfs_copy_root_64079 btrfs_copy_root 0 64079 NULL
110862 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
110863 +clear_update_marker_64088 clear_update_marker 0 64088 NULL nohasharray
110864 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 &clear_update_marker_64088
110865 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
110866 +SyS_set_mempolicy_64096 SyS_set_mempolicy 3 64096 NULL
110867 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
110868 +rdma_addr_size_64116 rdma_addr_size 0 64116 NULL
110869 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
110870 +bypass_wd_write_64120 bypass_wd_write 3 64120 NULL
110871 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
110872 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
110873 +init_bch_64130 init_bch 2-1 64130 NULL
110874 +SYSC_ptrace_64136 SYSC_ptrace 3 64136 NULL
110875 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
110876 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
110877 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
110878 +cpumask_scnprintf_64170 cpumask_scnprintf 0-2 64170 NULL
110879 +ocfs2_reserve_blocks_for_rec_trunc_64206 ocfs2_reserve_blocks_for_rec_trunc 0 64206 NULL
110880 +xfs_vm_direct_IO_64223 xfs_vm_direct_IO 4 64223 NULL
110881 +read_pulse_64227 read_pulse 0-3 64227 NULL
110882 +ea_len_64229 ea_len 0 64229 NULL
110883 +btrfs_make_block_group_64241 btrfs_make_block_group 0 64241 NULL
110884 +__btrfs_update_delayed_inode_64248 __btrfs_update_delayed_inode 0 64248 NULL
110885 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
110886 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
110887 +btrfs_next_item_64285 btrfs_next_item 0 64285 NULL
110888 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
110889 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
110890 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
110891 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
110892 +snd_hda_get_sub_nodes_64304 snd_hda_get_sub_nodes 0 64304 NULL
110893 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
110894 +ffz_64324 ffz 0-1 64324 NULL
110895 +map_region_64328 map_region 1 64328 NULL
110896 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
110897 +ts_write_64336 ts_write 3 64336 NULL
110898 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
110899 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
110900 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
110901 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
110902 +user_regset_copyin_64360 user_regset_copyin 7 64360 NULL
110903 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
110904 +reg_create_64372 reg_create 5 64372 NULL
110905 +ilo_write_64378 ilo_write 3 64378 NULL
110906 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
110907 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
110908 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
110909 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
110910 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
110911 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
110912 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
110913 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
110914 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
110915 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
110916 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
110917 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
110918 +ax25_recvmsg_64441 ax25_recvmsg 4 64441 NULL
110919 +single_open_size_64483 single_open_size 4 64483 NULL
110920 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
110921 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
110922 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
110923 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
110924 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
110925 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
110926 +iwl_dbgfs_ucode_tracing_write_64524 iwl_dbgfs_ucode_tracing_write 3 64524 NULL
110927 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
110928 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
110929 +SyS_bind_64544 SyS_bind 3 64544 NULL
110930 +rbd_obj_read_sync_64554 rbd_obj_read_sync 4-3 64554 NULL
110931 +__btrfs_prealloc_file_range_64557 __btrfs_prealloc_file_range 3-0 64557 NULL
110932 +__spi_sync_64561 __spi_sync 0 64561 NULL nohasharray
110933 +ll_max_rw_chunk_seq_write_64561 ll_max_rw_chunk_seq_write 3 64561 &__spi_sync_64561
110934 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
110935 +kstrtoul_from_user_64569 kstrtoul_from_user 2 64569 NULL
110936 +do_erase_64574 do_erase 4 64574 NULL
110937 +fanotify_write_64623 fanotify_write 3 64623 NULL
110938 +ocfs2_remove_refcount_extent_64631 ocfs2_remove_refcount_extent 0 64631 NULL
110939 +to_dblock_64655 to_dblock 0-1 64655 NULL
110940 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
110941 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
110942 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661 nohasharray
110943 +pool_create_64661 pool_create 3 64661 &tlbflush_read_file_64661
110944 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
110945 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
110946 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
110947 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL nohasharray
110948 +mremap_to_64691 mremap_to 0-3 64691 &sec_bulk_write_64691
110949 +pfn_to_hpa_64703 pfn_to_hpa 0-1 64703 NULL
110950 +ip_select_ident_more_64707 ip_select_ident_more 4 64707 NULL
110951 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
110952 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
110953 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
110954 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
110955 +AscGetChipVersion_64737 AscGetChipVersion 0 64737 NULL
110956 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
110957 +perf_swevent_event_64745 perf_swevent_event 2 64745 NULL
110958 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
110959 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
110960 +message_for_md_64777 message_for_md 5 64777 NULL
110961 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
110962 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
110963 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
110964 +rfkill_fop_write_64808 rfkill_fop_write 3 64808 NULL
110965 +proc_projid_map_write_64810 proc_projid_map_write 3 64810 NULL
110966 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
110967 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
110968 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
110969 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
110970 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
110971 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
110972 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
110973 +lprocfs_write_u64_helper_64880 lprocfs_write_u64_helper 2 64880 NULL
110974 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
110975 +mk_pid_64894 mk_pid 0-3 64894 NULL
110976 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
110977 +usb_reset_and_verify_device_64933 usb_reset_and_verify_device 0 64933 NULL
110978 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
110979 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
110980 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
110981 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
110982 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
110983 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
110984 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
110985 +insert_dent_65034 insert_dent 7 65034 NULL
110986 +snd_hda_get_pin_label_65035 snd_hda_get_pin_label 5 65035 NULL
110987 +ext4_ind_trans_blocks_65053 ext4_ind_trans_blocks 0-2 65053 NULL
110988 +pcibios_enable_device_65059 pcibios_enable_device 0 65059 NULL
110989 +make_idx_node_65068 make_idx_node 0 65068 NULL
110990 +count_run_65072 count_run 0-2-4-5 65072 NULL
110991 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
110992 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
110993 +send_create_inode_65090 send_create_inode 0 65090 NULL nohasharray
110994 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 &send_create_inode_65090
110995 +uasp_alloc_cmd_65097 uasp_alloc_cmd 0 65097 NULL
110996 +__ext3_journal_dirty_metadata_65103 __ext3_journal_dirty_metadata 0 65103 NULL
110997 +generic_ocp_write_65107 generic_ocp_write 4 65107 NULL
110998 +kswapd_shrink_zone_65174 kswapd_shrink_zone 4 65174 NULL
110999 +i2c_smbus_xfer_emulated_65183 i2c_smbus_xfer_emulated 0 65183 NULL
111000 +btrfs_run_delayed_items_nr_65204 btrfs_run_delayed_items_nr 0 65204 NULL
111001 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
111002 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
111003 +journal_get_write_access_65243 journal_get_write_access 0 65243 NULL
111004 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
111005 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
111006 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
111007 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
111008 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
111009 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
111010 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
111011 +get_var_len_65304 get_var_len 0 65304 NULL
111012 +unpack_array_65318 unpack_array 0 65318 NULL
111013 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
111014 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
111015 +init_list_set_65351 init_list_set 3-2 65351 NULL
111016 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
111017 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
111018 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
111019 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
111020 +SyS_writev_65372 SyS_writev 3 65372 NULL
111021 +mi_set_context_65395 mi_set_context 0 65395 NULL
111022 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
111023 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
111024 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
111025 +__read_vmcore_65402 __read_vmcore 2 65402 NULL
111026 +usb_ep_enable_65405 usb_ep_enable 0 65405 NULL
111027 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 4-3 65410 NULL
111028 +drm_calloc_large_65421 drm_calloc_large 2-1 65421 NULL
111029 +device_add_groups_65423 device_add_groups 0 65423 NULL
111030 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
111031 +vmalloc_to_pfn_65437 vmalloc_to_pfn 0 65437 NULL
111032 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
111033 +il_dbgfs_wd_timeout_write_65464 il_dbgfs_wd_timeout_write 3 65464 NULL
111034 +ext4_es_zeroout_65465 ext4_es_zeroout 0 65465 NULL
111035 +clear_user_65470 clear_user 2 65470 NULL
111036 +__pcibus_to_node_65489 __pcibus_to_node 0 65489 NULL nohasharray
111037 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 &__pcibus_to_node_65489
111038 +lookup_inline_extent_backref_65493 lookup_inline_extent_backref 9-0 65493 NULL
111039 +qib_create_ctxtdata_65497 qib_create_ctxtdata 3 65497 NULL
111040 +nvme_trans_standard_inquiry_page_65526 nvme_trans_standard_inquiry_page 4 65526 NULL
111041 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
111042 new file mode 100644
111043 index 0000000..50f8464
111044 --- /dev/null
111045 +++ b/tools/gcc/size_overflow_plugin.c
111046 @@ -0,0 +1,4072 @@
111047 +/*
111048 + * Copyright 2011, 2012, 2013, 2014 by Emese Revfy <re.emese@gmail.com>
111049 + * Licensed under the GPL v2, or (at your option) v3
111050 + *
111051 + * Homepage:
111052 + * http://www.grsecurity.net/~ephox/overflow_plugin/
111053 + *
111054 + * Documentation:
111055 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
111056 + *
111057 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
111058 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
111059 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
111060 + *
111061 + * Usage:
111062 + * $ gcc -I`gcc -print-file-name=plugin`/include/c-family -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -ggdb -Wall -W -o size_overflow_plugin.so size_overflow_plugin.c
111063 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
111064 + */
111065 +
111066 +#include "gcc-plugin.h"
111067 +#include "config.h"
111068 +#include "system.h"
111069 +#include "coretypes.h"
111070 +#include "tree.h"
111071 +#include "tree-pass.h"
111072 +#include "intl.h"
111073 +#include "plugin-version.h"
111074 +#include "tm.h"
111075 +#include "toplev.h"
111076 +#include "function.h"
111077 +#include "tree-flow.h"
111078 +#include "plugin.h"
111079 +#include "gimple.h"
111080 +#include "diagnostic.h"
111081 +#include "cfgloop.h"
111082 +
111083 +#if BUILDING_GCC_VERSION >= 4008
111084 +#define TODO_dump_func 0
111085 +#define TODO_dump_cgraph 0
111086 +#endif
111087 +
111088 +#define __unused __attribute__((__unused__))
111089 +#define ASM_NAME(node) IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node))
111090 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
111091 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
111092 +#define BEFORE_STMT true
111093 +#define AFTER_STMT false
111094 +#define CREATE_NEW_VAR NULL_TREE
111095 +#define CODES_LIMIT 32
111096 +#define MAX_PARAM 31
111097 +#define VEC_LEN 128
111098 +#define MY_STMT GF_PLF_1
111099 +#define NO_CAST_CHECK GF_PLF_2
111100 +#define RET_CHECK NULL_TREE
111101 +#define CANNOT_FIND_ARG 32
111102 +#define WRONG_NODE 32
111103 +#define NOT_INTENTIONAL_ASM NULL
111104 +#define MIN_CHECK true
111105 +#define MAX_CHECK false
111106 +
111107 +#define TURN_OFF_ASM_STR "# size_overflow MARK_TURN_OFF "
111108 +#define YES_ASM_STR "# size_overflow MARK_YES "
111109 +#define OK_ASM_STR "# size_overflow "
111110 +
111111 +#if BUILDING_GCC_VERSION == 4005
111112 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
111113 +#endif
111114 +
111115 +struct size_overflow_hash {
111116 + const struct size_overflow_hash * const next;
111117 + const char * const name;
111118 + const unsigned int param;
111119 +};
111120 +
111121 +#include "size_overflow_hash.h"
111122 +
111123 +enum mark {
111124 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
111125 +};
111126 +
111127 +static unsigned int call_count;
111128 +
111129 +struct visited {
111130 + struct visited *next;
111131 + const_tree fndecl;
111132 + unsigned int num;
111133 + const_gimple first_stmt;
111134 +};
111135 +
111136 +struct next_cgraph_node {
111137 + struct next_cgraph_node *next;
111138 + struct cgraph_node *current_function;
111139 + tree callee_fndecl;
111140 + unsigned int num;
111141 +};
111142 +
111143 +struct interesting_node {
111144 + struct interesting_node *next;
111145 + gimple first_stmt;
111146 + const_tree fndecl;
111147 + tree node;
111148 +#if BUILDING_GCC_VERSION <= 4007
111149 + VEC(tree, gc) *last_nodes;
111150 +#else
111151 + vec<tree, va_gc> *last_nodes;
111152 +#endif
111153 + unsigned int num;
111154 + enum mark intentional_attr_decl;
111155 + enum mark intentional_attr_cur_fndecl;
111156 + gimple intentional_mark_from_gimple;
111157 +};
111158 +
111159 +int plugin_is_GPL_compatible;
111160 +void debug_gimple_stmt(gimple gs);
111161 +
111162 +static tree report_size_overflow_decl;
111163 +static const_tree const_char_ptr_type_node;
111164 +
111165 +static tree expand(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs);
111166 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs);
111167 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs);
111168 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs);
111169 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs);
111170 +
111171 +static void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
111172 +static tree get_size_overflow_type(gimple stmt, const_tree node);
111173 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
111174 +
111175 +static struct plugin_info size_overflow_plugin_info = {
111176 + .version = "20140111beta",
111177 + .help = "no-size-overflow\tturn off size overflow checking\n",
111178 +};
111179 +
111180 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
111181 +{
111182 + unsigned int arg_count;
111183 + enum tree_code code = TREE_CODE(*node);
111184 +
111185 + switch (code) {
111186 + case FUNCTION_DECL:
111187 + arg_count = type_num_arguments(TREE_TYPE(*node));
111188 + break;
111189 + case FUNCTION_TYPE:
111190 + case METHOD_TYPE:
111191 + arg_count = type_num_arguments(*node);
111192 + break;
111193 + default:
111194 + *no_add_attrs = true;
111195 + error("%s: %qE attribute only applies to functions", __func__, name);
111196 + return NULL_TREE;
111197 + }
111198 +
111199 + for (; args; args = TREE_CHAIN(args)) {
111200 + tree position = TREE_VALUE(args);
111201 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
111202 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
111203 + *no_add_attrs = true;
111204 + }
111205 + }
111206 + return NULL_TREE;
111207 +}
111208 +
111209 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
111210 +{
111211 + unsigned int arg_count;
111212 + enum tree_code code = TREE_CODE(*node);
111213 +
111214 + switch (code) {
111215 + case FUNCTION_DECL:
111216 + arg_count = type_num_arguments(TREE_TYPE(*node));
111217 + break;
111218 + case FUNCTION_TYPE:
111219 + case METHOD_TYPE:
111220 + arg_count = type_num_arguments(*node);
111221 + break;
111222 + case FIELD_DECL:
111223 + return NULL_TREE;
111224 + default:
111225 + *no_add_attrs = true;
111226 + error("%qE attribute only applies to functions", name);
111227 + return NULL_TREE;
111228 + }
111229 +
111230 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
111231 + return NULL_TREE;
111232 +
111233 + for (; args; args = TREE_CHAIN(args)) {
111234 + tree position = TREE_VALUE(args);
111235 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
111236 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
111237 + *no_add_attrs = true;
111238 + }
111239 + }
111240 + return NULL_TREE;
111241 +}
111242 +
111243 +static struct attribute_spec size_overflow_attr = {
111244 + .name = "size_overflow",
111245 + .min_length = 1,
111246 + .max_length = -1,
111247 + .decl_required = true,
111248 + .type_required = false,
111249 + .function_type_required = false,
111250 + .handler = handle_size_overflow_attribute,
111251 +#if BUILDING_GCC_VERSION >= 4007
111252 + .affects_type_identity = false
111253 +#endif
111254 +};
111255 +
111256 +static struct attribute_spec intentional_overflow_attr = {
111257 + .name = "intentional_overflow",
111258 + .min_length = 1,
111259 + .max_length = -1,
111260 + .decl_required = true,
111261 + .type_required = false,
111262 + .function_type_required = false,
111263 + .handler = handle_intentional_overflow_attribute,
111264 +#if BUILDING_GCC_VERSION >= 4007
111265 + .affects_type_identity = false
111266 +#endif
111267 +};
111268 +
111269 +static void register_attributes(void __unused *event_data, void __unused *data)
111270 +{
111271 + register_attribute(&size_overflow_attr);
111272 + register_attribute(&intentional_overflow_attr);
111273 +}
111274 +
111275 +static bool is_bool(const_tree node)
111276 +{
111277 + const_tree type;
111278 +
111279 + if (node == NULL_TREE)
111280 + return false;
111281 +
111282 + type = TREE_TYPE(node);
111283 + if (!INTEGRAL_TYPE_P(type))
111284 + return false;
111285 + if (TREE_CODE(type) == BOOLEAN_TYPE)
111286 + return true;
111287 + if (TYPE_PRECISION(type) == 1)
111288 + return true;
111289 + return false;
111290 +}
111291 +
111292 +static bool skip_types(const_tree var)
111293 +{
111294 + tree type;
111295 + enum tree_code code;
111296 +
111297 + if (is_gimple_constant(var))
111298 + return true;
111299 +
111300 + switch (TREE_CODE(var)) {
111301 + case ADDR_EXPR:
111302 +#if BUILDING_GCC_VERSION >= 4006
111303 + case MEM_REF:
111304 +#endif
111305 + case ARRAY_REF:
111306 + case BIT_FIELD_REF:
111307 + case INDIRECT_REF:
111308 + case TARGET_MEM_REF:
111309 + case COMPONENT_REF:
111310 + case VAR_DECL:
111311 + case VIEW_CONVERT_EXPR:
111312 + return true;
111313 + default:
111314 + break;
111315 + }
111316 +
111317 + code = TREE_CODE(var);
111318 + gcc_assert(code == SSA_NAME || code == PARM_DECL);
111319 +
111320 + type = TREE_TYPE(var);
111321 + switch (TREE_CODE(type)) {
111322 + case INTEGER_TYPE:
111323 + case ENUMERAL_TYPE:
111324 + return false;
111325 + case BOOLEAN_TYPE:
111326 + return is_bool(var);
111327 + default:
111328 + return true;
111329 + }
111330 +}
111331 +
111332 +static inline gimple get_def_stmt(const_tree node)
111333 +{
111334 + gcc_assert(node != NULL_TREE);
111335 +
111336 + if (skip_types(node))
111337 + return NULL;
111338 +
111339 + if (TREE_CODE(node) != SSA_NAME)
111340 + return NULL;
111341 + return SSA_NAME_DEF_STMT(node);
111342 +}
111343 +
111344 +static unsigned char get_tree_code(const_tree type)
111345 +{
111346 + switch (TREE_CODE(type)) {
111347 + case ARRAY_TYPE:
111348 + return 0;
111349 + case BOOLEAN_TYPE:
111350 + return 1;
111351 + case ENUMERAL_TYPE:
111352 + return 2;
111353 + case FUNCTION_TYPE:
111354 + return 3;
111355 + case INTEGER_TYPE:
111356 + return 4;
111357 + case POINTER_TYPE:
111358 + return 5;
111359 + case RECORD_TYPE:
111360 + return 6;
111361 + case UNION_TYPE:
111362 + return 7;
111363 + case VOID_TYPE:
111364 + return 8;
111365 + case REAL_TYPE:
111366 + return 9;
111367 + case VECTOR_TYPE:
111368 + return 10;
111369 + case REFERENCE_TYPE:
111370 + return 11;
111371 + case OFFSET_TYPE:
111372 + return 12;
111373 + case COMPLEX_TYPE:
111374 + return 13;
111375 + default:
111376 + debug_tree((tree)type);
111377 + gcc_unreachable();
111378 + }
111379 +}
111380 +
111381 +struct function_hash {
111382 + size_t tree_codes_len;
111383 + unsigned char tree_codes[CODES_LIMIT];
111384 + tree fndecl;
111385 + unsigned int hash;
111386 +};
111387 +
111388 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
111389 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
111390 +{
111391 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
111392 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
111393 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
111394 +
111395 + unsigned int m = 0x57559429;
111396 + unsigned int n = 0x5052acdb;
111397 + const unsigned int *key4 = (const unsigned int *)key;
111398 + unsigned int h = len;
111399 + unsigned int k = len + seed + n;
111400 + unsigned long long p;
111401 +
111402 + while (len >= 8) {
111403 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
111404 + len -= 8;
111405 + }
111406 + if (len >= 4) {
111407 + cwmixb(key4[0]) key4 += 1;
111408 + len -= 4;
111409 + }
111410 + if (len)
111411 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
111412 + cwmixb(h ^ (k + n));
111413 + return k ^ h;
111414 +
111415 +#undef cwfold
111416 +#undef cwmixa
111417 +#undef cwmixb
111418 +}
111419 +
111420 +static void set_hash(const char *fn_name, struct function_hash *fn_hash_data)
111421 +{
111422 + unsigned int fn, codes, seed = 0;
111423 +
111424 + fn = CrapWow(fn_name, strlen(fn_name), seed) & 0xffff;
111425 + codes = CrapWow((const char*)fn_hash_data->tree_codes, fn_hash_data->tree_codes_len, seed) & 0xffff;
111426 +
111427 + fn_hash_data->hash = fn ^ codes;
111428 +}
111429 +
111430 +static void set_node_codes(const_tree type, struct function_hash *fn_hash_data)
111431 +{
111432 + gcc_assert(type != NULL_TREE);
111433 + gcc_assert(TREE_CODE_CLASS(TREE_CODE(type)) == tcc_type);
111434 +
111435 + while (type && fn_hash_data->tree_codes_len < CODES_LIMIT) {
111436 + fn_hash_data->tree_codes[fn_hash_data->tree_codes_len] = get_tree_code(type);
111437 + fn_hash_data->tree_codes_len++;
111438 + type = TREE_TYPE(type);
111439 + }
111440 +}
111441 +
111442 +static void set_result_codes(const_tree node, struct function_hash *fn_hash_data)
111443 +{
111444 + const_tree result;
111445 +
111446 + gcc_assert(node != NULL_TREE);
111447 +
111448 + if (DECL_P(node)) {
111449 + result = DECL_RESULT(node);
111450 + if (result != NULL_TREE)
111451 + return set_node_codes(TREE_TYPE(result), fn_hash_data);
111452 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
111453 + }
111454 +
111455 + gcc_assert(TYPE_P(node));
111456 +
111457 + if (TREE_CODE(node) == FUNCTION_TYPE)
111458 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
111459 +
111460 + return set_node_codes(node, fn_hash_data);
111461 +}
111462 +
111463 +static void set_function_codes(struct function_hash *fn_hash_data)
111464 +{
111465 + const_tree arg, type = TREE_TYPE(fn_hash_data->fndecl);
111466 + enum tree_code code = TREE_CODE(type);
111467 +
111468 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
111469 +
111470 + set_result_codes(fn_hash_data->fndecl, fn_hash_data);
111471 +
111472 + for (arg = TYPE_ARG_TYPES(type); arg != NULL_TREE && fn_hash_data->tree_codes_len < CODES_LIMIT; arg = TREE_CHAIN(arg))
111473 + set_node_codes(TREE_VALUE(arg), fn_hash_data);
111474 +}
111475 +
111476 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
111477 +{
111478 + const struct size_overflow_hash *entry;
111479 + struct function_hash fn_hash_data;
111480 + const char *func_name;
111481 +
111482 + // skip builtins __builtin_constant_p
111483 + if (DECL_BUILT_IN(fndecl))
111484 + return NULL;
111485 +
111486 + fn_hash_data.fndecl = fndecl;
111487 + fn_hash_data.tree_codes_len = 0;
111488 +
111489 + set_function_codes(&fn_hash_data);
111490 + gcc_assert(fn_hash_data.tree_codes_len != 0);
111491 +
111492 + func_name = ASM_NAME(fn_hash_data.fndecl);
111493 + set_hash(func_name, &fn_hash_data);
111494 +
111495 + entry = size_overflow_hash[fn_hash_data.hash];
111496 +
111497 + while (entry) {
111498 + if (!strcmp(entry->name, func_name))
111499 + return entry;
111500 + entry = entry->next;
111501 + }
111502 + return NULL;
111503 +}
111504 +
111505 +static void print_missing_msg(tree func, unsigned int argnum)
111506 +{
111507 + location_t loc;
111508 + const char *curfunc;
111509 + struct function_hash fn_hash_data;
111510 +
111511 + fn_hash_data.fndecl = DECL_ORIGIN(func);
111512 + fn_hash_data.tree_codes_len = 0;
111513 +
111514 + loc = DECL_SOURCE_LOCATION(fn_hash_data.fndecl);
111515 + curfunc = ASM_NAME(fn_hash_data.fndecl);
111516 +
111517 + set_function_codes(&fn_hash_data);
111518 + set_hash(curfunc, &fn_hash_data);
111519 +
111520 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, fn_hash_data.hash);
111521 +}
111522 +
111523 +static unsigned int find_arg_number_tree(const_tree arg, const_tree func)
111524 +{
111525 + tree var;
111526 + unsigned int argnum = 1;
111527 +
111528 + if (TREE_CODE(arg) == SSA_NAME)
111529 + arg = SSA_NAME_VAR(arg);
111530 +
111531 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
111532 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
111533 + continue;
111534 + if (!skip_types(var))
111535 + return argnum;
111536 + }
111537 +
111538 + return CANNOT_FIND_ARG;
111539 +}
111540 +
111541 +static tree create_new_var(tree type)
111542 +{
111543 + tree new_var = create_tmp_var(type, "cicus");
111544 +
111545 +#if BUILDING_GCC_VERSION <= 4007
111546 + add_referenced_var(new_var);
111547 +#endif
111548 + return new_var;
111549 +}
111550 +
111551 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
111552 +{
111553 + gimple assign;
111554 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111555 + tree type = TREE_TYPE(rhs1);
111556 + tree lhs = create_new_var(type);
111557 +
111558 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
111559 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
111560 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
111561 +
111562 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
111563 + update_stmt(assign);
111564 + gimple_set_plf(assign, MY_STMT, true);
111565 + return assign;
111566 +}
111567 +
111568 +static tree cast_a_tree(tree type, tree var)
111569 +{
111570 + gcc_assert(type != NULL_TREE);
111571 + gcc_assert(var != NULL_TREE);
111572 + gcc_assert(fold_convertible_p(type, var));
111573 +
111574 + return fold_convert(type, var);
111575 +}
111576 +
111577 +static tree get_lhs(const_gimple stmt)
111578 +{
111579 + switch (gimple_code(stmt)) {
111580 + case GIMPLE_ASSIGN:
111581 + case GIMPLE_CALL:
111582 + return gimple_get_lhs(stmt);
111583 + case GIMPLE_PHI:
111584 + return gimple_phi_result(stmt);
111585 + default:
111586 + return NULL_TREE;
111587 + }
111588 +}
111589 +
111590 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
111591 +{
111592 + const_gimple def_stmt = get_def_stmt(rhs);
111593 +
111594 + if (force)
111595 + return false;
111596 +
111597 + if (is_gimple_constant(rhs))
111598 + return false;
111599 +
111600 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
111601 + return false;
111602 +
111603 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
111604 + return false;
111605 +
111606 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
111607 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
111608 + return false;
111609 +
111610 + return true;
111611 +}
111612 +
111613 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
111614 +{
111615 + gimple assign, def_stmt;
111616 +
111617 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
111618 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
111619 + gcc_unreachable();
111620 +
111621 + def_stmt = get_def_stmt(rhs);
111622 + if (def_stmt && gimple_code(def_stmt) != GIMPLE_NOP && skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
111623 + return def_stmt;
111624 +
111625 + if (lhs == CREATE_NEW_VAR)
111626 + lhs = create_new_var(dst_type);
111627 +
111628 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
111629 +
111630 + if (!gsi_end_p(*gsi)) {
111631 + location_t loc = gimple_location(gsi_stmt(*gsi));
111632 + gimple_set_location(assign, loc);
111633 + }
111634 +
111635 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
111636 +
111637 + if (before)
111638 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
111639 + else
111640 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
111641 + update_stmt(assign);
111642 + return assign;
111643 +}
111644 +
111645 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
111646 +{
111647 + gimple_stmt_iterator gsi;
111648 + tree lhs;
111649 + gimple new_stmt;
111650 +
111651 + if (rhs == NULL_TREE)
111652 + return NULL_TREE;
111653 +
111654 + gsi = gsi_for_stmt(stmt);
111655 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
111656 + gimple_set_plf(new_stmt, MY_STMT, true);
111657 +
111658 + lhs = get_lhs(new_stmt);
111659 + gcc_assert(lhs != NULL_TREE);
111660 + return lhs;
111661 +}
111662 +
111663 +static tree cast_to_TI_type(gimple stmt, tree node)
111664 +{
111665 + gimple_stmt_iterator gsi;
111666 + gimple cast_stmt;
111667 + tree type = TREE_TYPE(node);
111668 +
111669 + if (types_compatible_p(type, intTI_type_node))
111670 + return node;
111671 +
111672 + gsi = gsi_for_stmt(stmt);
111673 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
111674 + gimple_set_plf(cast_stmt, MY_STMT, true);
111675 + return gimple_assign_lhs(cast_stmt);
111676 +}
111677 +
111678 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
111679 +{
111680 + tree lhs, new_lhs;
111681 + gimple_stmt_iterator gsi;
111682 +
111683 + if (rhs1 == NULL_TREE) {
111684 + debug_gimple_stmt(oldstmt);
111685 + error("%s: rhs1 is NULL_TREE", __func__);
111686 + gcc_unreachable();
111687 + }
111688 +
111689 + switch (gimple_code(oldstmt)) {
111690 + case GIMPLE_ASM:
111691 + lhs = rhs1;
111692 + break;
111693 + case GIMPLE_CALL:
111694 + case GIMPLE_ASSIGN:
111695 + lhs = gimple_get_lhs(oldstmt);
111696 + break;
111697 + default:
111698 + debug_gimple_stmt(oldstmt);
111699 + gcc_unreachable();
111700 + }
111701 +
111702 + gsi = gsi_for_stmt(oldstmt);
111703 + pointer_set_insert(visited, oldstmt);
111704 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
111705 + basic_block next_bb, cur_bb;
111706 + const_edge e;
111707 +
111708 + gcc_assert(before == false);
111709 + gcc_assert(stmt_can_throw_internal(oldstmt));
111710 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
111711 + gcc_assert(!gsi_end_p(gsi));
111712 +
111713 + cur_bb = gimple_bb(oldstmt);
111714 + next_bb = cur_bb->next_bb;
111715 + e = find_edge(cur_bb, next_bb);
111716 + gcc_assert(e != NULL);
111717 + gcc_assert(e->flags & EDGE_FALLTHRU);
111718 +
111719 + gsi = gsi_after_labels(next_bb);
111720 + gcc_assert(!gsi_end_p(gsi));
111721 +
111722 + before = true;
111723 + oldstmt = gsi_stmt(gsi);
111724 + }
111725 +
111726 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
111727 + return new_lhs;
111728 +}
111729 +
111730 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
111731 +{
111732 + gimple stmt;
111733 + gimple_stmt_iterator gsi;
111734 + tree size_overflow_type, new_var, lhs = gimple_assign_lhs(oldstmt);
111735 +
111736 + if (gimple_plf(oldstmt, MY_STMT))
111737 + return lhs;
111738 +
111739 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
111740 + rhs1 = gimple_assign_rhs1(oldstmt);
111741 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
111742 + }
111743 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
111744 + rhs2 = gimple_assign_rhs2(oldstmt);
111745 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
111746 + }
111747 +
111748 + stmt = gimple_copy(oldstmt);
111749 + gimple_set_location(stmt, gimple_location(oldstmt));
111750 + gimple_set_plf(stmt, MY_STMT, true);
111751 +
111752 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
111753 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
111754 +
111755 + size_overflow_type = get_size_overflow_type(oldstmt, node);
111756 +
111757 + new_var = create_new_var(size_overflow_type);
111758 + new_var = make_ssa_name(new_var, stmt);
111759 + gimple_assign_set_lhs(stmt, new_var);
111760 +
111761 + if (rhs1 != NULL_TREE)
111762 + gimple_assign_set_rhs1(stmt, rhs1);
111763 +
111764 + if (rhs2 != NULL_TREE)
111765 + gimple_assign_set_rhs2(stmt, rhs2);
111766 +#if BUILDING_GCC_VERSION >= 4007
111767 + if (rhs3 != NULL_TREE)
111768 + gimple_assign_set_rhs3(stmt, rhs3);
111769 +#endif
111770 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
111771 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
111772 +
111773 + gsi = gsi_for_stmt(oldstmt);
111774 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
111775 + update_stmt(stmt);
111776 + pointer_set_insert(visited, oldstmt);
111777 + return gimple_assign_lhs(stmt);
111778 +}
111779 +
111780 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type, basic_block bb)
111781 +{
111782 + gimple assign;
111783 + gimple_stmt_iterator gsi;
111784 + basic_block first_bb;
111785 +
111786 + gcc_assert(SSA_NAME_IS_DEFAULT_DEF(arg));
111787 +
111788 + if (bb->index == 0) {
111789 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
111790 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
111791 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
111792 + bb = first_bb;
111793 + }
111794 +
111795 + gsi = gsi_after_labels(bb);
111796 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
111797 + gimple_set_plf(assign, MY_STMT, true);
111798 +
111799 + return gimple_assign_lhs(assign);
111800 +}
111801 +
111802 +static tree use_phi_ssa_name(tree ssa_name_var, tree new_arg)
111803 +{
111804 + gimple_stmt_iterator gsi;
111805 + gimple assign, def_stmt = get_def_stmt(new_arg);
111806 +
111807 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
111808 + gsi = gsi_after_labels(gimple_bb(def_stmt));
111809 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, BEFORE_STMT, true);
111810 + } else {
111811 + gsi = gsi_for_stmt(def_stmt);
111812 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, AFTER_STMT, true);
111813 + }
111814 +
111815 + gimple_set_plf(assign, MY_STMT, true);
111816 + return gimple_assign_lhs(assign);
111817 +}
111818 +
111819 +static tree cast_visited_phi_arg(tree ssa_name_var, tree arg, tree size_overflow_type)
111820 +{
111821 + basic_block bb;
111822 + gimple_stmt_iterator gsi;
111823 + const_gimple def_stmt;
111824 + gimple assign;
111825 +
111826 + def_stmt = get_def_stmt(arg);
111827 + bb = gimple_bb(def_stmt);
111828 + gcc_assert(bb->index != 0);
111829 + gsi = gsi_after_labels(bb);
111830 +
111831 + assign = build_cast_stmt(size_overflow_type, arg, ssa_name_var, &gsi, BEFORE_STMT, false);
111832 + gimple_set_plf(assign, MY_STMT, true);
111833 + return gimple_assign_lhs(assign);
111834 +}
111835 +
111836 +static tree create_new_phi_arg(tree ssa_name_var, tree new_arg, gimple oldstmt, unsigned int i)
111837 +{
111838 + tree size_overflow_type;
111839 + tree arg;
111840 + const_gimple def_stmt;
111841 +
111842 + if (new_arg != NULL_TREE && is_gimple_constant(new_arg))
111843 + return new_arg;
111844 +
111845 + arg = gimple_phi_arg_def(oldstmt, i);
111846 + def_stmt = get_def_stmt(arg);
111847 + gcc_assert(def_stmt != NULL);
111848 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
111849 +
111850 + switch (gimple_code(def_stmt)) {
111851 + case GIMPLE_PHI:
111852 + return cast_visited_phi_arg(ssa_name_var, arg, size_overflow_type);
111853 + case GIMPLE_NOP: {
111854 + basic_block bb;
111855 +
111856 + bb = gimple_phi_arg_edge(oldstmt, i)->src;
111857 + return cast_parm_decl(ssa_name_var, arg, size_overflow_type, bb);
111858 + }
111859 + case GIMPLE_ASM: {
111860 + gimple_stmt_iterator gsi;
111861 + gimple assign, stmt = get_def_stmt(arg);
111862 +
111863 + gsi = gsi_for_stmt(stmt);
111864 + assign = build_cast_stmt(size_overflow_type, arg, ssa_name_var, &gsi, AFTER_STMT, false);
111865 + gimple_set_plf(assign, MY_STMT, true);
111866 + return gimple_assign_lhs(assign);
111867 + }
111868 + default:
111869 + gcc_assert(new_arg != NULL_TREE);
111870 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
111871 + return use_phi_ssa_name(ssa_name_var, new_arg);
111872 + }
111873 +}
111874 +
111875 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
111876 +{
111877 + basic_block bb;
111878 + gimple phi;
111879 + gimple_seq seq;
111880 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
111881 +
111882 + bb = gsi_bb(gsi);
111883 +
111884 + if (result == NULL_TREE) {
111885 + tree old_result = gimple_phi_result(oldstmt);
111886 + tree size_overflow_type = get_size_overflow_type(oldstmt, old_result);
111887 +
111888 + result = create_new_var(size_overflow_type);
111889 + }
111890 +
111891 + phi = create_phi_node(result, bb);
111892 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
111893 + seq = phi_nodes(bb);
111894 + gsi = gsi_last(seq);
111895 + gsi_remove(&gsi, false);
111896 +
111897 + gsi = gsi_for_stmt(oldstmt);
111898 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
111899 + gimple_set_bb(phi, bb);
111900 + gimple_set_plf(phi, MY_STMT, true);
111901 + return phi;
111902 +}
111903 +
111904 +#if BUILDING_GCC_VERSION <= 4007
111905 +static tree create_new_phi_node(VEC(tree, gc) *args, tree ssa_name_var, gimple oldstmt)
111906 +#else
111907 +static tree create_new_phi_node(vec<tree, va_gc> *args, tree ssa_name_var, gimple oldstmt)
111908 +#endif
111909 +{
111910 + gimple new_phi;
111911 + unsigned int i;
111912 + tree arg, result;
111913 + location_t loc = gimple_location(oldstmt);
111914 +
111915 +#if BUILDING_GCC_VERSION <= 4007
111916 + gcc_assert(!VEC_empty(tree, args));
111917 +#else
111918 + gcc_assert(!args->is_empty());
111919 +#endif
111920 +
111921 + new_phi = overflow_create_phi_node(oldstmt, ssa_name_var);
111922 + result = gimple_phi_result(new_phi);
111923 + ssa_name_var = SSA_NAME_VAR(result);
111924 +
111925 +
111926 +#if BUILDING_GCC_VERSION == 4005
111927 + for (i = 0; i < VEC_length(tree, args); i++) {
111928 + arg = VEC_index(tree, args, i);
111929 +#elif BUILDING_GCC_VERSION <= 4007
111930 + FOR_EACH_VEC_ELT(tree, args, i, arg) {
111931 +#else
111932 + FOR_EACH_VEC_ELT(*args, i, arg) {
111933 +#endif
111934 + arg = create_new_phi_arg(ssa_name_var, arg, oldstmt, i);
111935 + add_phi_arg(new_phi, arg, gimple_phi_arg_edge(oldstmt, i), loc);
111936 + }
111937 +
111938 +#if BUILDING_GCC_VERSION <= 4007
111939 + VEC_free(tree, gc, args);
111940 +#else
111941 + vec_free(args);
111942 +#endif
111943 + update_stmt(new_phi);
111944 + return result;
111945 +}
111946 +
111947 +static tree handle_phi(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree orig_result)
111948 +{
111949 + tree ssa_name_var = NULL_TREE;
111950 +#if BUILDING_GCC_VERSION <= 4007
111951 + VEC(tree, gc) *args;
111952 +#else
111953 + vec<tree, va_gc> *args;
111954 +#endif
111955 + gimple oldstmt = get_def_stmt(orig_result);
111956 + unsigned int i, len = gimple_phi_num_args(oldstmt);
111957 +
111958 + pointer_set_insert(visited, oldstmt);
111959 +#if BUILDING_GCC_VERSION <= 4007
111960 + args = VEC_alloc(tree, gc, len);
111961 +#else
111962 + vec_alloc(args, len);
111963 +#endif
111964 + for (i = 0; i < len; i++) {
111965 + tree arg, new_arg;
111966 +
111967 + arg = gimple_phi_arg_def(oldstmt, i);
111968 + new_arg = expand(visited, caller_node, arg);
111969 +
111970 + if (ssa_name_var == NULL_TREE && new_arg != NULL_TREE)
111971 + ssa_name_var = SSA_NAME_VAR(new_arg);
111972 +
111973 + if (is_gimple_constant(arg)) {
111974 + tree size_overflow_type = get_size_overflow_type(oldstmt, arg);
111975 +
111976 + new_arg = cast_a_tree(size_overflow_type, arg);
111977 + }
111978 +
111979 +#if BUILDING_GCC_VERSION <= 4007
111980 + VEC_safe_push(tree, gc, args, new_arg);
111981 +#else
111982 + vec_safe_push(args, new_arg);
111983 +#endif
111984 + }
111985 +
111986 + return create_new_phi_node(args, ssa_name_var, oldstmt);
111987 +}
111988 +
111989 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
111990 +{
111991 + gimple assign;
111992 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111993 + tree origtype = TREE_TYPE(orig_rhs);
111994 +
111995 + gcc_assert(is_gimple_assign(stmt));
111996 +
111997 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
111998 + gimple_set_plf(assign, MY_STMT, true);
111999 + return gimple_assign_lhs(assign);
112000 +}
112001 +
112002 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
112003 +{
112004 + const_tree rhs1, lhs, rhs1_type, lhs_type;
112005 + enum machine_mode lhs_mode, rhs_mode;
112006 + gimple def_stmt = get_def_stmt(no_const_rhs);
112007 +
112008 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
112009 + return false;
112010 +
112011 + rhs1 = gimple_assign_rhs1(def_stmt);
112012 + lhs = gimple_assign_lhs(def_stmt);
112013 + rhs1_type = TREE_TYPE(rhs1);
112014 + lhs_type = TREE_TYPE(lhs);
112015 + rhs_mode = TYPE_MODE(rhs1_type);
112016 + lhs_mode = TYPE_MODE(lhs_type);
112017 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
112018 + return false;
112019 +
112020 + return true;
112021 +}
112022 +
112023 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
112024 +{
112025 + tree rhs1 = gimple_assign_rhs1(stmt);
112026 + tree lhs = gimple_assign_lhs(stmt);
112027 + const_tree rhs1_type = TREE_TYPE(rhs1);
112028 + const_tree lhs_type = TREE_TYPE(lhs);
112029 +
112030 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
112031 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112032 +
112033 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
112034 +}
112035 +
112036 +static bool no_uses(tree node)
112037 +{
112038 + imm_use_iterator imm_iter;
112039 + use_operand_p use_p;
112040 +
112041 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
112042 + const_gimple use_stmt = USE_STMT(use_p);
112043 +
112044 + if (use_stmt == NULL)
112045 + return true;
112046 + if (is_gimple_debug(use_stmt))
112047 + continue;
112048 + return false;
112049 + }
112050 + return true;
112051 +}
112052 +
112053 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
112054 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
112055 +{
112056 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
112057 + gimple def_stmt = get_def_stmt(lhs);
112058 +
112059 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
112060 + return false;
112061 +
112062 + rhs1 = gimple_assign_rhs1(def_stmt);
112063 + rhs_type = TREE_TYPE(rhs1);
112064 + lhs_type = TREE_TYPE(lhs);
112065 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
112066 + return false;
112067 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
112068 + return false;
112069 +
112070 + def_stmt = get_def_stmt(rhs1);
112071 + if (!def_stmt || !is_gimple_assign(def_stmt) || gimple_num_ops(def_stmt) != 3)
112072 + return false;
112073 +
112074 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
112075 + return false;
112076 +
112077 + rhs1 = gimple_assign_rhs1(def_stmt);
112078 + rhs2 = gimple_assign_rhs2(def_stmt);
112079 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
112080 + return false;
112081 +
112082 + if (is_gimple_constant(rhs2))
112083 + not_const_rhs = rhs1;
112084 + else
112085 + not_const_rhs = rhs2;
112086 +
112087 + return no_uses(not_const_rhs);
112088 +}
112089 +
112090 +static bool skip_lhs_cast_check(const_gimple stmt)
112091 +{
112092 + const_tree rhs = gimple_assign_rhs1(stmt);
112093 + const_gimple def_stmt = get_def_stmt(rhs);
112094 +
112095 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
112096 + if (gimple_code(def_stmt) == GIMPLE_ASM)
112097 + return true;
112098 +
112099 + if (is_const_plus_unsigned_signed_truncation(rhs))
112100 + return true;
112101 +
112102 + return false;
112103 +}
112104 +
112105 +static tree create_cast_overflow_check(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree new_rhs1, gimple stmt)
112106 +{
112107 + bool cast_lhs, cast_rhs;
112108 + tree lhs = gimple_assign_lhs(stmt);
112109 + tree rhs = gimple_assign_rhs1(stmt);
112110 + const_tree lhs_type = TREE_TYPE(lhs);
112111 + const_tree rhs_type = TREE_TYPE(rhs);
112112 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
112113 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
112114 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
112115 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
112116 +
112117 + static bool check_lhs[3][4] = {
112118 + // ss su us uu
112119 + { false, true, true, false }, // lhs > rhs
112120 + { false, false, false, false }, // lhs = rhs
112121 + { true, true, true, true }, // lhs < rhs
112122 + };
112123 +
112124 + static bool check_rhs[3][4] = {
112125 + // ss su us uu
112126 + { true, false, true, true }, // lhs > rhs
112127 + { true, false, true, true }, // lhs = rhs
112128 + { true, false, true, true }, // lhs < rhs
112129 + };
112130 +
112131 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
112132 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
112133 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112134 +
112135 + if (lhs_size > rhs_size) {
112136 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112137 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112138 + } else if (lhs_size == rhs_size) {
112139 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112140 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112141 + } else {
112142 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112143 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112144 + }
112145 +
112146 + if (!cast_lhs && !cast_rhs)
112147 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
112148 +
112149 + if (cast_lhs && !skip_lhs_cast_check(stmt))
112150 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
112151 +
112152 + if (cast_rhs)
112153 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
112154 +
112155 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
112156 +}
112157 +
112158 +static tree handle_unary_rhs(struct pointer_set_t *visited, struct cgraph_node *caller_node, gimple stmt)
112159 +{
112160 + tree rhs1, new_rhs1, lhs = gimple_assign_lhs(stmt);
112161 +
112162 + if (gimple_plf(stmt, MY_STMT))
112163 + return lhs;
112164 +
112165 + rhs1 = gimple_assign_rhs1(stmt);
112166 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
112167 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112168 +
112169 + new_rhs1 = expand(visited, caller_node, rhs1);
112170 +
112171 + if (new_rhs1 == NULL_TREE)
112172 + return create_cast_assign(visited, stmt);
112173 +
112174 + if (gimple_plf(stmt, NO_CAST_CHECK))
112175 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
112176 +
112177 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
112178 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
112179 +
112180 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
112181 + check_size_overflow(caller_node, stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
112182 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112183 + }
112184 +
112185 + if (!gimple_assign_cast_p(stmt))
112186 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
112187 +
112188 + return create_cast_overflow_check(visited, caller_node, new_rhs1, stmt);
112189 +}
112190 +
112191 +static tree handle_unary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, gimple stmt)
112192 +{
112193 + tree rhs1, lhs = gimple_assign_lhs(stmt);
112194 + gimple def_stmt = get_def_stmt(lhs);
112195 +
112196 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
112197 + rhs1 = gimple_assign_rhs1(def_stmt);
112198 +
112199 + if (is_gimple_constant(rhs1))
112200 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
112201 +
112202 + switch (TREE_CODE(rhs1)) {
112203 + case SSA_NAME:
112204 + return handle_unary_rhs(visited, caller_node, def_stmt);
112205 + case ARRAY_REF:
112206 + case BIT_FIELD_REF:
112207 + case ADDR_EXPR:
112208 + case COMPONENT_REF:
112209 + case INDIRECT_REF:
112210 +#if BUILDING_GCC_VERSION >= 4006
112211 + case MEM_REF:
112212 +#endif
112213 + case TARGET_MEM_REF:
112214 + case VIEW_CONVERT_EXPR:
112215 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
112216 + case PARM_DECL:
112217 + case VAR_DECL:
112218 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112219 +
112220 + default:
112221 + debug_gimple_stmt(def_stmt);
112222 + debug_tree(rhs1);
112223 + gcc_unreachable();
112224 + }
112225 +}
112226 +
112227 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
112228 +{
112229 + gimple cond_stmt;
112230 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
112231 +
112232 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
112233 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
112234 + update_stmt(cond_stmt);
112235 +}
112236 +
112237 +static tree create_string_param(tree string)
112238 +{
112239 + tree i_type, a_type;
112240 + const int length = TREE_STRING_LENGTH(string);
112241 +
112242 + gcc_assert(length > 0);
112243 +
112244 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
112245 + a_type = build_array_type(char_type_node, i_type);
112246 +
112247 + TREE_TYPE(string) = a_type;
112248 + TREE_CONSTANT(string) = 1;
112249 + TREE_READONLY(string) = 1;
112250 +
112251 + return build1(ADDR_EXPR, ptr_type_node, string);
112252 +}
112253 +
112254 +#if BUILDING_GCC_VERSION <= 4006
112255 +struct cgraph_node *cgraph_get_create_node(tree decl);
112256 +
112257 +struct cgraph_node *cgraph_get_create_node(tree decl)
112258 +{
112259 + struct cgraph_node *node;
112260 +
112261 + node = cgraph_get_node(decl);
112262 + if (node)
112263 + return node;
112264 + return cgraph_node(decl);
112265 +}
112266 +#endif
112267 +
112268 +static void insert_cond_result(struct cgraph_node *caller_node, basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
112269 +{
112270 + gimple func_stmt;
112271 + const_gimple def_stmt;
112272 + const_tree loc_line;
112273 + tree loc_file, ssa_name, current_func;
112274 + expanded_location xloc;
112275 + char *ssa_name_buf;
112276 + int len;
112277 + struct cgraph_edge *edge;
112278 + struct cgraph_node *callee_node;
112279 + int frequency;
112280 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
112281 +
112282 + def_stmt = get_def_stmt(arg);
112283 + xloc = expand_location(gimple_location(def_stmt));
112284 +
112285 + if (!gimple_has_location(def_stmt)) {
112286 + xloc = expand_location(gimple_location(stmt));
112287 + if (!gimple_has_location(stmt))
112288 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
112289 + }
112290 +
112291 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
112292 +
112293 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
112294 + loc_file = create_string_param(loc_file);
112295 +
112296 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
112297 + current_func = create_string_param(current_func);
112298 +
112299 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
112300 + call_count++;
112301 + len = asprintf(&ssa_name_buf, "%s_%u %s, count: %u\n", NAME(SSA_NAME_VAR(arg)), SSA_NAME_VERSION(arg), min ? "min" : "max", call_count);
112302 + gcc_assert(len > 0);
112303 + ssa_name = build_string(len + 1, ssa_name_buf);
112304 + free(ssa_name_buf);
112305 + ssa_name = create_string_param(ssa_name);
112306 +
112307 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
112308 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
112309 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
112310 +
112311 + callee_node = cgraph_get_create_node(report_size_overflow_decl);
112312 + frequency = compute_call_stmt_bb_frequency(current_function_decl, bb_true);
112313 +
112314 +#if BUILDING_GCC_VERSION <= 4006
112315 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency, bb_true->loop_depth);
112316 +#else
112317 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency);
112318 +#endif
112319 + gcc_assert(edge != NULL);
112320 +}
112321 +
112322 +static void __unused print_the_code_insertions(const_gimple stmt)
112323 +{
112324 + location_t loc = gimple_location(stmt);
112325 +
112326 + inform(loc, "Integer size_overflow check applied here.");
112327 +}
112328 +
112329 +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)
112330 +{
112331 + basic_block cond_bb, join_bb, bb_true;
112332 + edge e;
112333 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
112334 +
112335 + cond_bb = gimple_bb(stmt);
112336 + if (before)
112337 + gsi_prev(&gsi);
112338 + if (gsi_end_p(gsi))
112339 + e = split_block_after_labels(cond_bb);
112340 + else
112341 + e = split_block(cond_bb, gsi_stmt(gsi));
112342 + cond_bb = e->src;
112343 + join_bb = e->dest;
112344 + e->flags = EDGE_FALSE_VALUE;
112345 + e->probability = REG_BR_PROB_BASE;
112346 +
112347 + bb_true = create_empty_bb(cond_bb);
112348 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
112349 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
112350 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
112351 +
112352 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
112353 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
112354 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
112355 +
112356 + if (current_loops != NULL) {
112357 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
112358 + add_bb_to_loop(bb_true, cond_bb->loop_father);
112359 + }
112360 +
112361 + insert_cond(cond_bb, arg, cond_code, type_value);
112362 + insert_cond_result(caller_node, bb_true, stmt, arg, min);
112363 +
112364 +// print_the_code_insertions(stmt);
112365 +}
112366 +
112367 +static void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
112368 +{
112369 + const_tree rhs_type = TREE_TYPE(rhs);
112370 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
112371 +
112372 + gcc_assert(rhs_type != NULL_TREE);
112373 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
112374 + return;
112375 +
112376 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
112377 +
112378 + if (is_const_plus_unsigned_signed_truncation(rhs))
112379 + return;
112380 +
112381 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
112382 + // typemax (-1) < typemin (0)
112383 + if (TREE_OVERFLOW(type_max))
112384 + return;
112385 +
112386 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
112387 +
112388 + cast_rhs_type = TREE_TYPE(cast_rhs);
112389 + type_max_type = TREE_TYPE(type_max);
112390 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
112391 +
112392 + insert_check_size_overflow(caller_node, stmt, GT_EXPR, cast_rhs, type_max, before, MAX_CHECK);
112393 +
112394 + // special case: get_size_overflow_type(), 32, u64->s
112395 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode) && TYPE_UNSIGNED(size_overflow_type) && !TYPE_UNSIGNED(rhs_type))
112396 + return;
112397 +
112398 + type_min_type = TREE_TYPE(type_min);
112399 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
112400 + insert_check_size_overflow(caller_node, stmt, LT_EXPR, cast_rhs, type_min, before, MIN_CHECK);
112401 +}
112402 +
112403 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
112404 +{
112405 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
112406 + return false;
112407 + if (!is_gimple_constant(rhs))
112408 + return false;
112409 + return true;
112410 +}
112411 +
112412 +static tree get_def_stmt_rhs(const_tree var)
112413 +{
112414 + tree rhs1, def_stmt_rhs1;
112415 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
112416 +
112417 + def_stmt = get_def_stmt(var);
112418 + if (!gimple_assign_cast_p(def_stmt))
112419 + return NULL_TREE;
112420 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
112421 +
112422 + rhs1 = gimple_assign_rhs1(def_stmt);
112423 + rhs1_def_stmt = get_def_stmt(rhs1);
112424 + if (!gimple_assign_cast_p(rhs1_def_stmt))
112425 + return rhs1;
112426 +
112427 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
112428 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
112429 +
112430 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
112431 + case GIMPLE_CALL:
112432 + case GIMPLE_NOP:
112433 + case GIMPLE_ASM:
112434 + case GIMPLE_PHI:
112435 + return def_stmt_rhs1;
112436 + case GIMPLE_ASSIGN:
112437 + return rhs1;
112438 + default:
112439 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
112440 + gcc_unreachable();
112441 + }
112442 +}
112443 +
112444 +static tree handle_intentional_overflow(struct pointer_set_t *visited, struct cgraph_node *caller_node, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
112445 +{
112446 + tree new_rhs, orig_rhs;
112447 + void (*gimple_assign_set_rhs)(gimple, tree);
112448 + tree rhs1 = gimple_assign_rhs1(stmt);
112449 + tree rhs2 = gimple_assign_rhs2(stmt);
112450 + tree lhs = gimple_assign_lhs(stmt);
112451 +
112452 + if (!check_overflow)
112453 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112454 +
112455 + if (change_rhs == NULL_TREE)
112456 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112457 +
112458 + if (new_rhs2 == NULL_TREE) {
112459 + orig_rhs = rhs1;
112460 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
112461 + } else {
112462 + orig_rhs = rhs2;
112463 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
112464 + }
112465 +
112466 + check_size_overflow(caller_node, stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
112467 +
112468 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
112469 + gimple_assign_set_rhs(stmt, new_rhs);
112470 + update_stmt(stmt);
112471 +
112472 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112473 +}
112474 +
112475 +static bool is_subtraction_special(const_gimple stmt)
112476 +{
112477 + gimple rhs1_def_stmt, rhs2_def_stmt;
112478 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
112479 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
112480 + const_tree rhs1 = gimple_assign_rhs1(stmt);
112481 + const_tree rhs2 = gimple_assign_rhs2(stmt);
112482 +
112483 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
112484 + return false;
112485 +
112486 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
112487 +
112488 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
112489 + return false;
112490 +
112491 + rhs1_def_stmt = get_def_stmt(rhs1);
112492 + rhs2_def_stmt = get_def_stmt(rhs2);
112493 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
112494 + return false;
112495 +
112496 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
112497 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
112498 + rhs1_def_stmt_lhs = gimple_assign_lhs(rhs1_def_stmt);
112499 + rhs2_def_stmt_lhs = gimple_assign_lhs(rhs2_def_stmt);
112500 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
112501 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
112502 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
112503 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
112504 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
112505 + return false;
112506 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
112507 + return false;
112508 +
112509 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
112510 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
112511 + return true;
112512 +}
112513 +
112514 +static tree handle_integer_truncation(struct pointer_set_t *visited, struct cgraph_node *caller_node, const_tree lhs)
112515 +{
112516 + tree new_rhs1, new_rhs2;
112517 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
112518 + gimple assign, stmt = get_def_stmt(lhs);
112519 + tree rhs1 = gimple_assign_rhs1(stmt);
112520 + tree rhs2 = gimple_assign_rhs2(stmt);
112521 +
112522 + if (!is_subtraction_special(stmt))
112523 + return NULL_TREE;
112524 +
112525 + new_rhs1 = expand(visited, caller_node, rhs1);
112526 + new_rhs2 = expand(visited, caller_node, rhs2);
112527 +
112528 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
112529 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
112530 +
112531 + if (new_rhs1_def_stmt_rhs1 == NULL_TREE || new_rhs2_def_stmt_rhs1 == NULL_TREE)
112532 + return NULL_TREE;
112533 +
112534 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
112535 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
112536 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
112537 + }
112538 +
112539 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
112540 + new_lhs = gimple_assign_lhs(assign);
112541 + check_size_overflow(caller_node, assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
112542 +
112543 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
112544 +}
112545 +
112546 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
112547 +{
112548 + const_gimple def_stmt;
112549 +
112550 + if (TREE_CODE(rhs) != SSA_NAME)
112551 + return false;
112552 +
112553 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
112554 + return false;
112555 +
112556 + def_stmt = get_def_stmt(rhs);
112557 + if (!is_gimple_assign(def_stmt) || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
112558 + return false;
112559 +
112560 + return true;
112561 +}
112562 +
112563 +static tree handle_binary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
112564 +{
112565 + tree rhs1, rhs2, new_lhs;
112566 + gimple def_stmt = get_def_stmt(lhs);
112567 + tree new_rhs1 = NULL_TREE;
112568 + tree new_rhs2 = NULL_TREE;
112569 +
112570 + rhs1 = gimple_assign_rhs1(def_stmt);
112571 + rhs2 = gimple_assign_rhs2(def_stmt);
112572 +
112573 + /* no DImode/TImode division in the 32/64 bit kernel */
112574 + switch (gimple_assign_rhs_code(def_stmt)) {
112575 + case RDIV_EXPR:
112576 + case TRUNC_DIV_EXPR:
112577 + case CEIL_DIV_EXPR:
112578 + case FLOOR_DIV_EXPR:
112579 + case ROUND_DIV_EXPR:
112580 + case TRUNC_MOD_EXPR:
112581 + case CEIL_MOD_EXPR:
112582 + case FLOOR_MOD_EXPR:
112583 + case ROUND_MOD_EXPR:
112584 + case EXACT_DIV_EXPR:
112585 + case POINTER_PLUS_EXPR:
112586 + case BIT_AND_EXPR:
112587 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
112588 + default:
112589 + break;
112590 + }
112591 +
112592 + new_lhs = handle_integer_truncation(visited, caller_node, lhs);
112593 + if (new_lhs != NULL_TREE)
112594 + return new_lhs;
112595 +
112596 + if (TREE_CODE(rhs1) == SSA_NAME)
112597 + new_rhs1 = expand(visited, caller_node, rhs1);
112598 + if (TREE_CODE(rhs2) == SSA_NAME)
112599 + new_rhs2 = expand(visited, caller_node, rhs2);
112600 +
112601 + if (is_a_neg_overflow(def_stmt, rhs2))
112602 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs1, NULL_TREE);
112603 + if (is_a_neg_overflow(def_stmt, rhs1))
112604 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs2, new_rhs2);
112605 +
112606 +
112607 + if (is_a_constant_overflow(def_stmt, rhs2))
112608 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
112609 + if (is_a_constant_overflow(def_stmt, rhs1))
112610 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
112611 +
112612 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
112613 +}
112614 +
112615 +#if BUILDING_GCC_VERSION >= 4007
112616 +static tree get_new_rhs(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree size_overflow_type, tree rhs)
112617 +{
112618 + if (is_gimple_constant(rhs))
112619 + return cast_a_tree(size_overflow_type, rhs);
112620 + if (TREE_CODE(rhs) != SSA_NAME)
112621 + return NULL_TREE;
112622 + return expand(visited, caller_node, rhs);
112623 +}
112624 +
112625 +static tree handle_ternary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
112626 +{
112627 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
112628 + gimple def_stmt = get_def_stmt(lhs);
112629 +
112630 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
112631 +
112632 + rhs1 = gimple_assign_rhs1(def_stmt);
112633 + rhs2 = gimple_assign_rhs2(def_stmt);
112634 + rhs3 = gimple_assign_rhs3(def_stmt);
112635 + new_rhs1 = get_new_rhs(visited, caller_node, size_overflow_type, rhs1);
112636 + new_rhs2 = get_new_rhs(visited, caller_node, size_overflow_type, rhs2);
112637 + new_rhs3 = get_new_rhs(visited, caller_node, size_overflow_type, rhs3);
112638 +
112639 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
112640 +}
112641 +#endif
112642 +
112643 +static tree get_size_overflow_type(gimple stmt, const_tree node)
112644 +{
112645 + const_tree type;
112646 + tree new_type;
112647 +
112648 + gcc_assert(node != NULL_TREE);
112649 +
112650 + type = TREE_TYPE(node);
112651 +
112652 + if (gimple_plf(stmt, MY_STMT))
112653 + return TREE_TYPE(node);
112654 +
112655 + switch (TYPE_MODE(type)) {
112656 + case QImode:
112657 + new_type = intHI_type_node;
112658 + break;
112659 + case HImode:
112660 + new_type = intSI_type_node;
112661 + break;
112662 + case SImode:
112663 + new_type = intDI_type_node;
112664 + break;
112665 + case DImode:
112666 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
112667 + new_type = TYPE_UNSIGNED(type) ? unsigned_intDI_type_node : intDI_type_node;
112668 + else
112669 + new_type = intTI_type_node;
112670 + break;
112671 + case TImode:
112672 + gcc_assert(!TYPE_UNSIGNED(type));
112673 + new_type = intTI_type_node;
112674 + break;
112675 + default:
112676 + debug_tree((tree)node);
112677 + error("%s: unsupported gcc configuration (%qE).", __func__, current_function_decl);
112678 + gcc_unreachable();
112679 + }
112680 +
112681 + if (TYPE_QUALS(type) != 0)
112682 + return build_qualified_type(new_type, TYPE_QUALS(type));
112683 + return new_type;
112684 +}
112685 +
112686 +static tree expand_visited(gimple def_stmt)
112687 +{
112688 + const_gimple next_stmt;
112689 + gimple_stmt_iterator gsi;
112690 + enum gimple_code code = gimple_code(def_stmt);
112691 +
112692 + if (code == GIMPLE_ASM)
112693 + return NULL_TREE;
112694 +
112695 + gsi = gsi_for_stmt(def_stmt);
112696 + gsi_next(&gsi);
112697 +
112698 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
112699 + return NULL_TREE;
112700 + gcc_assert(!gsi_end_p(gsi));
112701 + next_stmt = gsi_stmt(gsi);
112702 +
112703 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
112704 + return NULL_TREE;
112705 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
112706 +
112707 + return get_lhs(next_stmt);
112708 +}
112709 +
112710 +static tree expand(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
112711 +{
112712 + gimple def_stmt;
112713 +
112714 + def_stmt = get_def_stmt(lhs);
112715 +
112716 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
112717 + return NULL_TREE;
112718 +
112719 + if (gimple_plf(def_stmt, MY_STMT))
112720 + return lhs;
112721 +
112722 + if (pointer_set_contains(visited, def_stmt))
112723 + return expand_visited(def_stmt);
112724 +
112725 + switch (gimple_code(def_stmt)) {
112726 + case GIMPLE_PHI:
112727 + return handle_phi(visited, caller_node, lhs);
112728 + case GIMPLE_CALL:
112729 + case GIMPLE_ASM:
112730 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
112731 + case GIMPLE_ASSIGN:
112732 + switch (gimple_num_ops(def_stmt)) {
112733 + case 2:
112734 + return handle_unary_ops(visited, caller_node, def_stmt);
112735 + case 3:
112736 + return handle_binary_ops(visited, caller_node, lhs);
112737 +#if BUILDING_GCC_VERSION >= 4007
112738 + case 4:
112739 + return handle_ternary_ops(visited, caller_node, lhs);
112740 +#endif
112741 + }
112742 + default:
112743 + debug_gimple_stmt(def_stmt);
112744 + error("%s: unknown gimple code", __func__);
112745 + gcc_unreachable();
112746 + }
112747 +}
112748 +
112749 +static tree cast_to_orig_type(gimple stmt, const_tree orig_node, tree new_node)
112750 +{
112751 + const_gimple assign;
112752 + tree orig_type = TREE_TYPE(orig_node);
112753 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
112754 +
112755 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
112756 + return gimple_assign_lhs(assign);
112757 +}
112758 +
112759 +static void change_orig_node(struct interesting_node *cur_node, tree new_node)
112760 +{
112761 + void (*set_rhs)(gimple, tree);
112762 + gimple stmt = cur_node->first_stmt;
112763 + const_tree orig_node = cur_node->node;
112764 +
112765 + switch (gimple_code(stmt)) {
112766 + case GIMPLE_RETURN:
112767 + gimple_return_set_retval(stmt, cast_to_orig_type(stmt, orig_node, new_node));
112768 + break;
112769 + case GIMPLE_CALL:
112770 + gimple_call_set_arg(stmt, cur_node->num - 1, cast_to_orig_type(stmt, orig_node, new_node));
112771 + break;
112772 + case GIMPLE_ASSIGN:
112773 + switch (cur_node->num) {
112774 + case 1:
112775 + set_rhs = &gimple_assign_set_rhs1;
112776 + break;
112777 + case 2:
112778 + set_rhs = &gimple_assign_set_rhs2;
112779 + break;
112780 +#if BUILDING_GCC_VERSION > 4005
112781 + case 3:
112782 + set_rhs = &gimple_assign_set_rhs3;
112783 + break;
112784 +#endif
112785 + default:
112786 + gcc_unreachable();
112787 + }
112788 +
112789 + set_rhs(stmt, cast_to_orig_type(stmt, orig_node, new_node));
112790 + break;
112791 + default:
112792 + debug_gimple_stmt(stmt);
112793 + gcc_unreachable();
112794 + }
112795 +
112796 + update_stmt(stmt);
112797 +}
112798 +
112799 +static unsigned int get_correct_arg_count(unsigned int argnum, tree fndecl)
112800 +{
112801 + const struct size_overflow_hash *hash;
112802 + unsigned int new_argnum;
112803 + tree arg;
112804 + const_tree origarg;
112805 +
112806 + if (argnum == 0)
112807 + return argnum;
112808 +
112809 + hash = get_function_hash(fndecl);
112810 + if (hash && hash->param & (1U << argnum))
112811 + return argnum;
112812 +
112813 + if (DECL_EXTERNAL(fndecl))
112814 + return argnum;
112815 +
112816 + origarg = DECL_ARGUMENTS(DECL_ORIGIN(fndecl));
112817 + argnum--;
112818 + while (origarg && argnum) {
112819 + origarg = TREE_CHAIN(origarg);
112820 + argnum--;
112821 + }
112822 + gcc_assert(argnum == 0);
112823 + gcc_assert(origarg != NULL_TREE);
112824 +
112825 + for (arg = DECL_ARGUMENTS(fndecl), new_argnum = 1; arg; arg = TREE_CHAIN(arg), new_argnum++)
112826 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
112827 + return new_argnum;
112828 +
112829 + return CANNOT_FIND_ARG;
112830 +}
112831 +
112832 +// Don't want to duplicate entries in next_cgraph_node
112833 +static bool is_in_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, const_tree fndecl, unsigned int num)
112834 +{
112835 + const_tree new_callee_fndecl;
112836 + struct next_cgraph_node *cur_node;
112837 +
112838 + if (fndecl == RET_CHECK)
112839 +#if BUILDING_GCC_VERSION <= 4007
112840 + new_callee_fndecl = node->decl;
112841 +#else
112842 + new_callee_fndecl = node->symbol.decl;
112843 +#endif
112844 + else
112845 + new_callee_fndecl = fndecl;
112846 +
112847 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
112848 +#if BUILDING_GCC_VERSION <= 4007
112849 + if (!operand_equal_p(cur_node->current_function->decl, node->decl, 0))
112850 +#else
112851 + if (!operand_equal_p(cur_node->current_function->symbol.decl, node->symbol.decl, 0))
112852 +#endif
112853 + continue;
112854 + if (!operand_equal_p(cur_node->callee_fndecl, new_callee_fndecl, 0))
112855 + continue;
112856 + if (num == cur_node->num)
112857 + return true;
112858 + }
112859 + return false;
112860 +}
112861 +
112862 +/* Add a next_cgraph_node into the list for handle_function().
112863 + * handle_function() iterates over all the next cgraph nodes and
112864 + * starts the overflow check insertion process.
112865 + */
112866 +static struct next_cgraph_node *create_new_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, tree fndecl, unsigned int num)
112867 +{
112868 + struct next_cgraph_node *new_node;
112869 +
112870 + if (is_in_next_cgraph_node(head, node, fndecl, num))
112871 + return head;
112872 +
112873 + new_node = (struct next_cgraph_node *)xmalloc(sizeof(*new_node));
112874 + new_node->current_function = node;
112875 + new_node->next = NULL;
112876 + new_node->num = num;
112877 + if (fndecl == RET_CHECK)
112878 +#if BUILDING_GCC_VERSION <= 4007
112879 + new_node->callee_fndecl = node->decl;
112880 +#else
112881 + new_node->callee_fndecl = node->symbol.decl;
112882 +#endif
112883 + else
112884 + new_node->callee_fndecl = fndecl;
112885 +
112886 + if (!head)
112887 + return new_node;
112888 +
112889 + new_node->next = head;
112890 + return new_node;
112891 +}
112892 +
112893 +static struct next_cgraph_node *create_new_next_cgraph_nodes(struct next_cgraph_node *head, struct cgraph_node *node, unsigned int num)
112894 +{
112895 + struct cgraph_edge *e;
112896 +
112897 + if (num == 0)
112898 + return create_new_next_cgraph_node(head, node, RET_CHECK, num);
112899 +
112900 + for (e = node->callers; e; e = e->next_caller) {
112901 + tree fndecl = gimple_call_fndecl(e->call_stmt);
112902 +
112903 + gcc_assert(fndecl != NULL_TREE);
112904 + head = create_new_next_cgraph_node(head, e->caller, fndecl, num);
112905 + }
112906 +
112907 + return head;
112908 +}
112909 +
112910 +static bool is_a_return_check(const_tree node)
112911 +{
112912 + if (TREE_CODE(node) == FUNCTION_DECL)
112913 + return true;
112914 +
112915 + gcc_assert(TREE_CODE(node) == PARM_DECL);
112916 + return false;
112917 +}
112918 +
112919 +static bool is_in_hash_table(tree fndecl, unsigned int num)
112920 +{
112921 + const struct size_overflow_hash *hash;
112922 +
112923 + hash = get_function_hash(fndecl);
112924 + if (hash && (hash->param & (1U << num)))
112925 + return true;
112926 + return false;
112927 +}
112928 +
112929 +struct missing_functions {
112930 + struct missing_functions *next;
112931 + const_tree node;
112932 + tree fndecl;
112933 +};
112934 +
112935 +static struct missing_functions *create_new_missing_function(struct missing_functions *missing_fn_head, tree node)
112936 +{
112937 + struct missing_functions *new_function;
112938 +
112939 + new_function = (struct missing_functions *)xmalloc(sizeof(*new_function));
112940 + new_function->node = node;
112941 + new_function->next = NULL;
112942 +
112943 + if (TREE_CODE(node) == FUNCTION_DECL)
112944 + new_function->fndecl = node;
112945 + else
112946 + new_function->fndecl = current_function_decl;
112947 + gcc_assert(new_function->fndecl);
112948 +
112949 + if (!missing_fn_head)
112950 + return new_function;
112951 +
112952 + new_function->next = missing_fn_head;
112953 + return new_function;
112954 +}
112955 +
112956 +/* Check if the function has a size_overflow attribute or it is in the size_overflow hash table.
112957 + * If the function is missing everywhere then print the missing message into stderr.
112958 + */
112959 +static bool is_missing_function(tree orig_fndecl, unsigned int num)
112960 +{
112961 + switch (DECL_FUNCTION_CODE(orig_fndecl)) {
112962 +#if BUILDING_GCC_VERSION >= 4008
112963 + case BUILT_IN_BSWAP16:
112964 +#endif
112965 + case BUILT_IN_BSWAP32:
112966 + case BUILT_IN_BSWAP64:
112967 + case BUILT_IN_EXPECT:
112968 + case BUILT_IN_MEMCMP:
112969 + return false;
112970 + default:
112971 + break;
112972 + }
112973 +
112974 + // skip test.c
112975 + if (strcmp(NAME(current_function_decl), "coolmalloc")) {
112976 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(orig_fndecl)))
112977 + warning(0, "unnecessary size_overflow attribute on: %s\n", NAME(orig_fndecl));
112978 + }
112979 +
112980 + if (is_in_hash_table(orig_fndecl, num))
112981 + return false;
112982 +
112983 + print_missing_msg(orig_fndecl, num);
112984 + return true;
112985 +}
112986 +
112987 +// Get the argnum of a function decl, if node is a return then the argnum is 0
112988 +static unsigned int get_function_num(const_tree node, const_tree orig_fndecl)
112989 +{
112990 + if (is_a_return_check(node))
112991 + return 0;
112992 + else
112993 + return find_arg_number_tree(node, orig_fndecl);
112994 +}
112995 +
112996 +/* If the function is missing from the hash table and it is a static function
112997 + * then create a next_cgraph_node from it for handle_function()
112998 + */
112999 +static struct next_cgraph_node *check_missing_overflow_attribute_and_create_next_node(struct next_cgraph_node *cnodes, struct missing_functions *missing_fn_head)
113000 +{
113001 + unsigned int num;
113002 + tree orig_fndecl;
113003 + struct cgraph_node *next_node = NULL;
113004 +
113005 + orig_fndecl = DECL_ORIGIN(missing_fn_head->fndecl);
113006 +
113007 + num = get_function_num(missing_fn_head->node, orig_fndecl);
113008 + if (num == CANNOT_FIND_ARG)
113009 + return cnodes;
113010 +
113011 + if (!is_missing_function(orig_fndecl, num))
113012 + return cnodes;
113013 +
113014 + next_node = cgraph_get_node(missing_fn_head->fndecl);
113015 + if (next_node && next_node->local.local)
113016 + cnodes = create_new_next_cgraph_nodes(cnodes, next_node, num);
113017 + return cnodes;
113018 +}
113019 +
113020 +/* Search for missing size_overflow attributes on the last nodes in ipa and collect them
113021 + * into the next_cgraph_node list. They will be the next interesting returns or callees.
113022 + */
113023 +static struct next_cgraph_node *search_overflow_attribute(struct next_cgraph_node *cnodes, struct interesting_node *cur_node)
113024 +{
113025 + unsigned int i;
113026 + tree node;
113027 + struct missing_functions *cur, *missing_fn_head = NULL;
113028 +
113029 +#if BUILDING_GCC_VERSION == 4005
113030 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
113031 + node = VEC_index(tree, cur_node->last_nodes, i);
113032 +#elif BUILDING_GCC_VERSION <= 4007
113033 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, node) {
113034 +#else
113035 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, node) {
113036 +#endif
113037 + switch (TREE_CODE(node)) {
113038 + case PARM_DECL:
113039 + if (TREE_CODE(TREE_TYPE(node)) != INTEGER_TYPE)
113040 + break;
113041 + case FUNCTION_DECL:
113042 + missing_fn_head = create_new_missing_function(missing_fn_head, node);
113043 + break;
113044 + default:
113045 + break;
113046 + }
113047 + }
113048 +
113049 + while (missing_fn_head) {
113050 + cnodes = check_missing_overflow_attribute_and_create_next_node(cnodes, missing_fn_head);
113051 +
113052 + cur = missing_fn_head->next;
113053 + free(missing_fn_head);
113054 + missing_fn_head = cur;
113055 + }
113056 +
113057 + return cnodes;
113058 +}
113059 +
113060 +static void walk_phi_set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree result)
113061 +{
113062 + gimple phi = get_def_stmt(result);
113063 + unsigned int i, n = gimple_phi_num_args(phi);
113064 +
113065 + pointer_set_insert(visited, phi);
113066 + for (i = 0; i < n; i++) {
113067 + const_tree arg = gimple_phi_arg_def(phi, i);
113068 +
113069 + set_conditions(visited, interesting_conditions, arg);
113070 + }
113071 +}
113072 +
113073 +enum conditions {
113074 + FROM_CONST, NOT_UNARY, CAST
113075 +};
113076 +
113077 +// Search for constants, cast assignments and binary/ternary assignments
113078 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs)
113079 +{
113080 + gimple def_stmt = get_def_stmt(lhs);
113081 +
113082 + if (is_gimple_constant(lhs)) {
113083 + interesting_conditions[FROM_CONST] = true;
113084 + return;
113085 + }
113086 +
113087 + if (!def_stmt)
113088 + return;
113089 +
113090 + if (pointer_set_contains(visited, def_stmt))
113091 + return;
113092 +
113093 + switch (gimple_code(def_stmt)) {
113094 + case GIMPLE_NOP:
113095 + case GIMPLE_CALL:
113096 + case GIMPLE_ASM:
113097 + return;
113098 + case GIMPLE_PHI:
113099 + return walk_phi_set_conditions(visited, interesting_conditions, lhs);
113100 + case GIMPLE_ASSIGN:
113101 + if (gimple_num_ops(def_stmt) == 2) {
113102 + const_tree rhs = gimple_assign_rhs1(def_stmt);
113103 +
113104 + if (gimple_assign_cast_p(def_stmt))
113105 + interesting_conditions[CAST] = true;
113106 +
113107 + return set_conditions(visited, interesting_conditions, rhs);
113108 + } else {
113109 + interesting_conditions[NOT_UNARY] = true;
113110 + return;
113111 + }
113112 + default:
113113 + debug_gimple_stmt(def_stmt);
113114 + gcc_unreachable();
113115 + }
113116 +}
113117 +
113118 +// determine whether duplication will be necessary or not.
113119 +static void search_interesting_conditions(struct interesting_node *cur_node, bool *interesting_conditions)
113120 +{
113121 + struct pointer_set_t *visited;
113122 +
113123 + if (gimple_assign_cast_p(cur_node->first_stmt))
113124 + interesting_conditions[CAST] = true;
113125 + else if (is_gimple_assign(cur_node->first_stmt) && gimple_num_ops(cur_node->first_stmt) > 2)
113126 + interesting_conditions[NOT_UNARY] = true;
113127 +
113128 + visited = pointer_set_create();
113129 + set_conditions(visited, interesting_conditions, cur_node->node);
113130 + pointer_set_destroy(visited);
113131 +}
113132 +
113133 +// Remove the size_overflow asm stmt and create an assignment from the input and output of the asm
113134 +static void replace_size_overflow_asm_with_assign(gimple asm_stmt, tree lhs, tree rhs)
113135 +{
113136 + gimple assign;
113137 + gimple_stmt_iterator gsi;
113138 +
113139 + // already removed
113140 + if (gimple_bb(asm_stmt) == NULL)
113141 + return;
113142 + gsi = gsi_for_stmt(asm_stmt);
113143 +
113144 + assign = gimple_build_assign(lhs, rhs);
113145 + gsi_insert_before(&gsi, assign, GSI_SAME_STMT);
113146 + SSA_NAME_DEF_STMT(lhs) = assign;
113147 +
113148 + gsi_remove(&gsi, true);
113149 +}
113150 +
113151 +// Get the field decl of a component ref for intentional_overflow checking
113152 +static const_tree search_field_decl(const_tree comp_ref)
113153 +{
113154 + const_tree field = NULL_TREE;
113155 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
113156 +
113157 + for (i = 0; i < len; i++) {
113158 + field = TREE_OPERAND(comp_ref, i);
113159 + if (TREE_CODE(field) == FIELD_DECL)
113160 + break;
113161 + }
113162 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
113163 + return field;
113164 +}
113165 +
113166 +/* Get the fndecl of an interesting stmt, the fndecl is the caller function if the interesting
113167 + * stmt is a return otherwise it is the callee function.
113168 + */
113169 +static const_tree get_interesting_orig_fndecl(const_gimple stmt, unsigned int argnum)
113170 +{
113171 + const_tree fndecl;
113172 +
113173 + if (argnum == 0)
113174 + fndecl = current_function_decl;
113175 + else
113176 + fndecl = gimple_call_fndecl(stmt);
113177 +
113178 + if (fndecl == NULL_TREE)
113179 + return NULL_TREE;
113180 +
113181 + return DECL_ORIGIN(fndecl);
113182 +}
113183 +
113184 +/* Get the param of the intentional_overflow attribute.
113185 + * * 0: MARK_NOT_INTENTIONAL
113186 + * * 1..MAX_PARAM: MARK_YES
113187 + * * -1: MARK_TURN_OFF
113188 + */
113189 +static tree get_attribute_param(const_tree decl)
113190 +{
113191 + const_tree attr;
113192 +
113193 + if (decl == NULL_TREE)
113194 + return NULL_TREE;
113195 +
113196 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(decl));
113197 + if (!attr || !TREE_VALUE(attr))
113198 + return NULL_TREE;
113199 +
113200 + return TREE_VALUE(attr);
113201 +}
113202 +
113203 +// MARK_TURN_OFF
113204 +static bool is_turn_off_intentional_attr(const_tree decl)
113205 +{
113206 + const_tree param_head;
113207 +
113208 + param_head = get_attribute_param(decl);
113209 + if (param_head == NULL_TREE)
113210 + return false;
113211 +
113212 + if (TREE_INT_CST_HIGH(TREE_VALUE(param_head)) == -1)
113213 + return true;
113214 + return false;
113215 +}
113216 +
113217 +// MARK_NOT_INTENTIONAL
113218 +static bool is_end_intentional_intentional_attr(const_tree decl, unsigned int argnum)
113219 +{
113220 + const_tree param_head;
113221 +
113222 + if (argnum == 0)
113223 + return false;
113224 +
113225 + param_head = get_attribute_param(decl);
113226 + if (param_head == NULL_TREE)
113227 + return false;
113228 +
113229 + if (!TREE_INT_CST_LOW(TREE_VALUE(param_head)))
113230 + return true;
113231 + return false;
113232 +}
113233 +
113234 +// MARK_YES
113235 +static bool is_yes_intentional_attr(const_tree decl, unsigned int argnum)
113236 +{
113237 + tree param, param_head;
113238 +
113239 + if (argnum == 0)
113240 + return false;
113241 +
113242 + param_head = get_attribute_param(decl);
113243 + for (param = param_head; param; param = TREE_CHAIN(param))
113244 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(param)))
113245 + return true;
113246 + return false;
113247 +}
113248 +
113249 +static const char *get_asm_string(const_gimple stmt)
113250 +{
113251 + if (!stmt)
113252 + return NULL;
113253 + if (gimple_code(stmt) != GIMPLE_ASM)
113254 + return NULL;
113255 +
113256 + return gimple_asm_string(stmt);
113257 +}
113258 +
113259 +static bool is_size_overflow_intentional_asm_turn_off(const_gimple stmt)
113260 +{
113261 + const char *str;
113262 +
113263 + str = get_asm_string(stmt);
113264 + if (!str)
113265 + return false;
113266 + return !strncmp(str, TURN_OFF_ASM_STR, sizeof(TURN_OFF_ASM_STR) - 1);
113267 +}
113268 +
113269 +static bool is_size_overflow_intentional_asm_yes(const_gimple stmt)
113270 +{
113271 + const char *str;
113272 +
113273 + str = get_asm_string(stmt);
113274 + if (!str)
113275 + return false;
113276 + return !strncmp(str, YES_ASM_STR, sizeof(YES_ASM_STR) - 1);
113277 +}
113278 +
113279 +static bool is_size_overflow_asm(const_gimple stmt)
113280 +{
113281 + const char *str;
113282 +
113283 + str = get_asm_string(stmt);
113284 + if (!str)
113285 + return false;
113286 + return !strncmp(str, OK_ASM_STR, sizeof(OK_ASM_STR) - 1);
113287 +}
113288 +
113289 +static void print_missing_intentional(enum mark callee_attr, enum mark caller_attr, const_tree decl, unsigned int argnum)
113290 +{
113291 + location_t loc;
113292 +
113293 + if (caller_attr == MARK_NO || caller_attr == MARK_NOT_INTENTIONAL || caller_attr == MARK_TURN_OFF)
113294 + return;
113295 +
113296 + if (callee_attr == MARK_NOT_INTENTIONAL || callee_attr == MARK_YES)
113297 + return;
113298 +
113299 + loc = DECL_SOURCE_LOCATION(decl);
113300 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", NAME(decl), argnum);
113301 +}
113302 +
113303 +/* Get the type of the intentional_overflow attribute of a node
113304 + * * MARK_TURN_OFF
113305 + * * MARK_YES
113306 + * * MARK_NO
113307 + * * MARK_NOT_INTENTIONAL
113308 + */
113309 +static enum mark get_intentional_attr_type(const_tree node)
113310 +{
113311 + const_tree cur_decl;
113312 +
113313 + if (node == NULL_TREE)
113314 + return MARK_NO;
113315 +
113316 + switch (TREE_CODE(node)) {
113317 + case COMPONENT_REF:
113318 + cur_decl = search_field_decl(node);
113319 + if (is_turn_off_intentional_attr(cur_decl))
113320 + return MARK_TURN_OFF;
113321 + if (is_end_intentional_intentional_attr(cur_decl, 1))
113322 + return MARK_YES;
113323 + break;
113324 + case PARM_DECL: {
113325 + unsigned int argnum;
113326 +
113327 + cur_decl = DECL_ORIGIN(current_function_decl);
113328 + argnum = find_arg_number_tree(node, cur_decl);
113329 + if (argnum == CANNOT_FIND_ARG)
113330 + return MARK_NO;
113331 + if (is_yes_intentional_attr(cur_decl, argnum))
113332 + return MARK_YES;
113333 + if (is_end_intentional_intentional_attr(cur_decl, argnum))
113334 + return MARK_NOT_INTENTIONAL;
113335 + break;
113336 + }
113337 + case FUNCTION_DECL:
113338 + if (is_turn_off_intentional_attr(DECL_ORIGIN(node)))
113339 + return MARK_TURN_OFF;
113340 + break;
113341 + default:
113342 + break;
113343 + }
113344 + return MARK_NO;
113345 +}
113346 +
113347 +// Search for the intentional_overflow attribute on the last nodes
113348 +static enum mark search_last_nodes_intentional(struct interesting_node *cur_node)
113349 +{
113350 + unsigned int i;
113351 + tree last_node;
113352 + enum mark mark = MARK_NO;
113353 +
113354 +#if BUILDING_GCC_VERSION == 4005
113355 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
113356 + last_node = VEC_index(tree, cur_node->last_nodes, i);
113357 +#elif BUILDING_GCC_VERSION <= 4007
113358 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, last_node) {
113359 +#else
113360 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, last_node) {
113361 +#endif
113362 + mark = get_intentional_attr_type(last_node);
113363 + if (mark != MARK_NO)
113364 + break;
113365 + }
113366 + return mark;
113367 +}
113368 +
113369 +/* Check the intentional kind of size_overflow asm stmt (created by the gimple pass) and
113370 + * set the appropriate intentional_overflow type. Delete the asm stmt in the end.
113371 + */
113372 +static bool is_intentional_attribute_from_gimple(struct interesting_node *cur_node)
113373 +{
113374 + if (!cur_node->intentional_mark_from_gimple)
113375 + return false;
113376 +
113377 + if (is_size_overflow_intentional_asm_yes(cur_node->intentional_mark_from_gimple))
113378 + cur_node->intentional_attr_cur_fndecl = MARK_YES;
113379 + else
113380 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
113381 +
113382 + // skip param decls
113383 + if (gimple_asm_noutputs(cur_node->intentional_mark_from_gimple) == 0)
113384 + return true;
113385 + return true;
113386 +}
113387 +
113388 +/* Search intentional_overflow attribute on caller and on callee too.
113389 + * 0</MARK_YES: no dup, search size_overflow and intentional_overflow attributes
113390 + * 0/MARK_NOT_INTENTIONAL: no dup, search size_overflow attribute (int)
113391 + * -1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
113392 +*/
113393 +static void check_intentional_attribute_ipa(struct interesting_node *cur_node)
113394 +{
113395 + const_tree fndecl;
113396 +
113397 + if (is_intentional_attribute_from_gimple(cur_node))
113398 + return;
113399 +
113400 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
113401 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
113402 + return;
113403 + }
113404 +
113405 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASM) {
113406 + cur_node->intentional_attr_cur_fndecl = MARK_NOT_INTENTIONAL;
113407 + return;
113408 + }
113409 +
113410 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASSIGN)
113411 + return;
113412 +
113413 + fndecl = get_interesting_orig_fndecl(cur_node->first_stmt, cur_node->num);
113414 + if (is_turn_off_intentional_attr(fndecl)) {
113415 + cur_node->intentional_attr_decl = MARK_TURN_OFF;
113416 + return;
113417 + }
113418 +
113419 + if (is_end_intentional_intentional_attr(fndecl, cur_node->num))
113420 + cur_node->intentional_attr_decl = MARK_NOT_INTENTIONAL;
113421 + else if (is_yes_intentional_attr(fndecl, cur_node->num))
113422 + cur_node->intentional_attr_decl = MARK_YES;
113423 +
113424 + cur_node->intentional_attr_cur_fndecl = search_last_nodes_intentional(cur_node);
113425 + print_missing_intentional(cur_node->intentional_attr_decl, cur_node->intentional_attr_cur_fndecl, cur_node->fndecl, cur_node->num);
113426 +}
113427 +
113428 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
113429 +static bool skip_asm(const_tree arg)
113430 +{
113431 + gimple def_stmt = get_def_stmt(arg);
113432 +
113433 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
113434 + return false;
113435 +
113436 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
113437 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
113438 +}
113439 +
113440 +static void walk_use_def_phi(struct pointer_set_t *visited, struct interesting_node *cur_node, tree result)
113441 +{
113442 + gimple phi = get_def_stmt(result);
113443 + unsigned int i, n = gimple_phi_num_args(phi);
113444 +
113445 + pointer_set_insert(visited, phi);
113446 + for (i = 0; i < n; i++) {
113447 + tree arg = gimple_phi_arg_def(phi, i);
113448 +
113449 + walk_use_def(visited, cur_node, arg);
113450 + }
113451 +}
113452 +
113453 +static void walk_use_def_binary(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
113454 +{
113455 + gimple def_stmt = get_def_stmt(lhs);
113456 + tree rhs1, rhs2;
113457 +
113458 + rhs1 = gimple_assign_rhs1(def_stmt);
113459 + rhs2 = gimple_assign_rhs2(def_stmt);
113460 +
113461 + walk_use_def(visited, cur_node, rhs1);
113462 + walk_use_def(visited, cur_node, rhs2);
113463 +}
113464 +
113465 +static void insert_last_node(struct interesting_node *cur_node, tree node)
113466 +{
113467 + unsigned int i;
113468 + tree element;
113469 + enum tree_code code;
113470 +
113471 + gcc_assert(node != NULL_TREE);
113472 +
113473 + if (is_gimple_constant(node))
113474 + return;
113475 +
113476 + code = TREE_CODE(node);
113477 + if (code == VAR_DECL) {
113478 + node = DECL_ORIGIN(node);
113479 + code = TREE_CODE(node);
113480 + }
113481 +
113482 + if (code != PARM_DECL && code != FUNCTION_DECL && code != COMPONENT_REF)
113483 + return;
113484 +
113485 +#if BUILDING_GCC_VERSION == 4005
113486 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
113487 + element = VEC_index(tree, cur_node->last_nodes, i);
113488 +#elif BUILDING_GCC_VERSION <= 4007
113489 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, element) {
113490 +#else
113491 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, element) {
113492 +#endif
113493 + if (operand_equal_p(node, element, 0))
113494 + return;
113495 + }
113496 +
113497 +#if BUILDING_GCC_VERSION <= 4007
113498 + gcc_assert(VEC_length(tree, cur_node->last_nodes) < VEC_LEN);
113499 + VEC_safe_push(tree, gc, cur_node->last_nodes, node);
113500 +#else
113501 + gcc_assert(cur_node->last_nodes->length() < VEC_LEN);
113502 + vec_safe_push(cur_node->last_nodes, node);
113503 +#endif
113504 +}
113505 +
113506 +// a size_overflow asm stmt in the control flow doesn't stop the recursion
113507 +static void handle_asm_stmt(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs, const_gimple stmt)
113508 +{
113509 + if (!is_size_overflow_asm(stmt))
113510 + walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
113511 +}
113512 +
113513 +/* collect the parm_decls and fndecls (for checking a missing size_overflow attribute (ret or arg) or intentional_overflow)
113514 + * and component refs (for checking the intentional_overflow attribute).
113515 + */
113516 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
113517 +{
113518 + const_gimple def_stmt;
113519 +
113520 + if (TREE_CODE(lhs) != SSA_NAME) {
113521 + insert_last_node(cur_node, lhs);
113522 + return;
113523 + }
113524 +
113525 + def_stmt = get_def_stmt(lhs);
113526 + if (!def_stmt)
113527 + return;
113528 +
113529 + if (pointer_set_insert(visited, def_stmt))
113530 + return;
113531 +
113532 + switch (gimple_code(def_stmt)) {
113533 + case GIMPLE_NOP:
113534 + return walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
113535 + case GIMPLE_ASM:
113536 + return handle_asm_stmt(visited, cur_node, lhs, def_stmt);
113537 + case GIMPLE_CALL: {
113538 + tree fndecl = gimple_call_fndecl(def_stmt);
113539 +
113540 + if (fndecl == NULL_TREE)
113541 + return;
113542 + insert_last_node(cur_node, fndecl);
113543 + return;
113544 + }
113545 + case GIMPLE_PHI:
113546 + return walk_use_def_phi(visited, cur_node, lhs);
113547 + case GIMPLE_ASSIGN:
113548 + switch (gimple_num_ops(def_stmt)) {
113549 + case 2:
113550 + return walk_use_def(visited, cur_node, gimple_assign_rhs1(def_stmt));
113551 + case 3:
113552 + return walk_use_def_binary(visited, cur_node, lhs);
113553 + }
113554 + default:
113555 + debug_gimple_stmt((gimple)def_stmt);
113556 + error("%s: unknown gimple code", __func__);
113557 + gcc_unreachable();
113558 + }
113559 +}
113560 +
113561 +// Collect all the last nodes for checking the intentional_overflow and size_overflow attributes
113562 +static void set_last_nodes(struct interesting_node *cur_node)
113563 +{
113564 + struct pointer_set_t *visited;
113565 +
113566 + visited = pointer_set_create();
113567 + walk_use_def(visited, cur_node, cur_node->node);
113568 + pointer_set_destroy(visited);
113569 +}
113570 +
113571 +enum precond {
113572 + NO_ATTRIBUTE_SEARCH, NO_CHECK_INSERT, NONE
113573 +};
113574 +
113575 +/* 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.
113576 + * There is only missing size_overflow attribute checking if the intentional_overflow attribute is the mark_no type.
113577 + * Stmt duplication is unnecessary if there are no binary/ternary assignements or if the unary assignment isn't a cast.
113578 + * 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.
113579 + */
113580 +static enum precond check_preconditions(struct interesting_node *cur_node)
113581 +{
113582 + bool interesting_conditions[3] = {false, false, false};
113583 +
113584 + set_last_nodes(cur_node);
113585 +
113586 + check_intentional_attribute_ipa(cur_node);
113587 + if (cur_node->intentional_attr_decl == MARK_TURN_OFF || cur_node->intentional_attr_cur_fndecl == MARK_TURN_OFF)
113588 + return NO_ATTRIBUTE_SEARCH;
113589 +
113590 + search_interesting_conditions(cur_node, interesting_conditions);
113591 +
113592 + // error code
113593 + if (interesting_conditions[CAST] && interesting_conditions[FROM_CONST] && !interesting_conditions[NOT_UNARY])
113594 + return NO_ATTRIBUTE_SEARCH;
113595 +
113596 + // unnecessary overflow check
113597 + if (!interesting_conditions[CAST] && !interesting_conditions[NOT_UNARY])
113598 + return NO_CHECK_INSERT;
113599 +
113600 + if (cur_node->intentional_attr_cur_fndecl != MARK_NO)
113601 + return NO_CHECK_INSERT;
113602 +
113603 + return NONE;
113604 +}
113605 +
113606 +/* This function calls the main recursion function (expand) that duplicates the stmts. Before that it checks the intentional_overflow attribute and asm stmts,
113607 + * 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
113608 + * in the original stmt (first stmt) and it inserts the overflow check for the arg of the callee or for the return value.
113609 + */
113610 +static struct next_cgraph_node *handle_interesting_stmt(struct next_cgraph_node *cnodes, struct interesting_node *cur_node, struct cgraph_node *caller_node)
113611 +{
113612 + enum precond ret;
113613 + struct pointer_set_t *visited;
113614 + tree new_node, orig_node = cur_node->node;
113615 +
113616 + ret = check_preconditions(cur_node);
113617 + if (ret == NO_ATTRIBUTE_SEARCH)
113618 + return cnodes;
113619 +
113620 + cnodes = search_overflow_attribute(cnodes, cur_node);
113621 +
113622 + if (ret == NO_CHECK_INSERT)
113623 + return cnodes;
113624 +
113625 + visited = pointer_set_create();
113626 + new_node = expand(visited, caller_node, orig_node);
113627 + pointer_set_destroy(visited);
113628 +
113629 + if (new_node == NULL_TREE)
113630 + return cnodes;
113631 +
113632 + change_orig_node(cur_node, new_node);
113633 + check_size_overflow(caller_node, cur_node->first_stmt, TREE_TYPE(new_node), new_node, orig_node, BEFORE_STMT);
113634 +
113635 + return cnodes;
113636 +}
113637 +
113638 +// Check visited interesting nodes.
113639 +static bool is_in_interesting_node(struct interesting_node *head, const_gimple first_stmt, const_tree node, unsigned int num)
113640 +{
113641 + struct interesting_node *cur;
113642 +
113643 + for (cur = head; cur; cur = cur->next) {
113644 + if (!operand_equal_p(node, cur->node, 0))
113645 + continue;
113646 + if (num != cur->num)
113647 + continue;
113648 + if (first_stmt == cur->first_stmt)
113649 + return true;
113650 + }
113651 + return false;
113652 +}
113653 +
113654 +/* Create an interesting node. The ipa pass starts to duplicate from these stmts.
113655 + 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
113656 + 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
113657 + the intentional_overflow attribute check. They are collected by set_last_nodes().
113658 + num: arg count of a call stmt or 0 when it is a ret
113659 + node: the recursion starts from here, it is a call arg or a return value
113660 + 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.
113661 + intentional_attr_decl: intentional_overflow attribute of the callee function
113662 + intentional_attr_cur_fndecl: intentional_overflow attribute of the caller function
113663 + intentional_mark_from_gimple: the intentional overflow type of size_overflow asm stmt from gimple if it exists
113664 + */
113665 +static struct interesting_node *create_new_interesting_node(struct interesting_node *head, gimple first_stmt, tree node, unsigned int num, gimple asm_stmt)
113666 +{
113667 + struct interesting_node *new_node;
113668 + tree fndecl;
113669 + enum gimple_code code;
113670 +
113671 + gcc_assert(node != NULL_TREE);
113672 + code = gimple_code(first_stmt);
113673 + gcc_assert(code == GIMPLE_CALL || code == GIMPLE_ASM || code == GIMPLE_ASSIGN || code == GIMPLE_RETURN);
113674 +
113675 + if (num == CANNOT_FIND_ARG)
113676 + return head;
113677 +
113678 + if (skip_types(node))
113679 + return head;
113680 +
113681 + if (skip_asm(node))
113682 + return head;
113683 +
113684 + if (is_gimple_call(first_stmt))
113685 + fndecl = gimple_call_fndecl(first_stmt);
113686 + else
113687 + fndecl = current_function_decl;
113688 +
113689 + if (fndecl == NULL_TREE)
113690 + return head;
113691 +
113692 + if (is_in_interesting_node(head, first_stmt, node, num))
113693 + return head;
113694 +
113695 + new_node = (struct interesting_node *)xmalloc(sizeof(*new_node));
113696 +
113697 + new_node->next = NULL;
113698 + new_node->first_stmt = first_stmt;
113699 +#if BUILDING_GCC_VERSION <= 4007
113700 + new_node->last_nodes = VEC_alloc(tree, gc, VEC_LEN);
113701 +#else
113702 + vec_alloc(new_node->last_nodes, VEC_LEN);
113703 +#endif
113704 + new_node->num = num;
113705 + new_node->node = node;
113706 + new_node->fndecl = fndecl;
113707 + new_node->intentional_attr_decl = MARK_NO;
113708 + new_node->intentional_attr_cur_fndecl = MARK_NO;
113709 + new_node->intentional_mark_from_gimple = asm_stmt;
113710 +
113711 + if (!head)
113712 + return new_node;
113713 +
113714 + new_node->next = head;
113715 + return new_node;
113716 +}
113717 +
113718 +/* 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).
113719 + * If the ret stmt is in the next cgraph node list then it's an interesting ret.
113720 + */
113721 +static struct interesting_node *handle_stmt_by_cgraph_nodes_ret(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
113722 +{
113723 + struct next_cgraph_node *cur_node;
113724 + tree ret = gimple_return_retval(stmt);
113725 +
113726 + if (ret == NULL_TREE)
113727 + return head;
113728 +
113729 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
113730 + if (!operand_equal_p(cur_node->callee_fndecl, DECL_ORIGIN(current_function_decl), 0))
113731 + continue;
113732 + if (cur_node->num == 0)
113733 + head = create_new_interesting_node(head, stmt, ret, 0, NOT_INTENTIONAL_ASM);
113734 + }
113735 +
113736 + return head;
113737 +}
113738 +
113739 +/* 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).
113740 + * If the call stmt is in the next cgraph node list then it's an interesting call.
113741 + */
113742 +static struct interesting_node *handle_stmt_by_cgraph_nodes_call(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
113743 +{
113744 + unsigned int argnum;
113745 + tree fndecl, arg;
113746 + struct next_cgraph_node *cur_node;
113747 +
113748 + fndecl = gimple_call_fndecl(stmt);
113749 + if (fndecl == NULL_TREE)
113750 + return head;
113751 +
113752 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
113753 + if (!operand_equal_p(cur_node->callee_fndecl, fndecl, 0))
113754 + continue;
113755 + argnum = get_correct_arg_count(cur_node->num, fndecl);
113756 + gcc_assert(argnum != CANNOT_FIND_ARG);
113757 + if (argnum == 0)
113758 + continue;
113759 +
113760 + arg = gimple_call_arg(stmt, argnum - 1);
113761 + head = create_new_interesting_node(head, stmt, arg, argnum, NOT_INTENTIONAL_ASM);
113762 + }
113763 +
113764 + return head;
113765 +}
113766 +
113767 +static unsigned int check_ops(const_tree orig_node, const_tree node, unsigned int ret_count)
113768 +{
113769 + if (!operand_equal_p(orig_node, node, 0))
113770 + return WRONG_NODE;
113771 + if (skip_types(node))
113772 + return WRONG_NODE;
113773 + return ret_count;
113774 +}
113775 +
113776 +// Get the index of the rhs node in an assignment
113777 +static unsigned int get_assign_ops_count(const_gimple stmt, tree node)
113778 +{
113779 + const_tree rhs1, rhs2;
113780 + unsigned int ret;
113781 +
113782 + gcc_assert(stmt);
113783 + gcc_assert(is_gimple_assign(stmt));
113784 +
113785 + rhs1 = gimple_assign_rhs1(stmt);
113786 + gcc_assert(rhs1 != NULL_TREE);
113787 +
113788 + switch (gimple_num_ops(stmt)) {
113789 + case 2:
113790 + return check_ops(node, rhs1, 1);
113791 + case 3:
113792 + ret = check_ops(node, rhs1, 1);
113793 + if (ret != WRONG_NODE)
113794 + return ret;
113795 +
113796 + rhs2 = gimple_assign_rhs2(stmt);
113797 + gcc_assert(rhs2 != NULL_TREE);
113798 + return check_ops(node, rhs2, 2);
113799 + default:
113800 + gcc_unreachable();
113801 + }
113802 +}
113803 +
113804 +// Find the correct arg number of a call stmt. It is needed when the interesting function is a cloned function.
113805 +static unsigned int find_arg_number_gimple(const_tree arg, const_gimple stmt)
113806 +{
113807 + unsigned int i;
113808 +
113809 + if (gimple_call_fndecl(stmt) == NULL_TREE)
113810 + return CANNOT_FIND_ARG;
113811 +
113812 + for (i = 0; i < gimple_call_num_args(stmt); i++) {
113813 + tree node;
113814 +
113815 + node = gimple_call_arg(stmt, i);
113816 + if (!operand_equal_p(arg, node, 0))
113817 + continue;
113818 + if (!skip_types(node))
113819 + return i + 1;
113820 + }
113821 +
113822 + return CANNOT_FIND_ARG;
113823 +}
113824 +
113825 +/* starting from the size_overflow asm stmt collect interesting stmts. They can be
113826 + * any of return, call or assignment stmts (because of inlining).
113827 + */
113828 +static struct interesting_node *get_interesting_ret_or_call(struct pointer_set_t *visited, struct interesting_node *head, tree node, gimple intentional_asm)
113829 +{
113830 + use_operand_p use_p;
113831 + imm_use_iterator imm_iter;
113832 + unsigned int argnum;
113833 +
113834 + gcc_assert(TREE_CODE(node) == SSA_NAME);
113835 +
113836 + if (pointer_set_insert(visited, node))
113837 + return head;
113838 +
113839 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
113840 + gimple stmt = USE_STMT(use_p);
113841 +
113842 + if (stmt == NULL)
113843 + return head;
113844 + if (is_gimple_debug(stmt))
113845 + continue;
113846 +
113847 + switch (gimple_code(stmt)) {
113848 + case GIMPLE_CALL:
113849 + argnum = find_arg_number_gimple(node, stmt);
113850 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
113851 + break;
113852 + case GIMPLE_RETURN:
113853 + head = create_new_interesting_node(head, stmt, node, 0, intentional_asm);
113854 + break;
113855 + case GIMPLE_ASSIGN:
113856 + argnum = get_assign_ops_count(stmt, node);
113857 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
113858 + break;
113859 + case GIMPLE_PHI: {
113860 + tree result = gimple_phi_result(stmt);
113861 + head = get_interesting_ret_or_call(visited, head, result, intentional_asm);
113862 + break;
113863 + }
113864 + case GIMPLE_ASM:
113865 + if (gimple_asm_noutputs(stmt) != 0)
113866 + break;
113867 + if (!is_size_overflow_asm(stmt))
113868 + break;
113869 + head = create_new_interesting_node(head, stmt, node, 1, intentional_asm);
113870 + break;
113871 + case GIMPLE_COND:
113872 + case GIMPLE_SWITCH:
113873 + break;
113874 + default:
113875 + debug_gimple_stmt(stmt);
113876 + gcc_unreachable();
113877 + break;
113878 + }
113879 + }
113880 + return head;
113881 +}
113882 +
113883 +static void remove_size_overflow_asm(gimple stmt)
113884 +{
113885 + gimple_stmt_iterator gsi;
113886 + tree input, output;
113887 +
113888 + if (!is_size_overflow_asm(stmt))
113889 + return;
113890 +
113891 + if (gimple_asm_noutputs(stmt) == 0) {
113892 + gsi = gsi_for_stmt(stmt);
113893 + gsi_remove(&gsi, true);
113894 + return;
113895 + }
113896 +
113897 + input = gimple_asm_input_op(stmt, 0);
113898 + output = gimple_asm_output_op(stmt, 0);
113899 + replace_size_overflow_asm_with_assign(stmt, TREE_VALUE(output), TREE_VALUE(input));
113900 +}
113901 +
113902 +/* handle the size_overflow asm stmts from the gimple pass and collect the interesting stmts.
113903 + * If the asm stmt is a parm_decl kind (noutputs == 0) then remove it.
113904 + * If it is a simple asm stmt then replace it with an assignment from the asm input to the asm output.
113905 + */
113906 +static struct interesting_node *handle_stmt_by_size_overflow_asm(gimple stmt, struct interesting_node *head)
113907 +{
113908 + const_tree output;
113909 + struct pointer_set_t *visited;
113910 + gimple intentional_asm = NOT_INTENTIONAL_ASM;
113911 +
113912 + if (!is_size_overflow_asm(stmt))
113913 + return head;
113914 +
113915 + if (is_size_overflow_intentional_asm_yes(stmt) || is_size_overflow_intentional_asm_turn_off(stmt))
113916 + intentional_asm = stmt;
113917 +
113918 + gcc_assert(gimple_asm_ninputs(stmt) == 1);
113919 +
113920 + if (gimple_asm_noutputs(stmt) == 0 && is_size_overflow_intentional_asm_turn_off(stmt))
113921 + return head;
113922 +
113923 + if (gimple_asm_noutputs(stmt) == 0) {
113924 + const_tree input;
113925 +
113926 + if (!is_size_overflow_intentional_asm_turn_off(stmt))
113927 + return head;
113928 +
113929 + input = gimple_asm_input_op(stmt, 0);
113930 + remove_size_overflow_asm(stmt);
113931 + if (is_gimple_constant(TREE_VALUE(input)))
113932 + return head;
113933 + visited = pointer_set_create();
113934 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(input), intentional_asm);
113935 + pointer_set_destroy(visited);
113936 + return head;
113937 + }
113938 +
113939 + if (!is_size_overflow_intentional_asm_yes(stmt) && !is_size_overflow_intentional_asm_turn_off(stmt))
113940 + remove_size_overflow_asm(stmt);
113941 +
113942 + visited = pointer_set_create();
113943 + output = gimple_asm_output_op(stmt, 0);
113944 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(output), intentional_asm);
113945 + pointer_set_destroy(visited);
113946 + return head;
113947 +}
113948 +
113949 +/* Iterate over all the stmts of a function and look for the size_overflow asm stmts (they were created in the gimple pass)
113950 + * or a call stmt or a return stmt and store them in the interesting_node list
113951 + */
113952 +static struct interesting_node *collect_interesting_stmts(struct next_cgraph_node *next_node)
113953 +{
113954 + basic_block bb;
113955 + struct interesting_node *head = NULL;
113956 +
113957 + FOR_ALL_BB(bb) {
113958 + gimple_stmt_iterator gsi;
113959 +
113960 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
113961 + enum gimple_code code;
113962 + gimple stmt = gsi_stmt(gsi);
113963 +
113964 + code = gimple_code(stmt);
113965 +
113966 + if (code == GIMPLE_ASM)
113967 + head = handle_stmt_by_size_overflow_asm(stmt, head);
113968 +
113969 + if (!next_node)
113970 + continue;
113971 + if (code == GIMPLE_CALL)
113972 + head = handle_stmt_by_cgraph_nodes_call(head, stmt, next_node);
113973 + if (code == GIMPLE_RETURN)
113974 + head = handle_stmt_by_cgraph_nodes_ret(head, stmt, next_node);
113975 + }
113976 + }
113977 + return head;
113978 +}
113979 +
113980 +static void set_current_function_decl(tree fndecl)
113981 +{
113982 + gcc_assert(fndecl != NULL_TREE);
113983 +
113984 + push_cfun(DECL_STRUCT_FUNCTION(fndecl));
113985 + calculate_dominance_info(CDI_DOMINATORS);
113986 + current_function_decl = fndecl;
113987 +}
113988 +
113989 +static void unset_current_function_decl(void)
113990 +{
113991 + free_dominance_info(CDI_DOMINATORS);
113992 + pop_cfun();
113993 + current_function_decl = NULL_TREE;
113994 +}
113995 +
113996 +static void free_interesting_node(struct interesting_node *head)
113997 +{
113998 + struct interesting_node *cur;
113999 +
114000 + while (head) {
114001 + cur = head->next;
114002 +#if BUILDING_GCC_VERSION <= 4007
114003 + VEC_free(tree, gc, head->last_nodes);
114004 +#else
114005 + vec_free(head->last_nodes);
114006 +#endif
114007 + free(head);
114008 + head = cur;
114009 + }
114010 +}
114011 +
114012 +static struct visited *insert_visited_function(struct visited *head, struct interesting_node *cur_node)
114013 +{
114014 + struct visited *new_visited;
114015 +
114016 + new_visited = (struct visited *)xmalloc(sizeof(*new_visited));
114017 + new_visited->fndecl = cur_node->fndecl;
114018 + new_visited->num = cur_node->num;
114019 + new_visited->first_stmt = cur_node->first_stmt;
114020 + new_visited->next = NULL;
114021 +
114022 + if (!head)
114023 + return new_visited;
114024 +
114025 + new_visited->next = head;
114026 + return new_visited;
114027 +}
114028 +
114029 +/* Check whether the function was already visited. If the fndecl, the arg count of the fndecl and the first_stmt (call or return) are same then
114030 + * it is a visited function.
114031 + */
114032 +static bool is_visited_function(struct visited *head, struct interesting_node *cur_node)
114033 +{
114034 + struct visited *cur;
114035 +
114036 + if (!head)
114037 + return false;
114038 +
114039 + for (cur = head; cur; cur = cur->next) {
114040 + if (!operand_equal_p(cur_node->fndecl, cur->fndecl, 0))
114041 + continue;
114042 + if (cur_node->num != cur->num)
114043 + continue;
114044 + if (cur_node->first_stmt == cur->first_stmt)
114045 + return true;
114046 + }
114047 + return false;
114048 +}
114049 +
114050 +static void free_next_cgraph_node(struct next_cgraph_node *head)
114051 +{
114052 + struct next_cgraph_node *cur;
114053 +
114054 + while (head) {
114055 + cur = head->next;
114056 + free(head);
114057 + head = cur;
114058 + }
114059 +}
114060 +
114061 +static void remove_all_size_overflow_asm(void)
114062 +{
114063 + basic_block bb;
114064 +
114065 + FOR_ALL_BB(bb) {
114066 + gimple_stmt_iterator si;
114067 +
114068 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
114069 + remove_size_overflow_asm(gsi_stmt(si));
114070 + }
114071 +}
114072 +
114073 +/* Main recursive walk of the ipa pass: iterate over the collected interesting stmts in a function
114074 + * (they are interesting if they have an associated size_overflow asm stmt) and recursively walk
114075 + * the newly collected interesting functions (they are interesting if there is control flow between
114076 + * the interesting stmts and them).
114077 + */
114078 +static struct visited *handle_function(struct cgraph_node *node, struct next_cgraph_node *next_node, struct visited *visited)
114079 +{
114080 + struct interesting_node *head, *cur_node;
114081 + struct next_cgraph_node *cur_cnodes, *cnodes_head = NULL;
114082 +
114083 +#if BUILDING_GCC_VERSION <= 4007
114084 + set_current_function_decl(node->decl);
114085 +#else
114086 + set_current_function_decl(node->symbol.decl);
114087 +#endif
114088 + call_count = 0;
114089 +
114090 + head = collect_interesting_stmts(next_node);
114091 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
114092 + if (is_visited_function(visited, cur_node))
114093 + continue;
114094 + cnodes_head = handle_interesting_stmt(cnodes_head, cur_node, node);
114095 + visited = insert_visited_function(visited, cur_node);
114096 + }
114097 +
114098 + free_interesting_node(head);
114099 + remove_all_size_overflow_asm();
114100 + unset_current_function_decl();
114101 +
114102 + for (cur_cnodes = cnodes_head; cur_cnodes; cur_cnodes = cur_cnodes->next)
114103 + visited = handle_function(cur_cnodes->current_function, cur_cnodes, visited);
114104 +
114105 + free_next_cgraph_node(cnodes_head);
114106 + return visited;
114107 +}
114108 +
114109 +static void free_visited(struct visited *head)
114110 +{
114111 + struct visited *cur;
114112 +
114113 + while (head) {
114114 + cur = head->next;
114115 + free(head);
114116 + head = cur;
114117 + }
114118 +}
114119 +
114120 +// erase the local flag
114121 +static void set_plf_false(void)
114122 +{
114123 + basic_block bb;
114124 +
114125 + FOR_ALL_BB(bb) {
114126 + gimple_stmt_iterator si;
114127 +
114128 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
114129 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
114130 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
114131 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
114132 + }
114133 +}
114134 +
114135 +#if BUILDING_GCC_VERSION <= 4006
114136 +static bool cgraph_function_with_gimple_body_p(struct cgraph_node *node)
114137 +{
114138 + return node->analyzed && !node->thunk.thunk_p && !node->alias;
114139 +}
114140 +
114141 +static struct cgraph_node *cgraph_first_function_with_gimple_body(void)
114142 +{
114143 + struct cgraph_node *node;
114144 +
114145 + for (node = cgraph_nodes; node; node = node->next) {
114146 + if (cgraph_function_with_gimple_body_p(node))
114147 + return node;
114148 + }
114149 + return NULL;
114150 +}
114151 +
114152 +static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct cgraph_node *node)
114153 +{
114154 + for (node = node->next; node; node = node->next) {
114155 + if (cgraph_function_with_gimple_body_p(node))
114156 + return node;
114157 + }
114158 + return NULL;
114159 +}
114160 +
114161 +#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
114162 + for ((node) = cgraph_first_function_with_gimple_body (); (node); \
114163 + (node) = cgraph_next_function_with_gimple_body (node))
114164 +
114165 +#endif
114166 +
114167 +// Main entry point of the ipa pass: erases the plf flag of all stmts and iterates over all the functions
114168 +static unsigned int search_function(void)
114169 +{
114170 + struct cgraph_node *node;
114171 + struct visited *visited = NULL;
114172 +
114173 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
114174 +#if BUILDING_GCC_VERSION <= 4007
114175 + set_current_function_decl(node->decl);
114176 +#else
114177 + set_current_function_decl(node->symbol.decl);
114178 +#endif
114179 + set_plf_false();
114180 + unset_current_function_decl();
114181 + }
114182 +
114183 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
114184 + gcc_assert(cgraph_function_flags_ready);
114185 +#if BUILDING_GCC_VERSION <= 4007
114186 + gcc_assert(node->reachable);
114187 +#endif
114188 +
114189 + visited = handle_function(node, NULL, visited);
114190 + }
114191 +
114192 + free_visited(visited);
114193 + return 0;
114194 +}
114195 +
114196 +static struct ipa_opt_pass_d pass_ipa = {
114197 + .pass = {
114198 + .type = SIMPLE_IPA_PASS,
114199 + .name = "size_overflow",
114200 +#if BUILDING_GCC_VERSION >= 4008
114201 + .optinfo_flags = OPTGROUP_NONE,
114202 +#endif
114203 + .gate = NULL,
114204 + .execute = search_function,
114205 + .sub = NULL,
114206 + .next = NULL,
114207 + .static_pass_number = 0,
114208 + .tv_id = TV_NONE,
114209 + .properties_required = 0,
114210 + .properties_provided = 0,
114211 + .properties_destroyed = 0,
114212 + .todo_flags_start = 0,
114213 + .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,
114214 + },
114215 + .generate_summary = NULL,
114216 + .write_summary = NULL,
114217 + .read_summary = NULL,
114218 +#if BUILDING_GCC_VERSION >= 4006
114219 + .write_optimization_summary = NULL,
114220 + .read_optimization_summary = NULL,
114221 +#endif
114222 + .stmt_fixup = NULL,
114223 + .function_transform_todo_flags_start = 0,
114224 + .function_transform = NULL,
114225 + .variable_transform = NULL,
114226 +};
114227 +
114228 +// data for the size_overflow asm stmt
114229 +struct asm_data {
114230 + gimple def_stmt;
114231 + tree input;
114232 + tree output;
114233 +};
114234 +
114235 +#if BUILDING_GCC_VERSION <= 4007
114236 +static VEC(tree, gc) *create_asm_io_list(tree string, tree io)
114237 +#else
114238 +static vec<tree, va_gc> *create_asm_io_list(tree string, tree io)
114239 +#endif
114240 +{
114241 + tree list;
114242 +#if BUILDING_GCC_VERSION <= 4007
114243 + VEC(tree, gc) *vec_list = NULL;
114244 +#else
114245 + vec<tree, va_gc> *vec_list = NULL;
114246 +#endif
114247 +
114248 + list = build_tree_list(NULL_TREE, string);
114249 + list = chainon(NULL_TREE, build_tree_list(list, io));
114250 +#if BUILDING_GCC_VERSION <= 4007
114251 + VEC_safe_push(tree, gc, vec_list, list);
114252 +#else
114253 + vec_safe_push(vec_list, list);
114254 +#endif
114255 + return vec_list;
114256 +}
114257 +
114258 +static void create_asm_stmt(const char *str, tree str_input, tree str_output, struct asm_data *asm_data)
114259 +{
114260 + gimple asm_stmt;
114261 + gimple_stmt_iterator gsi;
114262 +#if BUILDING_GCC_VERSION <= 4007
114263 + VEC(tree, gc) *input, *output = NULL;
114264 +#else
114265 + vec<tree, va_gc> *input, *output = NULL;
114266 +#endif
114267 +
114268 + input = create_asm_io_list(str_input, asm_data->input);
114269 +
114270 + if (asm_data->output)
114271 + output = create_asm_io_list(str_output, asm_data->output);
114272 +
114273 + asm_stmt = gimple_build_asm_vec(str, input, output, NULL, NULL);
114274 + gsi = gsi_for_stmt(asm_data->def_stmt);
114275 + gsi_insert_after(&gsi, asm_stmt, GSI_NEW_STMT);
114276 +
114277 + if (asm_data->output)
114278 + SSA_NAME_DEF_STMT(asm_data->output) = asm_stmt;
114279 +}
114280 +
114281 +static void replace_call_lhs(const struct asm_data *asm_data)
114282 +{
114283 + gimple_set_lhs(asm_data->def_stmt, asm_data->input);
114284 + update_stmt(asm_data->def_stmt);
114285 + SSA_NAME_DEF_STMT(asm_data->input) = asm_data->def_stmt;
114286 +}
114287 +
114288 +static enum mark search_intentional_phi(struct pointer_set_t *visited, const_tree result)
114289 +{
114290 + enum mark cur_fndecl_attr;
114291 + gimple phi = get_def_stmt(result);
114292 + unsigned int i, n = gimple_phi_num_args(phi);
114293 +
114294 + pointer_set_insert(visited, phi);
114295 + for (i = 0; i < n; i++) {
114296 + tree arg = gimple_phi_arg_def(phi, i);
114297 +
114298 + cur_fndecl_attr = search_intentional(visited, arg);
114299 + if (cur_fndecl_attr != MARK_NO)
114300 + return cur_fndecl_attr;
114301 + }
114302 + return MARK_NO;
114303 +}
114304 +
114305 +static enum mark search_intentional_binary(struct pointer_set_t *visited, const_tree lhs)
114306 +{
114307 + enum mark cur_fndecl_attr;
114308 + const_tree rhs1, rhs2;
114309 + gimple def_stmt = get_def_stmt(lhs);
114310 +
114311 + rhs1 = gimple_assign_rhs1(def_stmt);
114312 + rhs2 = gimple_assign_rhs2(def_stmt);
114313 +
114314 + cur_fndecl_attr = search_intentional(visited, rhs1);
114315 + if (cur_fndecl_attr != MARK_NO)
114316 + return cur_fndecl_attr;
114317 + return search_intentional(visited, rhs2);
114318 +}
114319 +
114320 +// Look up the intentional_overflow attribute on the caller and the callee functions.
114321 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs)
114322 +{
114323 + const_gimple def_stmt;
114324 +
114325 + if (TREE_CODE(lhs) != SSA_NAME)
114326 + return get_intentional_attr_type(lhs);
114327 +
114328 + def_stmt = get_def_stmt(lhs);
114329 + if (!def_stmt)
114330 + return MARK_NO;
114331 +
114332 + if (pointer_set_contains(visited, def_stmt))
114333 + return MARK_NO;
114334 +
114335 + switch (gimple_code(def_stmt)) {
114336 + case GIMPLE_NOP:
114337 + return search_intentional(visited, SSA_NAME_VAR(lhs));
114338 + case GIMPLE_ASM:
114339 + if (is_size_overflow_intentional_asm_turn_off(def_stmt))
114340 + return MARK_TURN_OFF;
114341 + return MARK_NO;
114342 + case GIMPLE_CALL:
114343 + return MARK_NO;
114344 + case GIMPLE_PHI:
114345 + return search_intentional_phi(visited, lhs);
114346 + case GIMPLE_ASSIGN:
114347 + switch (gimple_num_ops(def_stmt)) {
114348 + case 2:
114349 + return search_intentional(visited, gimple_assign_rhs1(def_stmt));
114350 + case 3:
114351 + return search_intentional_binary(visited, lhs);
114352 + }
114353 + case GIMPLE_RETURN:
114354 + return MARK_NO;
114355 + default:
114356 + debug_gimple_stmt((gimple)def_stmt);
114357 + error("%s: unknown gimple code", __func__);
114358 + gcc_unreachable();
114359 + }
114360 +}
114361 +
114362 +// Check the intentional_overflow attribute and create the asm comment string for the size_overflow asm stmt.
114363 +static enum mark check_intentional_attribute_gimple(const_tree arg, const_gimple stmt, unsigned int argnum)
114364 +{
114365 + const_tree fndecl;
114366 + struct pointer_set_t *visited;
114367 + enum mark cur_fndecl_attr, decl_attr = MARK_NO;
114368 +
114369 + fndecl = get_interesting_orig_fndecl(stmt, argnum);
114370 + if (is_end_intentional_intentional_attr(fndecl, argnum))
114371 + decl_attr = MARK_NOT_INTENTIONAL;
114372 + else if (is_yes_intentional_attr(fndecl, argnum))
114373 + decl_attr = MARK_YES;
114374 + else if (is_turn_off_intentional_attr(fndecl) || is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
114375 + return MARK_TURN_OFF;
114376 + }
114377 +
114378 + visited = pointer_set_create();
114379 + cur_fndecl_attr = search_intentional(visited, arg);
114380 + pointer_set_destroy(visited);
114381 +
114382 + switch (cur_fndecl_attr) {
114383 + case MARK_NO:
114384 + case MARK_TURN_OFF:
114385 + return cur_fndecl_attr;
114386 + default:
114387 + print_missing_intentional(decl_attr, cur_fndecl_attr, fndecl, argnum);
114388 + return MARK_YES;
114389 + }
114390 +}
114391 +
114392 +static void check_missing_size_overflow_attribute(tree var)
114393 +{
114394 + tree orig_fndecl;
114395 + unsigned int num;
114396 +
114397 + if (is_a_return_check(var))
114398 + orig_fndecl = DECL_ORIGIN(var);
114399 + else
114400 + orig_fndecl = DECL_ORIGIN(current_function_decl);
114401 +
114402 + num = get_function_num(var, orig_fndecl);
114403 + if (num == CANNOT_FIND_ARG)
114404 + return;
114405 +
114406 + is_missing_function(orig_fndecl, num);
114407 +}
114408 +
114409 +static void search_size_overflow_attribute_phi(struct pointer_set_t *visited, const_tree result)
114410 +{
114411 + gimple phi = get_def_stmt(result);
114412 + unsigned int i, n = gimple_phi_num_args(phi);
114413 +
114414 + pointer_set_insert(visited, phi);
114415 + for (i = 0; i < n; i++) {
114416 + tree arg = gimple_phi_arg_def(phi, i);
114417 +
114418 + search_size_overflow_attribute(visited, arg);
114419 + }
114420 +}
114421 +
114422 +static void search_size_overflow_attribute_binary(struct pointer_set_t *visited, const_tree lhs)
114423 +{
114424 + const_gimple def_stmt = get_def_stmt(lhs);
114425 + tree rhs1, rhs2;
114426 +
114427 + rhs1 = gimple_assign_rhs1(def_stmt);
114428 + rhs2 = gimple_assign_rhs2(def_stmt);
114429 +
114430 + search_size_overflow_attribute(visited, rhs1);
114431 + search_size_overflow_attribute(visited, rhs2);
114432 +}
114433 +
114434 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs)
114435 +{
114436 + const_gimple def_stmt;
114437 +
114438 + if (TREE_CODE(lhs) == PARM_DECL) {
114439 + check_missing_size_overflow_attribute(lhs);
114440 + return;
114441 + }
114442 +
114443 + def_stmt = get_def_stmt(lhs);
114444 + if (!def_stmt)
114445 + return;
114446 +
114447 + if (pointer_set_insert(visited, def_stmt))
114448 + return;
114449 +
114450 + switch (gimple_code(def_stmt)) {
114451 + case GIMPLE_NOP:
114452 + return search_size_overflow_attribute(visited, SSA_NAME_VAR(lhs));
114453 + case GIMPLE_ASM:
114454 + return;
114455 + case GIMPLE_CALL: {
114456 + tree fndecl = gimple_call_fndecl(def_stmt);
114457 +
114458 + if (fndecl == NULL_TREE)
114459 + return;
114460 + check_missing_size_overflow_attribute(fndecl);
114461 + return;
114462 + }
114463 + case GIMPLE_PHI:
114464 + return search_size_overflow_attribute_phi(visited, lhs);
114465 + case GIMPLE_ASSIGN:
114466 + switch (gimple_num_ops(def_stmt)) {
114467 + case 2:
114468 + return search_size_overflow_attribute(visited, gimple_assign_rhs1(def_stmt));
114469 + case 3:
114470 + return search_size_overflow_attribute_binary(visited, lhs);
114471 + }
114472 + default:
114473 + debug_gimple_stmt((gimple)def_stmt);
114474 + error("%s: unknown gimple code", __func__);
114475 + gcc_unreachable();
114476 + }
114477 +}
114478 +
114479 +// Search missing entries in the hash table (invoked from the gimple pass)
114480 +static void search_missing_size_overflow_attribute_gimple(const_gimple stmt, unsigned int num)
114481 +{
114482 + tree fndecl = NULL_TREE;
114483 + tree lhs;
114484 + struct pointer_set_t *visited;
114485 +
114486 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl)))
114487 + return;
114488 +
114489 + if (num == 0) {
114490 + gcc_assert(gimple_code(stmt) == GIMPLE_RETURN);
114491 + lhs = gimple_return_retval(stmt);
114492 + } else {
114493 + gcc_assert(is_gimple_call(stmt));
114494 + lhs = gimple_call_arg(stmt, num - 1);
114495 + fndecl = gimple_call_fndecl(stmt);
114496 + }
114497 +
114498 + if (fndecl != NULL_TREE && is_turn_off_intentional_attr(DECL_ORIGIN(fndecl)))
114499 + return;
114500 +
114501 + visited = pointer_set_create();
114502 + search_size_overflow_attribute(visited, lhs);
114503 + pointer_set_destroy(visited);
114504 +}
114505 +
114506 +static void create_output_from_phi(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
114507 +{
114508 + gimple_stmt_iterator gsi;
114509 + gimple assign;
114510 +
114511 + assign = gimple_build_assign(asm_data->input, asm_data->output);
114512 + gsi = gsi_for_stmt(stmt);
114513 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
114514 + asm_data->def_stmt = assign;
114515 +
114516 + asm_data->output = create_new_var(TREE_TYPE(asm_data->output));
114517 + asm_data->output = make_ssa_name(asm_data->output, stmt);
114518 + if (gimple_code(stmt) == GIMPLE_RETURN)
114519 + gimple_return_set_retval(stmt, asm_data->output);
114520 + else
114521 + gimple_call_set_arg(stmt, argnum - 1, asm_data->output);
114522 + update_stmt(stmt);
114523 +}
114524 +
114525 +static char *create_asm_comment(unsigned int argnum, const_gimple stmt , const char *mark_str)
114526 +{
114527 + const char *fn_name;
114528 + char *asm_comment;
114529 + unsigned int len;
114530 +
114531 + if (argnum == 0)
114532 + fn_name = NAME(current_function_decl);
114533 + else
114534 + fn_name = NAME(gimple_call_fndecl(stmt));
114535 +
114536 + len = asprintf(&asm_comment, "%s %s %u", mark_str, fn_name, argnum);
114537 + gcc_assert(len > 0);
114538 +
114539 + return asm_comment;
114540 +}
114541 +
114542 +static const char *convert_mark_to_str(enum mark mark)
114543 +{
114544 + switch (mark) {
114545 + case MARK_NO:
114546 + return OK_ASM_STR;
114547 + case MARK_YES:
114548 + case MARK_NOT_INTENTIONAL:
114549 + return YES_ASM_STR;
114550 + case MARK_TURN_OFF:
114551 + return TURN_OFF_ASM_STR;
114552 + }
114553 +
114554 + gcc_unreachable();
114555 +}
114556 +
114557 +/* Create the input of the size_overflow asm stmt.
114558 + * When the arg of the callee function is a parm_decl it creates this kind of size_overflow asm stmt:
114559 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
114560 + * The input field in asm_data will be empty if there is no need for further size_overflow asm stmt insertion.
114561 + * otherwise create the input (for a phi stmt the output too) of the asm stmt.
114562 + */
114563 +static void create_asm_input(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
114564 +{
114565 + if (!asm_data->def_stmt) {
114566 + asm_data->input = NULL_TREE;
114567 + return;
114568 + }
114569 +
114570 + asm_data->input = create_new_var(TREE_TYPE(asm_data->output));
114571 + asm_data->input = make_ssa_name(asm_data->input, asm_data->def_stmt);
114572 +
114573 + switch (gimple_code(asm_data->def_stmt)) {
114574 + case GIMPLE_ASSIGN:
114575 + case GIMPLE_CALL:
114576 + replace_call_lhs(asm_data);
114577 + break;
114578 + case GIMPLE_PHI:
114579 + create_output_from_phi(stmt, argnum, asm_data);
114580 + break;
114581 + case GIMPLE_NOP: {
114582 + enum mark mark;
114583 + const char *mark_str;
114584 + char *asm_comment;
114585 +
114586 + mark = check_intentional_attribute_gimple(asm_data->output, stmt, argnum);
114587 +
114588 + asm_data->input = asm_data->output;
114589 + asm_data->output = NULL;
114590 + asm_data->def_stmt = stmt;
114591 +
114592 + mark_str = convert_mark_to_str(mark);
114593 + asm_comment = create_asm_comment(argnum, stmt, mark_str);
114594 +
114595 + create_asm_stmt(asm_comment, build_string(2, "rm"), NULL, asm_data);
114596 + free(asm_comment);
114597 + asm_data->input = NULL_TREE;
114598 + break;
114599 + }
114600 + case GIMPLE_ASM:
114601 + if (is_size_overflow_asm(asm_data->def_stmt)) {
114602 + asm_data->input = NULL_TREE;
114603 + break;
114604 + }
114605 + default:
114606 + debug_gimple_stmt(asm_data->def_stmt);
114607 + gcc_unreachable();
114608 + }
114609 +}
114610 +
114611 +/* This is the gimple part of searching for a missing size_overflow attribute. If the intentional_overflow attribute type
114612 + * is of the right kind create the appropriate size_overflow asm stmts:
114613 + * __asm__("# size_overflow" : =rm" D.3344_8 : "0" cicus.4_16);
114614 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
114615 + */
114616 +static void create_size_overflow_asm(gimple stmt, tree output_node, unsigned int argnum)
114617 +{
114618 + struct asm_data asm_data;
114619 + const char *mark_str;
114620 + char *asm_comment;
114621 + enum mark mark;
114622 +
114623 + if (is_gimple_constant(output_node))
114624 + return;
114625 +
114626 + asm_data.output = output_node;
114627 + mark = check_intentional_attribute_gimple(asm_data.output, stmt, argnum);
114628 + if (mark != MARK_TURN_OFF)
114629 + search_missing_size_overflow_attribute_gimple(stmt, argnum);
114630 +
114631 + asm_data.def_stmt = get_def_stmt(asm_data.output);
114632 + if (is_size_overflow_intentional_asm_turn_off(asm_data.def_stmt))
114633 + return;
114634 +
114635 + create_asm_input(stmt, argnum, &asm_data);
114636 + if (asm_data.input == NULL_TREE)
114637 + return;
114638 +
114639 + mark_str = convert_mark_to_str(mark);
114640 + asm_comment = create_asm_comment(argnum, stmt, mark_str);
114641 + create_asm_stmt(asm_comment, build_string(1, "0"), build_string(3, "=rm"), &asm_data);
114642 + free(asm_comment);
114643 +}
114644 +
114645 +// Insert an asm stmt with "MARK_TURN_OFF", "MARK_YES" or "MARK_NOT_INTENTIONAL".
114646 +static bool create_mark_asm(gimple stmt, enum mark mark)
114647 +{
114648 + struct asm_data asm_data;
114649 + const char *asm_str;
114650 +
114651 + switch (mark) {
114652 + case MARK_TURN_OFF:
114653 + asm_str = TURN_OFF_ASM_STR;
114654 + break;
114655 + case MARK_NOT_INTENTIONAL:
114656 + case MARK_YES:
114657 + asm_str = YES_ASM_STR;
114658 + break;
114659 + default:
114660 + gcc_unreachable();
114661 + }
114662 +
114663 + asm_data.def_stmt = stmt;
114664 + asm_data.output = gimple_call_lhs(stmt);
114665 +
114666 + if (asm_data.output == NULL_TREE) {
114667 + asm_data.input = gimple_call_arg(stmt, 0);
114668 + if (is_gimple_constant(asm_data.input))
114669 + return false;
114670 + asm_data.output = NULL;
114671 + create_asm_stmt(asm_str, build_string(2, "rm"), NULL, &asm_data);
114672 + return true;
114673 + }
114674 +
114675 + create_asm_input(stmt, 0, &asm_data);
114676 + gcc_assert(asm_data.input != NULL_TREE);
114677 +
114678 + create_asm_stmt(asm_str, build_string(1, "0"), build_string(3, "=rm"), &asm_data);
114679 + return true;
114680 +}
114681 +
114682 +static bool is_from_cast(const_tree node)
114683 +{
114684 + gimple def_stmt = get_def_stmt(node);
114685 +
114686 + if (!def_stmt)
114687 + return false;
114688 +
114689 + if (gimple_assign_cast_p(def_stmt))
114690 + return true;
114691 +
114692 + return false;
114693 +}
114694 +
114695 +// Skip duplication when there is a minus expr and the type of rhs1 or rhs2 is a pointer_type.
114696 +static bool skip_ptr_minus(gimple stmt)
114697 +{
114698 + const_tree rhs1, rhs2, ptr1_rhs, ptr2_rhs;
114699 +
114700 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
114701 + return false;
114702 +
114703 + rhs1 = gimple_assign_rhs1(stmt);
114704 + if (!is_from_cast(rhs1))
114705 + return false;
114706 +
114707 + rhs2 = gimple_assign_rhs2(stmt);
114708 + if (!is_from_cast(rhs2))
114709 + return false;
114710 +
114711 + ptr1_rhs = gimple_assign_rhs1(get_def_stmt(rhs1));
114712 + ptr2_rhs = gimple_assign_rhs1(get_def_stmt(rhs2));
114713 +
114714 + if (TREE_CODE(TREE_TYPE(ptr1_rhs)) != POINTER_TYPE && TREE_CODE(TREE_TYPE(ptr2_rhs)) != POINTER_TYPE)
114715 + return false;
114716 +
114717 + create_mark_asm(stmt, MARK_YES);
114718 + return true;
114719 +}
114720 +
114721 +static void walk_use_def_ptr(struct pointer_set_t *visited, const_tree lhs)
114722 +{
114723 + gimple def_stmt;
114724 +
114725 + def_stmt = get_def_stmt(lhs);
114726 + if (!def_stmt)
114727 + return;
114728 +
114729 + if (pointer_set_insert(visited, def_stmt))
114730 + return;
114731 +
114732 + switch (gimple_code(def_stmt)) {
114733 + case GIMPLE_NOP:
114734 + case GIMPLE_ASM:
114735 + case GIMPLE_CALL:
114736 + break;
114737 + case GIMPLE_PHI: {
114738 + unsigned int i, n = gimple_phi_num_args(def_stmt);
114739 +
114740 + pointer_set_insert(visited, def_stmt);
114741 +
114742 + for (i = 0; i < n; i++) {
114743 + tree arg = gimple_phi_arg_def(def_stmt, i);
114744 +
114745 + walk_use_def_ptr(visited, arg);
114746 + }
114747 + }
114748 + case GIMPLE_ASSIGN:
114749 + switch (gimple_num_ops(def_stmt)) {
114750 + case 2:
114751 + walk_use_def_ptr(visited, gimple_assign_rhs1(def_stmt));
114752 + return;
114753 + case 3:
114754 + if (skip_ptr_minus(def_stmt))
114755 + return;
114756 +
114757 + walk_use_def_ptr(visited, gimple_assign_rhs1(def_stmt));
114758 + walk_use_def_ptr(visited, gimple_assign_rhs2(def_stmt));
114759 + return;
114760 + default:
114761 + return;
114762 + }
114763 + default:
114764 + debug_gimple_stmt((gimple)def_stmt);
114765 + error("%s: unknown gimple code", __func__);
114766 + gcc_unreachable();
114767 + }
114768 +}
114769 +
114770 +// Look for a ptr - ptr expression (e.g., cpuset_common_file_read() s - page)
114771 +static void insert_mark_not_intentional_asm_at_ptr(const_tree arg)
114772 +{
114773 + struct pointer_set_t *visited;
114774 +
114775 + visited = pointer_set_create();
114776 + walk_use_def_ptr(visited, arg);
114777 + pointer_set_destroy(visited);
114778 +}
114779 +
114780 +// Determine the return value and insert the asm stmt to mark the return stmt.
114781 +static void insert_asm_ret(gimple stmt)
114782 +{
114783 + tree ret;
114784 +
114785 + ret = gimple_return_retval(stmt);
114786 + create_size_overflow_asm(stmt, ret, 0);
114787 +}
114788 +
114789 +// Determine the correct arg index and arg and insert the asm stmt to mark the stmt.
114790 +static void insert_asm_arg(gimple stmt, unsigned int orig_argnum)
114791 +{
114792 + tree arg;
114793 + unsigned int argnum;
114794 +
114795 + argnum = get_correct_arg_count(orig_argnum, gimple_call_fndecl(stmt));
114796 + gcc_assert(argnum != 0);
114797 + if (argnum == CANNOT_FIND_ARG)
114798 + return;
114799 +
114800 + arg = gimple_call_arg(stmt, argnum - 1);
114801 + gcc_assert(arg != NULL_TREE);
114802 +
114803 + // skip all ptr - ptr expressions
114804 + insert_mark_not_intentional_asm_at_ptr(arg);
114805 +
114806 + create_size_overflow_asm(stmt, arg, argnum);
114807 +}
114808 +
114809 +// If a function arg or the return value is marked by the size_overflow attribute then set its index in the array.
114810 +static void set_argnum_attribute(const_tree attr, bool *argnums)
114811 +{
114812 + unsigned int argnum;
114813 + tree attr_value;
114814 +
114815 + for (attr_value = TREE_VALUE(attr); attr_value; attr_value = TREE_CHAIN(attr_value)) {
114816 + argnum = TREE_INT_CST_LOW(TREE_VALUE(attr_value));
114817 + argnums[argnum] = true;
114818 + }
114819 +}
114820 +
114821 +// If a function arg or the return value is in the hash table then set its index in the array.
114822 +static void set_argnum_hash(tree fndecl, bool *argnums)
114823 +{
114824 + unsigned int num;
114825 + const struct size_overflow_hash *hash;
114826 +
114827 + hash = get_function_hash(DECL_ORIGIN(fndecl));
114828 + if (!hash)
114829 + return;
114830 +
114831 + for (num = 0; num <= MAX_PARAM; num++) {
114832 + if (!(hash->param & (1U << num)))
114833 + continue;
114834 +
114835 + argnums[num] = true;
114836 + }
114837 +}
114838 +
114839 +static bool is_all_the_argnums_empty(bool *argnums)
114840 +{
114841 + unsigned int i;
114842 +
114843 + for (i = 0; i <= MAX_PARAM; i++)
114844 + if (argnums[i])
114845 + return false;
114846 + return true;
114847 +}
114848 +
114849 +// Check whether the arguments or the return value of the function are in the hash table or are marked by the size_overflow attribute.
114850 +static void search_interesting_args(tree fndecl, bool *argnums)
114851 +{
114852 + const_tree attr;
114853 +
114854 + set_argnum_hash(fndecl, argnums);
114855 + if (!is_all_the_argnums_empty(argnums))
114856 + return;
114857 +
114858 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
114859 + if (attr && TREE_VALUE(attr))
114860 + set_argnum_attribute(attr, argnums);
114861 +}
114862 +
114863 +/*
114864 + * Look up the intentional_overflow attribute that turns off ipa based duplication
114865 + * on the callee function.
114866 + */
114867 +static bool is_mark_turn_off_attribute(gimple stmt)
114868 +{
114869 + enum mark mark;
114870 + const_tree fndecl = gimple_call_fndecl(stmt);
114871 +
114872 + mark = get_intentional_attr_type(DECL_ORIGIN(fndecl));
114873 + if (mark == MARK_TURN_OFF)
114874 + return true;
114875 + return false;
114876 +}
114877 +
114878 +// 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
114879 +static void handle_interesting_function(gimple stmt)
114880 +{
114881 + unsigned int argnum;
114882 + tree fndecl;
114883 + bool orig_argnums[MAX_PARAM + 1] = {false};
114884 +
114885 + if (gimple_call_num_args(stmt) == 0)
114886 + return;
114887 + fndecl = gimple_call_fndecl(stmt);
114888 + if (fndecl == NULL_TREE)
114889 + return;
114890 + fndecl = DECL_ORIGIN(fndecl);
114891 +
114892 + if (is_mark_turn_off_attribute(stmt)) {
114893 + create_mark_asm(stmt, MARK_TURN_OFF);
114894 + return;
114895 + }
114896 +
114897 + search_interesting_args(fndecl, orig_argnums);
114898 +
114899 + for (argnum = 1; argnum < MAX_PARAM; argnum++)
114900 + if (orig_argnums[argnum])
114901 + insert_asm_arg(stmt, argnum);
114902 +}
114903 +
114904 +// 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
114905 +static void handle_interesting_ret(gimple stmt)
114906 +{
114907 + bool orig_argnums[MAX_PARAM + 1] = {false};
114908 +
114909 + search_interesting_args(current_function_decl, orig_argnums);
114910 +
114911 + if (orig_argnums[0])
114912 + insert_asm_ret(stmt);
114913 +}
114914 +
114915 +// Iterate over all the stmts and search for call and return stmts and mark them if they're in the hash table
114916 +static unsigned int search_interesting_functions(void)
114917 +{
114918 + basic_block bb;
114919 +
114920 + FOR_ALL_BB(bb) {
114921 + gimple_stmt_iterator gsi;
114922 +
114923 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
114924 + gimple stmt = gsi_stmt(gsi);
114925 +
114926 + if (is_size_overflow_asm(stmt))
114927 + continue;
114928 +
114929 + if (is_gimple_call(stmt))
114930 + handle_interesting_function(stmt);
114931 + else if (gimple_code(stmt) == GIMPLE_RETURN)
114932 + handle_interesting_ret(stmt);
114933 + }
114934 + }
114935 + return 0;
114936 +}
114937 +
114938 +/*
114939 + * A lot of functions get inlined before the ipa passes so after the build_ssa gimple pass
114940 + * this pass inserts asm stmts to mark the interesting args
114941 + * that the ipa pass will detect and insert the size overflow checks for.
114942 + */
114943 +static struct gimple_opt_pass insert_size_overflow_asm_pass = {
114944 + .pass = {
114945 + .type = GIMPLE_PASS,
114946 + .name = "insert_size_overflow_asm",
114947 +#if BUILDING_GCC_VERSION >= 4008
114948 + .optinfo_flags = OPTGROUP_NONE,
114949 +#endif
114950 + .gate = NULL,
114951 + .execute = search_interesting_functions,
114952 + .sub = NULL,
114953 + .next = NULL,
114954 + .static_pass_number = 0,
114955 + .tv_id = TV_NONE,
114956 + .properties_required = PROP_cfg,
114957 + .properties_provided = 0,
114958 + .properties_destroyed = 0,
114959 + .todo_flags_start = 0,
114960 + .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
114961 + }
114962 +};
114963 +
114964 +// Create the noreturn report_size_overflow() function decl.
114965 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
114966 +{
114967 + tree fntype;
114968 +
114969 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
114970 +
114971 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
114972 + fntype = build_function_type_list(void_type_node,
114973 + const_char_ptr_type_node,
114974 + unsigned_type_node,
114975 + const_char_ptr_type_node,
114976 + const_char_ptr_type_node,
114977 + NULL_TREE);
114978 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
114979 +
114980 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
114981 + TREE_PUBLIC(report_size_overflow_decl) = 1;
114982 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
114983 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
114984 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
114985 +}
114986 +
114987 +static unsigned int dump_functions(void)
114988 +{
114989 + struct cgraph_node *node;
114990 +
114991 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
114992 + basic_block bb;
114993 +
114994 +#if BUILDING_GCC_VERSION <= 4007
114995 + push_cfun(DECL_STRUCT_FUNCTION(node->decl));
114996 + current_function_decl = node->decl;
114997 +#else
114998 + push_cfun(DECL_STRUCT_FUNCTION(node->symbol.decl));
114999 + current_function_decl = node->symbol.decl;
115000 +#endif
115001 +
115002 + fprintf(stderr, "-----------------------------------------\n%s\n-----------------------------------------\n", NAME(current_function_decl));
115003 +
115004 + FOR_ALL_BB(bb) {
115005 + gimple_stmt_iterator si;
115006 +
115007 + fprintf(stderr, "<bb %u>:\n", bb->index);
115008 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
115009 + debug_gimple_stmt(gsi_stmt(si));
115010 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
115011 + debug_gimple_stmt(gsi_stmt(si));
115012 + fprintf(stderr, "\n");
115013 + }
115014 +
115015 + fprintf(stderr, "-------------------------------------------------------------------------\n");
115016 +
115017 + pop_cfun();
115018 + current_function_decl = NULL_TREE;
115019 + }
115020 +
115021 + fprintf(stderr, "###############################################################################\n");
115022 +
115023 + return 0;
115024 +}
115025 +
115026 +static struct ipa_opt_pass_d pass_dump = {
115027 + .pass = {
115028 + .type = SIMPLE_IPA_PASS,
115029 + .name = "dump",
115030 +#if BUILDING_GCC_VERSION >= 4008
115031 + .optinfo_flags = OPTGROUP_NONE,
115032 +#endif
115033 + .gate = NULL,
115034 + .execute = dump_functions,
115035 + .sub = NULL,
115036 + .next = NULL,
115037 + .static_pass_number = 0,
115038 + .tv_id = TV_NONE,
115039 + .properties_required = 0,
115040 + .properties_provided = 0,
115041 + .properties_destroyed = 0,
115042 + .todo_flags_start = 0,
115043 + .todo_flags_finish = 0,
115044 + },
115045 + .generate_summary = NULL,
115046 + .write_summary = NULL,
115047 + .read_summary = NULL,
115048 +#if BUILDING_GCC_VERSION >= 4006
115049 + .write_optimization_summary = NULL,
115050 + .read_optimization_summary = NULL,
115051 +#endif
115052 + .stmt_fixup = NULL,
115053 + .function_transform_todo_flags_start = 0,
115054 + .function_transform = NULL,
115055 + .variable_transform = NULL,
115056 +};
115057 +
115058 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
115059 +{
115060 + int i;
115061 + const char * const plugin_name = plugin_info->base_name;
115062 + const int argc = plugin_info->argc;
115063 + const struct plugin_argument * const argv = plugin_info->argv;
115064 + bool enable = true;
115065 +
115066 + struct register_pass_info insert_size_overflow_asm_pass_info = {
115067 + .pass = &insert_size_overflow_asm_pass.pass,
115068 + .reference_pass_name = "ssa",
115069 + .ref_pass_instance_number = 1,
115070 + .pos_op = PASS_POS_INSERT_AFTER
115071 + };
115072 +
115073 + struct register_pass_info __unused dump_before_pass_info = {
115074 + .pass = &pass_dump.pass,
115075 + .reference_pass_name = "increase_alignment",
115076 + .ref_pass_instance_number = 1,
115077 + .pos_op = PASS_POS_INSERT_BEFORE
115078 + };
115079 +
115080 + struct register_pass_info ipa_pass_info = {
115081 + .pass = &pass_ipa.pass,
115082 + .reference_pass_name = "increase_alignment",
115083 + .ref_pass_instance_number = 1,
115084 + .pos_op = PASS_POS_INSERT_BEFORE
115085 + };
115086 +
115087 + struct register_pass_info __unused dump_after_pass_info = {
115088 + .pass = &pass_dump.pass,
115089 + .reference_pass_name = "increase_alignment",
115090 + .ref_pass_instance_number = 1,
115091 + .pos_op = PASS_POS_INSERT_BEFORE
115092 + };
115093 +
115094 + if (!plugin_default_version_check(version, &gcc_version)) {
115095 + error(G_("incompatible gcc/plugin versions"));
115096 + return 1;
115097 + }
115098 +
115099 + for (i = 0; i < argc; ++i) {
115100 + if (!strcmp(argv[i].key, "no-size-overflow")) {
115101 + enable = false;
115102 + continue;
115103 + }
115104 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
115105 + }
115106 +
115107 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
115108 + if (enable) {
115109 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
115110 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &insert_size_overflow_asm_pass_info);
115111 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_before_pass_info);
115112 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &ipa_pass_info);
115113 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_after_pass_info);
115114 + }
115115 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
115116 +
115117 + return 0;
115118 +}
115119 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
115120 new file mode 100644
115121 index 0000000..ac2901e
115122 --- /dev/null
115123 +++ b/tools/gcc/stackleak_plugin.c
115124 @@ -0,0 +1,327 @@
115125 +/*
115126 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
115127 + * Licensed under the GPL v2
115128 + *
115129 + * Note: the choice of the license means that the compilation process is
115130 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
115131 + * but for the kernel it doesn't matter since it doesn't link against
115132 + * any of the gcc libraries
115133 + *
115134 + * gcc plugin to help implement various PaX features
115135 + *
115136 + * - track lowest stack pointer
115137 + *
115138 + * TODO:
115139 + * - initialize all local variables
115140 + *
115141 + * BUGS:
115142 + * - none known
115143 + */
115144 +#include "gcc-plugin.h"
115145 +#include "config.h"
115146 +#include "system.h"
115147 +#include "coretypes.h"
115148 +#include "tree.h"
115149 +#include "tree-pass.h"
115150 +#include "flags.h"
115151 +#include "intl.h"
115152 +#include "toplev.h"
115153 +#include "plugin.h"
115154 +//#include "expr.h" where are you...
115155 +#include "diagnostic.h"
115156 +#include "plugin-version.h"
115157 +#include "tm.h"
115158 +#include "function.h"
115159 +#include "basic-block.h"
115160 +#include "gimple.h"
115161 +#include "rtl.h"
115162 +#include "emit-rtl.h"
115163 +
115164 +#if BUILDING_GCC_VERSION >= 4008
115165 +#define TODO_dump_func 0
115166 +#endif
115167 +
115168 +extern void print_gimple_stmt(FILE *, gimple, int, int);
115169 +
115170 +int plugin_is_GPL_compatible;
115171 +
115172 +static int track_frame_size = -1;
115173 +static const char track_function[] = "pax_track_stack";
115174 +static const char check_function[] = "pax_check_alloca";
115175 +static bool init_locals;
115176 +
115177 +static struct plugin_info stackleak_plugin_info = {
115178 + .version = "201302112000",
115179 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
115180 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
115181 +};
115182 +
115183 +static bool gate_stackleak_track_stack(void);
115184 +static unsigned int execute_stackleak_tree_instrument(void);
115185 +static unsigned int execute_stackleak_final(void);
115186 +
115187 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
115188 + .pass = {
115189 + .type = GIMPLE_PASS,
115190 + .name = "stackleak_tree_instrument",
115191 +#if BUILDING_GCC_VERSION >= 4008
115192 + .optinfo_flags = OPTGROUP_NONE,
115193 +#endif
115194 + .gate = gate_stackleak_track_stack,
115195 + .execute = execute_stackleak_tree_instrument,
115196 + .sub = NULL,
115197 + .next = NULL,
115198 + .static_pass_number = 0,
115199 + .tv_id = TV_NONE,
115200 + .properties_required = PROP_gimple_leh | PROP_cfg,
115201 + .properties_provided = 0,
115202 + .properties_destroyed = 0,
115203 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
115204 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
115205 + }
115206 +};
115207 +
115208 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
115209 + .pass = {
115210 + .type = RTL_PASS,
115211 + .name = "stackleak_final",
115212 +#if BUILDING_GCC_VERSION >= 4008
115213 + .optinfo_flags = OPTGROUP_NONE,
115214 +#endif
115215 + .gate = gate_stackleak_track_stack,
115216 + .execute = execute_stackleak_final,
115217 + .sub = NULL,
115218 + .next = NULL,
115219 + .static_pass_number = 0,
115220 + .tv_id = TV_NONE,
115221 + .properties_required = 0,
115222 + .properties_provided = 0,
115223 + .properties_destroyed = 0,
115224 + .todo_flags_start = 0,
115225 + .todo_flags_finish = TODO_dump_func
115226 + }
115227 +};
115228 +
115229 +static bool gate_stackleak_track_stack(void)
115230 +{
115231 + return track_frame_size >= 0;
115232 +}
115233 +
115234 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
115235 +{
115236 + gimple check_alloca;
115237 + tree fntype, fndecl, alloca_size;
115238 +
115239 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
115240 + fndecl = build_fn_decl(check_function, fntype);
115241 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
115242 +
115243 + // insert call to void pax_check_alloca(unsigned long size)
115244 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
115245 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
115246 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
115247 +}
115248 +
115249 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
115250 +{
115251 + gimple track_stack;
115252 + tree fntype, fndecl;
115253 +
115254 + fntype = build_function_type_list(void_type_node, NULL_TREE);
115255 + fndecl = build_fn_decl(track_function, fntype);
115256 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
115257 +
115258 + // insert call to void pax_track_stack(void)
115259 + track_stack = gimple_build_call(fndecl, 0);
115260 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
115261 +}
115262 +
115263 +#if BUILDING_GCC_VERSION == 4005
115264 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
115265 +{
115266 + tree fndecl;
115267 +
115268 + if (!is_gimple_call(stmt))
115269 + return false;
115270 + fndecl = gimple_call_fndecl(stmt);
115271 + if (!fndecl)
115272 + return false;
115273 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
115274 + return false;
115275 +// print_node(stderr, "pax", fndecl, 4);
115276 + return DECL_FUNCTION_CODE(fndecl) == code;
115277 +}
115278 +#endif
115279 +
115280 +static bool is_alloca(gimple stmt)
115281 +{
115282 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
115283 + return true;
115284 +
115285 +#if BUILDING_GCC_VERSION >= 4007
115286 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
115287 + return true;
115288 +#endif
115289 +
115290 + return false;
115291 +}
115292 +
115293 +static unsigned int execute_stackleak_tree_instrument(void)
115294 +{
115295 + basic_block bb, entry_bb;
115296 + bool prologue_instrumented = false, is_leaf = true;
115297 +
115298 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
115299 +
115300 + // 1. loop through BBs and GIMPLE statements
115301 + FOR_EACH_BB(bb) {
115302 + gimple_stmt_iterator gsi;
115303 +
115304 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
115305 + gimple stmt;
115306 +
115307 + stmt = gsi_stmt(gsi);
115308 +
115309 + if (is_gimple_call(stmt))
115310 + is_leaf = false;
115311 +
115312 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
115313 + if (!is_alloca(stmt))
115314 + continue;
115315 +
115316 + // 2. insert stack overflow check before each __builtin_alloca call
115317 + stackleak_check_alloca(&gsi);
115318 +
115319 + // 3. insert track call after each __builtin_alloca call
115320 + stackleak_add_instrumentation(&gsi);
115321 + if (bb == entry_bb)
115322 + prologue_instrumented = true;
115323 + }
115324 + }
115325 +
115326 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
115327 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
115328 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
115329 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
115330 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
115331 + return 0;
115332 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
115333 + return 0;
115334 +
115335 + // 4. insert track call at the beginning
115336 + if (!prologue_instrumented) {
115337 + gimple_stmt_iterator gsi;
115338 +
115339 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
115340 + if (dom_info_available_p(CDI_DOMINATORS))
115341 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
115342 + gsi = gsi_start_bb(bb);
115343 + stackleak_add_instrumentation(&gsi);
115344 + }
115345 +
115346 + return 0;
115347 +}
115348 +
115349 +static unsigned int execute_stackleak_final(void)
115350 +{
115351 + rtx insn, next;
115352 +
115353 + if (cfun->calls_alloca)
115354 + return 0;
115355 +
115356 + // keep calls only if function frame is big enough
115357 + if (get_frame_size() >= track_frame_size)
115358 + return 0;
115359 +
115360 + // 1. find pax_track_stack calls
115361 + for (insn = get_insns(); insn; insn = next) {
115362 + // 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))
115363 + rtx body;
115364 +
115365 + next = NEXT_INSN(insn);
115366 + if (!CALL_P(insn))
115367 + continue;
115368 + body = PATTERN(insn);
115369 + if (GET_CODE(body) != CALL)
115370 + continue;
115371 + body = XEXP(body, 0);
115372 + if (GET_CODE(body) != MEM)
115373 + continue;
115374 + body = XEXP(body, 0);
115375 + if (GET_CODE(body) != SYMBOL_REF)
115376 + continue;
115377 + if (strcmp(XSTR(body, 0), track_function))
115378 + continue;
115379 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
115380 + // 2. delete call
115381 + delete_insn_and_edges(insn);
115382 +#if BUILDING_GCC_VERSION >= 4007
115383 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
115384 + insn = next;
115385 + next = NEXT_INSN(insn);
115386 + delete_insn_and_edges(insn);
115387 + }
115388 +#endif
115389 + }
115390 +
115391 +// print_simple_rtl(stderr, get_insns());
115392 +// print_rtl(stderr, get_insns());
115393 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
115394 +
115395 + return 0;
115396 +}
115397 +
115398 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
115399 +{
115400 + const char * const plugin_name = plugin_info->base_name;
115401 + const int argc = plugin_info->argc;
115402 + const struct plugin_argument * const argv = plugin_info->argv;
115403 + int i;
115404 + struct register_pass_info stackleak_tree_instrument_pass_info = {
115405 + .pass = &stackleak_tree_instrument_pass.pass,
115406 +// .reference_pass_name = "tree_profile",
115407 + .reference_pass_name = "optimized",
115408 + .ref_pass_instance_number = 1,
115409 + .pos_op = PASS_POS_INSERT_BEFORE
115410 + };
115411 + struct register_pass_info stackleak_final_pass_info = {
115412 + .pass = &stackleak_final_rtl_opt_pass.pass,
115413 + .reference_pass_name = "final",
115414 + .ref_pass_instance_number = 1,
115415 + .pos_op = PASS_POS_INSERT_BEFORE
115416 + };
115417 +
115418 + if (!plugin_default_version_check(version, &gcc_version)) {
115419 + error(G_("incompatible gcc/plugin versions"));
115420 + return 1;
115421 + }
115422 +
115423 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
115424 +
115425 + for (i = 0; i < argc; ++i) {
115426 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
115427 + if (!argv[i].value) {
115428 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
115429 + continue;
115430 + }
115431 + track_frame_size = atoi(argv[i].value);
115432 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
115433 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
115434 + continue;
115435 + }
115436 + if (!strcmp(argv[i].key, "initialize-locals")) {
115437 + if (argv[i].value) {
115438 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
115439 + continue;
115440 + }
115441 + init_locals = true;
115442 + continue;
115443 + }
115444 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
115445 + }
115446 +
115447 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
115448 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
115449 +
115450 + return 0;
115451 +}
115452 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
115453 new file mode 100644
115454 index 0000000..4fae911
115455 --- /dev/null
115456 +++ b/tools/gcc/structleak_plugin.c
115457 @@ -0,0 +1,277 @@
115458 +/*
115459 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
115460 + * Licensed under the GPL v2
115461 + *
115462 + * Note: the choice of the license means that the compilation process is
115463 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
115464 + * but for the kernel it doesn't matter since it doesn't link against
115465 + * any of the gcc libraries
115466 + *
115467 + * gcc plugin to forcibly initialize certain local variables that could
115468 + * otherwise leak kernel stack to userland if they aren't properly initialized
115469 + * by later code
115470 + *
115471 + * Homepage: http://pax.grsecurity.net/
115472 + *
115473 + * Usage:
115474 + * $ # for 4.5/4.6/C based 4.7
115475 + * $ 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
115476 + * $ # for C++ based 4.7/4.8+
115477 + * $ 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
115478 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
115479 + *
115480 + * TODO: eliminate redundant initializers
115481 + * increase type coverage
115482 + */
115483 +
115484 +#include "gcc-plugin.h"
115485 +#include "config.h"
115486 +#include "system.h"
115487 +#include "coretypes.h"
115488 +#include "tree.h"
115489 +#include "tree-pass.h"
115490 +#include "intl.h"
115491 +#include "plugin-version.h"
115492 +#include "tm.h"
115493 +#include "toplev.h"
115494 +#include "function.h"
115495 +#include "tree-flow.h"
115496 +#include "plugin.h"
115497 +#include "gimple.h"
115498 +#include "diagnostic.h"
115499 +#include "cfgloop.h"
115500 +#include "langhooks.h"
115501 +
115502 +#if BUILDING_GCC_VERSION >= 4008
115503 +#define TODO_dump_func 0
115504 +#endif
115505 +
115506 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
115507 +
115508 +// unused type flag in all versions 4.5-4.8
115509 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
115510 +
115511 +int plugin_is_GPL_compatible;
115512 +void debug_gimple_stmt(gimple gs);
115513 +
115514 +static struct plugin_info structleak_plugin_info = {
115515 + .version = "201304082245",
115516 + .help = "disable\tdo not activate plugin\n",
115517 +};
115518 +
115519 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
115520 +{
115521 + *no_add_attrs = true;
115522 +
115523 + // check for types? for now accept everything linux has to offer
115524 + if (TREE_CODE(*node) != FIELD_DECL)
115525 + return NULL_TREE;
115526 +
115527 + *no_add_attrs = false;
115528 + return NULL_TREE;
115529 +}
115530 +
115531 +static struct attribute_spec user_attr = {
115532 + .name = "user",
115533 + .min_length = 0,
115534 + .max_length = 0,
115535 + .decl_required = false,
115536 + .type_required = false,
115537 + .function_type_required = false,
115538 + .handler = handle_user_attribute,
115539 +#if BUILDING_GCC_VERSION >= 4007
115540 + .affects_type_identity = true
115541 +#endif
115542 +};
115543 +
115544 +static void register_attributes(void *event_data, void *data)
115545 +{
115546 + register_attribute(&user_attr);
115547 +// register_attribute(&force_attr);
115548 +}
115549 +
115550 +static tree get_field_type(tree field)
115551 +{
115552 + return strip_array_types(TREE_TYPE(field));
115553 +}
115554 +
115555 +static bool is_userspace_type(tree type)
115556 +{
115557 + tree field;
115558 +
115559 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
115560 + tree fieldtype = get_field_type(field);
115561 + enum tree_code code = TREE_CODE(fieldtype);
115562 +
115563 + if (code == RECORD_TYPE || code == UNION_TYPE)
115564 + if (is_userspace_type(fieldtype))
115565 + return true;
115566 +
115567 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
115568 + return true;
115569 + }
115570 + return false;
115571 +}
115572 +
115573 +static void finish_type(void *event_data, void *data)
115574 +{
115575 + tree type = (tree)event_data;
115576 +
115577 + if (TYPE_USERSPACE(type))
115578 + return;
115579 +
115580 + if (is_userspace_type(type))
115581 + TYPE_USERSPACE(type) = 1;
115582 +}
115583 +
115584 +static void initialize(tree var)
115585 +{
115586 + basic_block bb;
115587 + gimple_stmt_iterator gsi;
115588 + tree initializer;
115589 + gimple init_stmt;
115590 +
115591 + // this is the original entry bb before the forced split
115592 + // TODO: check further BBs in case more splits occured before us
115593 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
115594 +
115595 + // first check if the variable is already initialized, warn otherwise
115596 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
115597 + gimple stmt = gsi_stmt(gsi);
115598 + tree rhs1;
115599 +
115600 + // we're looking for an assignment of a single rhs...
115601 + if (!gimple_assign_single_p(stmt))
115602 + continue;
115603 + rhs1 = gimple_assign_rhs1(stmt);
115604 +#if BUILDING_GCC_VERSION >= 4007
115605 + // ... of a non-clobbering expression...
115606 + if (TREE_CLOBBER_P(rhs1))
115607 + continue;
115608 +#endif
115609 + // ... to our variable...
115610 + if (gimple_get_lhs(stmt) != var)
115611 + continue;
115612 + // if it's an initializer then we're good
115613 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
115614 + return;
115615 + }
115616 +
115617 + // these aren't the 0days you're looking for
115618 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
115619 +
115620 + // build the initializer expression
115621 + initializer = build_constructor(TREE_TYPE(var), NULL);
115622 +
115623 + // build the initializer stmt
115624 + init_stmt = gimple_build_assign(var, initializer);
115625 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
115626 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
115627 + update_stmt(init_stmt);
115628 +}
115629 +
115630 +static unsigned int handle_function(void)
115631 +{
115632 + basic_block bb;
115633 + unsigned int ret = 0;
115634 + tree var;
115635 +
115636 +#if BUILDING_GCC_VERSION == 4005
115637 + tree vars;
115638 +#else
115639 + unsigned int i;
115640 +#endif
115641 +
115642 + // split the first bb where we can put the forced initializers
115643 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
115644 + if (dom_info_available_p(CDI_DOMINATORS))
115645 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
115646 +
115647 + // enumarate all local variables and forcibly initialize our targets
115648 +#if BUILDING_GCC_VERSION == 4005
115649 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
115650 + var = TREE_VALUE(vars);
115651 +#else
115652 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
115653 +#endif
115654 + tree type = TREE_TYPE(var);
115655 +
115656 + gcc_assert(DECL_P(var));
115657 + if (!auto_var_in_fn_p(var, current_function_decl))
115658 + continue;
115659 +
115660 + // only care about structure types
115661 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
115662 + continue;
115663 +
115664 + // if the type is of interest, examine the variable
115665 + if (TYPE_USERSPACE(type))
115666 + initialize(var);
115667 + }
115668 +
115669 + return ret;
115670 +}
115671 +
115672 +static struct gimple_opt_pass structleak_pass = {
115673 + .pass = {
115674 + .type = GIMPLE_PASS,
115675 + .name = "structleak",
115676 +#if BUILDING_GCC_VERSION >= 4008
115677 + .optinfo_flags = OPTGROUP_NONE,
115678 +#endif
115679 + .gate = NULL,
115680 + .execute = handle_function,
115681 + .sub = NULL,
115682 + .next = NULL,
115683 + .static_pass_number = 0,
115684 + .tv_id = TV_NONE,
115685 + .properties_required = PROP_cfg,
115686 + .properties_provided = 0,
115687 + .properties_destroyed = 0,
115688 + .todo_flags_start = 0,
115689 + .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
115690 + }
115691 +};
115692 +
115693 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
115694 +{
115695 + int i;
115696 + const char * const plugin_name = plugin_info->base_name;
115697 + const int argc = plugin_info->argc;
115698 + const struct plugin_argument * const argv = plugin_info->argv;
115699 + bool enable = true;
115700 +
115701 + struct register_pass_info structleak_pass_info = {
115702 + .pass = &structleak_pass.pass,
115703 + .reference_pass_name = "ssa",
115704 + .ref_pass_instance_number = 1,
115705 + .pos_op = PASS_POS_INSERT_AFTER
115706 + };
115707 +
115708 + if (!plugin_default_version_check(version, &gcc_version)) {
115709 + error(G_("incompatible gcc/plugin versions"));
115710 + return 1;
115711 + }
115712 +
115713 + if (strcmp(lang_hooks.name, "GNU C")) {
115714 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
115715 + enable = false;
115716 + }
115717 +
115718 + for (i = 0; i < argc; ++i) {
115719 + if (!strcmp(argv[i].key, "disable")) {
115720 + enable = false;
115721 + continue;
115722 + }
115723 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
115724 + }
115725 +
115726 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
115727 + if (enable) {
115728 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
115729 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
115730 + }
115731 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
115732 +
115733 + return 0;
115734 +}
115735 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
115736 index 3dba0a4..97175dc 100644
115737 --- a/tools/lib/lk/Makefile
115738 +++ b/tools/lib/lk/Makefile
115739 @@ -13,7 +13,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
115740
115741 LIBFILE = liblk.a
115742
115743 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
115744 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
115745 EXTLIBS = -lelf -lpthread -lrt -lm
115746 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
115747 ALL_LDFLAGS = $(LDFLAGS)
115748 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
115749 index 6789d78..4afd019e 100644
115750 --- a/tools/perf/util/include/asm/alternative-asm.h
115751 +++ b/tools/perf/util/include/asm/alternative-asm.h
115752 @@ -5,4 +5,7 @@
115753
115754 #define altinstruction_entry #
115755
115756 + .macro pax_force_retaddr rip=0, reload=0
115757 + .endm
115758 +
115759 #endif
115760 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
115761 index 96b919d..c49bb74 100644
115762 --- a/tools/perf/util/include/linux/compiler.h
115763 +++ b/tools/perf/util/include/linux/compiler.h
115764 @@ -18,4 +18,12 @@
115765 #define __force
115766 #endif
115767
115768 +#ifndef __size_overflow
115769 +# define __size_overflow(...)
115770 +#endif
115771 +
115772 +#ifndef __intentional_overflow
115773 +# define __intentional_overflow(...)
115774 +#endif
115775 +
115776 #endif
115777 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
115778 index aac732d..bc87a5d 100644
115779 --- a/virt/kvm/kvm_main.c
115780 +++ b/virt/kvm/kvm_main.c
115781 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
115782
115783 static cpumask_var_t cpus_hardware_enabled;
115784 static int kvm_usage_count = 0;
115785 -static atomic_t hardware_enable_failed;
115786 +static atomic_unchecked_t hardware_enable_failed;
115787
115788 struct kmem_cache *kvm_vcpu_cache;
115789 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
115790
115791 -static __read_mostly struct preempt_ops kvm_preempt_ops;
115792 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
115793 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
115794 +static struct preempt_ops kvm_preempt_ops = {
115795 + .sched_in = kvm_sched_in,
115796 + .sched_out = kvm_sched_out,
115797 +};
115798
115799 struct dentry *kvm_debugfs_dir;
115800
115801 @@ -749,7 +754,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
115802 /* We can read the guest memory with __xxx_user() later on. */
115803 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
115804 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
115805 - !access_ok(VERIFY_WRITE,
115806 + !__access_ok(VERIFY_WRITE,
115807 (void __user *)(unsigned long)mem->userspace_addr,
115808 mem->memory_size)))
115809 goto out;
115810 @@ -1613,8 +1618,17 @@ EXPORT_SYMBOL_GPL(kvm_read_guest_cached);
115811
115812 int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len)
115813 {
115814 - return kvm_write_guest_page(kvm, gfn, (const void *) empty_zero_page,
115815 - offset, len);
115816 + int r;
115817 + unsigned long addr;
115818 +
115819 + addr = gfn_to_hva(kvm, gfn);
115820 + if (kvm_is_error_hva(addr))
115821 + return -EFAULT;
115822 + r = __clear_user((void __user *)addr + offset, len);
115823 + if (r)
115824 + return -EFAULT;
115825 + mark_page_dirty(kvm, gfn);
115826 + return 0;
115827 }
115828 EXPORT_SYMBOL_GPL(kvm_clear_guest_page);
115829
115830 @@ -1867,7 +1881,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
115831 return 0;
115832 }
115833
115834 -static struct file_operations kvm_vcpu_fops = {
115835 +static file_operations_no_const kvm_vcpu_fops __read_only = {
115836 .release = kvm_vcpu_release,
115837 .unlocked_ioctl = kvm_vcpu_ioctl,
115838 #ifdef CONFIG_COMPAT
115839 @@ -2553,7 +2567,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
115840 return 0;
115841 }
115842
115843 -static struct file_operations kvm_vm_fops = {
115844 +static file_operations_no_const kvm_vm_fops __read_only = {
115845 .release = kvm_vm_release,
115846 .unlocked_ioctl = kvm_vm_ioctl,
115847 #ifdef CONFIG_COMPAT
115848 @@ -2654,7 +2668,7 @@ out:
115849 return r;
115850 }
115851
115852 -static struct file_operations kvm_chardev_ops = {
115853 +static file_operations_no_const kvm_chardev_ops __read_only = {
115854 .unlocked_ioctl = kvm_dev_ioctl,
115855 .compat_ioctl = kvm_dev_ioctl,
115856 .llseek = noop_llseek,
115857 @@ -2680,7 +2694,7 @@ static void hardware_enable_nolock(void *junk)
115858
115859 if (r) {
115860 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
115861 - atomic_inc(&hardware_enable_failed);
115862 + atomic_inc_unchecked(&hardware_enable_failed);
115863 printk(KERN_INFO "kvm: enabling virtualization on "
115864 "CPU%d failed\n", cpu);
115865 }
115866 @@ -2734,10 +2748,10 @@ static int hardware_enable_all(void)
115867
115868 kvm_usage_count++;
115869 if (kvm_usage_count == 1) {
115870 - atomic_set(&hardware_enable_failed, 0);
115871 + atomic_set_unchecked(&hardware_enable_failed, 0);
115872 on_each_cpu(hardware_enable_nolock, NULL, 1);
115873
115874 - if (atomic_read(&hardware_enable_failed)) {
115875 + if (atomic_read_unchecked(&hardware_enable_failed)) {
115876 hardware_disable_all_nolock();
115877 r = -EBUSY;
115878 }
115879 @@ -3171,7 +3185,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
115880 kvm_arch_vcpu_put(vcpu);
115881 }
115882
115883 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
115884 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
115885 struct module *module)
115886 {
115887 int r;
115888 @@ -3218,7 +3232,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
115889 if (!vcpu_align)
115890 vcpu_align = __alignof__(struct kvm_vcpu);
115891 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
115892 - 0, NULL);
115893 + SLAB_USERCOPY, NULL);
115894 if (!kvm_vcpu_cache) {
115895 r = -ENOMEM;
115896 goto out_free_3;
115897 @@ -3228,9 +3242,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
115898 if (r)
115899 goto out_free;
115900
115901 + pax_open_kernel();
115902 kvm_chardev_ops.owner = module;
115903 kvm_vm_fops.owner = module;
115904 kvm_vcpu_fops.owner = module;
115905 + pax_close_kernel();
115906
115907 r = misc_register(&kvm_dev);
115908 if (r) {
115909 @@ -3240,9 +3256,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
115910
115911 register_syscore_ops(&kvm_syscore_ops);
115912
115913 - kvm_preempt_ops.sched_in = kvm_sched_in;
115914 - kvm_preempt_ops.sched_out = kvm_sched_out;
115915 -
115916 r = kvm_init_debug();
115917 if (r) {
115918 printk(KERN_ERR "kvm: create debugfs files failed\n");